father(prem,abhishek).
father(abhishek,ravi).
father(lias,waseem).
father(waseem,rahul).
father(ram,santosh).
father(shiv,pundir).
parent(P1,P2):-father(P1,P2).
grandparent(P1,P2):-parent(P1,P3),parent(P3,P2).
output
1 ?- parent(X,W).
X = prem,
W = abhishek ;
X = lias,
W = waseem ;
X = ram,
W = santosh ;
X = shiv,
W = pundir.
2 ?- grandparent(Who,Son).
Who = prem,
Son = ravi
3 ?- grandparent(Who,rahul).
Who = lias
0 comments:
Post a Comment