Lean
-
Elaboration: from syntax to Expr
Part 2 of Lean from the Inside. What you type is much shorter than what the kernel checks.
1 + 1leaves out the type, the addition instance and how the numerals are interpreted, and Lean fills all of that in before the kernel sees anything. That process is elaboration. This post follows a term from text to kernel term, then looks at the main things the elaborator fills in: metavariables and unification, implicit arguments, instances and coercions. -
Lean from the Inside: why I'm writing this
I use Lean for proofs about program analyses, but I learned it by imitation: copy a proof that works, change it until it works for my problem. This series is where I slow down and learn what is actually happening, from the type theory up through the elaborator, the tactics and the kernel.
The posts are notes for my future self first. If they help someone else, good.
-
Foundations: what an inductive type gives you
Part 1 of Lean from the Inside. Almost everything in Lean, from
NattoAndtoEq, is an inductive type, and almost every function and proof about those types ends up as a call to a single function the kernel generates: the recursor. This post works out what that means. It covers whatinductiveadds to the environment, how universes andPropconstrain the recursor, and how amatchyou write becomes a recursor call. -
Log: rfl proves equations, decide proves decidable propositions
Both of these close
2 + 2 = 4:example : 2 + 2 = 4 := rfl example : 2 + 2 = 4 := ⊢ 2 + 2 = 4 All goals completed! 🐙So I assumed they were interchangeable for small closed facts. They are not.
rflfails on10 < 20:example : 10 < 20 := rfl -
Tactics: what a tactic proof builds
Part 3 of Lean from the Inside. A tactic proof looks like a list of instructions, which makes it feel like a different thing from a term. It isn't. The kernel only checks terms, and a
byblock is a program that builds one. This post looks at what that program builds, how it keeps track of the goals it has left, what the main automation tactics produce, and how to write a tactic of your own.
