Slide 14.25: Rules (cont.)
Slide 14.27: Search
Home

Rules (Cont.)


Rules Exercise IV
Indicate whether the following are syntactically correct rules.

a :- b, c, d:- e f.

happy(X):- a , b.
happy(X):- hasmoney(X) & has_friends(X).
fun(fish):- blue(betty), bike(yamaha).

Rules Exercise V
Given the database below, study the queries underneath it. Indicate whether you think a particular query will succeed or fail by answer yes or no using the buttons.

   likes( john,mary ).
   likes( john, trains ).
   likes( peter, fast_cars ).
   likes( Person1, Person2 ) :-
     hobby( Person1, Hobby ), hobby( Person2, Hobby ).

   hobby( john, trainspotting ).
   hobby( tim, sailing ).
   hobby( helen, trainspotting ).
   hobby( simon, sailing ).

?- likes(john,trains).

?- likes(helen,john).
?- likes(tim,helen).
?- likes(john,helen).