Repository navigation
fix: PersistentArray.toList'_push is false without a well-formedness hypothesis - #13
Merged
Merged
Conversation
…hypothesis A malformed persistent array silently drops 32 elements, so the axiom is false as stated. It now takes WF arr, and is renamed to PersistentArray.WF.toList'_push to match the rest of that namespace. Two callers were relying on the false form: mkLocalDecl_toList and mkLetDecl_toList were @[simp] lemmas over an arbitrary LocalContext, hence false for the same reason. They now take the well-formedness of the declaration array and are no longer simp lemmas; both use sites supply it. Note this changes an axiom's fully qualified name, so Guard.lean's whitelist needs the new one. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.
The bug
No
WF arr. A malformed persistent array — one whose tail is already full whileits shift says otherwise — silently drops 32 elements on
push.#evalcounterexample with a 31-element
badarray in the report.Not Lean-inconsistent (
PersistentArrayoperations arepartial), but false ofthe implementation.
The fix
Take
WF arr, and rename toPersistentArray.WF.toList'_pushto match the restof that namespace.
WF.toList'_lengthpassesh.toList'_push.What this exposed
Two callers were relying on the false form.
mkLocalDecl_toListandmkLetDecl_toListwere@[simp]lemmas over an arbitraryLocalContext,hence false for exactly the same reason. They now take
(h : lctx.decls.WF)and are no longer@[simp]; both use sites(
TrLCtx.mkLocalDecl,TrLCtx.mkLetDecl) supply it fromh1.1.decls_wf.MLCtx.WF.decls_sizeandMLCtx.WF.toList_eqpasswf.1.tr.1.decls_wf.toList'_push.3 files, +47/−14.
lake build Lean4Lean.Verifygreen.Lean.PersistentArray.toList'_push→Lean.PersistentArray.WF.toList'_push.Verify/Guard.lean's whitelist pins axioms by name, so it will need the newone — and
Guard.leanis itself frozen, so that is a second sign-off. Flaggedhere rather than discovered at merge time. (
Guard.leanis not onmasteryet,so nothing fails today; see my note on #1 for the same issue arising from the
axiom removed there.)
Note on the freeze
Verify/Axioms.leanis frozen perCLAUDE.md; this is a proposal for sign-off.🤖 Generated with Claude Code