Repository navigation
fix: instantiate_eq is false — instantiate is simultaneous, the model is sequential - #11
Merged
Merged
Conversation
…l sequential Lean.Expr.instantiate is a simultaneous substitution; the model instantiateList applies its entries one after another. They differ whenever a substituend contains a loose bvar: instantiate (.bvar 0) #[.bvar 0, .sort .zero] is .bvar 0, the model gives .sort .zero. The axiom now requires every substituend to be closed, which is the condition under which the two agree. Expr.instantiateRev_push was relying on the false form -- as stated, with no hypotheses, it is itself false. Two type-checker lemmas needed genuinely new hypotheses rather than local derivations: inferApp.loop.WF and both isDefEqLambda.WF/isDefEqForall.WF. Note isDefEqLambda pushes `default` into the substitution, which is a closed constant, so the obligation is dischargeable there only by that accident. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov
pushed a commit
that referenced
this pull request
Aug 23, 2026
… the statement's own fixpoint New `Theory/Typing/ShapeSpine.lean` (389 lines, `[propext, Quot.sound]`, no `sorryAx`, no axiom added). **1. The propagated `iff` form composes at `trans` -- and it is FALSE.** `typeShapeAgree_false`, machine-checked at `n = 1` over the empty environment. The witness is `SubstCRefute`'s, lifted from a *substituted conversion* to **a term with two types** -- the hypothesis `SubstCRefute` explicitly declined to supply. With a closed `P` proved to be a genuine Π-type (so the context is not junk), a variable is typeable at `P` and, via `forallEDF` of the beta step, at a second Π whose codomain is a variable. So one term has a **stuck** type and a **sort** type: one sort-shaped, one not. The same witness refutes the substitution form (`substShapeAgree_false`). **2. Strong enough to close `AppCase`? The question inverts.** In the usable disjointness reading the hereditary statement is **logically equivalent to `SortForallEDisjoint` itself** (`SortForallEDisjointH.iff`, and the handoff's literal phrasing collapses identically at `SortForallEDisjointH₂.iff`). The collapse is one lemma, `Apply.hasType`: a spine peeled off a type of `e` is a type of the applied term, so quantifying over spines quantifies over terms -- **the hereditary clause is derivable, not additional.** And `AppCase` follows from `SortForallEDisjoint` in one line, because `Stratified.app` already gives the application its instantiated type. **`AppCase` is the statement's own fixpoint; nothing of equal strength can close it.** **3. Cost not incurred** -- the row-zero check closed it before anything was built. ~390 lines of pricing, of which the refutation was ~40 reusing `SubstCRefute.stuck`. **Correction to the handoff's own row 5**, which had been committed and relayed: *"shape-disjointness under substitution does not inherit `SubstC`'s refutation, criterion pass machine-checked"* was **true of a different statement**. The recorded `trans`-closure was for the version stated about a **conversion**, where `SortLike` composes by `trans'` with no induction. The version that does the work is about a **substitution**, and it is false. Logged as trap #10, with trap #11 for *a strengthening can be the same statement*. **What survives, named rather than described:** `SubstDisj` -- shape disjointness under substitution, hereditary. Not equivalent to the target (two types, no common term, so `Apply.hasType` does not collapse it); **satisfiable**, `SubstDisj.zero` beside `DefInv.zero`/`SubstC.zero`; and it buys `applyDisj`. **Not claimed sufficient** -- *analysis, not machine-checked*: a spine induction on typing closes `app` and `bvar` but not `lam`, where bridging the body's two types under instantiation needs an existence step only the refuted `∀∃` form supplies. **Reading result on `docs/design-shape-lattice.md`:** its recorded refutations are this same obstruction one altitude up -- `IsType.common` false, every relativisation refuted, each because two compatible Π-shapes need not share a codomain sort when their domains disagree. Its one survivor, `common_sort`, reads the sort off **the term's universe** rather than off the shapes. Nothing there is reusable as-is, but **that survivor is the one idea in it this route has not tried.** Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov
pushed a commit
that referenced
this pull request
Aug 23, 2026
…on relation New `Theory/Typing/UnivDiscrim.lean`, sorry-free, `[propext, Quot.sound]`. The route's last untried idea is closed, in both judgments. **What `common_sort` does differently** *(analysis)*: the datum is **not computed from the two objects compared**; it comes from a judgment **one level up** -- the type's own type, held as a *type-indexed* derivation that ships with its universe; and the hypothesis is a **uniformity at fixed `U`**, so two instantiations agree with no `∃`-common to construct. Structurally it is a **coherence lemma between two layers**, transporting a fact determinate on the *term* layer down to the *indeterminate shape* layer -- exactly what the shape-model refutations miss, since they have shapes with no term behind them. **It does not transfer, for two independent reasons.** **(a) One-layer degeneration** *(analysis)*. `SortForallEDisjoint` has no shape layer -- the two compared objects and the accompanying term are all terms of one syntax. Written out, the hypothesis reduces to `common_sort`'s own, nothing left over. **In a single-layer setting "consult the accompanying term" is "invoke the statement being proved".** **(b) The datum is empty** *(machine-checked)*. `succ_eq_imax`: for **every** `u`, `.succ u ≈ .imax (.succ u) (.succ u)`. So `.sort u` and `∀ (_ : .sort u), .sort u` are types at one and the same universe. In the shape model the datum read off the universe is the `Prop`/`Type` boolean, which *is* the fact needed; here the fact needed is sort-shaped versus Π-shaped, and **no universe carries it**. Judgment-independence is decisive: `HasTypeStrong.regular` -- **regularity is free in the unstratified type-indexed judgment**, no hypothesis at all, since every constructor ships the typing of its type (contrast the neighbouring `IsDefEqStrong.isType'`, which needs three). Hence `SortForallEDisjointSUniv.iff`: the universe-relativised statement **is** the statement, one line each way -- trap #11 running the *other* direction, **adding a premise is not automatically weakening**. And the only genuinely weaker variant has a premise consistent with a sort on one side and a Π on the other. **Two things landed anyway.** `SortForallEDisjoint.zero` / `.AppCase.zero` -- **the primitive the whole route funds is satisfiable** at the base index, and nothing had instantiated it. And **`appCase_ih_vacuous`**, a sharper diagnosis than "the fixpoint": `SortForallEDisjoint` *passes* the criterion (induction on typing, `trans` never arises) and is still open, because at the recursive position that could reach what `app` needs, **the IH is guarded by "the type is sort-shaped" and a Π never is** -- so the IH is provable with the sub-derivation unused. The case does not fail because the IH is hard to use; **there is nothing there to use.** Recorded as a **companion test** to the criterion: *at each recursive position, is the IH non-vacuous?* Cheap to run, and the criterion cannot see it. **Nothing found false.** `SortForallEDisjoint` is not refuted -- it is satisfiable and still open. What is closed is the hope of proving it by reading a discriminating datum off a universe. **§8's conclusion now stands from a fourth direction: what is missing is a reduction relation.** Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
vasnesterov
pushed a commit
that referenced
this pull request
Aug 23, 2026
…cycle **Verdict: do not build it.** `docs/logrel-scope.md` is the decision document; `Theory/Typing/LogRelRowZero.lean` is new, sorry-free, `[propext, Quot.sound]`, in the default target. **Two corrections to the premise, both load-bearing.** A logical relation does **not** avoid a reduction relation -- it avoids *confluence*; every such development, including both of this repo's own, is built on weak-head reduction. And **the route is not untried**: `Experimental/LogRel.lean` is a 379-line typed Kripke logical relation that stops inside `fundamental`'s `trans` with `sorry` for every other rule and no `Prop`/const/inductive case; `ShapeLogRel.lean` is its coarsened version at 8435 lines, failing to build, with **the relation itself `sorryAx`-backed**. **Row-zero check 1 -- machine-checked, decisive, and it reaches past this route.** `VEnv.WF` admits `VDecl.unsafeDef`, which typechecks members in an environment already carrying the block's constants, so two members naming each other install `f ≡ g` **and** `g ≡ f`. `exists_wf_env_headStep_cycle` / `headStep_not_wf`: **there is a `VEnv.WF` environment, one declaration step from empty, whose weak-head reduction has a two-cycle between closed terms both well typed at `∀ p : Prop, p`.** **Every open statement in `Injectivity.lean` is quantified over exactly that class, so no normalisation argument of any kind can establish them as stated.** The repair is already done on the model side (`TrEnv .safe → LeanWF`) and **not** on the algorithm side: `VContext` carries an arbitrary `DefinitionSafety`, and `TrProj.uniq` / `defeqDFC` / `weak'_inv` / `reduceRecursor.WF` all run there, because the kernel genuinely δ-unfolds `partial` definitions. **Not claimed: that the statements are false there.** Aiming a refutation of `sort_inv` at such an environment is a cheap untried thread. **Row-zero check 2 -- the two feared assumptions reverse.** `imax_measure` / `imax_domain_unbounded`: where a Π-type is **not** a proposition both component levels are bounded by its own, so a measure exists; where it **is**, the domain's level is unbounded -- and that is exactly where proof irrelevance makes recursion unnecessary. **Impredicativity is confined to precisely the case proof irrelevance trivialises.** Per trap #8 this licenses "not excluded", not "open". It forces one design fact: the relation must be indexed by a *level valuation*, since `imax u v` is `0` at some and `max u v` at others. **What survives, delivers, and costs.** Nothing in the tree becomes *wrong* -- the route adds no rule, unlike candidate 1 which made `SubstCRefute` false. ~6500 lines carry over; ~2550 lines of the stratified cone go **dead but stay true**. It delivers the whole family at once from one lemma, **already proved sorry-free** in `Experimental/LogRel.lean` -- so there is no cheaper sub-target inside the route. Hard part named, and it is **not `Prop`**: generic inductive families with nested declarations, canonicity, the ι-case. Two savings: the abstract theory has no K-like reduction and no structure η, and definitional η is free in a typed relation. One hidden cost: `Params.pat_wf` needs `forallE_inv`, so the reduction relation must be rebuilt un-gated. **The cheaper target, answered negatively.** `PropUniq` + `PropTypeAgree` is a weaker *statement*, not a cheaper *build*. A derivation-directed interpretation relocates `PropUniq` to a coherence obligation that **is `PropUniq`** -- trap #11 again, read straight off the constructor list -- and a type-directed one removes `PropSplit` but *is* a logical relation. 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
Lean.Expr.instantiateis a simultaneous substitution.instantiateListapplies its entries one after another. They differ whenever a substituend
contains a loose bvar:
(
#evalcounterexample.) Not Lean-inconsistent — the upstream side isopaque— but a wrong description of what runs, and the checker's correctness rests on
it.
The fix
Require every substituend to be closed, which is exactly when the two agree:
(h : ∀ a ∈ subst, a.looseBVarRange' = 0)What this exposed
Expr.instantiateRev_pushwas relying on the false form. As previouslystated — no hypotheses — it is itself false, refuted by the same counterexample.
It now carries the condition.
Two type-checker lemmas needed genuinely new hypotheses, not local
derivations:
inferApp.loop.WF—(hlm : ∀ x ∈ lm, x.looseBVarRange' = 0), discharged ateach recursive call from
ha.closed, and atinferApp.WFfromlm := [].isDefEqLambda.WFandisDefEqForall.WF—(hfvs : ∀ x ∈ fvs, x.looseBVarRange' = 0).One thing worth knowing about that last pair:
isDefEqLambdapushesdefault : Exprinto the substitution, which is.const \_inhabitedExprDummy []`and therefore closed. So the obligation is dischargeable there — but only by that
accident, not by design.
Elsewhere it discharges locally:
inferLambda.loop.WF,inferForall.loop.WFandinferLet.loop.WFsubstitute only.fvars, andwhnfCore'.WF's beta step getsclosedness of the spine arguments from
he.closed.getAppArgsRevList.5 files, +90/−24.
lake build Lean4Lean.Verifygreen.Note on the freeze
Verify/Axioms.leanis frozen perCLAUDE.md; this is a proposal for sign-off.The axiom's name is unchanged.
🤖 Generated with Claude Code