Repository navigation
Audit of all 32 axioms in Verify/Axioms.lean - #14
Closed
vasnesterov wants to merge 1 commit into
Closed
vasnesterov wants to merge 1 commit into
vasnesterov wants to merge 1 commit into
Conversation
Every axiom in Verify/Axioms.lean gets a verdict backed by an attempted refutation rather than by inspection -- differential testing over a 1456-expression corpus, twenty-one million levels for normalize_eq, and PersistentHashMap over 300-key maps with engineered low-bit collisions and malformed nodes. Two prove False on their own: Expr.looseBVarRange_eq, which equates a 20-bit field read with an unbounded model, and Level.mkLevelIMaxCore_eq, whose model carries a disjunct upstream does not have. Three more are jointly inconsistent, four are false of the implementation with #eval counterexamples, and two are true only under a side condition they do not state. Twenty-one are true, of which two are now provable outright from upstream. This matters because guard 2 whitelists the axioms *by name*. An inconsistent one makes kernel_sound provable vacuously while the guard reports success -- so the guard cannot be the thing that catches this. Each non-true axiom has a written-out corrected statement, its call sites, and a dischargeability verdict. Also records an adjacent gap: guard 1 scans only Axioms.lean, so it cannot see the nine axioms declared elsewhere in the repo, seven from bv_decide and two pointer-equality ones, none of which is whitelisted. bugs-found.md is restructured into four sections -- Lean's kernel, the lean4lean kernel implementation, the proof infrastructure, and the frozen axioms -- and records three pieces of upstream behaviour that constrain the specification and would otherwise be assumed the other way. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Owner
Author
|
Closing — superseded, content already on
Nothing here is new. Branch kept. |
vasnesterov
pushed a commit
that referenced
this pull request
Aug 23, 2026
…ide condition Neither possibility in the brief was right; the answer is a third. **They are consistent** (the argued contradiction is dead), **they are not provable** (their docstrings' claim is false), **and they become provable under a side condition.** New `Lean4Lean/Tests/AxiomConsistency.lean` (nothing imports it). It works by **model exhibition** against `dataOf f` -- `Lean/Level.lean`'s computed field with the opaque `mkData` replaced by `f` -- and checks clause-by-clause by `rfl` that `dataOf mkData` is the real `Level.data`. - **§1** a clamping model (`min d (2^24-1)` instead of panic) validates **all three** of #12/#13/#14 by induction on `Level`. So they are **jointly consistent**, and §4's argument needed the *unconditional* `mkData_eq`: it dies with the `H : d < 2^24` repair. - **§2** a zeroing model validates #12 but **refutes** #13/#14 on `succ^[2^24] (.param x)`. So **#13/#14 are independent of #12** -- nothing constrains `mkData` at `d ≥ 2^24`, and they cannot be proved "using `mkData_eq` and friends" as their docstrings claim. - **§3** `hasParam_eq_of_dep`, `hasMVar_eq_of_dep`, `depth_eq_of_dep`, each under `(h : dep l < 2^24)` -- proved **without** #13/#14. The hypothesis is verified load-bearing (§2 *is* the proof it must be) and satisfiable, and the qualified name was checked to be `Lean.Level.mkData_eq` rather than the `Expr` one. **Joint-consistency survey (§12).** Mechanical: which free symbol each axiom pins. The relation is a **DAG** -- verified no `X_eq : X = Total.X` has `Total.X` reaching `X`. That splits the set: - **Class (A), 23 axioms** -- each pins a free symbol to a total definable function. **Jointly consistent by topological interpretation.** - **Class (B), 6 axioms** -- constrain a free symbol *through* a definable observation with provable properties. **Both historical `False`-proofs were in class (B)**, which is where attack effort belongs. **Seven failed attacks recorded in §12.3, each with the step it fails at**: #15+digama0#31 and digama0#30+digama0#31 (no shared constant -- independent opaques); mutual definability of the ten substitution/abstraction primitives (all independent opaques, the equivalences are **docstrings only**); #18 at the `BVarBounded` boundary; off-by-one at both panic boundaries; #17's unconditional form. **The strongest single result:** an environment sweep over every constant whose type mentions any of the 27 pinned opaques (private manglings resolved, not grepped) returns 21 whitelisted axioms plus exactly four auto-generated inert lemmas. **No theorem anywhere asserts a behavioural property of any pinned opaque** -- so contradictions can only arise *between* whitelisted axioms. Unverified, stated as such: the `PersistentArray`/`PersistentHashMap` three are the **highest residual risk** -- class (B), same shape as the two that proved `False`; `WF` blocks the known counterexamples and no new attack succeeded, but no model exists and building one means proving the real HAMT algorithms correct. And the `Expr` analogue of §1 is hand-analysed, not mechanised. Also noted: removing the two `TreeMap` axioms eliminated the only two with **zero model freedom**. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov
pushed a commit
that referenced
this pull request
Aug 23, 2026
…nt guard-2 failure
**What those entries are: not certificates, axioms.**
`Lean.Meta.nativeEqTrue`, which `bv_decide` calls, builds an aux `def`,
`addAndCompile`s it, runs `unsafe evalConst Bool` -- **compiled machine
code** -- and on `true` calls `addDecl` on a fresh **`axiomDecl`**:
…mkData'_hasParam._native.bv_decide.ax_1_8
: Std.Tactic.BVDecide.Reflect.verifyBVExpr <expr> <cert> = true
**The kernel never checks it.** It is `native_decide`'s trust model --
compiler, runtime and LRAT checker all in the TCB -- and in one respect
worse than `Lean.ofReduceBool`: instead of one named, auditable axiom
shared by all uses, **each invocation mints a fresh anonymous axiom**
whose statement mentions two auto-generated definitions. The trust
surface grows silently per use and is **invisible to a by-name whitelist
review**.
**Re-proved without it; bit-blasting was convenience, not necessity.**
§0 of `Tests/AxiomConsistency.lean` is rewritten, the
`Std.Tactic.BVDecide` import gone, going through one packing lemma
(`mkData'_toNat`) plus one field-extraction lemma over an arbitrary
`UInt64`, using the standard `UInt64.toNat_*` lemmas,
`Nat.and_one_is_mod`, `Nat.shiftRight_eq_div_pow` and `omega`.
| | before | now |
|---|---|---|
| `mkData'_{depth,hasParam,hasMVar}` | `+ Classical.choice + 3 native` | **`[propext, Quot.sound]`** |
| §1/§2 models | `+ Classical.choice + native` | **`[propext, Quot.sound]`** |
| `hasParam_eq_of_dep` / `hasMVar_eq_of_dep` | `+ Classical.choice + native` | **`[propext, Quot.sound, Lean.Level.mkData_eq]`** |
Verified with `pp.fullNames` that it is `Lean.Level.mkData_eq`, not the
`Expr` one. All entries already whitelisted. **29 → 27 is a real
reduction now** -- no new trust, and `Classical.choice` drops out.
**The reason this mattered more than one file: the repo already contains
three of these axioms, unwhitelisted**, in `Verify/Level.lean`:
Lean.Level.mkData_depth._native.bv_decide.ax_1_9
Lean.Level.mkData_hasMVar._native.bv_decide.ax_1_8
Lean.Level.mkData_hasParam._native.bv_decide.ax_1_8
They sit outside `kernel_sound`'s cone **only because that cone is
currently four constants wide** -- the proof is still mostly `sorryAx`.
**Guard 2 passes today by accident of incompleteness, and will fail the
build the moment those three lemmas enter the real proof.** The new §0
proofs are a drop-in replacement, same statements modulo one
`mkData_eq` rewrite.
> Standing check worth having wherever the guard lives: **no axiom whose
> name contains `_native` may appear in any cone**, whitelisted or not.
> A by-name whitelist cannot catch this family, because the names are
> generated.
Audit: §12.1 carries the corrected axiom list, new **§12.5** documents
the mechanism, the trade it would have concealed, the replacement, and
the latent guard-2 failure. §12.2 now ends with the operational
conclusion:
> Stop auditing the set for consistency and attack class (B). The 23
> class-(A) axioms cannot produce a contradiction -- each pins a free
> symbol to a total definable function and the pinning relation is
> acyclic. They can still be *false of the C++ kernel*, but falsity
> there is a testing problem, not a soundness-of-the-proof problem.
> Every route by which this set could make `kernel_sound` vacuous runs
> through class (B); #13 and #14 are now closed, leaving **four**.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
docs/axiom-audit.md— an audit of all 32 axioms that were inLean4Lean/Verify/Axioms.lean, against toolchainv4.33.0-rc2and the C++ kernel at master. This is the evidence behind the fixes already onmaster(which is why the whitelist is now 31, not 32).Verdicts assigned per axiom:
Falseexists (2 axioms, each on its own)#evalcounterexample exists11 of the 32 failed. The audit is read-only: it changes nothing under
Lean4Lean/.Why it matters beyond the fixes
Verify/Guard.leancheck 2 whitelists axioms by name. It asks which axiomskernel_sounduses, never whether that set is consistent — so a whitelisted axiom provingFalsewould makekernel_soundprovable vacuously while the guard printed "proof COMPLETE". §0 documents that gap in the guard itself, which is worth keeping on record independently of the two axioms that exercised it.Still open, per the audit
Two axioms are provable now and could become theorems:
Std.TreeMap.all_eq_all_toListandany_eq_any_toList, both from existing upstream lemmas (the second after a ~10-line mirror of theallcase). That would take the whitelist 31 → 29.Also updates
bugs-found.mdEight numbered kernel/checker defects with reproductions.
🤖 Generated with Claude Code