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: BitVec normalization rule for udiv by twoPow #6029

Merged
merged 1 commit into from
Nov 11, 2024

Conversation

bollu
Copy link
Contributor

@bollu bollu commented Nov 11, 2024

This PR adds a normalization rule to bv_normalize (which is used by bv_decide) that converts x / 2^k into x >>> k under suitable conditions. This allows us to simplify the expensive division circuits that are used for bitblasting into much cheaper shifting circuits. Concretely, it allows for the following canonicalization:

example {x : BitVec 16} : x / (BitVec.twoPow 16 2) = x >>> 2 := by bv_normalize
example {x : BitVec 16} : x / (BitVec.ofNat 16 8) = x >>> 3 := by bv_normalize

@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 11, 2024
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

  • ❗ Mathlib CI can not be attempted yet, as the nightly-testing-2024-11-11 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-mathlib, Mathlib CI should run now. (2024-11-11 09:14:21)

@hargoniX hargoniX added the changelog-language Language features, tactics, and metaprograms label Nov 11, 2024
Copy link
Contributor

@hargoniX hargoniX left a comment

Choose a reason for hiding this comment

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

The This PR part of your PR will be included within the release notes. Please do make clear that this change affects bv_decide and not the general simp.

src/Std/Tactic/BVDecide/Normalize/BitVec.lean Outdated Show resolved Hide resolved
src/Lean/Elab/Tactic/BVDecide/Frontend/Normalize.lean Outdated Show resolved Hide resolved
@bollu bollu force-pushed the simproc-udiv-two-pow branch from 05d55f1 to 132b86d Compare November 11, 2024 09:29
This PR adds a normalization rule to `bv_normalize` (which is used by `bv_decide`) that converts `x / 2^k` into `x >>> k` under suitable conditions. This allows us to simplify the expensive division circuits that are used for bitblasting into much cheaper shifting circuits. Concretely, it allows for the following canonicalization:

```lean
example {x : BitVec 16} : x / (BitVec.twoPow 16 2) = x >>> 2 := by bv_normalize
example {x : BitVec 16} : x / (BitVec.ofNat 16 8) = x >>> 3 := by bv_normalize
```
@bollu bollu force-pushed the simproc-udiv-two-pow branch from 132b86d to d93545b Compare November 11, 2024 09:32
@hargoniX hargoniX enabled auto-merge November 11, 2024 09:37
@hargoniX hargoniX added this pull request to the merge queue Nov 11, 2024
Merged via the queue into leanprover:master with commit 722cb73 Nov 11, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog-language Language features, tactics, and metaprograms 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