MiniKanren: logic programming in Scheme
(require minikanren) | package: minikanren |
An embedding of logic programming in Scheme.
The miniKanren language in this package is the language presented in Byrd and Friedman’s "From variadic functions to variadic relations" [1]; it is a descendant of the language presented in Friedman, Byrd, and Kiselyov’s The Reasoned Schemer [2]. The code itself was written by (in alphabetical order) Will Byrd, Dan Friedman, Oleg Kiselyov, and Chung-Chieh Shan.
Minikanren provides the following new core forms, which comprise the core of the miniKanren language. These forms are all described in much greater detail in Byrd and Friedman’s "From variadic functions to variadic relations" [1], which those interested in learning how to use this library should consult. The documentation here is included only for reference.
syntax
(== e_1 e_2)
syntax
(conde ((goal_1 goal_1a ...) (goal_2 goal_2a ...) ...))
syntax
(fresh (x ...) goal_0 goal_1 ...)
syntax
(run n (x) goal_0 goal_1 ...)
Minikanren also provides the following helpers:
syntax
(run* (x) goal_0 goal_1 ...)
syntax
(conda ((goal_1 goal_1a ...) (goal_2 goal_2a ...) ...))
syntax
(condu ((goal_1 goal_1a ...) (goal_2 goal_2a ...) ...))
syntax
(project (x ...) goal_1 goal_2 ...)
References
[1] Byrd, William and Friedman, Daniel. "From variadic functions to variadic relations: a miniKanren perspective." In Proceedings of the 2006 Scheme and Functional Programming Workshop, 2006. Available online: http://scheme2006.cs.uchicago.edu/12-byrd.pdf.
[2] Friedman, Daniel, Byrd, William, and Kiselyov, Oleg. The Reasoned Schemer. MIT Press, 2005.