Fork me on GitHub
#core-logic
<
2018-02-10
>
Justin00:02:48

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?

hiredman00:02:15

what do you mean by stuck?

hiredman00:02:04

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

Justin00:02:01

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

Justin00:02:33

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

hiredman00:02:45

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

hiredman00:02:14

core.logic will generate every possible solution

hiredman00:02:41

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

Justin00:02:42

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

Justin00:02:18

i see, ok, thanks

hiredman00:02:07

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

Justin00:02:59

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

Justin00:02:06

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

hiredman00:02:04

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

Justin00:02:55

ok, I will investigate that, thanks for the assistance