Nothing Special   »   [go: up one dir, main page]

skip to main content
10.1145/2989225.2989230acmconferencesArticle/Chapter ViewAbstractPublication PagessplashConference Proceedingsconference-collections
research-article

A small embedding of logic programming with a simple complete search

Published: 01 November 2016 Publication History

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

Cited By

View all
  • (2023)Embedding Functional Logic Programming in Haskell via a Compiler PluginPractical Aspects of Declarative Languages10.1007/978-3-031-24841-2_3(37-55)Online publication date: 8-Jan-2023
  • (2020)Certified Semantics for Relational ProgrammingProgramming Languages and Systems10.1007/978-3-030-64437-6_9(167-185)Online publication date: 24-Nov-2020
  • (2018)Typed Embedding of a Relational Language in OCamlElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.285.1285(1-22)Online publication date: 31-Dec-2018
  • Show More Cited By

Index Terms

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

    Recommendations

    Comments

    Please enable JavaScript to view thecomments powered by Disqus.

    Information & Contributors

    Information

    Published In

    cover image ACM Conferences
    DLS 2016: Proceedings of the 12th Symposium on Dynamic Languages
    November 2016
    131 pages
    ISBN:9781450344456
    DOI:10.1145/2989225
    Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

    Sponsors

    In-Cooperation

    Publisher

    Association for Computing Machinery

    New York, NY, United States

    Publication History

    Published: 01 November 2016

    Permissions

    Request permissions for this article.

    Check for updates

    Author Tags

    1. Racket
    2. logic programming
    3. microKanren
    4. miniKanren
    5. relational programming
    6. search
    7. streams

    Qualifiers

    • Research-article

    Conference

    SPLASH '16
    Sponsor:

    Acceptance Rates

    Overall Acceptance Rate 32 of 77 submissions, 42%

    Upcoming Conference

    Contributors

    Other Metrics

    Bibliometrics & Citations

    Bibliometrics

    Article Metrics

    • Downloads (Last 12 months)14
    • Downloads (Last 6 weeks)4
    Reflects downloads up to 24 Nov 2024

    Other Metrics

    Citations

    Cited By

    View all
    • (2023)Embedding Functional Logic Programming in Haskell via a Compiler PluginPractical Aspects of Declarative Languages10.1007/978-3-031-24841-2_3(37-55)Online publication date: 8-Jan-2023
    • (2020)Certified Semantics for Relational ProgrammingProgramming Languages and Systems10.1007/978-3-030-64437-6_9(167-185)Online publication date: 24-Nov-2020
    • (2018)Typed Embedding of a Relational Language in OCamlElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.285.1285(1-22)Online publication date: 31-Dec-2018
    • (2018)Improving Refutational Completeness of Relational Search via Divergence TestProceedings of the 20th International Symposium on Principles and Practice of Declarative Programming10.1145/3236950.3236958(1-13)Online publication date: 3-Sep-2018
    • (2017)A Framework for Extending microKanren with ConstraintsElectronic Proceedings in Theoretical Computer Science10.4204/EPTCS.234.10234(135-149)Online publication date: 1-Jan-2017
    • (2018)Improving Refutational Completeness of Relational Search via Divergence TestProceedings of the 20th International Symposium on Principles and Practice of Declarative Programming10.1145/3236950.3236958(1-13)Online publication date: 3-Sep-2018
    • (2018)Typed Relational ConversionTrends in Functional Programming10.1007/978-3-319-89719-6_3(39-58)Online publication date: 19-Apr-2018

    View Options

    Login options

    View options

    PDF

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader

    Media

    Figures

    Other

    Tables

    Share

    Share

    Share this Publication link

    Share on social media