I have binary relations and I want to get result true if all binary relations are symmetric, otherwise false. So far I have this:
married(mary, tom).
married(sam, linda).
married(linda, sam).
spouse(X, Y) :- married(X, Y), married(Y, X).
Where the result is this:
?- spouse(X, Y).
X = sam,
Y = linda ;
X = linda,
Y = sam ;
false.
But in this case I want to get result false because there no binary relation married(tom, mary) (according formule ∀x,y:xRy⇒yRx). And on the other hand, when I have these binary relations:
married(tom, mary).
married(mary, tom).
married(sam, linda).
married(linda, sam).
I want to get result as true because binary relations are symmetric. How can I do that? I'm using SWI-Prolog.
For your first example:
For the second one: