core.logic

nominal unification misses after-the-fact fd constraints

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Related to http://dev.clojure.org/jira/browse/LOGIC-92, these two snippets both return (nom/tie 'a_0 1) instead of three results for 1, 2, 3.

(run* [q]
  (nom/fresh [a b c]
    (fresh [x y]
      (== (nom/tie b (nom/tie a x)) (nom/tie c q))
      (infd x (interval 1 3)))))

(run* [q]
  (nom/fresh [a b c]
    (fresh [x y]
      (infd y (interval 1 3))
      (== (nom/tie b (nom/tie a x)) (nom/tie c q))
      (== x y))))

Activity

Hide
Nada Amin added a comment -

logic-98.diff fixes this by forcing all nom-related vars at once.

Do you have any ideas for separating the concern, so that force-ans doesn't need to know about ::nom?

Show
Nada Amin added a comment - logic-98.diff fixes this by forcing all nom-related vars at once. Do you have any ideas for separating the concern, so that force-ans doesn't need to know about ::nom?
Hide
David Nolen added a comment -

Will need to think about this some more.

Show
David Nolen added a comment - Will need to think about this some more.
Hide
Nada Amin added a comment -

Ouch! Here is a snippet that doesn't do the right thing, even with the patch:

(run* [q]
  (nom/fresh [a b c d]
    (fresh [x y z]
      (== (nom/tie b (nom/tie a x)) (nom/tie c z))
      (infd x (interval 1 3))
      (== (nom/tie d q) z))))

It returns only (1) instead of (1 2 3).

Show
Nada Amin added a comment - Ouch! Here is a snippet that doesn't do the right thing, even with the patch:
(run* [q]
  (nom/fresh [a b c d]
    (fresh [x y z]
      (== (nom/tie b (nom/tie a x)) (nom/tie c z))
      (infd x (interval 1 3))
      (== (nom/tie d q) z))))
It returns only (1) instead of (1 2 3).
Hide
Nada Amin added a comment -

logic-98-nominal.diff is a solution that works for all three test cases above by simply making core.logic.nominal aware of ::fd and updating the doms when appropriate.

Show
Nada Amin added a comment - logic-98-nominal.diff is a solution that works for all three test cases above by simply making core.logic.nominal aware of ::fd and updating the doms when appropriate.
Hide
David Nolen added a comment -

fixed, http://github.com/clojure/core.logic/commit/ef27fa3ed2381f3ad4685d4bc59a298646a4febb

It would be nice if nominal didn't need to know about fd, as there will be other "enumerable" domains in the future. But this works great for now.

Show
David Nolen added a comment - fixed, http://github.com/clojure/core.logic/commit/ef27fa3ed2381f3ad4685d4bc59a298646a4febb It would be nice if nominal didn't need to know about fd, as there will be other "enumerable" domains in the future. But this works great for now.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: