core.logic

predc constraint is not enforced when it could be

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

The predc number constraint fails to be enforced here.

(is (= (run* [q]
           (fresh [x]
             (== q x)
             (predc q number? `number?)
             (== x "foo")))
        ())) ;; false -- actual is ((_0 :- number?))

Inverting the first two goals gives the expected result.

(is (= (run* [q]
           (fresh [x]
             (predc q number? `number?)
             (== q x)
             (== x "foo")))
        ())) ;; OK

Activity

Hide
Nada Amin added a comment -

Actually, the problem is not specific to predc. It's an issue that addcg can overwrite a precious binding. Here is another example without predc:

(is (= (run* [q]
           (fresh [x y z]
             (== q x)
             (distinctfd [q y])
             (== y x)
             (infd q x y (interval 1 3))))
        ()) ;; false -- actual is [1 2 3]

I have a fix that I'll submit shortly.

Show
Nada Amin added a comment - Actually, the problem is not specific to predc. It's an issue that addcg can overwrite a precious binding. Here is another example without predc:
(is (= (run* [q]
           (fresh [x y z]
             (== q x)
             (distinctfd [q y])
             (== y x)
             (infd q x y (interval 1 3))))
        ()) ;; false -- actual is [1 2 3]
I have a fix that I'll submit shortly.
Hide
Nada Amin added a comment -
Show
Nada Amin added a comment - Let's discuss on GitHub first: https://github.com/namin/core.logic/compare/logic-81
Hide
Nada Amin added a comment -

logic-81.diff include fix and tests. Since the interface for the constraint store has been modified, some tests needed to be udpated.

discussion: https://github.com/clojure/core.logic/pull/14

rebase:
https://github.com/namin/core.logic/compare/logic-81-base

Show
Nada Amin added a comment - logic-81.diff include fix and tests. Since the interface for the constraint store has been modified, some tests needed to be udpated. discussion: https://github.com/clojure/core.logic/pull/14 rebase: https://github.com/namin/core.logic/compare/logic-81-base

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: