CompilerSaysNo
CompilerSaysNo

Reputation: 415

unification in prolog failure

Can anyone please tell me why this fails?

f(X,X) = f(a,b).

It was my assumption that X would first be instantiated to a, then removed, then to b making just X = b. Trying it out, I see that I am wrong but I do not know why.

Thank you.

Upvotes: 1

Views: 299

Answers (1)

Vaughn Cato
Vaughn Cato

Reputation: 64308

Unification always gives variables a consistent meaning. There is no value of X that makes f(X,X) = f(a,b) true. If you said

f(X) = f(a); f(X) = f(b).

Then you would get a result more like you are expecting.

Upvotes: 1

Related Questions