packages-chr icon indicating copy to clipboard operation
packages-chr copied to clipboard

Unexpected rule fired.

Open chansey97 opened this issue 2 years ago • 6 comments

Hi,

For the following program

%% test.pl 
:- use_module(library(chr)).
:- chr_constraint c/2.

c(K,_I), c(K,_J) <=> writeln('rule 1 fired').
c(_I,K), c(_J,K) <=> writeln('rule 2 fired').
?- consult(["test.pl"]).
true.

?- c(X,Y).
rule 2 fired
c($VAR(X),$VAR(Y)).

Although the 2nd rule has two heads and I only added one constraint (c(X,Y)), the rule still fired.

This issue can be reproduced in Stable release - SWI-Prolog 8.4.1-1 for Microsoft Windows (64 bit), and Daily builds - swipl-w64-2022-01-31.exe (version 8.5.6-26-gee0b3fea1).

N.B. swish has no the same problem, but the constraint are not preserved, see https://swish.swi-prolog.org/p/unexpected_rule_fired.pl

Thanks.

chansey97 avatar Jan 31 '22 20:01 chansey97