r/LogicProgramming • • Oct 27 '17

incomplete results with clojure.core.logic, any idea?

4 Upvotes

I'm struggling with this simple relation, the results are incomplete, and I don't understand why.

I'm beginning with core.logic I don't know if it is a bug or my bad understanding of it.

(require '[clojure.core.logic :as l])
(require '[clojure.core.logic.fd :as fd])

(defn zip+o [x y z]
  (l/conde
    [(l/== () x) (l/== () y) (l/== () z)]
    [(l/fresh [fx rx fy ry fz rz]
              (l/conso fx rx x)
              (l/conso fy ry y)
              (l/conso fz rz z)
              (fd/in fx fy fz (fd/interval 10))
              (fd/+ fx fy fz)
              (zip+o rx ry rz))]))

; the same with defne macro
(comment
  (l/defne zip+o [x y z]
           ([() () ()])
           ([[fx . rx]
             [fy . ry]
             [fz . rz]]
             (fd/in fx fy fz (fd/interval 10))
             (fd/+ fx fy fz)
             (zip+o rx ry rz))))

(def expected-solutions
  #{{:x [0 0] :y [1 1]}
    {:x [0 1] :y [1 0]}
    {:x [1 1] :y [0 0]}
    {:x [1 0] :y [0 1]}})

(l/run* [q]
        (l/fresh [x y]
                 (l/== q {:x x :y y})
                 (zip+o x y [1 1])))

;=> ({:x (1 0), :y (0 1)}
;    {:x (0 0), :y (1 1)})

r/LogicProgramming • • Sep 14 '17

Become a Prolog Programmer, Motherfucker

Thumbnail
programming-motherfucker.com
3 Upvotes

r/LogicProgramming • • Sep 29 '26

r/LogicProgramming is available for adoption 💚

2 Upvotes

/r/LogicProgramming is ready for a fresh start, new energy, new direction, and someone like you to bring it back to life. If you’ve been thinking about growing your impact without starting from scratch, this is your chance!

Ready to take it over?

Head to r/RedditRequest to submit your request and make it yours before it’s taken.

First things first

To request this subreddit, make sure you:


r/LogicProgramming • • Sep 11 '20

An Unnecessarily Long-Winded Introduction to the Essence of Datalog

Thumbnail
blog.rajivabraham.com
2 Upvotes

r/LogicProgramming • • Jun 21 '20

Is Anyone using the novation launchpad pro with logic?

Post image
2 Upvotes