Skip to content

fix: mkLevelIMaxCore_eq is a false axiom (proves False) - #1

Merged
vasnesterov merged 1 commit into
masterfrom
fix/imax-core-axiom
Aug 22, 2026
Merged

vasnesterov merged 1 commit into
masterfrom
fix/imax-core-axiom

Conversation

@vasnesterov

Copy link
Copy Markdown
Owner

The bug

Lean4Lean/Verify/Axioms.lean asserts

@[simp] axiom mkLevelIMaxCore_eq (e : Expr) (n : Nat) : mkLevelIMaxCore = mkIMaxCore

against a local model whose third branch is

  else if u.isZero || u matches .succ .zero then v

Upstream Lean.Level.mkLevelIMaxCore has no such disjunct — in the pinned
v4.33.0-rc2 (src/lean/Lean/Level.lean:545) or in master, the branch is just
else if u.isZero then v.

mkLevelIMaxCore is a plain private def, not an opaque. So the equation is
decidable, and the axiom does not merely misdescribe the implementation — it
proves False:

'contradiction' depends on axioms: [propext, Quot.sound, mkLevelIMaxCore_eq]

The axiom is whitelisted by guard 2 of Lean4Lean/Verify/Guard.lean, so it sits
inside kernel_sound's trusted cone. Anything proved with it — including
kernel_sound itself — would be vacuous, while the guard reported success.
Today this is latent rather than exploited: Verify/Soundness.lean imports
nothing from the refinement layer, so kernel_sound's cone is currently just
{propext, sorryAx, Classical.choice, Quot.sound}.

The fix

Delete the spurious disjunct. The model is then a verbatim copy of upstream, the
equation holds by rfl, and the axiom becomes a theorem. The two binders
(e : Expr) (n : Nat) were never mentioned in the statement and are dropped.

Cost: zero. The axiom has no users anywhere in the Lean4Lean cone, so no
proof changes. lake build Lean4Lean.Verify is green on this branch.

This takes the frozen axiom list from 32 to 31.

Note on the freeze

Verify/Axioms.lean is frozen per CLAUDE.md, so this is a proposal for
sign-off rather than something to merge unreviewed. Found by a full audit of all
32 axioms, written up in docs/axiom-audit.md (on a separate branch); the
reproduction is in that document's §3.2.

🤖 Generated with Claude Code

The model `mkIMaxCore` carried an extra `|| u matches .succ .zero`
disjunct in its third branch. Upstream `Lean.Level.mkLevelIMaxCore` has
no such disjunct, in either the pinned v4.33.0-rc2 or master -- its third
branch is just `else if u.isZero then v`.

Because `mkLevelIMaxCore` is a plain `private def` rather than an
`opaque`, the equation is decidable, so the axiom did not merely
misdescribe the implementation: it proved `False`.

    theorem contradiction : False
    -- 'contradiction' depends on axioms: [propext, Quot.sound, mkLevelIMaxCore_eq]

Removing the disjunct makes the model a verbatim copy, so the equation
holds by `rfl` and the axiom is not needed at all. The two binders
`(e : Expr) (n : Nat)` were spurious -- the statement never mentioned
them -- and are dropped.

The axiom had no users anywhere in the Lean4Lean cone, so nothing else
changes. `lake build Lean4Lean.Verify` is green.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@vasnesterov

vasnesterov commented Aug 22, 2026 •

Copy link
Copy Markdown
Owner Author

I approve it, merge to the master

@vasnesterov

Copy link
Copy Markdown
Owner Author

Post-merge note — a consequence that isn't visible on master yet.

This PR removed an axiom, taking Verify/Axioms.lean from 32 declarations to 31. Verify/Guard.lean is not on master (it exists only in unpushed work), so nothing fails today. But guard 1 asserts that Axioms.lean declares exactly the 32 frozen axioms, and throws on either direction:

guard VIOLATION: frozen axiom {n} is no longer declared by Axioms.lean.
Changing that file requires human sign-off.

So the moment Guard.lean lands, guard 1 will fail on mkLevelIMaxCore_eq.

The fix is one line — drop ```Lean.Level.mkLevelIMaxCore_eqfromaxiomWhitelist` and change "32" to "31" in the comment and message. But `Guard.lean` is frozen too, so that is a second sign-off, and I am not making it unasked.

