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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
A detailed Prolog-to-miniKanren comparison can be found here: http://minikanren.org/minikanren-and-prolog.html.
- 2.
We respect here a conventional tradition for miniKanren programming to superscript all relational names with “\(^o\)”.
- 3.
The extended version of this paper is available at https://arxiv.org/abs/2005.01018.
- 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.
The specification is available at https://github.com/dboulytchev/miniKanren-coq.
- 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
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)
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)
Baader, F., Snyder, W.: Handbook of automated reasoning. In: Unification Theory. Elsevier Science Publishers B. V., Amsterdam, The Netherlands (2001)
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)
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)
Byrd, W.E.: Relational Programming in miniKanren: Techniques, Applications, and Implementations. PhD thesis, Indiana University (2009)
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)
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
Chlipala, A.: Certified Programming with Dependent Types - A Pragmatic Introduction to the Coq Proof Assistant. MIT Press, Cambridge (2013)
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)
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
Friedman, D.P., Byrd, W.E., Kiselyov, O.: The Reasoned Schemer. MIT Press, Cambridge (2005)
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)
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)
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)
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)
Keller, R.M.: Formal verification of parallel programs. Commun. ACM 19(7), 371–384 (1976)
Kiselyov, O., Shan, C., Friedman, D.P., Sabry, A.: Backtracking, interleaving, and terminating monad transformers: (functional pearl), pp. 192–203 (2005)
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)
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)
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)
Kumar, R.: Mechanising aspects of miniKanren in HOL. Bachelor Thesis, The Australian National University (2010)
Lloyd, J.W.: Foundations of Logic Programming, 1st edn. Springer (1984)
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
McBride, C.: First-order unification by structural recursion. J. Funct. Program. 13(6), 1061–1075 (2003)
Paulson, L.C.: Verifying the unification algorithm in LCF. Sci. Comput. Program. 5(2), 143–169 (1985)
Pfenning, F., Elliott, C.: Higher-Order Abstract Syntax, pp. 199–208 (1988)
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
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)
Swords, C., Friedman, D.P.: rKanren: guided search in miniKanren. In: Proceedings of the 2013 Annual Workshop on Scheme and Functional Programming (2013)
Tarski, A.: A lattice-theoretical fixpoint theorem and its applications. Pac. J. Math. 5, 06 (1955)
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)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this paper
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)