core.logic

The docstring of condu is incorrect or at least confusing

Details

  • Type: Enhancement Enhancement
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:

Description

The docstring of condu reads

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

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.

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: