λProlog and LeanElpi: a short book
A hands-on introduction to λProlog, to its implementation in Lean 4, and to why higher-order logic matters for neuro-symbolic systems. Read it in order, or jump to the chapter you need.
- Why λProlog
What λProlog adds to Prolog, and where ELPI and LeanElpi fit. - Getting started
Install LeanElpi and run a first program, standalone and inside Lean. - Terms, clauses and search
Facts, rules, unification, backtracking, cut and arithmetic. - Higher-order programming
Binders as data, pi and implication goals, and pattern unification. - Types and modes
Declaring kinds, types and predicates, and what input and output modes mean. - Constraints and CHR
Delayed goals, suspended unification, and constraint handling rules. - Using it standalone
The lean-elpi command, the REPL, include paths, fuel, and ELPI source files. - Using it inside Lean
Programs, queries, quotations, tactics and commands written in λProlog. - Sharing types between Lean and λProlog
Declare a data type, a function or an inductive type on one side and use it on the other, and what Coq-Elpi taught us about doing so. - Certified proof search with LF
The LF layer: signatures, proof terms, export to Lean, and kernel-checked certificates. - Higher-order logic and neuro-symbolic systems
Why binders, hypotheses and checkable derivations matter when learned and symbolic parts meet. - From Python, Node.js and Rust
Load ELPI programs and run queries from Python, Node.js or Rust through one native library. How it works, how to install it, how to use it.