Skip to content

Commit

Permalink
anoter issue with cKanren, related to suspensions
Browse files Browse the repository at this point in the history
  • Loading branch information
namin committed Dec 18, 2012
1 parent b59d7c8 commit 63a9805
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/test/clojure/clojure/core/logic/nominal/tests.clj
Expand Up @@ -263,6 +263,18 @@
(infd x (interval 1 3))
(== [x y] q))))
'([1 1] [2 2] [3 3])))
(is (= (run* [q]
(nom/fresh [a b]
(fresh [x y]
(== (nom/tie a (nom/tie b [b y])) (nom/tie b (nom/tie a [a x])))
;; TODO(namin): unfortunately, unifying with y instead of x generates a class cast exception:
;; clojure.core.logic.nominal.Suspension cannot be cast to java.lang.Number
;; at clojure.core.logic.IntervalFD.member_QMARK_ (logic.clj:525)
;; commenting out next constraint, and adding following to get intended result
;; (infd y (interval 1 3))
(infd x (interval 1 3))
(== [x y] q))))
'([1 1] [2 2] [3 3])))
(is (= (run* [q]
(nom/fresh [a b]
(fresh [x y]
Expand Down

2 comments on commit 63a9805

@swannodette
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been working on a possible solution to this. The purpose of the SubstValue type is to support "compound" values in the Substitutions. For example I think what we want the Substitutions map to look like is something like this:

{x (SubstValue. ::unbound {::fd (interval 1 3) ::nom ...})
 y (SubstValue. ::unbound {::fd (interval 1 3) ::nom ...})}

I'm not exactly sure what we would store under ::nom as I still haven't had time to look into how alphaKanren works because I've been a bit busy trying to squash some pressing cKanren bugs. But perhaps you can see if this will work or needs to be augmented in some way?

@namin
Copy link
Owner Author

@namin namin commented on 63a9805 Dec 19, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, this is insightful, thanks. I'll think more about it. My first idea of storing the pis of suspensions in there doesn't quite work, since the same variable can have many suspensions, and they shouldn't unify.

BTW, I signed the CCA and sent it by snail mail today. It will probably arrive before we figure all this out ;-)

Please sign in to comment.