Abstract
We present a straightforward, call-by-value embedding of a small logic programming language with a simple complete search. We construct the entire language in 54 lines of Racket---half of which implement unification. We then layer over it, in 43 lines, a reconstruction of an existing logic programming language, miniKanren, and attest to our implementation's pedagogical value. Evidence suggests our combination of expressiveness, concision, and elegance is compelling: since microKanren's release, it has spawned over 50 embeddings in over two dozen host languages, including Go, Haskell, Prolog and Smalltalk.
- Franz Baader and Wayne Snyder. Unification theory. In John Alan Robinson and Andrei Voronkov, editors, Handbook of Automated Reasoning, pages 445–532. Elsevier and MIT Press, 2001.Google Scholar
- Isaac Balbin and Koenraad Lecot. Logic Programming: A Classified Bibliography. Springer Science & Business Media, 2012. Google Scholar
Digital Library
- Michel Billaud. Prolog Control Structures: a Formalization and its Applications. In K. Fuhi and M. Nivat, editors, Programming of Future Generation Computers, pages 57–73. Elsevier Science Publishers, 1988. Google Scholar
Digital Library
- William E. Byrd and Daniel P. Friedman. αKanren: A Fresh Name in Nominal Logic Programming. In Scheme 8, pages 79–90 (see also http://webyrd.net/alphamk/alphamk.pdf for improvements ), 2007.Google Scholar
- William E. Byrd, Eric Holk, and Daniel P. Friedman. miniKanren, Live and Untagged: Quine Generation via Relational Interpreters (Programming Pearl). In Scheme 12, September 2012. Google Scholar
Digital Library
- Venanzio Capretta. General recursion via coinductive types. Logical Methods in Computer Science, 1(2), 2005.Google Scholar
- Mats Carlsson. On implementing Prolog in functional programming. New Generation Computing, 2(4):347–359, 1984.Google Scholar
Digital Library
- Matthew Flatt and PLT. Reference: Racket. Technical Report PLT-TR-2010-1, PLT Design Inc., 2010. http:// racket-lang.org/tr1/.Google Scholar
- Andreas Fordan. Projection in Constraint Logic Programming. Ios Press, 1999.Google Scholar
- Daniel P. Friedman and Oleg Kiselyov. A declarative applicative logic programming system, 2005.Google Scholar
- Daniel P. Friedman, William E. Byrd, and Oleg Kiselyov. The Reasoned Schemer. MIT Press, Cambridge, MA, 2005. Google Scholar
Digital Library
- Steven E. Ganz, Daniel P. Friedman, and Mitchell Wand. Trampolined Style. In Proc. 4th ICFP, pages 18–27. ACM, 1999. Google Scholar
Digital Library
- Jason Hemann and Daniel P. Friedman. µKanren: A minimal functional core for relational programming. In Scheme 13, 2013.Google Scholar
- Jason Hemann and Daniel P. Friedman. A framework for extending microkanren with constraints. In Scheme 15, 2015.Google Scholar
- Forthcoming.Google Scholar
- Ralf Hinze. Deriving backtracking monad transformers. In ACM SIGPLAN Notices, volume 35, pages 186–197. ACM, 2000. Google Scholar
Digital Library
- Ralf Hinze. Prolog’s control constructs in a functional setting: Axioms and implementation. International Journal of Foundations of Computer Science, 12(02):125–170, 2001.Google Scholar
Cross Ref
- Joxan Jaffar, Michael J. Maher, Peter J. Stuckey, and Roland HC Yap. Output in CLP(R). In Fifth Generation Computing Systems, pages 987–995, 1992.Google Scholar
- Oleg Kiselyov. The taste of logic programming, 2006.Google Scholar
- Oleg Kiselyov, Chung-chieh Shan, Daniel P. Friedman, and Amr Sabry. Backtracking, interleaving, and terminating monad transformers: (functional pearl). In Olivier Danvy and Benjamin C. Pierce, editors, Proceedings of the 10th ACM SIGPLAN ICFP, pages 192–203. ACM, September 2005. Google Scholar
Digital Library
- H. J. Komorowski. QLOG: The programming environment for PROLOG in LISP. In K. L. Clark et al., editors, Logic Programming, pages 315–324. Academic Press, 1982.Google Scholar
- Robert A. Kowalski. Logic for Problem Solving. North-Holland/Elsevier, 1979. Google Scholar
Digital Library
- Ramana Kumar. Mechanising Aspects of miniKanren in HOL, 2010. Australian National University. Bachelors thesis.Google Scholar
- Lee Naish. Pruning in logic programming. Technical report, Technical Report 95/16, Department of Computer Science, University of Melbourne, June 1995.Google Scholar
- Joseph P. Near, William E. Byrd, and Daniel P. Friedman. αleanTAP : A declarative theorem prover for first-order classical logic.Google Scholar
- John Alan Robinson. A machine-oriented logic based on the resolution principle. Journal of the ACM (JACM), 12(1):23– 41, 1965. Google Scholar
Digital Library
- Silvija Seres. The Algebra of Logic Programming. PhD thesis, University of Oxford, 2001.Google Scholar
- Olin Shivers. List Library. Scheme Request for Implementation. SRFI-1, 1999.Google Scholar
- Ben A. Sijtsma. On the productivity of recursive list definitions. ACM Trans. Program. Lang. Syst., 11(4):633–649, October 1989. doi: 10.1145/69558.69563. Google Scholar
Digital Library
- JM Spivey and Silvija Seres. Embedding Prolog in Haskell. In E. Meier, editor, Haskell 99, 1999.Google Scholar
Index Terms
A small embedding of logic programming with a simple complete search
Recommendations
A small embedding of logic programming with a simple complete search
DLS 2016: Proceedings of the 12th Symposium on Dynamic LanguagesWe present a straightforward, call-by-value embedding of a small logic programming language with a simple complete search. We construct the entire language in 54 lines of Racket---half of which implement unification. We then layer over it, in 43 lines, ...
A unified approach to solving seven programming problems (functional pearl)
We present seven programming challenges in Racket, and an elegant, unified approach to solving them using constraint logic programming in miniKanren.
miniKanren, live and untagged: quine generation via relational interpreters (programming pearl)
Scheme '12: Proceedings of the 2012 Annual Workshop on Scheme and Functional ProgrammingWe present relational interpreters for several subsets of Scheme, written in the pure logic programming language miniKanren. We demonstrate these interpreters running "backwards"---that is, generating programs that evaluate to a specified value---and ...







Comments