Skip to content

Commit d1fce61

Browse files
committed
getMsbD_rotateRightAux theorems
1 parent 5e599e2 commit d1fce61

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2781,6 +2781,16 @@ theorem getElem_rotateRight {x : BitVec w} {r i : Nat} (h : i < w) :
27812781
simp only [← BitVec.getLsbD_eq_getElem]
27822782
simp [getLsbD_rotateRight, h]
27832783

2784+
theorem getMsbD_rotateRightAux_of_le {x : BitVec w} {r : Nat} {i : Nat} (hi : i < r) :
2785+
(x.rotateRightAux r).getMsbD i = x.getMsbD (i + (w - r)) := by
2786+
rw [rotateRightAux, getMsbD_or, getMsbD_ushiftRight]
2787+
simp [show i < r by omega]
2788+
2789+
2790+
theorem getMsbD_rotateRightAux_of_geq {x : BitVec w} {r : Nat} {i : Nat} (hi : i ≥ r) :
2791+
(x.rotateRightAux r).getMsbD i = (decide (i < w) && x.getMsbD (i - r)) := by
2792+
simp [rotateRightAux, show ¬ i < r by omega, show i + (w - r) ≥ w by omega]
2793+
27842794
@[simp]
27852795
theorem getMsbD_rotateRight {w n m : Nat} {x : BitVec w} :
27862796
(x.rotateRight m).getMsbD n = (decide (n < w) && (if (n < m % w) then x.getMsbD ((w + n - m % w) % w) else x.getMsbD (n - m % w))):= by

0 commit comments

Comments
 (0)