core-logic

pbaille 2017-11-02T13:50:49.000691Z

thank you @norman, i've found a way to obtain the correct solution, see this ticket if interested https://dev.clojure.org/jira/browse/LOGIC-185

pbaille 2017-11-02T13:51:13.000001Z

I've got another question

pbaille 2017-11-02T13:53:30.000634Z

I'm going thru the reasoned schemer and i've noticed that the order of excecution differ sometimes in core.logic. in particular 'conde' seems to behave differently, looks like it tries all branch before doing any recursion. Any toughts on this?

pbaille 2017-11-02T14:01:59.000448Z

(defn pairo [x]
  (fresh [y] (firsto x y)))

(defn unwrapo [x y]
  (conde
    [(pairo x) (fresh [a] (firsto x a) (unwrapo a y))]
    [(== x y)]))

(run* [q] (unwrapo '(((pizza))) q))
; ((((pizza))) 
;  ((pizza)) 
;  (pizza) 
;  pizza
; )

;while in TRS it returns

; (pizza
;  (pizza)
;  ((pizza))
;  (((pizza)))
; )


;both:
(run 1 [q] (unwrapo q 'pizza))
;and
(run 1 [q] (unwrapo (list (list q)) 'pizza))

;returns:

;=> (pizza)

;while in TRS it returns

;=> ()

pbaille 2017-11-02T17:59:33.000246Z

the wiki actually explain this difference, i've missed it, sorry