Repository navigation
feat: extend unit-like criteria for eta - #15372
Conversation
|
downstream |
|
The adaptation PR for this PR is leanprover/downstream-lean4#116. |
|
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]>
|
!bench |
|
Benchmark results for b166d0d against 2c2bdd9 are in. There are significant results. @arthur-adjedj
Large changes (1✅, 3🟥)
Small changes (3✅, 38🟥)
|
|
Another complaint from Claude:
Ok, maybe not so bad given that we start with a loopy type to begin with. |
I don't think this complaint is relevant. Once the rest of the renovations are merged, all types should strongly normalize. |
|
@nomeata Should the cache be a realizable value instead as it only depends on the declaration? I can give that a try |
| if (!is_constant(I)) | ||
| return false; | ||
| name I_name = const_name(I); | ||
| if (!is_non_rec_structure(env(), I_name)) |
There was a problem hiding this comment.
| if (!is_non_rec_structure(env(), I_name)) | |
| // same check as in try_eta_struct_core | |
| if (!is_non_rec_structure(env(), I_name)) |
It also depends on the instantiation, so unfortunately not. |
|
!bench |
|
Benchmark results for 8087791 against 2c2bdd9 are in. There are significant results. @arthur-adjedj
Large changes (2🟥)
Medium changes (2🟥)
Small changes (1✅, 222🟥)
|
This is the adaptation PR for leanprover/lean4#15372. --------- Co-authored-by: downstream-lean4[bot] <downstream-lean4[bot]@users.noreply.github.com> Co-authored-by: arthur-adjedj <[email protected]>
…ctor This PR regenerates InLean from con-leche, which now has the two η rules of #15372 and #15373, verified: a type is unit-like when its head normal form is a function type into a unit-like type or a structure whose fields are all proofs or unit-like (`unitLikeLoopI`), and a partially applied structure constructor is compared with the other side after both are applied to fresh variables up to the full application (`structEtaExpandI`). `elab/2258`, `elab/match4`, `elab/13371` and `elab/12520_1` now pass. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This reverts commit 43d3355.
This reverts commit 43d3355.
…6443) This PR reverts leanprover#15372. The PR introduced a performance regression, adding around 2.2% instructions to Mathlib. The feature will still be merged again in the future, once better caching solutions have been found.
|
This PR was reverted by #16443, so I'm removing it from the changelog. |
This PR expands the unit-like criteria to handle pi-types whose codomain are unit-like, and structures whose fields are all unit-like or proof-irrelevant.
Since
isDefEqUnitLikeruns on every failing defeq tests, it is bound to be triggered and return negative answers often in the elaborator. As such, an elaborator-level cache is added to answer quickly when possible. The kernel probably doesn't need such a cache, as it usually only encounters well-typed terms, and thus only runs the equivalent function when necessary.This PR also adds a tests documenting the #13364 failure.
Related to #14977
Closes #2258.