Skip to content
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 1 commit into from
Oct 25, 2024

Conversation

kmill
Copy link
Collaborator

@kmill kmill commented Oct 25, 2024

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 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 #2512

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
@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 Oct 25, 2024
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
@kmill kmill added this pull request to the merge queue Oct 25, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@leanprover-community-bot leanprover-community-bot added the breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan label Oct 25, 2024
Merged via the queue into leanprover:master with commit a310488 Oct 25, 2024
17 checks passed
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
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better error message when trying to declare a recursive structure
2 participants