@@ -64,6 +64,7 @@ theorem getElem?_eq_none_iff {l : BitVec w} : l[n]? = none ↔ w ≤ n := by
6464theorem none_eq_getElem ?_iff {l : BitVec w} : none = l[n]? ↔ w ≤ n := by
6565 simp
6666
67+ @[simp]
6768theorem getElem ?_eq_none {l : BitVec w} (h : w ≤ n) : l[n]? = none := getElem?_eq_none_iff.mpr h
6869
6970theorem getElem ?_eq (l : BitVec w) (i : Nat) :
@@ -161,7 +162,8 @@ theorem getLsbD_eq_getMsbD (x : BitVec w) (i : Nat) : x.getLsbD i = (decide (i <
161162 apply getLsbD_of_ge
162163 omega
163164
164- @[simp] theorem getElem ?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : x[i]? = none := by
165+ @[deprecated getElem?_eq_none (since := " 2025-10-29" )]
166+ theorem getElem ?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : x[i]? = none := by
165167 simp [ge]
166168
167169@[simp] theorem getMsb ?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : getMsb? x i = none := by
@@ -421,9 +423,15 @@ theorem getElem?_zero_ofBool (b : Bool) : (ofBool b)[0]? = some b := by
421423 simp only [ofBool, ofNat_eq_ofNat, cond_eq_if]
422424 split <;> simp_all
423425
424- @[simp, grind =] theorem getElem_zero_ofBool (b : Bool) : (ofBool b)[0 ] = b := by
426+ @[simp, grind =]
427+ theorem getElem_ofBool_zero {b : Bool} : (ofBool b)[0 ] = b := by
425428 rw [getElem_eq_iff, getElem?_zero_ofBool]
426429
430+
431+ @[deprecated getElem_ofBool_zero (since := " 2025-10-29" )]
432+ theorem getElem_zero_ofBool (b : Bool) : (ofBool b)[0 ] = b := by
433+ simp
434+
427435theorem getElem ?_succ_ofBool (b : Bool) (i : Nat) : (ofBool b)[i + 1 ]? = none := by
428436 simp
429437
@@ -434,8 +442,6 @@ theorem getLsbD_ofBool (b : Bool) (i : Nat) : (ofBool b).getLsbD i = ((i = 0) &&
434442 · simp only [ofBool, ofNat_eq_ofNat, cond_true, getLsbD_ofNat, Bool.and_true]
435443 by_cases hi : i = 0 <;> simp [hi] <;> omega
436444
437- theorem getElem_ofBool_zero {b : Bool} : (ofBool b)[0 ] = b := by simp
438-
439445@[simp]
440446theorem getElem_ofBool {b : Bool} {h : i < 1 }: (ofBool b)[i] = b := by
441447 simp [← getLsbD_eq_getElem]
@@ -987,7 +993,14 @@ theorem msb_setWidth' (x : BitVec w) (h : w ≤ v) : (x.setWidth' h).msb = (deci
987993theorem msb_setWidth'' (x : BitVec w) : (x.setWidth (k + 1 )).msb = x.getLsbD k := by
988994 simp [BitVec.msb, getMsbD]
989995
996+ /-- Truncating to width 1 produces a bitvector equal to the least significant bit. -/
997+ theorem setWidth_one {x : BitVec w} :
998+ x.setWidth 1 = ofBool (x.getLsbD 0 ) := by
999+ ext i
1000+ simp [show i = 0 by omega]
1001+
9901002/-- zero extending a bitvector to width 1 equals the boolean of the lsb. -/
1003+ @[deprecated setWidth_one (since := " 2025-10-29" )]
9911004theorem setWidth_one_eq_ofBool_getLsb_zero (x : BitVec w) :
9921005 x.setWidth 1 = BitVec.ofBool (x.getLsbD 0 ) := by
9931006 ext i h
@@ -1003,12 +1016,6 @@ theorem setWidth_ofNat_one_eq_ofNat_one_of_lt {v w : Nat} (hv : 0 < v) :
10031016 have hv := (@Nat.testBit_one_eq_true_iff_self_eq_zero i)
10041017 by_cases h : Nat.testBit 1 i = true <;> simp_all
10051018
1006- /-- Truncating to width 1 produces a bitvector equal to the least significant bit. -/
1007- theorem setWidth_one {x : BitVec w} :
1008- x.setWidth 1 = ofBool (x.getLsbD 0 ) := by
1009- ext i
1010- simp [show i = 0 by omega]
1011-
10121019@[simp, grind =] theorem setWidth_ofNat_of_le (h : v ≤ w) (x : Nat) : setWidth v (BitVec.ofNat w x) = BitVec.ofNat v x := by
10131020 apply BitVec.eq_of_toNat_eq
10141021 simp only [toNat_setWidth, toNat_ofNat]
0 commit comments