Two related questions in one:
Can Clojure module core.logic do arithmetic, logical comparison, etc. like regular Prolog? I foresee the following:
(defrel points person n) (fact :bob 2) (fact :charlie 3) (run* [q] (fresh [xy] (points :bob x) (points :charlie y) (< xy) (== q (+ xy)))) => (5)
In this example, neither a logical comparison (< xy) nor an attempt to associate q with (+ xy) are performed. I believe this is due to the fact that I am working with LVar s and not integers at this point, and I cannot make these comparisons because the characters are not yet connected. But it works in the prologue:
points(bob, 2). points(charlie, 3). ?- points(bob, X), points(charlie, Y), Result is X + Y. => Result = 5.
In a similar vein, can you somehow use the Clojure functions (which return boolean values ββor other "true" values) as logical predicates? In other words, use functions to say Minikanren that combine terms or not. Something like:
(defmagic startswithhi-o [v] (.startsWith v "hi")) (defrel person n) (fact person "bob") (fact person "hillary") (run* [q] (fresh [n] (person n) (startswithhi-o n) (== qn))) => ("hillary")
If I try such things, I get errors, also complaining that LVars are not connected. Is there any way to do this?
Finally, if someone read this far, I might also ask: are there any plans to include probabilistic logic in core.logic, according to:
http://dtai.cs.kuleuven.be/problog/ ?
I can't hold my breath, but that would be awesome!
logic clojure prolog
gilesc
source share