
12 CHAPTER 1. The TOY(FD) System
TOY(FD)> domain [X,Y] 1 10, X #> Y
yes
Y in 1..9
X in 2..10
Elapsed time: 0 ms.
(#∗)/2, (#+)/2, (#−)/2, (#/)/2
• Type declaration:
(#∗) :: int → int → int
(#+) :: int → int → int
(#−) :: int → int → int
(#/) :: int → int → int
• Definition: ’#Op A B’, also written in infix notation as ’A #Op B’, where Op
∈ {∗, +, −, /} imposes the constraint ’A #Op B’ and returns true if it is entailed.
• Remarks: Infix notation allowed.
• Priorities:
infixr 90 #*, #/ (infix, right-associative)
infixl 50 #+, #- (infix, left-associative)
• Example at the TOY(FD) command level:
Next goal returns true and constrains X, Y and Z to have values in the intervals
[1,10], [1,10] and [1,100] respectively.
TOY(FD)> domain [X,Y] 1 10, X #* Y #= Z
yes
Z in 1..100
Y in 1..10
X in 1..10
Elapsed time: 0 ms.
1.4.4 Arithmetic Constraints
The following constraints express a relation between a sum or scalar product and a
value, using a dedicated algorithm that avoids creating any temporary variables hold-
ing intermediate values.
sum/3
Comentarios a estos manuales