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: add SMT-LIB overflow on addition for bitvectors (uadd_overflow,sadd_overflow, uadd_overflow_eq,sadd_overflow_eq) and support theorems #6628

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

Conversation

luisacicolini
Copy link
Contributor

@luisacicolini luisacicolini commented Jan 13, 2025

This PR adds SMT-LIB operators to detect overflow (uadd_overflow,sadd_overflow), according to the definitions here, and the theorems proving equivalence of such definitions with the BitVec library functions (uadd_overflow_eq, sadd_overflow_eq). Support theorems for these proofs are toInt_lt, le_toInt, toInd_add_toInt_lt_two_pow, neg_two_pow_le_toInd_add_toInt, bmod_two_pow_neg_iff, emod_eq_add_self_emo. A few theorems (emod_eq_add_self_emod,Nat.cast_pow,Nat.cast_ofNat) were also pulled from Mathlib.

@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 Jan 13, 2025
@leanprover-community-bot
Copy link
Collaborator

leanprover-community-bot commented Jan 13, 2025

Mathlib CI status (docs):

  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 8483ac7258b84b179f3ec369df533452afdeb758 --onto d2c4471cfa4611977bf4927b5cd849df1a4272b7. (2025-01-13 14:04:32)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 8483ac7258b84b179f3ec369df533452afdeb758 --onto e9bd9807ef7a983365df9ac55d35040d0b2d5ef2. (2025-01-14 14:29:28)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 6ebce421423445eeac59a6f4347a562897a99e8d --onto f35a6020704e003995d585c7baa216982134d75f. (2025-01-24 08:01:44)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 6ebce421423445eeac59a6f4347a562897a99e8d --onto 69a73a18fbfa1fc045bfbf1c4cf93b155d4c9387. (2025-01-27 12:40:23)
  • ❗ Batteries/Mathlib CI will not be attempted unless your PR branches off the nightly-with-mathlib branch. Try git rebase 6ebce421423445eeac59a6f4347a562897a99e8d --onto 20c616503abe5ce4253c56dbcd7766a91c675ba0. (2025-01-28 11:12:24)

@github-actions github-actions bot added the changelog-library Library label Jan 13, 2025
@luisacicolini
Copy link
Contributor Author

changelog-library

@luisacicolini luisacicolini marked this pull request as ready for review January 13, 2025 17:37
@luisacicolini luisacicolini requested a review from kim-em as a code owner January 13, 2025 17:37
@leanprover-bot leanprover-bot added the P-medium We may work on this issue if we find the time label Jan 14, 2025
@kim-em
Copy link
Collaborator

kim-em commented Jan 15, 2025

What are your plans for adding theorems about these?

@luisacicolini
Copy link
Contributor Author

Ideally supporting them in bvdecide - although there are some proofs missing (they're taking me more time than I expected), so I'll draft the PR for now and open it when the proofs are done!

@luisacicolini luisacicolini marked this pull request as draft January 15, 2025 08:34
@kim-em
Copy link
Collaborator

kim-em commented Jan 15, 2025

Okay! I'm happy with these definitions, and checked them against the reference, so I'm happy to click merge as soon as we're sure they are going to be used.

@luisacicolini luisacicolini changed the title feat: add SMT-LIB overflow definitions for bitvectors (not_overflow,uadd_overflow,sadd_overflow,umul_overflow,smul_overflow) feat: add SMT-LIB overflow on addition for bitvectors (uadd_overflow,sadd_overflow, uadd_overflow_eq,sadd_overflow_eq) Jan 22, 2025
luisacicolini and others added 2 commits January 22, 2025 12:51
Co-authored-by: Tobias Grosser <[email protected]>
Co-authored-by: Tobias Grosser <[email protected]>
src/Init/Data/BitVec/Basic.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Basic.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Lemmas.lean Outdated Show resolved Hide resolved
Co-authored-by: Alex Keizer <[email protected]>
Copy link
Contributor

@tobiasgrosser tobiasgrosser left a comment

Choose a reason for hiding this comment

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

This looks good to go from my side.

Co-authored-by: Tobias Grosser <[email protected]>
@luisacicolini luisacicolini marked this pull request as ready for review January 28, 2025 10:41
@luisacicolini
Copy link
Contributor Author

awaiting-review

@github-actions github-actions bot added the awaiting-review Waiting for someone to review the PR label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-review Waiting for someone to review the 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.

7 participants