-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: refactor structure
command, fixes
#5842
Merged
Merged
Conversation
This file contains 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
Refactors the `structure` command to support recursive structures. These are disabled for now, pending additional elaborator support in leanprover#5822. This refactor is also a step toward `structure` appearing in `mutual` blocks. Error reporting is now more precise, and this fixes an issue where general errors could appear on the last field. Closes leanprover#2512
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Oct 25, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Oct 25, 2024
Mathlib CI status (docs):
|
tobiasgrosser
pushed a commit
to opencompl/lean4
that referenced
this pull request
Oct 27, 2024
Refactors the `structure` command to support recursive structures. These are disabled for now, pending additional elaborator support in leanprover#5822. This refactor is also a step toward `structure` appearing in `mutual` blocks. Error reporting is now more precise, and this fixes an issue where general errors could appear on the last field. Adds "don't know how to synthesize placeholder" errors for default values. Closes leanprover#2512
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 31, 2024
Now that the elaborator supports primitive projections for recursive inductive types (#5822), enable defining recursive inductive types with the `structure` command, which was set up in #5842. Example: ```lean structure Tree where n : Nat children : Fin n → Tree def Tree.size : Tree → Nat | {n, children} => Id.run do let mut s := 0 for h : i in [0 : n] do s := s + (children ⟨i, h.2⟩).size pure s ``` Note for kernel re-implementors: recursive structures are exercising the kernel feature where primitive projections are valid for one-constructor inductive types in general, so long as the structure isn't a `Prop` and doesn't have any non-`Prop` fields, not just ones that are non-indexed and non-recursive. Closes #2512
kmill
added a commit
to kmill/lean4
that referenced
this pull request
Mar 4, 2025
This PR re-adds synthesizing synthetic mvars between `structure` parents, like fields. This was removed in leanprover#5842 because I had thought parents were like type parameters and would participate in header elaboration, but in the end it made more sense elaborating parents after the headers are done, since they're like fields.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Mar 4, 2025
#7314) This PR changes elaboration of `structure` parents so that each must be fully elaborated before the next one is processed. In particular, it re-adds synthesizing synthetic mvars between `structure` parents, in the same manner as other fields. This synthesis step was removed in #5842 because I had thought parents were like type parameters and would participate in header elaboration, but in the end it made more sense elaborating parents after the headers are done, since they're like fields. We want this enabled because it will help ensure that all the necessary reductions are done to types of fields as they're added to the structure.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaks-mathlib
This is not necessarily a blocker for merging: but there needs to be a plan
toolchain-available
A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
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.
Refactors the
structure
command to support recursive structures. These are disabled for now, pending additional elaborator support in #5822. This refactor is also a step towardstructure
appearing inmutual
blocks.Error reporting is now more precise, and this fixes an issue where general errors could appear on the last field. Adds "don't know how to synthesize placeholder" errors for default values.
Closes #2512