%-----------------------------------------------------------------------------% % Reflect an array of comparison values onto a comparison value variable using % a lexicographic interpretation of the array. The comparison values are % encoded as follows: > | = | < as -1 | 0 | +1. % Uses of this constraint are generated by Cadmium transformations that % simplify ordering constraints on expressions of complex types. %-----------------------------------------------------------------------------% predicate comparison_rel_array(array[int] of var -1..1: rels, var -1..1: rel) = let { int: l = min(index_set(rels)), int: u = max(index_set(rels)), array[l-1..u] of var -1..1: r } in r[l-1] = 0 % initial state (before first array position) is 'equal' /\ forall (i in l..u) ( % new state: as given array at current position if % previous state is 'equal', otherwise previous state % % r[i] = (if r[i-1] = 0 then rels[i] else r[i-1] endif) (r[i-1] = 0 -> r[i] = rels[i]) /\ (r[i-1] != 0 -> r[i] = r[i-1]) ) /\ r[u] = rel; % final state (at last array position)