@@ -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) :
@@ -158,7 +159,8 @@ theorem getLsbD_eq_getMsbD (x : BitVec w) (i : Nat) : x.getLsbD i = (decide (i <
158159 apply getLsbD_of_ge
159160 omega
160161
161- @[simp] theorem getElem ?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : x[i]? = none := by
162+ @[deprecated getElem?_eq_none (since := " 2025-10-29" )]
163+ theorem getElem ?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : x[i]? = none := by
162164 simp [ge]
163165
164166@[simp] theorem getMsb ?_of_ge (x : BitVec w) (i : Nat) (ge : w ≤ i) : getMsb? x i = none := by
@@ -415,12 +417,18 @@ theorem getElem?_zero_ofNat_one : (BitVec.ofNat (w+1) 1)[0]? = some true := by
415417
416418-- This does not need to be a `@[simp]` theorem as it is already handled by `getElem?_eq_getElem`.
417419theorem getElem ?_zero_ofBool (b : Bool) : (ofBool b)[0 ]? = some b := by
418- simp only [ofBool, ofNat_eq_ofNat, cond_eq_if ]
420+ simp only [ofBool, ofNat_eq_ofNat, cond_eq_ite ]
419421 split <;> simp_all
420422
421- @[simp, grind =] theorem getElem_zero_ofBool (b : Bool) : (ofBool b)[0 ] = b := by
423+ @[simp, grind =]
424+ theorem getElem_ofBool_zero {b : Bool} : (ofBool b)[0 ] = b := by
422425 rw [getElem_eq_iff, getElem?_zero_ofBool]
423426
427+
428+ @[deprecated getElem_ofBool_zero (since := " 2025-10-29" )]
429+ theorem getElem_zero_ofBool (b : Bool) : (ofBool b)[0 ] = b := by
430+ simp
431+
424432theorem getElem ?_succ_ofBool (b : Bool) (i : Nat) : (ofBool b)[i + 1 ]? = none := by
425433 simp
426434
@@ -431,8 +439,6 @@ theorem getLsbD_ofBool (b : Bool) (i : Nat) : (ofBool b).getLsbD i = ((i = 0) &&
431439 · simp only [ofBool, ofNat_eq_ofNat, cond_true, getLsbD_ofNat, Bool.and_true]
432440 by_cases hi : i = 0 <;> simp [hi] <;> omega
433441
434- theorem getElem_ofBool_zero {b : Bool} : (ofBool b)[0 ] = b := by simp
435-
436442@[simp]
437443theorem getElem_ofBool {b : Bool} {h : i < 1 }: (ofBool b)[i] = b := by
438444 simp [← getLsbD_eq_getElem]
@@ -580,7 +586,7 @@ theorem toInt_eq_toNat_bmod (x : BitVec n) : x.toInt = Int.bmod x.toNat (2^n) :=
580586 simp only [toInt_eq_toNat_cond]
581587 split
582588 next g =>
583- rw [Int.bmod_pos ] <;> simp only [←Int.natCast_emod, toNat_mod_cancel]
589+ rw [Int.bmod_eq_emod_of_lt ] <;> simp only [←Int.natCast_emod, toNat_mod_cancel]
584590 omega
585591 next g =>
586592 rw [Int.bmod_neg] <;> simp only [←Int.natCast_emod, toNat_mod_cancel]
@@ -988,7 +994,14 @@ theorem msb_setWidth' (x : BitVec w) (h : w ≤ v) : (x.setWidth' h).msb = (deci
988994theorem msb_setWidth'' (x : BitVec w) : (x.setWidth (k + 1 )).msb = x.getLsbD k := by
989995 simp [BitVec.msb, getMsbD]
990996
997+ /-- Truncating to width 1 produces a bitvector equal to the least significant bit. -/
998+ theorem setWidth_one {x : BitVec w} :
999+ x.setWidth 1 = ofBool (x.getLsbD 0 ) := by
1000+ ext i
1001+ simp [show i = 0 by omega]
1002+
9911003/-- zero extending a bitvector to width 1 equals the boolean of the lsb. -/
1004+ @[deprecated setWidth_one (since := " 2025-10-29" )]
9921005theorem setWidth_one_eq_ofBool_getLsb_zero (x : BitVec w) :
9931006 x.setWidth 1 = BitVec.ofBool (x.getLsbD 0 ) := by
9941007 ext i h
@@ -1004,12 +1017,6 @@ theorem setWidth_ofNat_one_eq_ofNat_one_of_lt {v w : Nat} (hv : 0 < v) :
10041017 have hv := (@Nat.testBit_one_eq_true_iff_self_eq_zero i)
10051018 by_cases h : Nat.testBit 1 i = true <;> simp_all
10061019
1007- /-- Truncating to width 1 produces a bitvector equal to the least significant bit. -/
1008- theorem setWidth_one {x : BitVec w} :
1009- x.setWidth 1 = ofBool (x.getLsbD 0 ) := by
1010- ext i
1011- simp [show i = 0 by omega]
1012-
10131020@[simp, grind =] theorem setWidth_ofNat_of_le (h : v ≤ w) (x : Nat) : setWidth v (BitVec.ofNat w x) = BitVec.ofNat v x := by
10141021 apply BitVec.eq_of_toNat_eq
10151022 simp only [toNat_setWidth, toNat_ofNat]
@@ -1639,11 +1646,11 @@ theorem not_def {x : BitVec v} : ~~~x = allOnes v ^^^ x := rfl
16391646
16401647@[simp] theorem ofInt_negSucc_eq_not_ofNat {w n : Nat} :
16411648 BitVec.ofInt w (Int.negSucc n) = ~~~.ofNat w n := by
1642- simp only [BitVec.ofInt, Int.toNat, Int.ofNat_eq_coe , toNat_eq, toNat_ofNatLT, toNat_not,
1649+ simp only [BitVec.ofInt, Int.toNat, Int.ofNat_eq_natCast , toNat_eq, toNat_ofNatLT, toNat_not,
16431650 toNat_ofNat]
16441651 cases h : Int.negSucc n % ((2 ^ w : Nat) : Int)
16451652 case ofNat =>
1646- rw [Int.ofNat_eq_coe , Int.negSucc_emod] at h
1653+ rw [Int.ofNat_eq_natCast , Int.negSucc_emod] at h
16471654 · dsimp only
16481655 omega
16491656 · omega
0 commit comments