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

feat: lemmas for Bitvector division when denominator is zero #5609

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bollu
Copy link
Contributor

@bollu bollu commented Oct 3, 2024

These lemmas explain what happens when the denominator is zero with udiv, umod, sdiv, smod. A follow-up PR will show what happens with smtUDiv and smtSMod, since these need some more bitvector theory.
These lemmas will be used by bv_decide for bitblasting.

The theorems {sdiv, smod}_zero_eq are located after neg theory has been built for the purpose of writing terse proofs.

These lemmas explain what happens when the denominator is zero.
This is used by bv_decide for bitblasting.
@bollu bollu changed the title Udiv denom zero lemmas feat: lemmas for division when denominator is zero Oct 3, 2024
@bollu bollu changed the title feat: lemmas for division when denominator is zero feat: lemmas for Bitvector division when denominator is zero Oct 3, 2024
@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 Oct 3, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 53c5470200eef7c6a185577c4d18106e4cf105aa --onto a4fda010f3d44c02393d5afd5cf05509989daf63. (2024-10-03 17:32:28)

Comment on lines +2060 to +2061
theorem sdiv_zero_eq (x : BitVec n) : x.sdiv 0#n = 0#n := by
simp only [sdiv_eq, msb_zero]
Copy link
Contributor

@tobiasgrosser tobiasgrosser Oct 3, 2024

Choose a reason for hiding this comment

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

Suggested change
theorem sdiv_zero_eq (x : BitVec n) : x.sdiv 0#n = 0#n := by
simp only [sdiv_eq, msb_zero]
@[simp]
theorem sdiv_zero {x : BitVec n} : x.sdiv 0#n = 0#n := by
simp only [sdiv_eq, msb_zero]

Comment on lines +2063 to +2064

theorem smod_zero_eq (x : BitVec n) : x.smod 0#n = x := by
Copy link
Contributor

@tobiasgrosser tobiasgrosser Oct 3, 2024

Choose a reason for hiding this comment

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

Suggested change
theorem smod_zero_eq (x : BitVec n) : x.smod 0#n = x := by
@[simp]
theorem smod_zero {x : BitVec n} : x.smod 0#n = x := by

@tobiasgrosser
Copy link
Contributor

I think you can also drop the _eq from the PR description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants