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: toNat theorems for rotateLeft and rotateRight #6347

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

Conversation

mhk119
Copy link
Contributor

@mhk119 mhk119 commented Dec 9, 2024

This PR adds BitVec.toNat_rotateLeft and BitVec.toNat_rotateLeft.

@mhk119 mhk119 requested a review from kim-em as a code owner December 9, 2024 17:53
@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 Dec 9, 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 520d4b698f3f1f8ed5d673fad6cc810179642279 --onto 3f791933f16d74d74ab8116c96cadec6cdf7b70e. (2024-12-09 18:11:11)

@tobiasgrosser
Copy link
Contributor

changelog-library

@github-actions github-actions bot added the changelog-library Library label Dec 9, 2024
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 LGTM. We just need to either a force-push to the PR to take into account the changelog-library (the relevant GitHub action does not rerun automatically). Alternatively, one can probably just merge this PR directly.

@[simp]
theorem toNat_rotateLeft {x : BitVec w} {r : Nat} :
(x.rotateLeft r).toNat = (x.toNat <<< (r % w)) % (2^w) ||| x.toNat >>> (w - r % w) := by
simp only [rotateLeft, rotateLeftAux, toNat_shiftLeft, toNat_ushiftRight, toNat_or]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we please have a lemma e.g. rotateLeft_def which combines the first two steps here? Similarly for right.

@kim-em kim-em added the awaiting-author Waiting for PR author to address issues label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-author Waiting for PR author to address issues changelog-library Library 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.

4 participants