Skip to content

Commit 5aed5df

Browse files
committed
chore: cleanup proof, use saner proof strategy
1 parent 229db42 commit 5aed5df

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,29 +1518,26 @@ theorem getLsb_replicate {n w : Nat} (x : BitVec w) :
15181518
(x.replicate n).getLsb i =
15191519
((decide (i < w * n)) && (x.getLsb (i % w))) := by
15201520
induction n generalizing x
1521-
case zero =>
1522-
simp
1521+
case zero => simp
15231522
case succ n ih =>
15241523
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]
15341529
congr
15351530
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
15461543
end BitVec

0 commit comments

Comments
 (0)