Skip to content

Commit 6df6011

Browse files
bollutobiasgrosser
andauthored
feat: BitVec.shiftLeft_neg_eq_neg_shiftLeft (leanprover#7508)
This PR shows that negation commutes with left shift, which is the Bitwuzla rewrite [NORM_BV_SHL_NEG](https://github.com/bitwuzla/bitwuzla/blob/e09c50818b798f990bd84bf61174553fef46d561/src/rewrite/rewrites_bv_norm.cpp#L142-L148). ```lean theorem shiftLeft_neg_eq_neg_shiftLeft {x : BitVec w} {y : Nat} : (-x) <<< y = - (x <<< y) ``` --------- Co-authored-by: Tobias Grosser <[email protected]>
1 parent e77b528 commit 6df6011

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4212,6 +4212,10 @@ theorem udiv_twoPow_eq_of_lt {w : Nat} {x : BitVec w} {k : Nat} (hk : k < w) : x
42124212
have : 2^k < 2^w := Nat.pow_lt_pow_of_lt (by decide) hk
42134213
simp [bitvec_to_nat, Nat.shiftRight_eq_div_pow, Nat.mod_eq_of_lt this]
42144214

4215+
theorem shiftLeft_neg {x : BitVec w} {y : Nat} :
4216+
(-x) <<< y = - (x <<< y) := by
4217+
rw [shiftLeft_eq_mul_twoPow, shiftLeft_eq_mul_twoPow, BitVec.neg_mul]
4218+
42154219
/- ### cons -/
42164220

42174221
@[simp] theorem true_cons_zero : cons true 0#w = twoPow (w + 1) w := by

0 commit comments

Comments
 (0)