core-logic

bajrachar 2018-08-03T17:20:53.000094Z

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

bajrachar 2018-08-03T17:21:38.000069Z

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

bajrachar 2018-08-03T17:24:26.000039Z

or is it supposed to eliminate duplicates in the result

bajrachar 2018-08-03T17:28:30.000507Z

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

bajrachar 2018-08-03T17:29:29.000217Z

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

2018-08-03T17:46:14.000325Z

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

2018-08-03T17:49:33.000066Z

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

2018-08-03T17:50:33.000080Z

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

2018-08-03T17:51:03.000446Z

maybe conda

2018-08-03T17:51:51.000336Z

or make the clauses in your conde mutually exclusive

bajrachar 2018-08-03T17:52:46.000503Z

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

bajrachar 2018-08-03T17:53:42.000051Z

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

2018-08-03T17:55:36.000064Z

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

bajrachar 2018-08-03T17:58:08.000077Z

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

bajrachar 2018-08-03T17:59:05.000008Z

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

bajrachar 2018-08-03T17:59:34.000260Z

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

2018-08-03T17:59:55.000524Z

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

bajrachar 2018-08-03T18:01:17.000221Z

Ah - Thank you - I will try that

2018-08-03T18:19:01.000153Z

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

bajrachar 2018-08-03T18:26:51.000154Z

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