[LOGIC-106] cannot use fresh/conde in the invoke of a constraint Created: 20/Jan/13 Updated: 21/Jan/13 Resolved: 21/Jan/13 |
|
| Status: | Resolved |
| Project: | core.logic |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Defect | Priority: | Major |
| Reporter: | Nada Amin | Assignee: | David Nolen |
| Resolution: | Completed | Votes: | 0 |
| Labels: | None | ||
| Description |
|
This means that we cannot really emulate modes with constraints. The problem is related to -inc. An easy way to try it out is to have a dummy fresh goal in predc and see the failing tests. @@ -2932,7 +2932,7 @@
(invoke [this a]
(let [x (walk a x)]
(when (p x)
- ((remcg this) a))))
+ (bind* a (fresh [y] (== x x)) (remcg this)))))
IConstraintOp
(rator [_] (if (seq? pform)
`(predc ~pform)
|
| Comments |
| Comment by David Nolen [ 20/Jan/13 7:55 PM ] |
|
Sorry I didn't mean to suggest this approach. In general you cannot put search related operators into a constraint. In fact I think we should replace any instances of bind* and bind in constraint logic as they really are a part of the search infrastructure and I'd like them to become implementation details of a particular search approach. Instead I meant to suggest that the disjunction expressed by your example (run 1 [re]
(forall [s o]
(conde
[(== s '(foo bar bar bar))
(== o regex-BLANK)]
[(!= s '(foo bar bar bar))
(== o regex-NULL)])
(regex-matcho re s o)))
Is perhaps best described as an explicit constraint something more like: (defn regexc [s o]
(reify
IFn
(invoke [c a]
(let [s (walk* a)[
(if (= s '(foo bar bar bar))
((== o regex-BLANK) a)
((== o regex-NULL) a)))))
...
IRunnable
(runnable? [c a]
(ground-terms? x))
...))
Of course someone might want to write constraint like this quite often, then I think it's question of what the best way to support that might be. |
| Comment by David Nolen [ 21/Jan/13 11:56 AM ] |
|
No plans to add support for search operators in constraints in the near future. |