Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.logic by

The docstring of {{condu}} reads

{quote}
Committed choice. Once the head (first goal) of a clause has succeeded, remaining goals of the clause will only be run once. Non-relational.
{quote}

The sentence with respect to the once-semantics isn't correct. The head (first goal) can succeed at most once whereas the remaining goals of the clause committed to can succeed an unbounded number of times. The following example demonstrates that.

`
(defn y-or-n [x]
(conde
[(== x :y)]
[(== x :n)]))

(run* [x y]
(condu
[(y-or-n x) (== y 1)] ;; (y-or-n x) succeeds once because it's the head goal
[(== x :y) (== y 2)]))
;;=> ([:y 1])

(run* [x y]
(condu
[(== y 1) (y-or-n x)] ;; (y-or-n x) succeeds twice because it's not the head goal
[(== x :y) (== y 2)]))
;;=> ([:y 1] [:n 1])
`

The current behavior shown in the example is in compliance with miniKanren on Scheme, so it's just the docstring which isn't right. The implementation is correct.

1 Answer

0 votes
by
...