Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ and Unreleased holds what has landed since.
marker is `LLP2003` and no module; every committed source classifies as
before. Register 444.

- Runtime bounds (`PF-24`, #263): `LexLeanRuntime.Laws` states three bounds of
the runtime, registered as laws a language-1.2 `law` proof cites:
`split_exact_fits` (a split on a separator that is not empty has at most the
UTF-8 byte length plus one pieces, so a maximum above a bound on that length
admits it), `utf8_decode_length` (a decoded string's UTF-8 byte length is
bounded by the length of its bytes), and `checked_add_fits` (`UInt32`
`checked_add` of a value at most `n` and `b` is `some` when `n + b < 2^32`).
Each is kernel-checked with its axioms pinned. The decoder of core module 2
imports `Init.Data.String.Legacy` in full, so the split can be unfolded. The
fold-laws example's `Guards` module mirrors prism-code's too-many-lines,
line-overflow, and response too-large guards and proves each branch
unreachable by law. The language-1.2 compiler-semantics ID moves; locks,
goldens, calculus, production export, fixtures, and verification records are
regenerated by the writers. Register 448.

- CI toolchain fetches (#242): every step of `ci.yml`, `honesty.yml` and
`reproducibility.yml` that fetches elan, the pinned Lean toolchain, or the
pinned Rust toolchain runs the fetch through `.github/retry.sh`, at most three
Expand Down
1 change: 1 addition & 0 deletions CONFORMANCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ the error registry does not sanction (R5, `ERRORS.md`).
| `PF-21` | `build` | The language-1.2 linear_arithmetic proof form reads the runtime: it rewrites less_than, equal, negate, quotient, remainder, and fixed-width order and equality into linear arithmetic over mathematical values, splits every if and match left in the goal, proves integer kernels for all inputs, and is refused by Lean on a false one. |
| `PF-22` | `build` | The runtime module LexLeanRuntime.Laws states the fold laws as LexLean source with every row's axioms pinned, and linear_arithmetic rewrites additive list, set, and map folds into sums that are linear and invariant under append and reverse, so fold equalities verify for all inputs with decide only on closed instances. |
| `PF-23` | `build` | The language-1.2 law proof form applies one registered fold law (fusion, the fold of a pair, or the fold of an append) to checked type arguments, arguments, and prior theorems discharging its premises, and is refused in linking for an unregistered law, a wrong argument count or type, or a missing premise, and by Lean for a statement the law does not prove. |
| `PF-24` | `build` | The runtime module LexLeanRuntime.Laws states three bounds of the runtime as registered laws a language-1.2 law proof cites: split_exact_fits (split_exact of a string whose UTF-8 byte length is at most n, on a separator that is not empty, under a maximum above n, is some, since a split has at most its byte length plus one pieces), utf8_decode_length (a string utf8_decode reads from bytes of length at most n has a UTF-8 byte length of at most n), and checked_add_fits (UInt32 checked_add of a value at most n and b is some when n plus b is below 2^32); each row pins its exact axioms, the request guards of the fold-laws example prove their too-many-lines, line-overflow, and response too-large branches unreachable by citing them, a guard that claims one more than its law gives fails verification with LLV7002, and a law the registry does not name is refused with LLT4001. |

## reasoning

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ just vv # the complete normative acceptance gate (SPEC.md §9.2)
just release # vv, then the §30 release criterion; refused until the completion release
```

All 447 registered conformance IDs are implemented and pass; `just vv` runs clean from a checkout with the pinned toolchain installed.
All 448 registered conformance IDs are implemented and pass; `just vv` runs clean from a checkout with the pinned toolchain installed.

The differential against the independent generator `lean4-prod` (SPEC.md §17.19, `OR-01`..`OR-08`) acquires it at its pinned commit: from the checkout `LEXLEAN_ORACLE_DIR` names, or by fetching the commit with `git` into the Cargo target directory (`LEXLEAN_ORACLE_CACHE` overrides), and builds it with the pinned Lean and Rust toolchains. It is validation evidence only and no input to any identity. An oracle that cannot be acquired, is not the pinned files, or fails is unavailable: that fails the gate on Linux x86-64 and is printed as `NOT VALIDATED` elsewhere, and is never reported as agreement.

Expand All @@ -172,7 +172,7 @@ Every row is validated by `just vv`; the IDs link the claim to its register row,
| Fixed structural, mathematical, and proposition grammar with closed ambiguity handling | `GR-01`..`GR-16` | `build` |
| Typed closed IR with canonical serialization, native core modules (and the second schema of them that lossless migration of the proof library needs), portable language-1.1 application data and operations, versioned language-1.2 semantic modules, products, first-class functions, and widening conversions, ordered collections and graphs, semantic snapshots, alpha identities, recursion evidence, and content identities | `SM-01`..`SM-34` | `build` |
| Document and generic semantic declarations with exact self-application, type checking, structural recursion, recursive and mutual language-1.2 data, generic and executable higher-order definitions, mutual and well-founded recursion with semantic evidence, explicit state threading, and acyclicity rules | `DF-01`..`DF-18` | `build` |
| The structured proof language with pinned Lean lowerings, including closed linear arithmetic, integer order, and the fold laws | `PF-01`..`PF-23` | `build` |
| The structured proof language with pinned Lean lowerings, including closed linear arithmetic, integer order, and the fold laws | `PF-01`..`PF-24` | `build` |
| Prose-free deterministic generated Lean with complete token traceability | `LN-01`..`LN-12` | `build` |
| Canonical LaTeX regeneration and the optional hash-checked PDF provider | `TX-01`..`TX-12` | `build` |
| Canonical diagnostics, source maps, coverage, manifests, and reproducible builds | `AR-01`..`AR-14` | `build` |
Expand Down
44 changes: 42 additions & 2 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -2144,6 +2144,15 @@ The proof parser MUST reject:
- a proof step after the current branch has closed;
- a branch that does not close.

A language-1.2 proof cites a lemma of the runtime library only through the
`law` form (§17.12, *Fold laws* and *Runtime bounds*), which applies a
registered theorem of `LexLeanRuntime.Laws` by name; no raw Lean names it. The
runtime bounds `split_exact_fits`, `utf8_decode_length`, and
`checked_add_fits` bound the piece count of `split_exact` by the UTF-8 byte
length plus one, the UTF-8 byte length of a decoded string by the length of
its bytes, and the result of `UInt32` `checked_add`, so that a model proves its
defensive error branches unreachable.

---

## 17. Semantic elaboration and IR
Expand Down Expand Up @@ -2400,7 +2409,9 @@ name, module, or feature. Generated Lean may import only the foundational
modules listed in the core data and other modules in the generated graph. The
generic environment-reconstruction runtime may privately import `Lean`, and
the runtime of a version 2 module also `Lean.Meta.Constructions.SparseCasesOn`
in full (below); no
in full (below) and `Init.Data.String.Legacy` in full, whose bodies of
`String.splitOn` and its loop Lean does not expose and the runtime bound of
`split_exact` unfolds (§17.12, *Runtime bounds*); no
generated module may import an independently authored implementation of the
declarations being generated.

Expand Down Expand Up @@ -3246,6 +3257,34 @@ rules are LexLean's own; the diagnostic each linking failure raises is
decide one with a free variable, so a statement over all inputs is proved
by the laws and `omega`, never by enumerating inputs.

**Runtime bounds.** `LexLeanRuntime.Laws` also states three bounds of the
runtime, registered in `language/runtime-1.2/laws.toml` as laws a `law` proof
applies by name like a fold law, so that a model proves a defensive error
branch of the split, the decoder, or checked addition unreachable without raw
Lean (§16.12). Each conclusion is an implication from a bound on the input, and
each closed side condition is a premise a prior theorem discharges:

- `split_exact_fits` (`LexLeanLaws.splitExact_fits`, parameters `s d : String`,
`m : UInt32`, `n : Nat`, premises `equal d "" = false` and `n < toNat m`):
`length (utf8_encode s) <= n` implies that `split_exact s d m` is `some`,
written `(match split_exact s d m | none => false | some _ => true) = true`.
A split on a separator that is not empty has at most the UTF-8 byte length
of the string plus one pieces, so a maximum above any bound on that length
admits it.
- `utf8_decode_length` (`LexLeanLaws.utf8Decode_length`, parameters
`b : Bytes`, `s : String`, `n : Nat`, no premise): `utf8_decode b = some s`
implies that `length b <= n` implies `length (utf8_encode s) <= n`; a
decoded string's UTF-8 byte length is bounded by the length of the bytes it
was decoded from.
- `checked_add_fits` (`LexLeanLaws.checkedAdd_fits`, parameters
`a b n : UInt32`, premise `toNat n + toNat b < 4294967296`): `a <= n`
implies that `checked_add a b` is `some`, written as for the split.

The split and the decoder pin `Classical.choice`, so the first two laws and a
theorem proved by them observe `Classical.choice`, `Quot.sound`, and
`propext`; `checked_add_fits` observes `Quot.sound` and `propext`. The fold
laws and the rewrite set of `linear_arithmetic` do not use them.

#### Models, contracts, realizations, and evidence (language 1.2)

A model is a contract bound to a realization of the same interface, with
Expand Down Expand Up @@ -10270,6 +10309,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f
| `PF-21` | `proofs` | The language-1.2 linear_arithmetic proof form reads the runtime: it rewrites less_than, equal, negate, quotient, remainder, and fixed-width order and equality into linear arithmetic over mathematical values, splits every if and match left in the goal, proves integer kernels for all inputs, and is refused by Lean on a false one. | §17.12, §16 |
| `PF-22` | `proofs` | The runtime module LexLeanRuntime.Laws states the fold laws as LexLean source with every row's axioms pinned, and linear_arithmetic rewrites additive list, set, and map folds into sums that are linear and invariant under append and reverse, so fold equalities verify for all inputs with decide only on closed instances. | §17.12, §22.6 |
| `PF-23` | `proofs` | The language-1.2 law proof form applies one registered fold law (fusion, the fold of a pair, or the fold of an append) to checked type arguments, arguments, and prior theorems discharging its premises, and is refused in linking for an unregistered law, a wrong argument count or type, or a missing premise, and by Lean for a statement the law does not prove. | §17.12, §16 |
| `PF-24` | `proofs` | The runtime module LexLeanRuntime.Laws states three bounds of the runtime as registered laws a language-1.2 law proof cites: split_exact_fits (split_exact of a string whose UTF-8 byte length is at most n, on a separator that is not empty, under a maximum above n, is some, since a split has at most its byte length plus one pieces), utf8_decode_length (a string utf8_decode reads from bytes of length at most n has a UTF-8 byte length of at most n), and checked_add_fits (UInt32 checked_add of a value at most n and b is some when n plus b is below 2^32); each row pins its exact axioms, the request guards of the fold-laws example prove their too-many-lines, line-overflow, and response too-large branches unreachable by citing them, a guard that claims one more than its law gives fails verification with LLV7002, and a law the registry does not name is refused with LLT4001. | §16, §17.12 |
| `LN-01` | `lean-backend` | Each generated Lean file has the exact module, import, option, namespace, declaration, and end structure. | §18.1 |
| `LN-02` | `lean-backend` | Imports are explicit, deduplicated, sorted, and every external global is fully qualified. | §18.3 |
| `LN-03` | `lean-backend` | Generated Lean contains no comments, documentation, prose-bearing strings, or copied source prose. | §18.2 |
Expand Down Expand Up @@ -10560,7 +10600,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f
| `NS-06` | `normative-source` | The hand-edited normative inputs of the repository are the `.lex.tex` modules of the specification project: `model/` holds only the projected files and the copies an authority row vendors, every Markdown file at the root is a projection or is on the closed list of hand-written documents, the projections carry the notice that names their source, and no hand-written document restates a registered statement, a plant of each being refused naming R1. | §27.2, §27.5, §27.10 |
| `NS-07` | `normative-source` | `cargo xtask spec` changes the chapter modules of the specification project by item: it replaces a block, inserts one after a block, and ports the hunks of a merged SPEC.md that lie outside derived regions, each through the authoring SDK, and it writes nothing unless the regenerated SPEC.md equals the intended text outside derived regions, refusing a first line that matches no block or two and a hunk that spans two blocks. | §24.8, §27.5 |

**Total required capability IDs:** 447.
**Total required capability IDs:** 448.

No row may be downgraded to `some-true` or `open`. Upstream Lean facts are ledger/authority rows, not substitutions for these build behaviors.

Expand Down
98 changes: 98 additions & 0 deletions VERIFICATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -17002,3 +17002,101 @@ itself, and a plant that leaves the text unchanged fails the case.
Removed: the three edits were restored; `conformance_pc_01` passes, and
`conformance_pc_02` passes with the export of every member under the pinned
Lean 4.32.1 (8 outputs over the 6 members, each `kernel-checked`, the bundle replayed `bindings-verified`; `cargo xtask verify-examples --write` wrote 138 normalized verification records for `performance-corpus`, attestation f92c50059ffb4f27a91ee7d43d5ca29d4ecd7c7d0e7cff63c1984b54ac344441; `check-golden --write` changed no other example; `check-test-inventory`, `cargo fmt --check` and `validate-model` pass).

## Planted defects for the runtime bounds (`PF-24`, #263)

Each defect below was planted in the working tree or in a scratch copy, the
command named was run, and the plant was reverted. Linux x86-64 (WSL),
pinned Lean 4.32.1. On the reverted tree `conformance_pf_20`..`pf_24` and
`conformance_rt_01`..`rt_04` pass (9 passed), and `lexlean verify
src/Guards.lex.tex` verifies the mirror.

Planted (a): one law weakened by one. In the authored Lean of the laws
module, the premise of `splitExact_fits` became `n + 1 < m.toNat` (a
maximum two above the bound, where the shipped law asks for one). The lemma
still proves, and it was exported into `Laws.lex.tex` by the same oracle and
built into the compiler. `lexlean verify src/Guards.lex.tex` on a copy of
`examples/fold-laws` refuses the mirror's citation, because the premise
`lines_fit` (`4096 < to_nat 4097`) no longer discharges the law:

```text
verify exit 1
error[LLV7002]: Lean rejected `FoldLaws.Guards` (error): Application type mismatch: The argument
lines_fit
has type
4096 <
have __widen0 := 4097;
((if LexLeanRuntime.equal (LexLeanRuntime.bitAnd __widen0 2147483648) 2147483648 = true then 2147483648 else 0) +
... (the widening of `to_nat 4097`, 32 terms)
but is expected to have type
4096 + 1 < UInt32.toNat 4097
in the application
...
--> src/Guards.lex.tex:52:1
```

Planted (b): a law the registry does not name. In a copy of
`examples/fold-laws`, `too_many_lines_unreachable` cites `split_exact_bound`
instead of `split_exact_fits`. `lexlean check`:

```text
error[LLT4001]: phase link: `split_exact_bound` is not a registered law
--> src/Guards.lex.tex:6:1
lexlean check exit 1
```

Planted (c): the piece-count lemma one tighter. `splitOn_length_le` stated
as `(s.splitOn sep).length ≤ s.utf8ByteSize`, without the `+ 1`, is refused
by Lean (compiled against the runtime modules, as the oracle does). The bound
is not slack: the empty string splits into one piece and has no bytes.

```text
error: omega could not prove the goal:
No usable constraints found. ...
error: Type mismatch
splitOnAux_length_le s sep 0 0 0 [] ...
has type
(s.splitOnAux sep 0 0 0 []).length ≤ s.utf8ByteSize + 1
but is expected to have type
(s.splitOnAux sep 0 0 0 []).length ≤ s.utf8ByteSize
```

Planted (d): each guard claims one more than its law gives (the split guard's
byte bound 4097, the counter's line bound 4098, the response bound 16383).
`conformance_pf_24` makes these edits on a copy and requires Lean to refuse
exactly the three guard theorems with `LLV7002`. The same edits made by hand
on a copy, `lexlean verify src/Guards.lex.tex`:

```text
verify exit 1
error[LLV7002]: Lean rejected `FoldLaws.Guards` (error): Type mismatch
LexLeanLaws.splitExact_fits text "
" 4097 4096 newline_separates lines_fit
...
but is expected to have type
LexLeanRuntime.length (LexLeanRuntime.utf8Encode text) ≤ 4097 → ...
--> src/Guards.lex.tex:52:1
error[LLV7002]: Lean rejected `FoldLaws.Guards` (error): Type mismatch
LexLeanLaws.checkedAdd_fits line 1 4097 counter_fits
...
but is expected to have type
line ≤ 4098 → ...
--> src/Guards.lex.tex:74:1
error[LLV7002]: Lean rejected `FoldLaws.Guards` (error): Type mismatch
LexLeanLaws.utf8Decode_length request text 16384
...
but is expected to have type
LexLeanRuntime.utf8Decode request = some text → ...
--> src/Guards.lex.tex:96:1
```

Before the implementation (the R3 commit), the mirror was refused at the
citation, `error[LLT4001]: phase link: split_exact_fits is not a registered
law`, and `conformance_pf_24` failed at its first assertion
(`LexLeanLaws.splitExact_fits` is a declaration of the laws module).

*What the evidence is.* The three laws are Lean theorems, kernel-checked in
the runtime build and replayed by `leanchecker` in every verification that
imports the laws module. The mirror module is what a downstream model writes.
Plant (a) shows its proof depends on the exact statement of the law. Plant (c)
shows the bound is the tightest constant offset.
Loading
Loading