

 Your job is to convert the 9 logical statements below into prolog rules. 
 The facts are given to you. The one query to test your knowledge base is:
      likes(X,Y): meaning X likes Y                                       

 The universe of discourse is a set of animals, U={fido,kitty,tweety,ratatat}. 
 Predicates are some characteristics of animals. The rules determine what kind
 of animal a member is. The inference engine infers which animal likes another
 animal.

 Prolog variables (X,Y,etc.) begin with uppercase and predicate names or 
 literals (loves, dog, animal, etc.) in lowercase.       

 Note that discontiguous predicates are ignored - put like predicates together. 

 Hint: If you make a change to your knowledge base, the safest thing to do is
 to exit prolog and reload the code from scratch.  */

% comment the next two lines out when testing - put back in to submit
% :- initialization(q1).
% :- initialization(end).

% FACTS. 
mammal(kitty).
mammal(ratatat).
mammal(fido).
claws(kitty).
tail(ratatat).
bestfriend(fido).
feathers(tweety).

% 9 RULES. 
% If X is a mammal then X has fur. 

% If X has fur and X has a tail then X is a rat. 

% If X has claws and X has fur then X is a cat.

% If X is a cat then X meows.

% If X has feathers then X is a bird.

% If X is a bestfriend and X has fur then X is a dog.

% If X is a dog and Y meows then X likes Y.

% If X is a cat and Y is a bird then X likes Y.

% If X is a cat and Y is a rat then X likes Y.

writeln(T) :- write(T), nl.

% QUERY. Uncomment after you have written all predicates.
% q1 :- findall(X, (likes(X,Y), format('~n~w ~w',[X,Y])),_).
end :- writeln('#'), halt.
