Fork me on GitHub
#core-logic
<
2018-09-14
>
rickmoynihan12:09:29

agreed. I think the confusion is also perhaps because conj in microkanren is not clojure’s conj. It’s conj^2 which is conjunctive (`and`)… likewise disj in microkanren is disjuntive i.e. or. Not sure if core.logic ports these functions directly either, as they’re part of microkanren… and perhaps not minikanren… would need to look.

rickmoynihan12:09:37

I don’t have the papers in front of me though so could also be wrong…

risto20:09:11

i know -o is a relation, how those lazy streams and conj/disj are implremented key in making sure appendo doesnt recurse forever and blow the stack

hiredman20:09:41

thats not true, the fact that appendo does case analysis and only one of the cases can be true at a time, and induction on the first argument (the first argument is smaller on every recursvie call) is what guarantees termination

hiredman20:09:20

ah, the blowing the stack

hiredman20:09:03

that is because in your implementation you are doing the recursive call to appendo when appendo is called, not as the logic program is running

hiredman20:09:19

doing that switch is tricky in a language without macros

hiredman20:09:08

in my go implementation I had a special goal constructor for making recursive calls to make that work

risto20:09:03

there's something key with that which im messing up

hiredman20:09:30

it doesn't have to do with the stream implementation

hiredman20:09:12

it has to do with goal construction, which without macros, you can't delay the recursive call until you know if you have to do it

hiredman20:09:18

so if or or disj is a regular function, all of its arguments must be evaluated before it is called, and if one of those is a recursive call, boom

risto20:09:58

yeah, it has to delay the goal somehow

hiredman20:09:41

so my Call goal constructor in go would look something like (fn [goal & args] (fn [package] ((apply goal args) package))) in clojure