Skip to main content

Certified Semantics for Relational Programming

  • Conference paper
  • First Online:
Programming Languages and Systems (APLAS 2020)

Abstract

We present a formal study of semantics for the relational programming language miniKanren. First, we formulate a denotational semantics which corresponds to the minimal Herbrand model for definite logic programs. Second, we present operational semantics which models interleaving, the distinctive feature of miniKanren implementation, and prove its soundness and completeness w.r.t. the denotational semantics. Our development is supported by a Coq specification, from which a reference interpreter can be extracted. We also derive from our main result a certified semantics (and a reference interpreter) for SLD resolution with cut and prove its soundness.

The reported study was funded by RFBR, project number 18-01-00380.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    A detailed Prolog-to-miniKanren comparison can be found here: http://minikanren.org/minikanren-and-prolog.html.

  2. 2.

    We respect here a conventional tradition for miniKanren programming to superscript all relational names with “\(^o\)”.

  3. 3.

    The extended version of this paper is available at https://arxiv.org/abs/2005.01018.

  4. 4.

    There still can be differences in observable behavior of concrete goals under different sound and complete search strategies. For example, a goal can be refutationally complete  [6] under one strategy and non-complete under another.

  5. 5.

    The specification is available at https://github.com/dboulytchev/miniKanren-coq.

  6. 6.

    Possible slowdown and loss of termination after reorderings in conjunction is a famous example of this phenomenon in miniKanren, known as conjunction non-commutativity  [6].

