Expand description
Literate Specification Parser for the Kernel.
This module parses English-like “Literate” syntax and emits the same
Command and Term structures as the Coq-style parser.
§Supported Syntax
§Inductive Types
A Bool is either Yes or No.
A Nat is either:
Zero.
a Successor with pred: Nat.§Function Definitions (with implicit recursion)
## To add (n: Nat) and (m: Nat) -> Nat:
Consider n:
When Zero: Yield m.
When Successor k: Yield Successor (add k m).§Pattern Matching
Consider x:
When Zero: Yield 0.
When Successor k: Yield k.Several columns at once, separated by and — Lean’s | 0, _ => … — with the overlap split
top-to-bottom by the equation compiler:
Consider a and b:
When Zero and _: Yield 1.
When _ and Zero: Yield 2.
When _ and _: Yield 3.§Lambda Expressions
given x: Nat yields Successor x
|x: Nat| -> Successor xConstants§
- ONE_
SHOT_ TACTICS - The closed one-shot tactic vocabulary of the literate
Proof:surface: the keyword a mathematician writes, and the reflected tactic it applies to the reified goal. Adding a tactic is a row here —parse_proof_tacticandparse_single_tacticboth read this table, so the two doors can never drift apart again.
Functions§
- measure_
definition - The EXTENT of the
## Toblock at the front ofinput— where it ends — read from its syntax alone. Seemeasure_theorem. - measure_
theorem - The EXTENT of the
## Theorem:block at the front ofinput, read from its syntax alone. - parse_
definition - Parse “## To [name] (params) -> RetType:” into Command::Definition
- parse_
definition_ in parse_definition, with the kernel context the equation compiler needs.- parse_
definition_ scoped parse_definition_in, reading every name in the namespace scopescope— the door the REPL reads through, so a literate definition’s names mean exactly what they mean to every other door.- parse_
inductive - Parse “A [Name] is either…” into Command::Inductive
- parse_
let_ definition - Parse “Let [name] be [term].” into Command::Definition (constant, not function)
- parse_
theorem - Parse “## Theorem: [name] Statement: [proposition].” into Command::Definition
- parse_
theorem_ in parse_theorem, with the kernel context.- parse_
theorem_ scoped parse_theorem_in, reading every name in the namespace scopescope. The statement is reflected into syntax only after its names are resolved, so a theorem aboutaddin a session that shadowsaddis a theorem about the session’sadd.