Second Prolog Assignment

Name: ___________________  Possible Points: 20   Earned points : ___

 

You can show the desired responses by doing a screen capture of your session and attaching it to this page or you can type the answers in.  Be  sure that you show all of the answers for each query.

 

Put the following 6 statements into a file.
 
likes(sarah,food).
likes(mike,beer).
likes(joe,beer).
likes(joe,sarah).
likes(mary,candy).
likes(mary,mike).
 
 
Consult the file you have just created.
 
Run the following queries and tell what the response to each is.
 
        likes(mike,food).
 
 
        likes(mary,mike).
 
 
        likes(sarah,joe).
 
 
        likes(joe,What).
 
 
        likes(Who,beer).
 
 
        likes(Who,What).
 
 
        likes(_,What).
 
 
        likes(Z,_).
 
 
Write the following rules and test them.

Joe likes anything that Sarah likes.

 

Joe likes anyone who likes beer.