core.logic

Usage of c.c.l/prep can lead to a different result (compared to not using it)

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

Below are two expressions that differ only in the use of c.c.l/prep. When using prep there is an extra term returned, that includes a free ?a, which seems wrong, considering the second pattern should unify on the :a key.

(let [rules
      [{:pattern (partial-map (prep {:a :clojure.core.logic/not-found :x 1}))
        :production (prep {:a 1})}
       {:pattern (partial-map (prep {:a '?a :c :clojure.core.logic/not-found}))
        :production (prep {:c '(* ?a 2)})}]]
  (run* [q]
    (fresh [pattern production guards rule rule-name]
      (membero {:pattern pattern :production production} rules)
      (== {:x 1}  pattern)
      (== q production))))
  => ({:a 1} {:c (* _.0 2)})
(let [rules
      [{:pattern (partial-map {:a :clojure.core.logic/not-found :x 1})
        :production {:a 1}}
       {:pattern (partial-map {:a '?a :c :clojure.core.logic/not-found})
        :production {:c '(* ?a 2)}}]]
  (run* [q]
    (fresh [pattern production guards rule rule-name]
      (membero {:pattern pattern :production production} rules)
      (== {:x 1}  pattern)
      (== q production))))
  => ({:a 1})

Activity

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: