/* Antisymmetric in Picat. Define the concept of antisymmetric. See http://en.wikipedia.org/wiki/Antisymmetric_relation This was used (though not as an explicit constraint) in the Who killed Agatha? problem for the concept of richer: * No one is richer than him-/herself * if i is richer than j then j is not richer than i. Cf http://www.hakank.org/picat/who_killed_agatha.pi . Here we implements two variants: * antisymmetric1/1 * antisymmetric2/1 This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> N = 4, X = new_array(N,N), X :: 0..1, antisymmetric1(X), % antisymmetric2(X), solve(X), foreach(Row in X) println(Row) end, nl, fail, nl. go => true. antisymmetric1(X) => N = X.len, % not(iRi) foreach(I in 1..N) X[I,I] #= 0 end, % if iRj then not(jRi) foreach(I in 1..N, J in 1..N, I != J) X[I,J] #= 1 #<=> X[J,I] #= 0 end. % % Alternative version from the definition in % http://en.wikipedia.org/wiki/Antisymmetric_relation % * if aRb with a != b, then not bRa % antisymmetric2(X) => N = X.len, foreach(A in 1..N, B in 1..N) (X[A,B] #= 1 #/\ A #!= B) #<=> X[B,A] #= 0 end.