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

Ambiguity with cons null and disequality constraint #13

Open
brandonwillard opened this issue Dec 27, 2019 · 0 comments
Open

Ambiguity with cons null and disequality constraint #13

brandonwillard opened this issue Dec 27, 2019 · 0 comments
Labels
CLP Constraint Logic Programming question Further information is requested

Comments

@brandonwillard
Copy link
Member

This isn't a problem in the neq constraint, but it's a confusing ambiguity/gotcha that arises from cons's "null" value for lists being both [] and None (i.e. cons(1, []) == [1] and cons(1, None) == [1]).

This simple examples shows how the ambiguity can arise.

from kanren import run, eq, conde, lall, var
from kanren.constraints import neq
from cons import cons

a_lv, b_lv = var(), var()
res = run(0, a_lv,
          neq([1], cons(1, a_lv)),
          eq(a_lv, b_lv),
          eq(b_lv, None))

assert res == ()

The assertion fails, even though the cons(1, a_lv) term will reify to [1].

@brandonwillard brandonwillard added CLP Constraint Logic Programming question Further information is requested labels Mar 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLP Constraint Logic Programming question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant