projog

3.22. X=Y - an equality test.

If X can be matched with Y the goal succeeds else the goal fails. A X=Y goal will consider an uninstantiated variable to be equal to anything. A X=Y goal will always succeed if either argument is uninstantiated.

Examples

?- a=a.

yes

?- a=b.

no

?- a=X.
X = a

yes

?- 2=1+1.

no

?- p(b,c)=p(b,d).

no

?- p(b,c)=p(c,b).

no

?- p(b,c)=p(b,X).
X = c

yes

?- p(Y,c)=p(b,X).
X = c
Y = b

yes

?- [a,b,c]=[a,b,c].

yes

?- [a,b,c]=[a,b,d].

no

?- [a,b,c]=[X|Y].
X = a
Y = [b,c]

yes

?- [X|[b]]=[a,b].
X = a

yes

?- [a,b,c|X]=[a,b,c,d,e,f,g].
X = [d,e,f,g]

yes

?- [a,b,c]=[a,b,c|[]].

yes

?- [a,b,c]=[X|[]].

no