How to create a rule that makes all relations symmetric in Prolog?

prolog

Solution

I figured it out after all:

marriedTo(X,Y) :- marriedTo(Y,Z), X = Z, !.

Problem

What I want is when I define: ``` marriedTo(martin, annie). ``` It also makes the following true: ``` marriedTo(annie, martin). ``` I have tried the following, but it's (obviously) an infinite loop. ``` marriedTo(X,Y) :- marriedTo(Y,X). ``` How would I do this in Prolog?

Original source