An Incremental Approach to Relational Interpreter
miniKanren is a family of constraint logic programming languages, usually embedded in a host language such as Scheme, OCaml, or Python. The most famous miniKanren program is a relational Scheme interpreter—that is, an interpreter for a subset of Scheme written as a relation, in which the Scheme expression to be evaluated, the environment, and the computed value of the Scheme expression may all contain logic variables representing unknown terms or subterms. Relational Scheme interpreters can synthesize self-evaluating expressions (Quines) ““for free,”” and perform example-based synthesis of simple recursive Scheme programs, among other interesting feats.
Over the past 18 years the miniKanren community has figured out better ways to explain the miniKanren core language and implementation, resulting in two editions of a book (‘The Reasoned Schemer’, MIT Press 2005 & 2018), the well-known ‘microKanren’ tutorial by Hemann and Friedman, and many short talks and tutorials. However, currently there is no accessible way for a non-expert programmer to learn how to write relational interpreters. Technical papers on relational interpreters, such as the Scheme Workshop 2012 and ICFP 2017 pearls, assume the reader has expertise in functional programming, Scheme, environment-passing meta-circular interpreters, and the basics of logic programming. The on-line and in-person courses I have taught on relational interpreters spend 30 hours on background information and techniques before writing the first relational interpreter.
I believe it is possible to teach relational interpreters to learners who are unfamiliar with Scheme, functional programming, interpreters, or logic programming, without first teaching 30+ hours of concepts and techniques. For the past 6 months I have been writing a book on relational interpreters, currently titled ‘Relational Interpreters, Alpine Style,’ that makes as few assumptions as possible about the learner’s background. Partly inspired by Abdulaziz Ghuloum’s classic tutorial on writing Scheme interpreters, ‘An Incremental Approach to Compiler Construction,’ my book builds up relational interpreters one language feature at a time, starting from a trivial relational interpreter that can only handle numbers.
In my talk I will briefly describe and demonstrate relational interpreters, describe the ““old way”” used to teach relational interpreters, and then explain the incremental approach I use in the book. I will release the book under a Creative Commons ‘CC BY’ license, and would like to find early readers. I also hope to have the book translated into Japanese.
Wed 11 MayDisplayed time zone: Osaka, Sapporo, Tokyo change
13:00 - 17:00
|An Incremental Approach to Relational Interpreter
William E. Byrd University of Alabama at Birmingham, USA
|Lambek Grammars and a new look to Context-Free Grammars (Half-Tutorial)
Oleg Kiselyov Tohoku University
|Space-Efficient Polymorphic Gradual Typing
Atsushi Igarashi Kyoto University, Japan