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

fix: FunInd: support structural recursion on reflexive types #4327

Merged
merged 1 commit into from
Jun 5, 2024

Conversation

nomeata
Copy link
Collaborator

@nomeata nomeata commented Jun 3, 2024

types like

inductive Many (α : Type u) where
  | none : Many α
  | more : α → (Unit → Many α) → Many α

have a .brecOn only supports motives producing Type u, but not Sort u, but our induction principles produce Prop. So the previous
implementation of functional induction would fail for functions that
structurally recurse over such types.

We recognize this case now and, rather hazardously, replace .brecOn
with .binductionOn (and thus .below with .ibelow and PProd with
And). This assumes that these definitions are highly analogous.

This also improves the error message when realizing a reserved name
fails with an exception, by prepending

Failed to realize constant {id}:

to the error message.

Fixes #4320

types like
```
inductive Many (α : Type u) where
  | none : Many α
  | more : α → (Unit → Many α) → Many α
```
have a `.brecOn` only supports motives producing `Type u`, but not `Sort
u`, but our induction principles produce `Prop`. So the previous
implementation of functional induction would fail for functions that
structurally recurse over such types.

We recognize this case now and, rather hazardously, replace `.brecOn`
with `.binductionOn` (and thus `.below ` with `.ibelow` and `PProd` with
`And`). This assumes that these definitions are highly analogous.

This also improves the error message when realizing a reserved name
fails with an exception, by prepending
```
Failed to realize constant {id}:
```
to the error message.

Fixes #4320
@nomeata nomeata requested a review from leodemoura as a code owner June 3, 2024 10:38
@nomeata nomeata changed the title fix: FunInd: Support structural recursion on reflexive types fix: FunInd: support structural recursion on reflexive types Jun 3, 2024
@github-actions github-actions bot temporarily deployed to lean-lang.org/lean4/doc June 3, 2024 10:54 Inactive
@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 Jun 3, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 3, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jun 3, 2024
@leanprover-community-mathlib4-bot leanprover-community-mathlib4-bot added breaks-mathlib This is not necessarily a blocker for merging: but there needs to be a plan release-ci Enable all CI checks for a PR, like is done for releases labels Jun 3, 2024
@leanprover-community-mathlib4-bot
Copy link
Collaborator

leanprover-community-mathlib4-bot commented Jun 3, 2024

Mathlib CI status (docs):

@nomeata nomeata added the will-merge-soon …unless someone speaks up label Jun 3, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/batteries that referenced this pull request Jun 3, 2024
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4 that referenced this pull request Jun 3, 2024
@nomeata nomeata added this pull request to the merge queue Jun 5, 2024
Merged via the queue into master with commit f0a11b8 Jun 5, 2024
29 checks passed
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 release-ci Enable all CI checks for a PR, like is done for releases toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN will-merge-soon …unless someone speaks up
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FunInd: brecOn with wrong universe parameters
2 participants