
1.4. FD Constraints 11
• Example in the TOY(FD)command level:
Next goal returns true and constrains X and Y to have values in the range [1,10].
TOY(FD)> domain [X,Y] 1 10
yes
Y in 1..10
X in 1..10
Elapsed time: 0 ms.
1.4.3 Relational Constraints
Relational constraints include equality and disequality constraints in the form e¦ e
0
where ¦ ∈ {#<, #=, #<=, #>=, #>, #\=} and e and e
0
are either integers, or FD
variables or functional expressions.
(#<)/2, (#=)/2, (#<=)/2, (#>=)/2, (#>)/2, (#\=)/2
• Type declaration:
(#>) :: int → int → bool
(#<) :: int → int → bool
(#>=) :: int → int → bool
(#<=):: int → int → bool
(# =) :: int → int → bool
(#\=) :: int → int → bool
• Definition: ’#Op A B’, also written in infix notation as ’A #Op B’, where Op
∈ {>, <, >=, <=, =, \ =}, returns true if the imposition of the relation ’A #Op
B’ entails the constraint store.
• Remarks: Infix notation allowed.
• Priorities:
infix 30 #>, #<, #>=, #<= (infix)
infix 20 #=, #\= (infix)
• Example at the TOY(FD) command level:
Next goal returns true and restricts X and Y to have values in the intervals [2,10]
and [1,9] respectively (as a consequence of range narrowing).
Kommentare zu diesen Handbüchern