Worth deciding the general rule now rather than per-PR, since #5 and #6 are queued behind this and two more axioms (Std.TreeMap.all_eq_all_toList and any_eq_any_toList) are provable outright and could be dropped as well. Guard 1's "exactly" is doing real work — it stops an axiom being added quietly — so I would keep the exactness and just re-pin the list each time the count legitimately drops, with the commit that drops it. If you would rather it only ever forbid additions, that is a different one-line change and I can prepare it.

vasnesterov pushed a commit that referenced this pull request Aug 22, 2026
…d points

`QuotInterp.lean` completes the value layer -- `quotRel`, `quotEqv`,
`quotVal`, `quotVal_mem_U`, plus the joint-definability lemmas that
`mkLam_mem_interp_forallE` consumes.

The plumbing was not mechanical. Everything placed inside a `mkLam`
must be `ℒₛₑₜ`-definable *jointly in all its arguments*, because the
fibre map varies with the domain element -- strictly stronger than
anything `Universe.lean` needed, where `eqvStep_definable` fixes the
carrier and relation and is definable only in the stage. Three things
were needed together:

* the `mem_ext_iff` route, restating `T = f a b` as a membership
  formula before calling `definability`;
* passing `sep`'s definability argument explicitly rather than through
  its `autoParam`, which runs `definability` without the local
  hypotheses that make it succeed;
* **replacing `lfp` by its Π₁ characterisation.** `eqvClosure` is
  `lfp`, hence `⋂ˢ` of the prefixed points, and `⋂ˢ`'s membership
  condition carries a nonemptiness existential -- isolated by proving
  the same statement with and without the clause. `quotEqv` states the
  same set by its universal property and goes straight through.

The generalisable lesson, now in the ledger: **a least fixed point is
fine to reason with and bad to compute inside a definable function.**
`Ind` and `indRec` in `SetModel/Inductive.lean` are also `lfp`s, so the
same substitution will be needed when the `.induct` oracle is built.

