Skip to content

feat: infer def/theorem DefKind for let rec#1866

Merged
leodemoura merged 1 commit intoleanprover:masterfrom
digama0:let_rec_theorem
Nov 29, 2022
Merged

feat: infer def/theorem DefKind for let rec#1866
leodemoura merged 1 commit intoleanprover:masterfrom
digama0:let_rec_theorem

Conversation

@digama0
Copy link
Copy Markdown
Collaborator

@digama0 digama0 commented Nov 21, 2022

Since let rec has no place to put the def/theorem annotation, we have to infer it. Currently uses of let rec inside instances or defs to construct proofs will cause the defLemma mathlib linter to trigger (this occurs in practice in mathlib, because as it turns out we were actually doing let rec in lean 3 using the _match hack).

bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Nov 23, 2022
mathlib3 SHA: 39af7d3bf61a98e928812dbc3e16f4ea8b795ca3

Porting notes:
1. There was a mathport "failed to parenthesize" error, but it was easily worked around, see the first commit for details.
2. I had to use `aux` declarations when constructing things recursively inside the field of a structure. I asked about this on [Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/recursive.20definitions.20in.20instance.20fields) and also [here](https://leanprover.zulipchat.com/#narrow/stream/270676-lean4/topic/recursive.20definition.20in.20structure.20fields), but so far there doesn't seem to be a better way. In any case, it compiles so it should be fine. Otherwise, this port was very smooth.
3. Because of the `aux where` (which is really `let rec aux`) this caused the `defLemma` linter to fire, which is being handled in [lean4#1866](leanprover/lean4#1866), so for now we just add these declarations to `nolints.json`; see [Zulip](https://leanprover.zulipchat.com/#narrow/stream/287929-mathlib4/topic/recursive.20definitions.20in.20instance.20fields)

Co-authored-by: Scott Morrison <scott.morrison@gmail.com>
@leodemoura leodemoura added the awaiting-author Waiting for PR author to address issues label Nov 28, 2022
@digama0 digama0 removed the awaiting-author Waiting for PR author to address issues label Nov 28, 2022
@leodemoura leodemoura merged commit 40e212c into leanprover:master Nov 29, 2022
mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jul 10, 2024
leanprover/lean4#1866 is merged, so this can go.



Co-authored-by: Moritz Firsching <firsching@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants