LeanElpi

· Volodymyr Pavlyshyn

Types across the boundary

LeanElpi 0.1 let ELPI programs read and build Lean terms. This week it learned to share data in both directions.

What is new

The book has a new chapter, Sharing types between Lean and λProlog, with every example from the test suite.

Why

Coq-Elpi works because declarations are data and host functions are typed predicates. We compared what it does with what LeanElpi did, and found three gaps: type parameters, a second copy of every type on the other side, and untyped glue code for host functions. All three are closed by one rule: declare a type once, on either side, and generate the other. The ELPI text of a type then has a single source, so round trips are tested properties.

Only plain data crosses. Indexed families, proofs and higher-order constructors are rejected with a message that points at term reflection or the LF layer. We prefer an error to a silent approximation.

Next

Type classes. Lean instance resolution and ELPI clause resolution are both tabled proof search, and a bridge in either direction is the obvious next step.