Skip to content

feat: eta-expand partial structure constructors - #15373

Merged
nomeata merged 6 commits into
leanprover:masterfrom
arthur-adjedj:eta-expand-partial-ctors
Oct 20, 2026
Merged

nomeata merged 6 commits into
leanprover:masterfrom
arthur-adjedj:eta-expand-partial-ctors

Conversation

@arthur-adjedj

@arthur-adjedj arthur-adjedj commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

This PR eta-expands partial constructor applications.

Related to #14977
First part of #12520

@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Sep 27, 2026
@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

downstream

phiferd commented Oct 3, 2026

Copy link
Copy Markdown

I ran some analysis on this PR and found a potential regression. With this change, Lean accept an invalid proof when a function type uses a reducible alias. Specifically, the supplied value proves ∀ f, f = f, while the declared type requires ∀ f, f = Box.mk.

More details here:

https://github.com/phiferd/lean-assurance-lab/blob/cbe4c8a63fa919775a44ffc6b784d661f1484ebf/results/research/lean-eta-admission-confirmation-1/report.md

Proposed regression (still needs some work to make it mergable):
https://github.com/phiferd/lean-assurance-lab/blob/cbe4c8a63fa919775a44ffc6b784d661f1484ebf/results/research/lean-eta-admission-confirmation-1/proposed-regression.lean

(FYI: this analysis was run using OpenAI Daybreak Blue)

@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

Thanks for the analysis! The code was indeed missing a whnf call. I've also added some assertions to the code to make sure the typing invariants that your mwe broke are always respected.

@arthur-adjedj

Copy link
Copy Markdown
Contributor Author

changelog-language

@github-actions github-actions Bot added the changelog-language Language features and metaprograms label Oct 11, 2026
@arthur-adjedj
arthur-adjedj marked this pull request as ready for review October 11, 2026 11:28
@downstream-lean4

Copy link
Copy Markdown

The adaptation PR for this PR is leanprover/downstream-lean4#118.

@arthur-adjedj arthur-adjedj changed the title feat: eta-expand partial constructors feat: eta-expand partial structure constructors Oct 11, 2026
nomeata added a commit to leanprover/lean-kernel-arena that referenced this pull request Oct 11, 2026
…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]>
@nomeata
nomeata added this pull request to the merge queue Oct 20, 2026
Merged via the queue into leanprover:master with commit 7632b2c Oct 20, 2026
17 checks passed
nomeata pushed a commit that referenced this pull request Nov 9, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-language Language features and metaprograms downstream Request a downstream-lean4 adaptation PR. toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants