Skip to content

feat: characterize when T-division equals zero - #8204

Merged
kim-em merged 9 commits into
leanprover:masterfrom
opencompl:tdiv-eq-zero-iff
Aug 31, 2026
Merged

feat: characterize when T-division equals zero#8204
kim-em merged 9 commits into
leanprover:masterfrom
opencompl:tdiv-eq-zero-iff

Conversation

@bollu

@bollu bollu commented May 2, 2025

Copy link
Copy Markdown
Contributor

This PR adds the lemma Int.tdiv_eq_zero_iff_natAbs_lt_or_eq_zero which shows that T-division equals zero iff the absolute value of the numerator is less than the denominator, or the denominator equals zero:

@[simp] theorem tdiv_eq_zero_iff_natAbs_lt_or_eq_zero {a : Int} {b : Int} :
    a.tdiv b = 0 ↔ (a.natAbs < b.natAbs ∨ b = 0):= by

This was used in reasoning about the MSB of BitVec.sdiv. The strategy was
superced, but this lemma was extracted from the earlier proof.

@bollu

bollu commented May 2, 2025

Copy link
Copy Markdown
Contributor Author

changelog-library

@github-actions github-actions Bot added changelog-library Library toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN labels May 2, 2025
ghost pushed a commit to leanprover-community/batteries that referenced this pull request May 2, 2025
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request May 2, 2025
ghost pushed a commit to leanprover-community/batteries that referenced this pull request May 2, 2025
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request May 2, 2025
@ghost

ghost commented May 2, 2025

Copy link
Copy Markdown

Mathlib CI status (docs):

  • 🟡 Mathlib branch lean-pr-testing-8204 build against this PR was cancelled. (2025-05-02 11:08:09) View Log
  • ✅ Mathlib branch lean-pr-testing-8204 has successfully built against this PR. (2025-05-02 11:55:35) View Log
  • ✅ Mathlib branch lean-pr-testing-8204 has successfully built against this PR. (2025-05-12 10:56:50) View Log
  • ✅ Mathlib branch lean-pr-testing-8204 has successfully built against this PR. (2025-06-06 14:49:47) View Log
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase ec9ff12fc65316c902224aa895a32ae943dcc762 --onto faffe863343211d03d07d4ef19d90a2aa9d6fc8c. You can force Mathlib CI using the force-mathlib-ci label. (2025-06-14 14:47:32)

@ghost ghost added the builds-mathlib CI has verified that Mathlib builds against this PR label May 2, 2025
Comment thread src/Init/Data/Int/DivMod/Lemmas.lean Outdated
Comment thread src/Init/Data/Int/DivMod/Lemmas.lean Outdated
ghost pushed a commit to leanprover-community/batteries that referenced this pull request May 12, 2025
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request May 12, 2025
@bollu
bollu marked this pull request as ready for review May 12, 2025 10:24
@bollu
bollu requested a review from kim-em as a code owner May 12, 2025 10:24
@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label May 13, 2025

@tobiasgrosser tobiasgrosser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment thread src/Init/Data/Int/DivMod/Lemmas.lean Outdated
Comment thread src/Init/Data/Int/DivMod/Lemmas.lean Outdated
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Jun 6, 2025
ghost pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jun 6, 2025
ghost pushed a commit to leanprover-community/batteries that referenced this pull request Jun 13, 2025
Comment thread src/Init/Data/Int/DivMod/Lemmas.lean Outdated
bollu and others added 6 commits June 14, 2025 14:55
This PR adds the lemma `Int.tdiv_eq_zero_iff_natAbs_lt_or_eq_zero`
which shows that T-division equals zero iff the absolute value
of the numerator is less than the denominator, or the denominator equals
zero.

This was used in reasoning about the MSB of `BitVec.sdiv`. The strategy was
superced, but this lemma was extracted from the earlier proof.
Co-authored-by: Luisa Cicolini <48860705+luisacicolini@users.noreply.github.com>
Co-authored-by: Alex Keizer <alex@keizer.dev>
Co-authored-by: Alex Keizer <alex@keizer.dev>
@bollu
bollu force-pushed the tdiv-eq-zero-iff branch from 7549331 to 030aad1 Compare June 14, 2025 14:19

@tobiasgrosser tobiasgrosser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you, @bollu.

@kim-em
kim-em enabled auto-merge August 31, 2026 05:17
@kim-em
kim-em added this pull request to the merge queue Aug 31, 2026
@mathlib-lean-pr-testing

Copy link
Copy Markdown

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 2a5b1a2f7ec519ab9f6196acd8c8e735c7e5a2b2 --onto ac0f56e6f6c8022a0b8df4ffd0738bc20723e1ef. You can force Mathlib CI using the force-mathlib-ci label. (2026-08-31 05:29:38)

@leanprover-bot

Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI will not be attempted unless your PR branches off the nightly-with-manual branch. Try git rebase 2a5b1a2f7ec519ab9f6196acd8c8e735c7e5a2b2 --onto e991a05e359a25988f49bff3ab8af986e959b866. You can force reference manual CI using the force-manual-ci label. (2026-08-31 05:29:39)

Merged via the queue into leanprover:master with commit 138ca9f Aug 31, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-library Library P-medium We may work on this issue if we find the time 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.

6 participants