Skip to content

Conversation

@cppio
Copy link
Contributor

@cppio cppio commented Jun 7, 2025

This PR allow structures to have non-bracketed binders, making it consistent with inductive.

The change allows the following to be written instead of having to write S (n):

structure S n where
  field : Fin n

@cppio cppio marked this pull request as draft June 7, 2025 00:37
@cppio
Copy link
Contributor Author

cppio commented Jun 7, 2025

changelog-language

@github-actions github-actions bot added changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN labels Jun 7, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 7, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jun 7, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Jun 7, 2025

Mathlib CI status (docs):

@leanprover-community-bot leanprover-community-bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Jun 7, 2025
@cppio
Copy link
Contributor Author

cppio commented Jun 7, 2025

awaiting-review

@cppio cppio marked this pull request as ready for review June 7, 2025 03:33
@github-actions github-actions bot added the awaiting-review Waiting for someone to review the PR label Jun 7, 2025
@leanprover-bot leanprover-bot added the P-low We are not planning to work on this issue label Jun 14, 2025
@cppio
Copy link
Contributor Author

cppio commented Jun 16, 2025

@kmill could you take a look at this? Using the optDeclSig parser for structures has been possible since the order of the type and extends was changed in #7100.

Copy link
Collaborator

@kmill kmill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I've been wanting to see this done.

The code looks good, and I just want to see some changes to the test file.

leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 17, 2025
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jun 17, 2025
stack.matches [`null, none, `null, none, ``Lean.Parser.Command.inductive] &&
(stack[3]? |>.any fun (stx, pos) =>
pos == 0 &&
[``Lean.Parser.Command.optDeclSig, ``Lean.Parser.Command.declSig].any (stx.isOfKind ·)))
Copy link
Collaborator

@kmill kmill Jun 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have any idea why it was looking for declSig? I looked through git history and, even when this was first introduced (maybe in this commit) the parser used optDeclSig.

As far as I can tell, inductive always used optDeclSig.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know for sure. My guess is that isInInductive in the original commit was copied from isInDeclarationSignature without simplification.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking a look. The PR looks good, and I'll add it to the merge queue, thanks!

@kmill kmill added this pull request to the merge queue Jun 17, 2025
Merged via the queue into leanprover:master with commit 92dec7e Jun 17, 2025
16 checks passed
@cppio cppio deleted the struct_binder_ident branch June 17, 2025 17:57
cppio added a commit to cppio/lean4 that referenced this pull request Jun 18, 2025
algebraic-dev pushed a commit to algebraic-dev/lean4 that referenced this pull request Jun 18, 2025
This PR allow structures to have non-bracketed binders, making it
consistent with `inductive`.

The change allows the following to be written instead of having to write
`S (n)`:
```lean
structure S n where
  field : Fin n
```
wkrozowski pushed a commit to wkrozowski/lean4 that referenced this pull request Jun 24, 2025
This PR allow structures to have non-bracketed binders, making it
consistent with `inductive`.

The change allows the following to be written instead of having to write
`S (n)`:
```lean
structure S n where
  field : Fin n
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review Waiting for someone to review the PR builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms P-low We are not planning to work on this issue 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.

4 participants