This is NOT homework -- the solution is already in the text. I just failed to understand the solution.
Problem
(run* (q)
(let [a (== true q)
b (== false q)]
b))
Correct Solution
(false)
My believed solution
()
My Confusion
Apparently the "a (== true q)" line is NOT executed, since only b is the goal. This confuses me. My mental model so far for logic programming has been:
- consider all possible assignemnts to q
output the ones that manages to pass through the entire program
Thus, the "a (== true q)" forces q = true, which makes it impossible to satisfy the "b (== false q)" line.
However, apparently only "thigns needed to compute the goal" are executed. What's going on? What's the right mental execution model for core.logic / mini-kanren?
Thanks
(BTW, I'm clearly in the wrong, since mini-karen + core.logic agre with each other -- I just want to understand what I'm doing wrong.)
==
produces a goal. But you don't pass thea
goal to run. So run doesn't know about it. A comparable situation is this:The
a
function is created but not passed tocall
. So it is never executed.