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: bitblasting support for BitVec.carry #6766

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

alexkeizer
Copy link
Contributor

@alexkeizer alexkeizer commented Jan 24, 2025

This PR adds two normalization lemmas to the bv_normalize simpset, which will enable bv_decide to reason about BitVec.carry: these lemmas are BitVec.carry_eq_getLsbD_add_zeroExtend and BitVec.carry_width_eq_msb_add_zeroExtend. In principle, the former is strictly more general than the latter (which is applicable only in the case carry w x y _, where w is the width of x and y). However, I choose to include the latter still, because asking for the final carry bit is particularly common, and it has a simpler rhs, which presumably means a faster bitblasted circuit.

In the process of adding these lemmas, I also proved carry_gt, which (analogous to getLsbD_ge) says that asking for an out-of-range carry bit gives false. I didn't end up needing this lemma, but it seemed a useful addition to the API nonetheless, so I kept it around. The PR also adds a missing Commutative instance for Boolean xor (which is needed for the main result).

TODO (this PR is still WIP):

  • write tests

src/Init/Data/BitVec/Bitblast.lean Outdated Show resolved Hide resolved
src/Init/Data/BitVec/Bitblast.lean Outdated Show resolved Hide resolved
alexkeizer and others added 2 commits January 24, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants