Some of the problems below can be worked by running the C-Prolog interpreter on Ivy. Here are a few guidelines for using the Prolog interpreter.
a :- b, c, d:- e f.
happy(X):- a , b.
happy(X):- hasmoney(X) & has_friends(X).
fun(fish):- blue(betty), bike(yamaha).
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).
fun(X) :- /* fun if .... */
red(X), /* red */
car(X). /* and a car */
fun(X) :- /* or its fun if its.... */
blue(X), /* blue */
bike(X). /* and a bike */
/* database of red & blue items */
red(cricket_ball). blue(cheese).
red(my_hat). blue(raleigh).
red(car_27). blue(honda).
/* database of cars and bikes*/
car(peugot). bike(yamaha).
car(rover). bike(raleigh).
bike(honda).
Below you will see pairs of goals. These may either be output of a goal e.g. red(my_hat) or calls to another goal e.g. car(my_hat). Indicate which one of the following goal pairs you would expect to see first, for the above query.
a(X):-
b(X), c(X), d(X).
a(X):-
c(X), d(X).
a(X):-
d(X).
b(1).
b(a).
b(2).
b(3).
d(10).
d(11).
c(3).
c(4).
Given the query ?- a(X). Indicate the successive variable bindings that the variable X gets when the above query is run. Separate bindings by a comma (ie. 1,3,5.....)