Lean4 Domain Explanation Language (L4DEL)

Acronym legend

L4DEL
Lean4 Domain Explanation Language

A domain explanation language keeps expert meaning, provenance, definitions, and reading order explicit instead of asking a reader to infer them from jargon.

lean4-explainer reads Lean4 Domain Explanation Language directives from Lean line comments. An annotation is optional at first. The tool checks every directive it finds, and for each declaration without a valid annotation it prints a template to paste in.

Workflow

  1. Run lean4-explainer check --lean-root lean to see errors and warnings.
  2. Run lean4-explainer annotate --lean-root lean --file Demo/Basics.lean to print templates.
  3. Paste a template directly above its declaration and replace every TODO_ value.
  4. Run check again. A TODO_ value left behind is a warning, so the build reports it.

Directives

Sources and attribution

Use immutable links where possible: a full-commit repository blob for the exact formal source, a DOI or versioned arXiv record for a paper, or a versioned project blueprint. A citation makes an explanation traceable; it does not by itself certify that the explanation is correct.

Rules

Only line comments carry directives. A directive attaches to the next declaration. Anonymous declarations cannot carry directives. Keys are case-sensitive. The full grammar is in the module docstring of lean4_explainer_l4del/grammar.py.

Same-named declarations

Identical copies of a declaration count as one object, so a plain name refers to it. Declarations that share a name but differ in code are distinct definitions. Refer to one as Name@path, for example Demo.value@Var/B.lean.

Example

/-- Three items in two boxes put two items in one box. -/
-- L4DEL: title: Pigeonhole for three items in two boxes
-- L4DEL: intuition: Three items cannot all sit in different boxes when there are only two boxes.
-- L4DEL: step: Assume no box holds two items.
-- L4DEL: step: Then three items need three different boxes, which do not exist.
-- L4DEL: source: Formal statement = https://example.org/pinned-source#L1
-- L4DEL: quote: Formal statement = Three items in two boxes put two items in one box.
-- L4DEL: acronym: DEL = Domain Explanation Language
-- L4DEL: prereq: Demo.box_count
-- L4DEL: term: box = a container for one item
theorem pigeonhole_three_two : ...