Welcome! Please see the About page for a little more info on how this works.

0 votes
in core.logic by
edited by

I'm solving a sub-part of my problem using core.logic. I'm anticipating that the declarative nature of describing the problem would lead to poor performance on large inputs.

But the setup I have is that the inputs to core.logic rarely change, but I query them a lot. So naturally I think that memoization would speed up the performance.

I could only memoize the results from top-level (l/run* form, but again that's less efficient than memoizing at every l/defne or at every call to conde, because the latter can give the same speedups as dynamic-programming does.

But I do not understand what kind of values (like LVars introduced by fresh) pass between the logical clauses. They are different from regular clojure values, and I have never even called one of the clauses (like l/== or l/membero) "normally". They are always called indirectly by l/run*.

So, do I need to do anything special if I want to memoize such defnes?

1 Answer

0 votes
by
selected by
 
Best answer

Never tried it, but I think it's called "tabling" in clojure.core.logic. Does tabled help? https://clojure.github.io/core.logic/#clojure.core.logic/tabled

by
Ah, that does it! A fuller explanation is available in byrd's dissertation, but I would've never thought to look at the "tabling" chapters was it not for your comment. Thanks!
...