Skip to content

fix: classify negative literals in grind by their syntactic type - #16341

Merged
leodemoura merged 1 commit into
masterfrom
grind-16286
Nov 7, 2026
Merged

leodemoura merged 1 commit into
masterfrom
grind-16286

Conversation

@leodemoura

Copy link
Copy Markdown
Member

This PR fixes the grind internal error "linarith term has not been internalized" on negative numerals such as -1 : T, where T unfolds to Int and has an ordered IntModule instance but no CommRing instance.

getLitKind unfolded T with whnfD, so it classified -1 : T as a literal and internalize skipped the inner 1. linarith reifies -1 : T as the negation of 1 and needs that 1. A negative literal's type must now be literally Int, Int8, Int16, Int32, or Int64, as in isInterpreted. The Int8..Int64 goals from #16286 already succeed since #16298 and are included as regression tests.

Closes #16286

🤖 Generated with Claude Code

This PR fixes the `grind` internal error "linarith term has not been internalized" on negative numerals such as `-1 : T`, where `T` unfolds to `Int` and has an ordered `IntModule` instance but no `CommRing` instance.

`getLitKind` unfolded `T` with `whnfD`, so it classified `-1 : T` as a literal and `internalize` skipped the inner `1`. `linarith` reifies `-1 : T` as the negation of `1` and needs that `1`. A negative literal's type must now be literally `Int`, `Int8`, `Int16`, `Int32`, or `Int64`, as in `isInterpreted`. The `Int8`..`Int64` goals from #16286 already succeed since #16298 and are included as regression tests.

Closes #16286

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@leodemoura leodemoura added the changelog-tactics User facing tactics label Nov 7, 2026
@leodemoura
leodemoura enabled auto-merge November 7, 2026 22:21
@leodemoura
leodemoura added this pull request to the merge queue Nov 7, 2026
@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 Nov 7, 2026
Merged via the queue into master with commit da4295a Nov 7, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-tactics User facing tactics 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.

grind_linarith: internal error "linarith term has not been internalized" on negative Int8..Int64 literals (regression after 4.36)

1 participant