Fork me on GitHub
#core-logic
<
2018-09-13
>
rickmoynihan12:09:21

@risto: minikanren and microkanren are different beasts in terms of implementation. The stream stuff is specific to microkanren and descendants of it I believe. Minikanren as I understand it is as described/used in the reasoned schemer. microkanren in the reasoned schemer 2nd edition. Also Byrd’s thesis is minikanren / Hemann’s paper microkanren. I’m only just delving into the differences here myself, but I’m not sure programs written for one are always portable to the other… e.g. microkanren skips the occurs check for infinite loops — which might be pertinent to what you’re saying.

rickmoynihan12:09:10

I think it’s more or less true that minikanren semantics is what core.logic essentially implements. So if you’re looking at a core.logic appendo and wondering how it works with reference to the microkanren scheme implementation… I’d first check to see if there is an important difference between how appendo is written for the two dialects. It may be the same, but I wouldn’t be surprised if it wasn’t.

risto12:09:29

does anyone know any paper I can read on this or something similar? I can't find anything on this

risto12:09:18

i don't want to rely on reverse engineering some implementation in case they're doing something weird to make it work, which could end up breaking other abstractions in weird ways

rickmoynihan15:09:30

If you’re using core.logic I think you’re probably safest sticking to minikanren literature…. but I have questions about this stuff myself, because i’m not 100% sure either.

hiredman15:09:18

core.logic is a minikanren like clojure is a lisp

hiredman15:09:26

I still think you are likely encountering a confusion of different levels, and the things you think are calling each other are at different levels of abstraction and not actually calling each other

risto16:09:23

i'm not confusing different levels of abstraction

risto16:09:30

i'm working on implementing minikanren

hiredman16:09:47

sure, I've done that, I followed the original thesis paper describing it

hiredman16:09:23

which seems to be a dead link now 😕

rickmoynihan23:09:33

Incidentally I can confirm there are differences in appendo between minikanren and microkanren… though they’re pretty close: The reasoned schemer 2nd edition (microkanren) lists it as:

(defrel (appendo l t out)
  (conde
    ((nullo l) (== t out))
    ((fresh (res)
     (fresh (d)
       (cdro l d)
       (appendo d t res))
     (fresh (a)
       (caro l a)
       (conso a res out))))))

rickmoynihan23:09:11

1st edition (minikanren) as:

(define appendo
  (lambda (l s out)
  (conde
    ((nullo l) (== s out))
    (else
      (fresh (a d res)
        (caro l a)
        (cdro l d)
        (appendo d s res)
        (conso a res out))))))

rickmoynihan23:09:39

(I hand typed those — so there may be errors)

rickmoynihan23:09:48

most differences are pretty negligible… main one here seems to be that fresh in microkanren doesn’t handle multiple bindings at once, and that conde no longer takes an else in microkanren

hiredman23:09:32

I know you keep saying it isn't a level confusion issue, but I really still think it is, because bind, flatmap, etc are part of the little mini monadic library used for the the lazy streams of results from goals, but they are not actually used in goals themselves

hiredman23:09:31

and it has been pretty much a million years since I read the paper, and my implementation was in go, so I didn't bother with any of the list processing library and instead built stuff for using reflection to unify over go records, so I didn't implement appendo or conso

hiredman23:09:48

conso, appendo, pretty much anything ending in o is a relation(or function returning a goal), that exists sort of within the domain of minikanren, but bind and flatmap are functions that exist outside of the domain of minikaren and are used to implement it

hiredman23:09:24

the papers tend translate the 'o' suffix as a ° (degree symbol) which can make it easy to miss and confuse the names