3.2. Key Theorems
The following capstone theorems represent the main formal guarantees established by L4YAML. Each is machine-checked by the Lean kernel with zero axioms beyond the built-in foundations.
Each theorem is accompanied by a bipartite dependency graph showing the implementation functions it proves properties about (blue, left) and the supporting theorems used in its proof (green, right). Stdlib lemmas surface in orange when they are domain-relevant.
3.2.1. Pipeline Composition
These theorems establish that the scanner and parser compose correctly into a single end-to-end pipeline.
Theorem | Module | Statement |
|---|---|---|
|
|
End-to-end: scan then parse composes correctly. If |
|
| Raw pipeline variant without schema resolution. |
|
|
Every successful |
|
|
|
3.2.1.1. parseYaml_pipeline
3.2.1.2. parseYamlRaw_pipeline
3.2.1.3. parseYamlRaw_ok_decompose
3.2.1.4. parseYaml_ok_iff
3.2.2. Scanner Correctness
Properties of the character-to-token scanner:
Theorem | Module | Statement |
|---|---|---|
|
|
The scanner output satisfies |
|
| Scanner advance strictly increases the byte offset when the offset is within bounds — this is the core termination lemma. |
|
|
A successful scan loop always terminates with a |
3.2.2.1. scan_produces_valid_tokens
3.2.2.2. advance_offset_lt
3.2.2.3. scanLoop_success_emits_streamEnd
3.2.3. Parser Correctness
Properties of the token-to-AST parser:
Theorem | Module | Statement |
|---|---|---|
|
| If the parser produces an AST, it corresponds to a valid YAML grammar derivation. |
|
|
The anchor set grows monotonically through |
|
|
Every alias ( |
|
|
After |
3.2.3.1. parseStream_sound
3.2.3.2. parseNode_anchors_grow
3.2.3.3. parseNode_aliases_resolve'
3.2.3.4. parseStream_output_anchors_wellformed
3.2.4. Soundness
Theorems establishing that the AST-to-value conversion faithfully implements the YAML specification:
Theorem | Module | Statement |
|---|---|---|
|
|
The |
|
|
Every well-formed AST node can be converted to a |
|
| AST-to-value conversion is deterministic: the same input always produces the same output. |
|
| Scalar string content is preserved through the parsing pipeline — no characters are added, dropped, or reordered. |
3.2.4.1. toYamlValue_correct
3.2.4.2. nodeToValue_total
3.2.4.3. nodeToValue_deterministic
3.2.4.4. scalar_content_preserved
3.2.5. Round-Trip Properties
Theorems about the parse → emit → parse cycle:
Theorem | Module | Statement |
|---|---|---|
|
| Content equality is reflexive: every YAML value is content-equal to itself. |
|
| Content equality is symmetric. |
|
|
Content equality is transitive — together with reflexivity and symmetry, this makes |
|
| The emitter preserves content equality: if two values are content-equal, their emitted canonical forms are identical. |
|
| Tag URI escape and unescape are inverse operations. |
3.2.5.1. contentEq_refl
3.2.5.2. contentEq_symm
3.2.5.3. contentEq_trans
3.2.5.4. emit_content_invariant
3.2.5.5. escapeTag_roundtrip