@@ -3711,14 +3711,19 @@ theorem and_one_eq_setWidth_ofBool_getLsbD {x : BitVec w} :
3711
3711
theorem replicate_zero {x : BitVec w} : x.replicate 0 = 0 #0 := by
3712
3712
simp [replicate]
3713
3713
3714
+ @[simp]
3715
+ theorem replicate_one {w : Nat} {x : BitVec w} :
3716
+ (x.replicate 1 ) = x.cast (by rw [Nat.mul_one]) := by
3717
+ simp [replicate]
3718
+
3714
3719
@[simp]
3715
3720
theorem replicate_succ {x : BitVec w} :
3716
3721
x.replicate (n + 1 ) =
3717
3722
(x ++ replicate n x).cast (by rw [Nat.mul_succ]; omega) := by
3718
3723
simp [replicate]
3719
3724
3720
3725
@[simp]
3721
- theorem getLsbD_replicate {n w : Nat} ( x : BitVec w) :
3726
+ theorem getLsbD_replicate {n w : Nat} { x : BitVec w} :
3722
3727
(x.replicate n).getLsbD i =
3723
3728
(decide (i < w * n) && x.getLsbD (i % w)) := by
3724
3729
induction n generalizing x
@@ -3729,17 +3734,17 @@ theorem getLsbD_replicate {n w : Nat} (x : BitVec w) :
3729
3734
· simp only [hi, decide_true, Bool.true_and]
3730
3735
by_cases hi' : i < w * n
3731
3736
· simp [hi', ih]
3732
- · simp [hi', decide_false ]
3733
- rw [Nat.sub_mul_eq_mod_of_lt_of_le] <;> omega
3737
+ · simp only [hi', ↓reduceIte ]
3738
+ rw [Nat.sub_mul_eq_mod_of_lt_of_le ( by omega) ( by omega)]
3734
3739
· rw [Nat.mul_succ] at hi ⊢
3735
3740
simp only [show ¬i < w * n by omega, decide_false, cond_false, hi, Bool.false_and]
3736
3741
apply BitVec.getLsbD_ge (x := x) (i := i - w * n) (ge := by omega)
3737
3742
3738
3743
@[simp]
3739
- theorem getElem_replicate {n w : Nat} ( x : BitVec w) (h : i < w * n) :
3744
+ theorem getElem_replicate {n w : Nat} { x : BitVec w} (h : i < w * n) :
3740
3745
(x.replicate n)[i] = if h' : w = 0 then false else x[i % w]'(@Nat.mod_lt i w (by omega)) := by
3741
3746
simp only [← getLsbD_eq_getElem, getLsbD_replicate]
3742
- by_cases h' : w = 0 <;> simp [h'] <;> omega
3747
+ cases w <;> simp; omega
3743
3748
3744
3749
theorem append_assoc {x₁ : BitVec w₁} {x₂ : BitVec w₂} {x₃ : BitVec w₃} :
3745
3750
(x₁ ++ x₂) ++ x₃ = (x₁ ++ (x₂ ++ x₃)).cast (by omega) := by
@@ -4113,6 +4118,17 @@ theorem reverse_replicate {n : Nat} {x : BitVec w} :
4113
4118
conv => lhs; simp only [replicate_succ']
4114
4119
simp [reverse_append, ih]
4115
4120
4121
+ @[simp]
4122
+ theorem getMsbD_replicate {n w : Nat} {x : BitVec w} :
4123
+ (x.replicate n).getMsbD i = (decide (i < w * n) && x.getMsbD (i % w)) := by
4124
+ rw [← getLsbD_reverse, reverse_replicate, getLsbD_replicate, getLsbD_reverse]
4125
+
4126
+ @[simp]
4127
+ theorem msb_replicate {n w : Nat} {x : BitVec w} :
4128
+ (x.replicate n).msb = (decide (0 < n) && x.msb) := by
4129
+ simp only [BitVec.msb, getMsbD_replicate, Nat.zero_mod]
4130
+ cases n <;> cases w <;> simp
4131
+
4116
4132
/-! ### Decidable quantifiers -/
4117
4133
4118
4134
theorem forall_zero_iff {P : BitVec 0 → Prop } :
0 commit comments