core-logic

Justin 2018-02-10T00:02:48.000135Z

hey, I am extremely-not a logical programming pro, I've been trying to use core.logic to generate test cases with somewhat complex constraints, and it works pretty decently for the most part as far as being a nice way to specify my constraints. the problem I'm facing now is that it tends to get stuck in particular branches of the search tree, when in reality I'd like to do something of a uniform-ish (for some meaning of uniform) sampling of the search tree - is there a way of doing this kind of thing in core.logic or am I using the wrong tool?

2018-02-10T00:10:15.000078Z

what do you mean by stuck?

2018-02-10T00:11:04.000075Z

core.logic uses a sort of streaming interleaving technique to avoid getting stuck in divergent goals

Justin 2018-02-10T00:14:01.000159Z

so I guess it's possible that I don't fully understand my problem 🙂 I guess what I'm seeing more concretely is like, the DFS is very observable in the output of my program

Justin 2018-02-10T00:14:33.000166Z

perhaps "stuck" was the wrong word - it is finding plenty of solutions, I would like to somehow have a way of generating more varied solutions

2018-02-10T00:15:45.000244Z

it will depend on the structure of your goals, but if you have a recursive goal that never reaches a base case for example, core.logic will still search other branches around that goal

2018-02-10T00:16:14.000221Z

core.logic will generate every possible solution

2018-02-10T00:16:41.000307Z

but you have little to no control of the order in which it generates them

Justin 2018-02-10T00:19:42.000152Z

I see, and there's no way I can say. limit the number of solutions that are reported from a particular branch?

2018-02-10T00:20:00.000251Z

no

Justin 2018-02-10T00:20:18.000313Z

i see, ok, thanks

2018-02-10T00:21:07.000152Z

you may want to look at test.check or data.generators, or spec for generating test cases

Justin 2018-02-10T00:22:59.000295Z

I haven't looked at test.check specifically but none of the quickcheck-likes I investigated seemed to allow me to do the same kind of branching search and goal-specifying that a prolog-like would

Justin 2018-02-10T00:23:06.000043Z

I feel like what I really want is some hybrid of those

2018-02-10T00:25:04.000155Z

of course I don't know what you are generating, but I would be surprised you couldn't do it via test.check

Justin 2018-02-10T00:25:55.000133Z

ok, I will investigate that, thanks for the assistance