/* Global constraint lex_greater in Picat. From Global Constraint Catalogue http://www.emn.fr/x-info/sdemasse/gccat/Clex_greater.html """ lex_greater(VECTOR1, VECTOR2) Purpose VECTOR1 is lexicographically strictly greater than VECTOR2. Given two vectors, X and Y of n components, 〈X0, ..., Xn−1〉 and 〈Y0, ...,Yn−1〉, X is lexicographically strictly greater than Y if and only if X0> Y0 or X0=Y0 and 〈X1, ..., Xn−1〉 is lexicographically strictly greater than 〈Y1, ..., Yn−1〉. Example ( <5, 2, 7, 1>, <5, 2, 6, 2> ) The lex_greater constraint holds since VECTOR1=<5, 2, 7, 1> is lexicographically strictly greater than VECTOR2=<5, 2, 6, 2>. """ 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, Vector1 = new_list(N), Vector1 :: 1..7, Vector2 = new_list(N), Vector2 :: 1..7, Vector1 = [5,2,7,1], % Vector2 = [5,2,6,2], lex_greater(Vector1, Vector2), Vars = Vector1 ++ Vector2, solve(Vars), println(vector1=Vector1), println(vector2=Vector2), nl, fail, nl. go => true. lex_greater(X, Y) => lex_lt(Y, X).