Skip to content

Commit 307178f

Browse files
bolluluisacicolini
authored andcommitted
feat: BitVec.ushiftRight in terms of extractLsb' (leanprover#6745)
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) ```
1 parent 7d82c16 commit 307178f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/Init/Data/BitVec/Lemmas.lean

+9
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,15 @@ theorem msb_shiftLeft {x : BitVec w} {n : Nat} :
19411941
(x <<< n).msb = x.getMsbD n := by
19421942
simp [BitVec.msb]
19431943

1944+
theorem ushiftRight_eq_extractLsb'_of_lt {x : BitVec w} {n : Nat} (hn : n < w) :
1945+
x >>> n = ((0#n) ++ (x.extractLsb' n (w - n))).cast (by omega) := by
1946+
ext i hi
1947+
simp only [getLsbD_ushiftRight, getLsbD_cast, getLsbD_append, getLsbD_extractLsb', getLsbD_zero,
1948+
Bool.if_false_right, Bool.and_self_left, Bool.iff_and_self, decide_eq_true_eq]
1949+
intros h
1950+
have := lt_of_getLsbD h
1951+
omega
1952+
19441953
/-! ### rev -/
19451954

19461955
theorem getLsbD_rev (x : BitVec w) (i : Fin w) :

0 commit comments

Comments
 (0)