Skip to content

fix: skip data-valued constructions for small-eliminating inductives - #14909

Merged
nomeata merged 2 commits into
masterfrom
joachim/issue14904
Aug 25, 2026
Merged

nomeata merged 2 commits into
masterfrom
joachim/issue14904

Conversation

@nomeata

@nomeata nomeata commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

This PR fixes elaboration of sort-polymorphic inductive types such as inductive T : Sort u | a | b, which previously failed with Unknown constant `T.ctorIdx`. It also fixes the same failure for set_option genCtorIdx false.

Such a type only eliminates into Prop, so it has no T.ctorIdx and no SizeOf instance. mkNoConfusionCore guarded against this, but mkNoConfusionEnum did not: isEnumType only rejects syntactic Prop, so the type was treated as an enum and noConfusionEnum was applied to the non-existent T.ctorIdx. mkSizeOfInstances had the same gap, and mkSizeOfFn then dropped a universe parameter via recInfo.levelParams.tail!.

The recurring recInfo.levelParams.length > indVal.levelParams.length test is extracted as Lean.isLargeEliminating, resolving the TODO: Extract to util in mkNoConfusionCore.

Fixes #14904

Co-Authored-By: Claude Opus 5 (1M context) [email protected]
Claude-Session: https://claude.ai/code/session_013tynPcTkcxEhbHRCtSLoh5

This PR fixes elaboration of sort-polymorphic inductive types such as `inductive T : Sort u | a | b`, which previously failed with `Unknown constant `T.ctorIdx``. It also fixes the same failure for `set_option genCtorIdx false`.

Such a type only eliminates into `Prop`, so it has no `T.ctorIdx` and no `SizeOf` instance. `mkNoConfusionCore` guarded against this, but `mkNoConfusionEnum` did not: `isEnumType` only rejects syntactic `Prop`, so the type was treated as an enum and `noConfusionEnum` was applied to the non-existent `T.ctorIdx`. `mkSizeOfInstances` had the same gap, and `mkSizeOfFn` then dropped a universe parameter via `recInfo.levelParams.tail!`.

The recurring `recInfo.levelParams.length > indVal.levelParams.length` test is extracted as `Lean.isLargeEliminating`, resolving the `TODO: Extract to util` in `mkNoConfusionCore`.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013tynPcTkcxEhbHRCtSLoh5
@nomeata
nomeata marked this pull request as ready for review August 24, 2026 11:49
@github-actions github-actions Bot added toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN labels Aug 24, 2026
@leanprover-bot leanprover-bot added the builds-manual CI has verified that the Lean Language Reference builds against this PR label Aug 24, 2026
@leanprover-bot

leanprover-bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ✅ Reference manual branch lean-pr-testing-14909 has successfully built against this PR. (2026-08-24 12:21:19) View Log
  • 🟡 Reference manual branch lean-pr-testing-14909 build against this PR didn't complete normally. (2026-08-24 12:22:21) View Log
  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2026-08-22 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2026-08-24 15:39:30)

@nomeata

nomeata commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

Just lake tests failing due to CI changes, will be resolved once mathlib reports green and I can update the branch.

@mathlib-lean-pr-testing mathlib-lean-pr-testing Bot added the builds-mathlib CI has verified that Mathlib builds against this PR label Aug 24, 2026
@mathlib-lean-pr-testing

mathlib-lean-pr-testing Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ✅ Mathlib branch lean-pr-testing-14909 has successfully built against this PR. (2026-08-24 13:10:12) View Log
  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2026-08-22 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-24 15:39:28)

@nomeata nomeata closed this Aug 24, 2026
@nomeata nomeata reopened this Aug 24, 2026
@nomeata nomeata added the changelog-language Language features and metaprograms label Aug 24, 2026
@nomeata
nomeata added this pull request to the merge queue Aug 25, 2026
Merged via the queue into master with commit 0dc10a4 Aug 25, 2026
38 of 49 checks passed
nomeata added a commit that referenced this pull request Aug 25, 2026
Replaces the inline level-parameter comparison with the predicate from #14909, which documents the extra-motive-universe encoding at its own definition.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01GSbnoYQjyFAGmX75t7snrX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-manual CI has verified that the Lean Language Reference builds against this PR builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms mathlib4-nightly-available A branch for this PR exists at leanprover-community/mathlib4-nightly-testing:lean-pr-testing-NNNN 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.

Sort-polymorphic Bool fails with obscure error message

2 participants