/* Global constraint arith_or in Picat. From Global Constraint Catalogue http://www.emn.fr/x-info/sdemasse/gccat/Carith_or.html """ Enforce for all pairs of variables var1i,var2i of the VARIABLES1 and VARIABLES2 collections to have var1i  RELOP VALUE∨var2i RELOP VALUE. Example ( 〈0,1,0,0,1〉, 〈0,0,0,1,0〉,=,0 ) The constraint arith_or holds since, for all pairs of variables var1i,var2i of the VARIABLES1 and VARIABLES2 collections, there is at least one variable that is equal to 0. """ Cf http://hakank.org/picat/arith.pi (for global constraint arith) 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 = 5, X = new_list(N), X :: 0..2, Y = new_list(N), Y :: 0..2, Z :: 0..9, % X = [0,1,0,0,1], % Y = [0,0,0,1,0], arith_or(X, Y, #=, Z), % Z #= 1, Vars = X ++ Y ++ [Z], solve(Vars), println(x=X), println(y=Y), println(z=Z), nl, fail, nl. go => true. arith_or(X, Y, Relop, Val) => foreach(I in 1..X.len) call(Relop,XVal,X[I]), call(Relop,YVal,Y[I]), XVal #= Val #\/ YVal #= Val end.