1. Given the knowledge base
We know that all dogs are manitas and all manitas are dogs, so write a predicate prove such that
?- prove(dog(X)). ?- prove(manita(X)).
X = ann ; X = orr ;
X = onn ; X = abb ;
X = orr ; X = ann ;
X = abb ; X = onn.
Improve your solution by writing a predicate test such that
A dog is a manita and a manita is a dog:
I do not expect a solution like dog(X) v manita(X).
2. Define a predicate & to represent logical AND (to have the same behaviour as comma). First, define its syntax: let & be an infix right-associative operator with slightly lower precedence than the comma, such that f(a & b, c) will mean f((a & ,c), not f(a & (b, c)). Next, tell Prolog how to solve a goal that contains ampersands: GoalA & GoalB should succeed if GoalA succeeds and then GoalB succeeds with the same instantiations. Finally, test it against this knowledge base
1. by defining a predicate grandparent(X, Y) (X is a grandparent of Y) and by providing a query such that it will display
Child = ana,
Grandparents = [iosif, maria, ion, elena] ;
Child = anabel,
Grandparents = [ion, elena].
2. by defining a predicate only-child(P, C) (what parent P has only a child C) which can be incorporated in a predicate testa to produce
ana is an only child of mihai
mihai is an only child of iosif
mihai is an only child of maria
veta is an only child of ion
veta is an only child of elena
Please help me with this....
Page 1 of 1
stuck with question in prolog
1 Replies - 868 Views - Last Post: 03 June 2010 - 07:20 AM
Replies To: PROLOG !
Page 1 of 1