Skip to content
LeanLearn
Level 5~30 minLean 4

Notation and macros

Lean is extensible: you can add notation and even new tactics. See how text becomes a checked term, write a notation and a tactic macro, and learn why new notation is a matter of trust.

You will be able to
  • Describe the pipeline: parsing, macro expansion, elaboration, kernel checking.
  • Define notation and a simple tactic macro.
  • Explain why notation can mislead a reader but not the kernel.

Recommended first: Choosing the next tactic, Propositions as types. You can start anyway. Nothing is locked.

EncounterActivity 1 of 6

Encounter

When you type theorem t : 2 + 2 = 4 := by decide, Lean works in stages:

  1. Parsing turns the text into a syntax tree.
  2. Macro expansion rewrites syntax into other syntax (2 + 2 becomes HAdd.hAdd 2 2).
  3. Elaboration fills in types and implicit arguments and runs tactics, producing a term.
  4. The kernel, a small trusted checker, type-checks the term.

Steps 1–3 can be extended by users. Only step 4 decides whether a proof is valid.