Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CHR: add unique non instantiable key instead of [_] #253

Open
FissoreD opened this issue Jul 30, 2024 · 1 comment
Open

CHR: add unique non instantiable key instead of [_] #253

FissoreD opened this issue Jul 30, 2024 · 1 comment

Comments

@FissoreD
Copy link
Collaborator

[_] 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

@gares
Copy link
Contributor

gares commented Jul 30, 2024

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.

| Discard -> [dummy_uvar_body]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants