Question

Please complete in Prolog, thank you.   Write the following statement as prolog clauses (one fact and...

Please complete in Prolog, thank you.  

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.

Do these different queries produce the same result in prolog? Why?
?- N is -(+(5,6),4). ?- N is (5+6)-4.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

The prolog code for the 1st part (“weather is hot. if weather is hot, everyone like it”) is as follows -

Code:

% weather is hot
is_hot(weather).

% anyone will like the weather if it is hot
likes(_, W):-
is_hot(W).

Run:

Part 2 -

Do these different queries produce the same result in prolog? Why?
?- N is -(+(5,6),4). ?- N is (5+6)-4.

Run:

Explanation:

Both the queries produce the same result, because both are mathematical expressions denoting the same thing.

N is -(+(5,6),4). - is prefix notation where the operator comes before the operands.

N is (5+6)-4. - is infix notation which is the common form for a mathematical expression.

Add a comment
Know the answer?
Add Answer to:
Please complete in Prolog, thank you.   Write the following statement as prolog clauses (one fact and...
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