Fork me on GitHub
#core-logic
<
2018-08-03
>
bajrachar17:08:53

I am trying to understand how a tabled goal works in core.logic?

bajrachar17:08:38

can it be used to eliminate circular references in for example a graph traversal for example

bajrachar17:08:26

or is it supposed to eliminate duplicates in the result

bajrachar17:08:30

I have a logic expression as such - which traverses a child hierarchy. CHD stands for Child relation and RN stands for narrow relation

bajrachar17:08:29

Issue is - it can go into endless loop if there are circular references

hiredman17:08:14

I think it is more like a performance optimization, if you have a goal that diverges it won't stop it from diverging

hiredman17:08:33

there is a correspondence between proof by induction and recursion, they both need a base case

hiredman17:08:33

you might be able to get by using one of the non-relational variants of conde

hiredman17:08:03

maybe conda

hiredman17:08:51

or make the clauses in your conde mutually exclusive

bajrachar17:08:46

Thank you @hiredman - as always your responses are very helpful

bajrachar17:08:42

just so I follow what you're saying - "divergence" means there is a cycle right?

hiredman17:08:36

it could be caused by cycle in something you are are traversing recursively, my very rough understanding of it is divergence == infinitely looping logic program

bajrachar17:08:08

by making the clauses mutually exclusive - do you mean adding something like !=

bajrachar17:08:05

sorry if this is a very stupid question 🙂 - still learning the ropes of core.logic

bajrachar17:08:34

It is very interesting - at the same time very difficult to wrap your head around

hiredman17:08:55

yeah, != or some other goal that will fail on the one branch if the other branch is the one you want

bajrachar18:08:17

Ah - Thank you - I will try that

hiredman18:08:01

I was wrong about tabling: https://github.com/clojure/core.logic/wiki/Features#tabling the docs say it will turn a non-terminating logic program in to a terminating one

bajrachar18:08:51

that was what I thought it was supposed to do - but still I see it is diverging - maybe I need to table only the recursive portion