added a comment - - edited
This issue actually impacts any "single shot" constraint that implements `-relevant?` as simply returning `true`. The problem is that the `cgoal` constraint wrapper checks `runnable?`, runs the constraint, and then checks `relevant?` and if that's true adds the constraint even though it may very well may be entailed!
There are 6 constraints (1 of them the `defc` macro) which implement `-relevant?` as returning `true`. I think we should have more support (a protocol) for constraints which are essentially "single shot" and don't need to bother with implementing the `IRelevant` protocol.
For some background - the CLP(FD) constraints benefit most from the `IRelevant` protocol, where the constraints involve up to 3 terms and a considerable amount of propagation work may be avoided by doing some checking up front.
Implementing -force-ans in Tie
clojure.core.logic.IForceAnswerTerm (-force-ans [v x] (force-ans (:body v)))resolves the test above, but not this one:
(is (= (run* [q] (nom/fresh [a b c] (fresh [x y] (== x 1) (predc x number? `number?) (== (nom/tie b (nom/tie a [a x])) (nom/tie c q))))) [(nom/tie 'a_0 '(a_0 1))])) ;; still false b/c of extra :- number? constraintclojure.core.logic.IForceAnswerTerm (-force-ans [v x] (force-ans (:body v)))(is (= (run* [q] (nom/fresh [a b c] (fresh [x y] (== x 1) (predc x number? `number?) (== (nom/tie b (nom/tie a [a x])) (nom/tie c q))))) [(nom/tie 'a_0 '(a_0 1))])) ;; still false b/c of extra :- number? constraint