Mini-Kanren, core.logic, clojure: Examined exercise pattern 60

This is NOT homework - the solution is already in the text. I just did not understand the solution.

Problem

(run* (q) (let [a (== true q) b (== false q)] b)) 

The right decision

 (false) 

My convinced decision

 () 

My confusion

Apparently, the string "a (== true q)" is NOT executed, since the target is only b. It bothers me. My mental model so far for logical programming has been:

  • consider all possible assignments q
  • display those that manage to go through the entire program

    Thus, "a (== true q)" forces q = true, which makes it impossible to execute the string "b (== false q)".

    However, apparently, only the “fabrications necessary to calculate the goal” are fulfilled. What's happening? What is the right mental execution model for core.logic / mini-kanren?

thanks

(By the way, I'm clearly mistaken, since mini-karen + core.logic agre with each other - I just want to understand what I'm doing wrong.)

+7
source share
1 answer

== creates a goal. But you will not miss target a to run. So the run does not know about it. A similar situation is as follows:

 (defn call [f] (f)) (call (let [a #(println "a") b #(println "b")] b)) 

Function a is created but not passed to call . Therefore, it is never executed.

+9
source

All Articles