nishkak said:
evo = piss easy
part (a) (ii) is just all the people who mary is the ancestor of.. answer:
ancestor(mary, bob)
ancestory(mary, cathy)
Hmm, from your post it looks like you had no idea wtf you were doing and just miraculously came accross the correct answer you fag!
First of all here are the two rules we must look at:
[1] ancestor(X, Y):- parent(X, Y)
[2] ancestor(X, Z):- parent(X, Y), ancestor(Y, Z)
Now from the [1] rule:
ancestor(X, Y):- parent(X, Y)
ancestor(marry, Y):- parent(marry, Y)
We search the knowledge base and find the following fact which satisfies our goal:
parent(marry, bob)
Thus our first output is bob
Now from [2] rule:
ancestor(X, Z):- parent(X, Y), ancestor(Y, Z)
ancestor(mary,Y):- parent(mary, Y
1), ancestor(Y
1, Y)
Now from above, we know taht Y
1 is bob so:
ancestor(mary,Y):- parent(mary, bob), ancestor(bob, Y)
taking the second part, ancestor(bob, Y)
which from rule [1] is:
ancestor(bob, Y):- parent(bob, Y)
We search the knowledge base and find the following fact which satisfies our goal:
parent(bob, cathy)
And thus our second output is cathy.
We conclude that the output is bob and cathy.
#