@@ -1518,29 +1518,26 @@ theorem getLsb_replicate {n w : Nat} (x : BitVec w) :
1518
1518
(x.replicate n).getLsb i =
1519
1519
((decide (i < w * n)) && (x.getLsb (i % w))) := by
1520
1520
induction n generalizing x
1521
- case zero =>
1522
- simp
1521
+ case zero => simp
1523
1522
case succ n ih =>
1524
1523
simp only [replicate_succ_eq, getLsb_cast, getLsb_append]
1525
- by_cases hi : i < w * n
1526
- · simp only [hi, decide_True, ih, Bool.true_and, cond_true, Bool.iff_and_self,
1527
- decide_eq_true_eq]
1528
- intros _
1529
- rw [Nat.mul_succ]
1530
- omega
1531
- · simp only [hi, decide_False, ih, Bool.false_and, cond_false]
1532
- by_cases hi' : i < w * (n + 1 )
1533
- · simp only [hi', decide_True, Bool.true_and]
1524
+ by_cases hi : i < w * (n + 1 )
1525
+ · simp only [hi, decide_True, Bool.true_and]
1526
+ by_cases hi' : i < w * n
1527
+ · simp [hi', ih]
1528
+ · simp only [hi', decide_False, cond_false]
1534
1529
congr
1535
1530
rw [Nat.sub_eq_of_eq_add]
1536
- have hi : i / w = n := by
1537
- apply Nat.div_eq_of_lt_le (m := i) (k := n)
1538
- (by simp at hi; rw[Nat.mul_comm]; assumption)
1539
- (by rw [Nat.mul_comm]; assumption)
1540
- rw [← hi, Nat.add_comm, Nat.div_add_mod]
1541
- · simp only [hi', decide_False, Bool.false_and]
1542
- apply getLsb_ge
1543
- apply Nat.le_sub_of_add_le
1544
- simp only [Nat.mul_succ, Nat.not_lt] at hi'
1545
- omega
1531
+ suffices i / w = n by
1532
+ rw [← this, Nat.add_comm, Nat.div_add_mod]
1533
+ apply Nat.div_eq_of_lt_le (m := i) (k := n)
1534
+ (by simp only [Nat.not_lt] at hi'; rw[Nat.mul_comm]; omega)
1535
+ (by rw [Nat.mul_comm]; omega)
1536
+ · have hi' : ¬ (i < w * n) := by
1537
+ simp [Nat.mul_succ] at hi; omega
1538
+ simp only [hi', decide_False, cond_false, hi, Bool.false_and]
1539
+ apply BitVec.getLsb_ge
1540
+ apply Nat.le_sub_of_add_le
1541
+ rw [Nat.mul_succ] at hi
1542
+ omega
1546
1543
end BitVec
0 commit comments