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.ushiftRight in terms of extractLsb' #6745

Merged

Conversation

bollu
Copy link
Contributor

@bollu bollu commented Jan 22, 2025

This PR supports rewriting ushiftRight in terms of extractLsb'. This is the companion PR to #6743 which adds the similar lemmas about shiftLeft.

theorem ushiftRight_eq_zero {x : BitVec w} {n : Nat} (hn : w ≤ n) :
    x >>> n = 0#w

theorem ushiftRight_eq_extractLsb'_of_lt {x : BitVec w} {n : Nat} (hn : n < w) :
    x >>> n = ((0#n) ++ (x.extractLsb' n (w - n))).cast (by omega)

@bollu bollu requested a review from kim-em as a code owner January 22, 2025 18:24
@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 22, 2025
@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 6ebce421423445eeac59a6f4347a562897a99e8d --onto 9b74c07767dc50645efa00356a7724e7f7176227. (2025-01-22 18:44:27)

@hargoniX hargoniX added changelog-doc Documentation changelog-language Language features, tactics, and metaprograms and removed changelog-doc Documentation labels Jan 22, 2025
@hargoniX hargoniX added this pull request to the merge queue Jan 22, 2025
Merged via the queue into leanprover:master with commit 5f3c0da Jan 22, 2025
20 of 21 checks passed
luisacicolini pushed a commit to opencompl/lean4 that referenced this pull request Feb 24, 2025
This PR supports rewriting `ushiftRight` in terms of `extractLsb'`. This
is the companion PR to leanprover#6743 which adds the similar lemmas about
`shiftLeft`.


```lean
theorem ushiftRight_eq_zero {x : BitVec w} {n : Nat} (hn : w ≤ n) :
    x >>> n = 0#w

theorem ushiftRight_eq_extractLsb'_of_lt {x : BitVec w} {n : Nat} (hn : n < w) :
    x >>> n = ((0#n) ++ (x.extractLsb' n (w - n))).cast (by omega)
```
luisacicolini pushed a commit to opencompl/lean4 that referenced this pull request Feb 25, 2025
This PR supports rewriting `ushiftRight` in terms of `extractLsb'`. This
is the companion PR to leanprover#6743 which adds the similar lemmas about
`shiftLeft`.


```lean
theorem ushiftRight_eq_zero {x : BitVec w} {n : Nat} (hn : w ≤ n) :
    x >>> n = 0#w

theorem ushiftRight_eq_extractLsb'_of_lt {x : BitVec w} {n : Nat} (hn : n < w) :
    x >>> n = ((0#n) ++ (x.extractLsb' n (w - n))).cast (by omega)
```
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