Lean from the Inside

A learning log about how Lean 4 works: its type theory, the elaborator, tactics, the kernel, and metaprogramming. I'm writing it to learn Lean properly and to have notes I can come back to. Every code block on these pages is checked by Lean when the site builds, so the examples compile on the toolchain named in each post. Hover over code to see the types and proof states Lean inferred.

The series has two kinds of posts:

Roadmap

  1. Foundations: dependent types, universes, Prop vs Type, inductive types and the recursors Lean generates for them.

  2. Elaboration: how surface syntax becomes a kernel Expr, including metavariables, unification, implicit arguments, instances and coercions.

  3. Tactics: what a tactic proof builds, how simp, omega and decide work, and writing a tactic in TacticM.

  4. Kernel and trust (not yet written): what the kernel checks, the standard axioms, and what native_decide, partial and implemented_by add to the trusted base.

  5. Programming (not yet written): structural and well-founded recursion, termination proofs, do notation, and the compiler.

  6. Metaprogramming (not yet written): macros, syntax extensions, custom elaborators and small embedded languages.

Every post in the series is in the lean category. Each written part has its own category too: foundations, elaboration and tactics. Log entries are under lean-log.