CHR: add unique non instantiable key instead of [_]
FissoreD opened this issue · comments
Davide Fissore commented
[_]
is used typically to retrieve all the goals suspended for a given predicate.
The use of [_]
can lead to goal resolution issue if the _
is accidentally instantiated.
For example, the following code raise a failure:
pred p i:int.
pred trig.
% this extends the previous constraint
constraint p trig {
rule \ trig (p A) <=> (false).
}
main :-
% declare_constraint (p 4) [_], not (declare_constraint trig [_]).
std.spy-do![declare_constraint (p 4) [_], not (declare_constraint trig [_])].
The premise with the spy-do!
fails, whereas the same premise without the spy-do!
succeeds
Enrico Tassi commented
Thanks for opening the issue.
I think the desired solution is to use some constant, say the-key
, instead of _
, eg declare_constraint (p X) [X,the-key]
to get it resumed when X
materializes and combined via CHR rules with all the other constraints about X
or about the-key
.
Line 3402 in 4cac107