]> Repositorios git - scryer-prolog.git/commit
ENHANCED: Suspend propagation during filtering in global_cardinality/2.
authorMarkus Triska <[email protected]>
Mon, 1 Jan 2024 09:26:42 +0000 (10:26 +0100)
committerMarkus Triska <[email protected]>
Mon, 1 Jan 2024 09:50:06 +0000 (10:50 +0100)
commitf5d9a67f3688ec9bb08dd3add05614552e082555
treec80a5ebd211167e9612b38980ba0c82fcb72d781
parent1f90dbec20b61995379059ff1d25ab98f309b9b2
ENHANCED: Suspend propagation during filtering in global_cardinality/2.

This allows subsequently invoked constraints to take the entire
filtering results into account, instead of being invoked when the
obtained information is not yet entirely used.

The SICStus-style attributed variables mechanism of Scryer Prolog
automatically prevents very subtle interaction problems that can arise
in systems that do not give all variables that are involved in a
unification an opportunity to schedule their propagators.

An example of such a subtle interaction is:

    ?- tuples_in([[A,C,B]], [[3,1,3],[4,2,4]]),
       global_cardinality([A,B,D], [3-1,4-2]),
       A = 4.

A = 4 causes pgcc_check/1 and pgcc/2 to be queued in the fast and slow
queue, respectively. In the fast queue, there is also rel_tuple/2,
which is worked off after gcc_check/1 and simultaneously instantiates
both C and B (to 2 and 4, respectively). Instantiation of C schedules
do_queue//0 from verify_attributes/3. Note that C does not participate
in the global_cardinality/2 constraint.

Critically, B also gets an opportunity to schedule its propagators in
this case, so another gcc_check/1 is run before gcc_global/2!
src/lib/clpz.pl