AIM: Logic
Problem
Domains
P=Symbol.
Predicates
Born(P,integer).
Male(P).
Female(P).
Parent(P,P).
Father(P).
Father(P,P).
Mother(P,P).
Sister(P,P).
Brother(P,P).
Son(P,P).
Daughter(P,P).
Uncle(P,P).
Aunt(P,P).
Child(P,P).
WifeOf(P,P).
HusbandOf(P,P).
GrandFather(P,P).
GrandMother(P,P).
Person(symbol).
Age(symbol,integer).
Elder_Brother(P,P).
Constants
Now=2008.
Clauses
Person(X) if Male(X) ; Female(X).
Age(X,A) if Person(X) , Born(X,Y).
Born("rajiv",1999).
Born("sanjay",1950).
Father("motilal" ,
"jawaharlal").
Father("jawaharlal" ,
"indira").
Father("feroz" ,
"rajiv").
Father("feroz" ,
"sanjay").
Father("rajiv" ,
"rahul").
Father("rajiv" ,
"priyanka").
Father(X) if Father(X,_).
Male(rahul)
WifeOf("menka" ,
"sanjay").
WifeOf("sanjay" ,
"rajiv").
WifeOf("indira" ,
"feroz").
Female(priyanka).
Female(X):- WifeOf(Y,X).
Elder_Brother(A,B) if
eelder_brother.
Parent(X,Y) :-
Father(X,Y),Mother(X,Y).
Mother(X,Y) :- WifeOf(X,Z),Father(Z,Y).
Child(X,Y) :- Parent(Y,X).
Son(X,Y) :- Child(X,Y) , Male(X).
Daughter(X,Y) :- Child(X,Y) ,
Female(X).
Brother(X,Y) :- Father(Z,X) ,
Father(Z,Y), Male(X) , not(X=Y).
Sister(X,Y) :- Father(Z,X) ,
Father(Z,Y), Female(X) , not(X=Y).
Aunt(X,Y) if Sister(X,Z) ,
Parent(Z,Y).
Aunt(X,Y) :- WifeOf(X,Z) ,
Uncle(Z,Y).
Grandfather(X,Y) :- Parent(X,Z),
Parent(Z,Y) , Male(X).
Grandmother(X,Y) :- Parent(X,Z),
Parent(Z,Y) , Female(X).
Output:
No comments:
Post a Comment