feat: make Function generalized field notation more usable#13244
Open
feat: make Function generalized field notation more usable#13244
Conversation
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).
mathlib-nightly-testing bot
pushed a commit
to leanprover-community/batteries
that referenced
this pull request
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 CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
|
Mathlib CI status (docs):
|
|
Mathlib CI status (docs):
|
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.
This PR changes two aspects of generalized field notation for functions to make it more usable. First, the resolution rules for functions and the
Functionpseudo-structure are the same as for other structures, so nowf.fooresolvesFunction.foousing 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.swapexample from issue #1629, and an issue from Zulip.