References

  1. Alvis, C.E., Willcock, J.J., Carter, K.M., Byrd, W.E., Friedman, D.P.: cKanren: miniKanren with constraints. In: Proceedings of the 2011 Annual Workshop on Scheme and Functional Programming (2011)

    Google Scholar 

  2. Appel, A.W., McAllester, D.A.: An indexed model of recursive types for foundational proof-carrying code. ACM Trans. Program. Lang. Syst. 23(5), 657–683 (2001)

    Article  Google Scholar 

  3. Baader, F., Snyder, W.: Handbook of automated reasoning. In: Unification Theory. Elsevier Science Publishers B. V., Amsterdam, The Netherlands (2001)

    Google Scholar 

  4. Bertot, Y., Castéran, P.: Interactive Theorem Proving and Program Development - Coq’Art: The Calculus of Inductive Constructions. Texts in Theoretical Computer Science. An EATCS Series. Springer (2004)

    Google Scholar 

  5. Bove, A.: Programming in martin-löf type theory: Unification - a non-trivial example, pp. 22–42, Department of Computer Science, Chalmers University of Technology (1999)

    Google Scholar 

  6. Byrd, W.E.: Relational Programming in miniKanren: Techniques, Applications, and Implementations. PhD thesis, Indiana University (2009)

    Google Scholar 

  7. Byrd, W.E., Friedman, D.P.: \(\alpha \)kanren: a fresh name in nominal logic programming. In: Proceedings of the 2007 Annual Workshop on Scheme and Functional Programming, pp. 79–90 (2007)

    Google Scholar 

  8. Byrd, W.E., Friedman, D.P., Kumar, R., Near, J.P.: A shallow Scheme embedding of bottom-avoiding streams. In: To appear in a special issue of Higher-Order and Symbolic Computation, in honor of Mitchell Wand’s 60th birthday

    Google Scholar 

  9. Chlipala, A.: Certified Programming with Dependent Types - A Pragmatic Introduction to the Coq Proof Assistant. MIT Press, Cambridge (2013)

    Google Scholar 

  10. Debray, S.K., Mishra, P.: Denotational and operational semantics for PROLOG. In: Formal Description of Programming Concepts - III: Proceedings of the IFIP TC 2/WG 2.2 Working Conference on Formal Description of Programming Concepts - III, Ebberup, Denmark, 25–28 August 1986, pp. 245–274 (1987)

    Google Scholar 

  11. Despeyroux, J., Felty, A., Hirschowitz, A.: Higher-order abstract syntax in Coq. In: Dezani-Ciancaglini, M., Plotkin, G. (eds.) TLCA 1995. LNCS, vol. 902, pp. 124–138. Springer, Heidelberg (1995). https://doi.org/10.1007/BFb0014049

    Chapter  Google Scholar 

  12. Friedman, D.P., Byrd, W.E., Kiselyov, O.: The Reasoned Schemer. MIT Press, Cambridge (2005)

    Google Scholar 

  13. Hemann, J., Friedman, D.P.: \(\mu \)Kanren: a minimal functional core for relational programming. In: Proceedings of the 2013 Annual Workshop on Scheme and Functional Programming (2013)

    Google Scholar 

  14. Hemann, J., Friedman, D.P.: A framework for extending microKanren with constraints. In Proceedings 29th and 30th Workshops on (Constraint) Logic Programming and 24th International Workshop on Functional and (Constraint) Logic Programming, WLP 2015 / WLP 2016 / WFLP 2016, Dresden and Leipzig, Germany, 22nd September 2015 and 12–14th September 2016, pp. 135–149 (2017)

    Google Scholar 

  15. Hemann, J., Friedman, D.P., Byrd, W.E., Might, M.: A small embedding of logic programming with a simple complete search. In: Proceedings of the 12th Symposium on Dynamic Languages, DLS 2016, Amsterdam, The Netherlands, 1 Nov 2016, pp. 96–107 (2016)

    Google Scholar 

  16. Jones, N.D., Mycroft, A.: Stepwise development of operational and denotational semantics for Prolog. In: Proceedings of the 1984 International Symposium on Logic Programming, Atlantic City, New Jersey, USA, 6–9 Feb 1984, pp. 281–288 (1984)

    Google Scholar 

  17. Keller, R.M.: Formal verification of parallel programs. Commun. ACM 19(7), 371–384 (1976)

    Article  MathSciNet  Google Scholar 

  18. Kiselyov, O., Shan, C., Friedman, D.P., Sabry, A.: Backtracking, interleaving, and terminating monad transformers: (functional pearl), pp. 192–203 (2005)

    Google Scholar 

  19. Kothari, S., Caldwell, J.: A machine checked model of idempotent MGU axioms for lists of equational constraints. In: Proceedings 24th International Workshop on Unification, UNIF 2010, Edinburgh, United Kingdom, 14th July 2010, pp. 24–38 (2010)

    Google Scholar 

  20. Kriener, J., King, A.: Semantics for Prolog with cut - revisited. In: Functional and Logic Programming - 12th International Symposium, FLOPS 2014, Kanazawa, Japan, 4–6 June 2014, Proceedings, pp. 270–284 (2014)

    Google Scholar 

  21. Kriener, J., King, A., Blazy, S.: Proofs you can believe. In: proving equivalences between Prolog semantics in Coq. In: 15th International Symposium on Principles and Practice of Declarative Programming, PPDP ’13, Madrid, Spain, 16–18 Sept 2013, pp. 37–48 (2013)

    Google Scholar 

  22. Kumar, R.: Mechanising aspects of miniKanren in HOL. Bachelor Thesis, The Australian National University (2010)

    Google Scholar 

  23. Lloyd, J.W.: Foundations of Logic Programming, 1st edn. Springer (1984)

    Google Scholar 

  24. Lozov, P., Vyatkin, A., Boulytchev, D.: Typed relational conversion. In: Wang, M., Owens, S. (eds.) TFP 2017. LNCS, vol. 10788, pp. 39–58. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-89719-6_3

    Chapter  Google Scholar 

  25. McBride, C.: First-order unification by structural recursion. J. Funct. Program. 13(6), 1061–1075 (2003)

    Article  MathSciNet  Google Scholar 

  26. Paulson, L.C.: Verifying the unification algorithm in LCF. Sci. Comput. Program. 5(2), 143–169 (1985)

    Article  MathSciNet  Google Scholar 

  27. Pfenning, F., Elliott, C.: Higher-Order Abstract Syntax, pp. 199–208 (1988)

    Google Scholar 

  28. Ribeiro, R., Camarão, C.: A mechanized textbook proof of a type unification algorithm. In: Cornélio, M., Roscoe, B. (eds.) SBMF 2015. LNCS, vol. 9526, pp. 127–141. Springer, Cham (2016). https://doi.org/10.1007/978-3-319-29473-5_8

    Chapter  Google Scholar 

  29. Rozplokhas, D., Boulytchev, D.: Improving refutational completeness of relational search via divergence test. In: Proceedings of the 20th International Symposium on Principles and Practice of Declarative Programming, PPDP 2018, Frankfurt am Main, Germany, 03–05 Sept 2018, pp. 18:1–18:13 (2018)

    Google Scholar 

  30. Swords, C., Friedman, D.P.: rKanren: guided search in miniKanren. In: Proceedings of the 2013 Annual Workshop on Scheme and Functional Programming (2013)

    Google Scholar 

  31. Tarski, A.: A lattice-theoretical fixpoint theorem and its applications. Pac. J. Math. 5, 06 (1955)

    Article  MathSciNet  Google Scholar 

  32. Wadler, P.: Monads for functional programming. In: Advanced Functional Programming, First International Spring School on Advanced Functional Programming Techniques, Båstad, Sweden, 24–30 May 1995, Tutorial Text, pp. 24–52 (1995)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Dmitry Boulytchev .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Rozplokhas, D., Vyatkin, A., Boulytchev, D. (2020). Certified Semantics for Relational Programming. In: Oliveira, B.C.d.S. (eds) Programming Languages and Systems. APLAS 2020. Lecture Notes in Computer Science(), vol 12470. Springer, Cham. https://doi.org/10.1007/978-3-030-64437-6_9

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-64437-6_9

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-64436-9

  • Online ISBN: 978-3-030-64437-6

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy