@@ -3732,14 +3732,19 @@ theorem and_one_eq_setWidth_ofBool_getLsbD {x : BitVec w} :
3732
3732
theorem replicate_zero {x : BitVec w} : x.replicate 0 = 0 #0 := by
3733
3733
simp [replicate]
3734
3734
3735
+ @[simp]
3736
+ theorem replicate_one {w : Nat} {x : BitVec w} :
3737
+ (x.replicate 1 ) = x.cast (by rw [Nat.mul_one]) := by
3738
+ simp [replicate]
3739
+
3735
3740
@[simp]
3736
3741
theorem replicate_succ {x : BitVec w} :
3737
3742
x.replicate (n + 1 ) =
3738
3743
(x ++ replicate n x).cast (by rw [Nat.mul_succ]; omega) := by
3739
3744
simp [replicate]
3740
3745
3741
3746
@[simp]
3742
- theorem getLsbD_replicate {n w : Nat} ( x : BitVec w) :
3747
+ theorem getLsbD_replicate {n w : Nat} { x : BitVec w} :
3743
3748
(x.replicate n).getLsbD i =
3744
3749
(decide (i < w * n) && x.getLsbD (i % w)) := by
3745
3750
induction n generalizing x
@@ -3750,17 +3755,17 @@ theorem getLsbD_replicate {n w : Nat} (x : BitVec w) :
3750
3755
· simp only [hi, decide_true, Bool.true_and]
3751
3756
by_cases hi' : i < w * n
3752
3757
· simp [hi', ih]
3753
- · simp [hi', decide_false ]
3754
- rw [Nat.sub_mul_eq_mod_of_lt_of_le] <;> omega
3758
+ · simp only [hi', ↓reduceIte ]
3759
+ rw [Nat.sub_mul_eq_mod_of_lt_of_le ( by omega) ( by omega)]
3755
3760
· rw [Nat.mul_succ] at hi ⊢
3756
3761
simp only [show ¬i < w * n by omega, decide_false, cond_false, hi, Bool.false_and]
3757
3762
apply BitVec.getLsbD_ge (x := x) (i := i - w * n) (ge := by omega)
3758
3763
3759
3764
@[simp]
3760
- theorem getElem_replicate {n w : Nat} ( x : BitVec w) (h : i < w * n) :
3765
+ theorem getElem_replicate {n w : Nat} { x : BitVec w} (h : i < w * n) :
3761
3766
(x.replicate n)[i] = if h' : w = 0 then false else x[i % w]'(@Nat.mod_lt i w (by omega)) := by
3762
3767
simp only [← getLsbD_eq_getElem, getLsbD_replicate]
3763
- by_cases h' : w = 0 <;> simp [h'] <;> omega
3768
+ cases w <;> simp; omega
3764
3769
3765
3770
theorem append_assoc {x₁ : BitVec w₁} {x₂ : BitVec w₂} {x₃ : BitVec w₃} :
3766
3771
(x₁ ++ x₂) ++ x₃ = (x₁ ++ (x₂ ++ x₃)).cast (by omega) := by
@@ -4126,6 +4131,17 @@ theorem reverse_replicate {n : Nat} {x : BitVec w} :
4126
4131
conv => lhs; simp only [replicate_succ']
4127
4132
simp [reverse_append, ih]
4128
4133
4134
+ @[simp]
4135
+ theorem getMsbD_replicate {n w : Nat} {x : BitVec w} :
4136
+ (x.replicate n).getMsbD i = (decide (i < w * n) && x.getMsbD (i % w)) := by
4137
+ rw [← getLsbD_reverse, reverse_replicate, getLsbD_replicate, getLsbD_reverse]
4138
+
4139
+ @[simp]
4140
+ theorem msb_replicate {n w : Nat} {x : BitVec w} :
4141
+ (x.replicate n).msb = (decide (0 < n) && x.msb) := by
4142
+ simp only [BitVec.msb, getMsbD_replicate, Nat.zero_mod]
4143
+ cases n <;> cases w <;> simp
4144
+
4129
4145
/-! ### Decidable quantifiers -/
4130
4146
4131
4147
theorem forall_zero_iff {P : BitVec 0 → Prop } :
0 commit comments