noclash(S1,S2) :- ic:(S1 $>= S2+5). noclash(S1,S2) :- ic:(S2 $>= S1+5). |
:- constraints noclash/2. noclash(S1,S2) <=> ic:(S2 #< S1+5) | ic:(S1 #>= S2+5). noclash(S1,S2) <=> ic:(S1 #< S2+5) | ic:(S2 #>= S1+5). |
In this query noclash achieves no propagation when it is initially posted with the start time domains set to?- ic:([S1,S2]::1..10), noclash(S1,S2), S1 #>= 6.
1..10
.
However, after imposing S1>=6,
the domain of S1 is reduced to 6..10
.
Immediately the noclash
constraint wakes, detects that the first
condition S1+5 >= S2 is entailed,
and narrows the domain of S2 to 1..5
.?- [S1,S2]::1..10, noclash(S1,S2) infers most, S1 #>= 6.
Propia and CHRs make it easy to turn the logical statement of a constraint into code that efficiently enforces that constraint.
Figure 15.1: Building Constraints without Tears