I have previously written about Adderall and logic programming in general, but I never made a really serious attempt on learning it. I’m going to give it a another go and see how far I get this time. Since I don’t have the Reasoned Schemer (which supposedly is really great book though), I have to rely on resources at http://minikanren.org/. Bear in mind, that I’m still learning all this stuff and most of my explanations might be completely wrong.
With miniKanren, I should be able to define one or more variables and some rules that define their values or relations. Adderall can then work it’s magic and find me missing values or verify that the results I have are correct (this is pretty hazy description, but I’m still trying to grasp the whole thing). It is possible to extend miniKanren (and Adderall I suppose) to work in constraint logic programming, which is the part I’m mainly interested at the moment.
An example program for Adderall is shown here:
(run* [q] (condᵉ [(≡ true q)] [(≡ false q)]))
Essentially, it is asking all possible values of q, when q is true or q is false. Output of the program is [true, false]. ≡ is unification operator and as the name implies, it is used to unify two values. condᵉ on another hand, is used to return multiple values. It can read as or in this case (at least in this case).
This doesn’t look particularly powerful or even useful. But these are just very basic building blocks that are built upon and extended to create more powerful tools. For example, here is a way of solving the zebra puzzle with Adderall.