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

Add "occurs-check" functionality #36

Open
rlouf opened this issue Aug 4, 2022 · 2 comments
Open

Add "occurs-check" functionality #36

rlouf opened this issue Aug 4, 2022 · 2 comments
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed important

Comments

@rlouf
Copy link
Contributor

rlouf commented Aug 4, 2022

I am trying to reproduce the examples in The Reasoned Schemer using kanren, and example 45 ("a variable cannot be equal to a list in which it occurs") hangs:

from kanren import var, run, eq

run(1, q, eq((q,), q))
# expected the empty tuple ()

The following also hangs:

from cons import cons
from kanren import var, run, eq

run(1, q, eq(cons(q, ()), q))
# expected an empty tuple

I am not sure this is a bug, so posting before investigating further.

@brandonwillard brandonwillard added the bug Something isn't working label Aug 4, 2022
@brandonwillard
Copy link
Member

brandonwillard commented Aug 4, 2022

This looks like an "occurs-check"-related issue appearing in reify, because the unification state would be {q: (q,)} and reify would attempt to walk (q,) and replace the q inside it with another (q,), then walk that result, and so on.

@brandonwillard brandonwillard added the enhancement New feature or request label Aug 4, 2022
@brandonwillard
Copy link
Member

FYI: I labeled this a bug for the time being, but, since unification doesn't advertise an "occurs-check" feature/support, it's more of a feature request.

@brandonwillard brandonwillard transferred this issue from pythological/kanren Aug 4, 2022
@brandonwillard brandonwillard changed the title kanren hangs on a simple example Add "occurs-check" functionality Aug 4, 2022
@brandonwillard brandonwillard added help wanted Extra attention is needed important labels Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request help wanted Extra attention is needed important
Projects
None yet
Development

No branches or pull requests

2 participants