Repository navigation
fix: eta-expand recursor majors before running whnf - #15351
arthur-adjedj wants to merge 5 commits into
Conversation
whnfwhnf
|
downstream |
|
!bench |
|
Benchmark results for edbdc1e against 2c2bdd9 are in. There are significant results. @arthur-adjedj
Large changes (1🟥)
Medium changes (1🟥)
Small changes (17✅, 34🟥)
|
edbdc1e to
d56f17a
Compare
d56f17a to
64440c6
Compare
|
changelog-language |
…264) Tests for the eta-related changes planned in leanprover/lean4#14977: * corner-cases/eta-struct-major-no-whnf: structure eta on a recursor major before reducing it (leanprover/lean4#15351) * corner-cases/eta-struct-major-and: structure eta on a major in `Prop`, like `And` (leanprover/lean4#15371, leanprover/lean4#3213) * corner-cases/eta-struct-major-and-no-whnf: both together, with a non-normalizing proof as major * corner-cases/eta-unit-like-{pi,struct,proof-field,nested}: the extended unit-like criterion (leanprover/lean4#15372, leanprover/lean4#2258) * corner-cases/eta-rec-struct: eta-expansion of a structure recursor missing its major (leanprover/lean4#15374) * bugs/eta-ctor-alias: a soundness bug in a draft of leanprover/lean4#15373 and point the existing corner-cases/eta-ctor and corner-cases/eta-rule-k at leanprover/lean4#15373 and leanprover/lean4#15374. Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
warning: this test leads to an infinite loop rather than a maxHeartBeats/maxRecDepth error in previous Lean versions
|
The adaptation PR for this PR is leanprover/downstream-lean4#110. |
…nstance_reducible`
|
This comment was written by Claude (an AI assistant), on behalf of @nomeata, who reviewed it before posting. This PR makes some Small reproducer. On its own, the inductive L | a | b | c | d | e
deriving DecidableEq
structure R where
fst : Bool × L
snd : Bool × L
tag : Nat
def ls : List L := [.a, .b, .c, .d, .e]
def xs : List R :=
(List.range 4).flatMap fun t => ls.flatMap fun l => ls.map fun l' => ⟨(t % 2 == 0, l), (t < 2, l'), t⟩
def count : Nat := (xs.flatMap fun p => xs.filter fun q => decide (p.snd = q.fst)).length
example : count = 1000 := by decide +kernelThe kernel's diagnostics change as follows:
In the wild. We re-checked the openai/math project's
On Mechanism. The Before the PR, Possible mitigation. I don't have one that fits #15371 cleanly. Two directions:
|
|
I was worried that this would have such a performance impact, but expected the caching mechanisms to help enough for this to not be an issue... only doing |
|
Yes, I think not reducing proofs is the right guiding principle. Tangential, recursors for inductives propositions, should they even get rules? If we never reduce them, they are essentially dead code, aren't they? |
This PR ensures that majors of structure recursors get eta-expanded before attempting to reduce them to weak-head normal form. This change is done in preparation for #15371, which allows for eta-expanding structure majors that are
Propsubsingletons, and is necessary to ensure such majors don't get reduced (as they may not normalize)While this change does not change which terms are accepted by the kernel's type-checker, it can lead to different unification problems at the elaborator level, and can thus produce errors that would need slight tweaks to be fixed.
Related to #14977.