Skip to content

Conversation

@mhk119
Copy link
Collaborator

@mhk119 mhk119 commented Dec 10, 2024

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

@mhk119 mhk119 changed the title feat: toInt_sshiftRight feat: BitVec.toInt_sshiftRight Dec 15, 2024
mhk119 and others added 11 commits February 16, 2025 11:08
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>
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.

4 participants