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.toInt_sshiftRight #39

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

feat: BitVec.toInt_sshiftRight #39

wants to merge 11 commits into from

Conversation

mhk119
Copy link
Collaborator

@mhk119 mhk119 commented Dec 10, 2024

This PR adds toInt_sshiftRight theorem as well as associated API/lemmas.

mhk119 and others added 11 commits December 9, 2024 16:11
Unsigned shift right by at least one bit makes the value of the bitvector less than or equal to `2^(w-1)`,
makes the interpretation of the bitvector `Int` and `Nat` agree.
In the case when `n = 0`, then the shift right value equals the integer interpretation.

```lean
theorem toInt_ushiftRight_eq_ite {x : BitVec w} {n : Nat} :
    (x >>> n).toInt = if n = 0 then x.toInt else x.toNat >>> n
```

---

```lean
theorem toFin_uShiftRight {x : BitVec w} {n : Nat} :
    (x >>> n).toFin = x.toFin / (Fin.ofNat' (2^w) (2^n))
```

Co-authored-by: Harun Khan <harun19@stanford.edu>
Co-authored-by: Tobias Grosser <github@grosser.es>
Co-authored-by: Tobias Grosser <github@grosser.es>
@mhk119 mhk119 changed the title feat: toInt_sshiftRight feat: BitVec.toInt_sshiftRight Dec 15, 2024
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