This also widens Foundation gap #1: the `aesop: goal N was not
normalised` failure is not only arity >= 4 composition but also an
existential nested under a set quantifier.

Ledger additions: the definability finding; the paragraph connecting
`Consistency.lean`'s "genuine declarations", `kernel_sound`'s note that
`propext` over a nonstandard `Eq` would honestly prove `False`, and the
specs saying strictly more than `const_type` -- one requirement in three
vocabularies; and the `u = 0` pattern promoted from observation to a
standing pre-proof check.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov pushed a commit that referenced this pull request Aug 22, 2026
`quotRelTy_type`, `quotCod_type`, `quotSortU_type`, built from
`sortDF`/`bvar`/`forallEDF` with no inversion, plus an `example := rfl`
pinning `quotConst.type.instL [u]`.

`const_type` is not finished. The two `mkLam` layers are not mechanical:
`mkLam`'s fibre map is itself a value-layer object, so each nested λ
introduces a new composite function needing its own joint-definability
proof, and `definability` cannot compose the ones already proved. The
cause was isolated rather than guessed -- the abstract form
`ℒₛₑₜ-function₁ f ⊢ ℒₛₑₜ-function₂ (fun _ y ↦ f y)` *succeeds* with `f`
an opaque hypothesis and fails with `f := quotVal`, so `definability`
re-unfolds the definition instead of using the supplied lemma. Supplying
more lemmas will not help; what is missing is a small library of `mkLam`
definability combinators.

Three findings from one source now compound -- joint definability is
needed at all, `lfp` must be replaced by its Π₁ form, and nesting needs
combinators. All three are prerequisites for `.induct`, where a
constructor or recursor is a deeper nest than `Quot`. The earlier
assessment that the model side was "finished and waiting" for `.induct`
was too optimistic on exactly this axis: `IndStage`/`IndCard` give the
*sets*, not the definable *functions* the oracle must hand over.

`docs/foundation-gaps.md` splits gap #1 into 1a (the known arity 4-5
`attribute` omission) and 1b: the identical internal error at arity 3
with the composition rules already registered, triggered by an
existential nested under a set quantifier. Minimal reproduction
recorded.

Verdict on reporting upstream, with the two symptoms separated: the
`maximum rule application depth` failure is a limitation -- it names its
own cause and is fixable by tuning. The `internal error during proof
reconstruction: goal N was not normalised` is a bug: an internal
invariant violation rather than a proof-search failure. A tactic that
cannot prove a goal should say so. Report to Foundation first, since the
trigger is their `Definability` rule set; we cannot tell from here
whether the root cause is aesop's or is provoked by a rule's shape.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov pushed a commit that referenced this pull request Aug 23, 2026
…lAssign, not EqSpec

`preludeSpec_satisfiable` (`SetModel/PreludeSpec.lean`) exhibits one
`ModelData` meeting `EqSpec` at every level, `IffSpec`, and
`NonemptySpec` at every level, **jointly** -- stated jointly on purpose,
since "each conjunct fine alone, the conjunction unsatisfiable" is the
failure mode this project has hit three times.

Three deliberate choices: the witness uses **no `LevelAssign`** (that
structure was itself refuted once; building on it would reproduce the
hole); it is environment-passing rather than capturing (the naive
version's inner λ captures `α` in its *domain* and the outer fibre map
stops being jointly definable); and **both branches of every `if` are
fired**, so no branch is vacuous.

**But `EqSpec` was not the cone's open hypothesis.** Running the same
audit one level down: every result in `SetModel/` is parameterised by
`L : LevelAssign envF nv`, and **nothing anywhere exhibits one**. Not a
new hidden vacuity -- it is tracked item #1, blocked on the two
`sorry`s in `Injectivity.lean` (`sort_inv`'s `trans` and `proofIrrel`
cases). For scale: the *unguarded* form of `LevelAssign` was `IsEmpty`
for every env and nv; the guarded form has not been shown empty, but has
never been shown inhabited for a single `(env, nv)` either.

**A recorded claim that looks too strong.** `SetModel/Interp.lean`'s
header calls `LevelAssign` "exactly `sort_inv` in functional form (plus
choice)". That holds for `lvl`. `srt_sound` demands agreement for
*every* `A` typing `e` while `srt` can choose only one -- so it needs
the sorts of a term's two types to agree, which nothing supplies without
unique typing. Not asserted: the necessary condition it implies,
`LevelAssign.srt_uniq`, is proved, so the claim is now testable rather
than folklore.

**`interp_congr` was already proved and nobody had noticed.**
`model-interface.md` §4 names it as the first `.induct` blocker and says
`interpSig_wf` cannot even be *stated* without it -- but `Sound.eq`
unfolds to exactly it. Now `SoundInduction.lean:interp_congr`, three
lines, for arbitrary `B`. **The caveat matters more than the theorem:**
it is `Above`-wrapped, because soundness is -- enough to *prove* things
about a construction, not enough to *define* one by rewriting. So the
blocker is **relocated, not removed**, and `interpSig` needs either an
unconditional `interp_congr` or a formulation that only ever uses the
`Above` form. Better decided before `interpSig` is written than after.

Carried forward: **peel by type agreement** is stated once, generally,
in `Cnst.lean` (`interp_lam_congr_of_type`) with the trap documented --
the `IsProof` agreement is syntactic, does *not* follow from pointwise
equality, and does follow from the shared type. `quotDefEq_eq`
refactored to six calls to it.

`.induct` surveyed: both ends finished, middle empty. `interp` appears
in none of the three inductive model files.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov pushed a commit that referenced this pull request Sep 1, 2026
Verify/Inductive/RunIdentity.lean (new, 827 lines, no sorryAx).  Build green 1415 jobs,
guards all ✓.

The identity is proved, and it needs three premises.  Two are supplied: no .inductInfo in
env comes from ves.WF env, and BlockNoFVar turns out NOT to be a new premise at all --
Environment.addInductive's own guard loop supplies it, and SS 5 of AddInductiveStep.lean had
discarded it as Q := fun _ => True.  The third, BlockClosed, is supplied by nothing.

CLOSING IT REFUTES THE NODE.  AddInductiveStepWF and AddInductiveRunRealises, as stated, are
FALSE.  Witness: a constructor declared at ∀ (α : Type) (x : #1), Foo #1 with np = 1.
withParams lowers the loose bvar and mkForall restores the binder with the real Expr.abstract,
WHICH LEAVES BVARS ALONE -- so the loose variable is CAPTURED and the stored type is the
ordinary ∀ α, α → Foo α.  addInductive accepts it; TrIndDecl requires closedness; so
AddInductPost fails at every ves' and every numNested.

And route (b) from the previous round is refuted at the same witness: res.types IS closed
while types is not, so closedness of the output -- all checkConstructors can give -- does not
imply the premise.

MY BRIEF'S REASON WAS FALSE IN EXACTLY THE INTERESTING SUB-CASE.  "Both kernels reject via the
type checker" holds when the loose index exceeds np, and fails when it is small enough to be
captured -- which is what makes the refutation possible.

Not a C++ divergence, verified independently against abstract.cpp and inductive.cpp: C++
captures identically.  Recorded in bugs-found.md as shared behaviour instead, with the note
that no unsoundness follows -- the stored declaration is well formed -- and that what breaks is
the SPECIFICATION.

MY RULING, taken in part and deferred in part.  addDecl.WF is mine to design, so it will carry
the closedness side condition: a top-level Expr with a loose bvar is not a term of the type
theory, so the condition states the contract's domain rather than narrowing it, and I am not
proposing the restrictive alternative.  What is NOT mine is whether it propagates to
kernel_sound, which is frozen and must not be narrowed -- that is unmeasured, is the next thing
to measure, and if it reaches the frozen statement it is a question for the human.

Two ingredients I cited as hole-free were not APPLICABLE -- a cone measurement says a lemma is
clean and says nothing about whether it can be used.  And a fifth duplicated proof this
session, this one caught by the elaborator rather than by a grep.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov pushed a commit that referenced this pull request Sep 4, 2026
…migratable, 5 open, 5 false or vacuous

A read-only round, no Lean touched, asking one question per hole: does a producer already exist, and can
the hole's own module cite it? The question has now paid off three times this week, so doing it
systematically was cheaper than paying for it again.

Three holes have a **hole-free producer sitting in the same module**, and each one-line close was checked
to actually elaborate. Every other negative was checked against the import closures directly: nothing is
merely mis-shelved, so there is no cheap migration anywhere in the remaining set.

The best finding overturns a standing bound. Hole #1's residual is a hole-free predicate of cone 696,
proved *equivalent* to the hole — while everyone has been pricing a route of cone 3698 carrying three
holes. Five times too large, and unnecessary. The audit found it only because its own self-audit section
flagged a query it had not run; that query then changed its headline. An instrument that corrects its own
conclusions is the point of writing one.

Two false claims in one file. `kernel_sound`'s cone contains **exactly one hole — itself**: because its
value *is* the hole, nothing downstream is reached, so the familiar nine-hole set is not its at all and
belongs to `addDecl.WF`. Every dependency claim about the main theorem therefore has to be made against
that instead. And a parenthetical asserting a relation has no inhabitants is false — a witness environment
exists where all ten of its fields hold unconditionally. The conclusion that depended on it survives for
a different reason; the premise does not, which is exactly the defect worth recording, because the premise
is what the next round reuses.

Three of the five genuinely-open holes turn out to be one problem: every cheap producer has its hypothesis
proved *equivalent* to the target in-tree, so they are restatements rather than reductions, and the one
independent ingredient is proved in-tree to be too weak. That is the same wall two other rounds hit from
opposite sides this turn.

The two closable holes are queued rather than applied, since three streams are compiling — with the
audit's own advice followed: leave the third `sorry` alone, because its statement is false once the branch
goes live and so it carries information the others don't. Both closes are vacuity-based and will reopen
when the flip lands; the queue entry says so, and says why closing them is still right.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov pushed a commit that referenced this pull request Sep 4, 2026
…ecommendation was circular

The documented best route to census hole #1 paid 3698 constants, three census holes and three
watched-by-policy names. The new route pays 3412 and **zero of each**. The mechanism is exact and worth
keeping: the old route ran its key move on the major premise's *type only*, which forced it to discard two
structural fields and rebuild them with a lemma that is itself watched — and that rebuild is where all
three holes and all three watched names entered. Substituting the whole derivation instead discards
nothing, so none of them enter. Hole #1 now also holds *outright* wherever no type is uninhabited, and the
reduction has its converse proved, so it is tight.

The round corrected the audit that commissioned it. The residual it was sent to attack is not a weakening
— measured, it is the hole written at the field level, both directions pointwise and without
well-formedness — so "attack the residual" and "attack the hole" were the same instruction. The audit's own
verdict on a neighbouring lemma, that it repackages rather than produces, applies verbatim to the route it
then recommended. And its headline comparison was not like-for-like: one side discharges the hole from a
strictly stronger hypothesis, the other from an equivalent one, where hole-freeness is free because no
mathematics crosses. My suspicion about that figure was right for the wrong reason.

The remainder is graded honestly: unproved, not false. Every existing witness has an inhabited inserted
binder; the round added the first genuinely uninhabited one and then stated why it does not settle the
matter, since the well-formed uninhabited region is a consistency question nobody has exhibited. Refuting
it would need a consistency witness plus a non-strengthening projection — more than any refutation here has
needed.

On instruments: I added a cone-members-by-module mode to the search script, which answers "reachable with
no new import" — the citability question that keeps recurring. But I am recording that it would **not** have
found the lemma four rounds walked past, because that lemma was never in the failing cone; it was a tool
nobody knew existed. What surfaces it is nine lines of grep over the hole's own module, where it sits forty
lines from the hole. So the rule is brief-level, not script-level: before attacking a hole, inventory its
own module on the same subject and read every hit.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov pushed a commit that referenced this pull request Sep 4, 2026
…eue now outweighs the work in flight

Four corrections to today's audit, all found by the rounds it commissioned: its ranked recommendation for
hole #1 is circular, because the 'residual' is measurably the hole restated at field level with both
directions pointwise; its headline comparison is not like-for-like and misattributes a figure to a predicate
that is actually hole-free, the number belonging to a consumer; the migration it called under-explored had
already been done in a stronger form; and its cluster count is a moving number quoted without a date. Its
own self-audit section is what surfaced the hole #1 lead in the first place, so the report was still worth
commissioning.

Also recording an orchestration state change. Nine rounds reported today and every one handed me a
shared-module edit rather than applying it — the additive-only rule working exactly as intended, nine
rounds and zero collisions with four streams compiling. The cost has landed where predicted: the drain list
is now longer than the work in flight. So I am holding three free slots deliberately rather than spawning
into them. Every new stream extends the busy window, and the queue's value decays — five of its entries are
false claims that the next round will read and believe, which is precisely how one stale '(open)' annotation
cost three rounds this week.

One distinction worth having: doc-only edits under docs/ compile nothing and are always drainable, which is
why the audit corrections landed now; docstring edits inside .lean files invalidate oleans and are not.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov pushed a commit that referenced this pull request Sep 5, 2026
…lent to the hole, not stronger

Neither proved nor refuted, and reduced in two independent directions that make its truth unnecessary. The
uninhabitedness premise is provably free at one binder — the statement with it deleted is equivalent at every
ordered environment — so any proof must come from the contexts and the derivation alone. And the context guard
can be kept at no cost, giving a route at cone 3415 with zero holes and zero watched names whose residual is
*equivalent* to the hole, where yesterday's route was strictly stronger than what it proves. The move earlier
rounds missed: do not reduce to one binder, hand the residual the whole remaining lift at the first uninhabited
peel, and the guard never crosses an uninhabited binder.

It also ordered holes #1 and #2, with the borrow smaller than #2 itself, and a like-for-like comparison that
favours the new route on both axes: 3674 against 3698 constants and four by-policy names against six, from a
strictly weaker starting residual.

The finding that corrects my brief: there are six statements in this family, the four on the abstract side keep
both context guards and are equivalences with their targets, and only the two on the verification side gave a
guard away — so the statement I handed over as "the reduced target" was the lossiest member of its own family.
Three of its priors were wrong in direction, the most in this series, and it says the result came from the two
that surprised it rather than from its bet.

The price is stated rather than buried: nothing is discharged, and the repair costs known non-vacuity, since the
tree's only uninhabited-binder witness has an ill-formed context — so the new residuals are vacuous exactly if
the hole is already closed.

Its checklist correction is adopted: in a corner with sibling statements, build the family table by hypothesis
shape *first*. Extremes are for a single statement; a family table prices every route before you pick one, and
all three of this round's results came from one such grep after a third of the round went to extremes.

Two of its three instrument claims I adjudicated rather than adopting. That a bare build does not re-run the
guards is refuted — it emitted all three lines; the true and sharper point is that guard 2 audits one cone, so a
leaf's hole is invisible to it by design, which is why the census exists beside it. That the fixed-root census
script cannot see orphan modules is confirmed, and I have been using the whole-population variant throughout, so
the figures I have reported stand.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant