smt(
:ConstraintBody)
since release 4.2The arithmetic, membership, and propositional constraints described
earlier are transformed at compile time to conjunctions of library
constraints. Although linear in the size of the source code, the
expansion of a propositional formula over reifiable constraints to
library goals can have time and memory overheads, and propagates
disjunctions very weakly. Temporary variables holding intermediate
values may have to be introduced, and the grain size of the constraint
solver invocations can be rather small. As an alternative to the
default propagation of such constraint formulas, this constraint is a
front-end to the case/[3,4]
propagator, which treats such a
formula globally. The pruning can be stronger and it can run faster
than the default propagator, but this is not necessarily the case.
Bounds-consistency is not guaranteed.
ConstraintBody should be of one of the following forms, or a propositional combination of such forms. See Syntax of Indexicals for the exact definition:
in
ConstantRange
element(
var,
CList,
var)
table([
VList],
CTable)
X
stands for X#=1
}
count(
+Val,
+List,
+RelOp,
?Count)
since release 4.0.5,deprecatedsum/3
constraint, one arithmetic comparison, and several
reified equalities.
Corresponds to count_*/3
, exactly/3
in MiniZinc.
count/4
maintains domain-consistency, but in practice, the
following constraint is a better alternative.
global_cardinality(
+Xs,
+Vals)
global_cardinality(
+Xs,
+Vals,
+Options)
If either Xs or Vals is ground, and in many other special
cases, global_cardinality/[2,3]
maintains domain-consistency, but
generally, bounds-consistency cannot be guaranteed. An
domain-consistency algorithm [Regin 96] is used, roughly linear in the
total size of the domains.
Corresponds to global_cardinality*/*
and distribute/3
in MiniZinc.
Options is a list of zero or more of the following:
consistency(
Cons)
domain
on(dom)
. The default.
bounds
on(minmax)
.
value
on(val)
.
on(
On)
dom
minmax
val
cost(
Cost,
Matrix)
consistency/1
option value. A cost is associated
with the constraint and reflected into the domain variable Cost.
Matrix should be a d*n matrix of integers, represented as a
list of d lists, each of length n. Assume that each
Xi equals K(pi). The cost of the constraint is then
Matrix[1,p1]+...+Matrix[d,pd].
With this option, a domain-consistency algorithm [Regin 99] is used, the complexity of which is roughly O(d(m + n log n)) where m is the total size of the domains.
all_different(
+Variables)
all_different(
+Variables,
+Options)
all_distinct(
+Variables)
all_distinct(
+Variables,
+Options)
Corresponds to alldifferent/1
in MiniZinc.
Options is a list of zero or more of the following:
#=
R
since release 4.3 + ... +
Xj*
X1 + ... +
Xj*
Xj * ... *
Xjconsistency(
Cons)
domain
all_distinct/[1,2]
and assignment/[2,3]
.
A domain-consistency algorithm [Regin 94] is used, roughly linear in
the total size of the domains. Implies on(dom)
.
bounds
on(minmax)
.
value
all_different/[1,2]
. An algorithm achieving
exactly the same pruning as a set of pairwise inequality constraints is
used, roughly linear in the number of variables. Implies
on(val)
.
on(
On)
dom
all_distinct/[1,2]
and assignment/[2,3]
),
to wake up when the domain of a variable is changed;
min
max
minmax
val
all_different/[1,2]
), to wake up when a variable becomes ground.
nvalue(
?N,
+Variables)
all_distinct/2
.
Corresponds to nvalue/2
in MiniZinc.
The following is a constraint over two lists of length n of variables. Each variable is constrained to take a value in [1,n] that is unique for its list. Furthermore, the lists are dual in a sense described below.
assignment(
+Xs,
+Ys)
assignment(
+Xs,
+Ys,
+Options)
Corresponds to inverse/2
in MiniZinc.
Options is a list of zero or more of the following, where
Boolean must be true
or false
(false
is the
default):
on(
On)
all_different/2
.
consistency(
Cons)
all_different/2
.
circuit(
Boolean)
true
, circuit(
Xs,
Ys)
must hold for the
constraint to be true.
cost(
Cost,
Matrix)
With this option, a domain-consistency algorithm [Sellmann 02] is used, the complexity of which is roughly O(n(m + n log n)) where m is the total size of the domains.
The following constraint captures the relation between a list of values, a list of the values in ascending order, and their positions in the original list:
sorting(
+Xs,
+Ps,
+Ys)
In practice, the underlying algorithm [Mehlhorn 00] is likely to achieve bounds-consistency, and is guaranteed to do so if Ps is ground or completely free.
Corresponds to sort/2
in MiniZinc.
The following constraint is a generalization of sorting/3
, namely:
keysorting(
+Xs,
+Ys)
keysorting(
+Xs,
+Ys,
+Options)
The filtering algorithm is based on [Mehlhorn 00] and endeavors to achieve bounds-consistency, but does not guarantee it.
Corresponds to Prolog's keysort/2
.
Options is a list of zero or more of the following:
keys(
Keys)
permutation(
Ps)
The following constraints express the fact that several vectors of domain variables are in ascending lexicographic order:
lex_chain(
+Vectors)
lex_chain(
+Vectors,
+Options)
Corresponds to *lex2/1
, lex_greater*/2
, lex_less*/2
in MiniZinc.
Options is a list of zero or more of the following:
op(
Op)
#=<
(the default), the constraints holds
if Vectors are in non-descending lexicographic order. If Op
is the atom #<
, the constraints holds if Vectors are in
strictly ascending lexicographic order.
increasing
among(
Least,
Most,
Values)
global(
Boolean)
since release 4.2.1true
, a more expensive algorithm [Carlsson & Beldiceanu 02],
which guaranteed domain-consistency unless the increasing/0
or
among/3
options are given, will be used.
In the following constraints, a literal is either a term X
or a term #\ X
, where X
is a 0/1 variable. They maintain
domain-consistency:
bool_and(
+Lits,
+Lit)
since release 4.3[L0,...,Lj]
and Lit is a literal.
True if Lit equals the Boolean conjunction of Lits, and
usually more efficient than the equivalent L0#/\...#/\Lj #<=> Lit
.
bool_or(
+Lits,
+Lit)
since release 4.3[L0,...,Lj]
and Lit is a literal.
True if Lit equals the Boolean disjunction of Lits, and
usually more efficient than the equivalent L0#\/...#\/Lj #<=> Lit
.
bool_xor(
+Lits,
+Lit)
since release 4.3[L0,...,Lj]
and Lit is a literal.
True if Lit equals the Boolean exclusive or of Lits, and
usually more efficient than the equivalent L0#\...#\Lj #<=> Lit
.
bool_channel(
+Lits,
?Y,
+Relop,
+Offset)
since release 4.3[L0,...,Lj]
, Y is a
domain variable, RelOp is an arithmetic comparison as in
Syntax of Arithmetic Expressions, and Offset is an integer.
Expresses the constraint Li #<=> (Y RelOp i+Offset) for
i in 0..j
. Usually more efficient than a bunch of reified
comparisons between a given variable and a sequence of integers.