Sem 7‎ > ‎AI‎ > ‎

Lisp and Prolog 1

posted Jul 29, 2013, 11:36 PM by Neil Mathew   [ updated Jul 29, 2013, 11:58 PM ]
   

female(mary).


father(X,Y):- male(X), parent(X,Y).



SAMPLE PROLOG FILE: familytree.pl

parent(pet,mike).
parent(pet,july).
parent(pet,amenda).
parent(mary,mike).
parent(mary,july).
parent(mary,amenda).

female(mary).
female(july).
female(amenda).
male(mike).
male(pet).

sibling(mike,july).
sibling(mike,amenda).
sibling(amenda,mike).
sibling(july,mike).
sibling(july,amenda).
sibling(amenda,july).

father(X,Y):-male(X),parent(X,Y).
mother(X,Y):-female(X),parent(X,Y).
brother(X,Y):-male(X),sibling(X,Y),X\=Y.
sister(X,Y):-female(X),sibling(X,Y),X\=Y.
SAMPLE QUERIES:




Comments