Question

CSE 240 Homework 5- Programming with PROLOG Due: Monday, April 22, 11:59 PM A. What This Assignment Is About: Facts, Rules, G2. Write the following statement as prolog clauses (one fact and one rule): weather is hot. if weather is hot, everyone like8Facts & Rules (1) jane is a (2) john is a man. (3) john is healthy. (4) jane is healthy (5) john is wealthy (6) anyone is aa) Write English statement for the facts and rule. b) Describe step by step how the fib (3) is calculated. c) What is the ansd) Jane hates any city if it is big and crowdie 8. Write the facts and rules, that compute the sum of the first n numbers. Fo

CSE 240 Homework 5- Programming with PROLOG Due: Monday, April 22, 11:59 PM A. What This Assignment Is About: Facts, Rules, Goals Prolog execution model Arithmetic operations . Recursive Rules B. Use the following Guidelines Give identifiers semantic meaning and make them easy to read (examples numStudents, grossPay, etc.) Use tabs or spaces to indent code within blocks (code surrounded by braces). This includes classes, methods, and code associated with ifs, switches and loops. Be consistent with the number of spaces or tabs that you use to indent Use white space and newlines (enters) to make your program more readable C. Instructions Code the following functions in a single file named homework.pl Provide a heading (in comments) which includes: (1) the assignment number, (2) its author - your name, and (3) descriptions of what this program is doing. 1. 2. Write the following statement as prolog clauses (one fact and one rule) "weather is hot. if weather is hot, everyone like it."
2. Write the following statement as prolog clauses (one fact and one rule): "weather is hot. if weather is hot, everyone like it." So, all following queries will return true likes (me, weather) likes jane, weather). likes john, weather) etc 3. Do these different queries produce the same result in prolog? Why? - (+ (5, 6) , 4) . ?- N is ? N is (5+6)-4 4. For each of the following English statements write a prolog program 8Facts & Rules (1) jane is a (2) john is a man. (3) john is healthy (4) jane is healthy (5) john is wealthy (6) anyone is a traveler if he is healthy and wealthy (7) anyone can travel if he is a traveler. Goals (queries) (8) Who can travel? Woman (9) Who is healthy and wealthy?
8Facts & Rules (1) jane is a (2) john is a man. (3) john is healthy. (4) jane is healthy (5) john is wealthy (6) anyone is a traveler if he is healthy and wealthy (7) anyone can travel if he is a traveler. % Goals (queries) (8) Who can travel? (9) Who is healthy and wealthy? Woman. 5. What answers do you get for below queries for this given program? Facts & Rules vegetarian (jose) vegetarian (james) vegetable (carrot) vegetable (egg_plant) likes jose, X) loves (Who, egg plant) vegetable (X). vegetarian (Who). :- & This are queries. You do not need to copy the ?- symbol ? vegetable (X) ? vegetable (potato) ? likes (jose, What) ?likes (Who, egg_plant) ?- loves (Who, egg_plant) 6. Given the fact, rules, and queries below Facts & Rules fib (1,1) fib (2,1) fib (N, R) Goals (queries) ? fib (9,R) ? fib (9,9). N >= 3, N1 is N-1, N2 is N-2,fib (N1,R1),fib (N2, R2),R is R1+R2 a) Write English statement for the facts and rule.
a) Write English statement for the facts and rule. b) Describe step by step how the fib (3) is calculated. c) What is the answer of the two queries listed in blue. Explain them 7. For below English sentences write applicable Prolog facts, rules & goals. a) John reads programming book. b) Anyone likes sparky if he/she is an ASU student c) Who likes sparky? d) Jane hates any city if it is big and crowdie. 8. Write the facts and rules, that compute the sum of the first n numbers. For example, ? sum (3, X) X-6 ? sum (5, X) X-15 ? sum (7, X)
d) Jane hates any city if it is big and crowdie 8. Write the facts and rules, that compute the sum of the first n numbers. For example ? sum (3, X) X 6 ? sum (5,X) X -15 ? sum (7,X) X-28 D. Grading Criteria 10 pts: File have the name defined in section B requested, contains header information and follow the guidelines 10 pts for correctly provide a fact and a rule in question 2 10 pts for correctly answer (and provide an explanation) in question 3 20 pts for providing a Prolog program for the listed English statements in question 4. Two points per rule/fact, and three points per query (goal) 10 pts for correctly answer question 5. Two points per query 10 pts for correctly answer question 6. Three points per question, and one point granted only if all answers are correct 10 pts for providing a Prolog program for the listed English statements in question 7. 2.5 points per question 20 pts for providing a prolog program for question 8
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution

4.

(1)
woman(jane).
(2)
man(john).
(3)
healthy(john).
(4)
healthy(jane).
(5)
wealthy(john).
(6)
traveler(X) :- healthy(X), wealthy(X).
(7)
travel(X) :- traveler(X).

(8)
travel(X).
% John can travel because he is healthy and wealthy
(9)
healthy(X), wealthy(X).
%John

--

5)

?- vegetable(X).   
carrot

?- vegetable(potato).
false

?- likes(jose, What).
carrot

?- likes(Who, egg_plant).
Jose

?- loves(Who, egg_plant).
Jose

--

solved 2 problems, really sorry for that

please post remaining question separately, love to answer

all the best

Add a comment
Know the answer?
Add Answer to:
CSE 240 Homework 5- Programming with PROLOG Due: Monday, April 22, 11:59 PM A. What This...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT