skip to main content
article

A small embedding of logic programming with a simple complete search

Published:01 November 2016Publication History
Skip Abstract Section

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.

References

  1. 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 ScholarGoogle Scholar
  2. Isaac Balbin and Koenraad Lecot. Logic Programming: A Classified Bibliography. Springer Science & Business Media, 2012. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  4. 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 ScholarGoogle Scholar
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. Venanzio Capretta. General recursion via coinductive types. Logical Methods in Computer Science, 1(2), 2005.Google ScholarGoogle Scholar
  7. Mats Carlsson. On implementing Prolog in functional programming. New Generation Computing, 2(4):347–359, 1984.Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. Matthew Flatt and PLT. Reference: Racket. Technical Report PLT-TR-2010-1, PLT Design Inc., 2010. http:// racket-lang.org/tr1/.Google ScholarGoogle Scholar
  9. Andreas Fordan. Projection in Constraint Logic Programming. Ios Press, 1999.Google ScholarGoogle Scholar
  10. Daniel P. Friedman and Oleg Kiselyov. A declarative applicative logic programming system, 2005.Google ScholarGoogle Scholar
  11. Daniel P. Friedman, William E. Byrd, and Oleg Kiselyov. The Reasoned Schemer. MIT Press, Cambridge, MA, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. Steven E. Ganz, Daniel P. Friedman, and Mitchell Wand. Trampolined Style. In Proc. 4th ICFP, pages 18–27. ACM, 1999. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. Jason Hemann and Daniel P. Friedman. µKanren: A minimal functional core for relational programming. In Scheme 13, 2013.Google ScholarGoogle Scholar
  14. Jason Hemann and Daniel P. Friedman. A framework for extending microkanren with constraints. In Scheme 15, 2015.Google ScholarGoogle Scholar
  15. Forthcoming.Google ScholarGoogle Scholar
  16. Ralf Hinze. Deriving backtracking monad transformers. In ACM SIGPLAN Notices, volume 35, pages 186–197. ACM, 2000. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarCross RefCross Ref
  18. 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 ScholarGoogle Scholar
  19. Oleg Kiselyov. The taste of logic programming, 2006.Google ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle Scholar
  22. Robert A. Kowalski. Logic for Problem Solving. North-Holland/Elsevier, 1979. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Ramana Kumar. Mechanising Aspects of miniKanren in HOL, 2010. Australian National University. Bachelors thesis.Google ScholarGoogle Scholar
  24. Lee Naish. Pruning in logic programming. Technical report, Technical Report 95/16, Department of Computer Science, University of Melbourne, June 1995.Google ScholarGoogle Scholar
  25. Joseph P. Near, William E. Byrd, and Daniel P. Friedman. αleanTAP : A declarative theorem prover for first-order classical logic.Google ScholarGoogle Scholar
  26. John Alan Robinson. A machine-oriented logic based on the resolution principle. Journal of the ACM (JACM), 12(1):23– 41, 1965. Google ScholarGoogle ScholarDigital LibraryDigital Library
  27. Silvija Seres. The Algebra of Logic Programming. PhD thesis, University of Oxford, 2001.Google ScholarGoogle Scholar
  28. Olin Shivers. List Library. Scheme Request for Implementation. SRFI-1, 1999.Google ScholarGoogle Scholar
  29. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  30. JM Spivey and Silvija Seres. Embedding Prolog in Haskell. In E. Meier, editor, Haskell 99, 1999.Google ScholarGoogle Scholar

Index Terms

  1. A small embedding of logic programming with a simple complete search

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    Full Access

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!