Skip to content

feat: make Function generalized field notation more usable#13244

Open
kmill wants to merge 1 commit intomasterfrom
kmill_1629
Open

feat: make Function generalized field notation more usable#13244
kmill wants to merge 1 commit intomasterfrom
kmill_1629

Conversation

@kmill
Copy link
Copy Markdown
Collaborator

@kmill kmill commented Apr 1, 2026

This PR changes two aspects of generalized field notation for functions to make it more usable. First, the resolution rules for functions and the Function pseudo-structure are the same as for other structures, so now f.foo resolves Function.foo using the currently open namespaces, and it can be used for defining recursive functions (e.g. Function.iterate). Second, generalized field notation for functions has an additional rule that it only matches the first explicit function argument, which makes it possible to use dot notation with implicit arguments that are type families.

Addresses the Function.swap example from issue #1629, and an issue from Zulip.

This PR changes two aspects of generalized field notation for functions to make it more usable. First, the resolution rules for functions and the `Function` pseudo-structure are the same as for other structures, so now `f.foo` resolves `Function.foo` using the currently open namespaces, and it can be used for defining recursive functions (e.g. `Function.iterate`). Second, generalized field notation for functions has an additional rule that it only matches the first *explicit* function argument, which makes it possible to use dot notation with implicit arguments that are type families.

Addresses the `Function.swap` example from issue #1629, and an issue from [Zulip](https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/generalized.20field.20notation.20vs.20namespaces/near/582689850).
@kmill kmill added the changelog-language Language features and metaprograms label Apr 1, 2026
@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 Apr 1, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/batteries that referenced this pull request Apr 1, 2026
@github-actions github-actions bot added the mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN label Apr 1, 2026
mathlib-nightly-testing bot pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Apr 1, 2026
leanprover-bot added a commit to leanprover/reference-manual that referenced this pull request Apr 1, 2026
@mathlib-lean-pr-testing mathlib-lean-pr-testing bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Apr 1, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

@leanprover-bot leanprover-bot added the builds-manual CI has verified that the Lean Language Reference builds against this PR label Apr 1, 2026
@leanprover-bot
Copy link
Copy Markdown
Collaborator

leanprover-bot commented Apr 1, 2026

Reference manual CI status:

@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

@mathlib-lean-pr-testing mathlib-lean-pr-testing bot added builds-mathlib CI has verified that Mathlib builds against this PR and removed breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan labels Apr 2, 2026
@mathlib-lean-pr-testing
Copy link
Copy Markdown

Mathlib CI status (docs):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-manual CI has verified that the Lean Language Reference builds against this PR builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN 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.

2 participants