Skip to content

Commit f2eb419

Browse files
committed
chore: polish
1 parent abdf304 commit f2eb419

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/Init/Data/BitVec/Lemmas.lean

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5639,28 +5639,26 @@ theorem clzAux_eq_iff {x : BitVec w} {n : Nat} :
56395639
induction n
56405640
· case zero => simp [clzAux]
56415641
· case succ n ihn =>
5642-
by_cases hn1 : x.getLsbD (n + 1)
5643-
· simp only [clzAux, hn1, ↓reduceIte, Nat.right_eq_add, Nat.add_eq_zero, reduceCtorEq, and_false,
5644-
false_iff, Classical.not_forall, not_imp, Bool.not_eq_false]
5642+
by_cases hxn : x.getLsbD (n + 1)
5643+
· simp only [clzAux, hxn, ↓reduceIte, Nat.right_eq_add, Nat.add_eq_zero, reduceCtorEq,
5644+
and_false, false_iff, Classical.not_forall, not_imp, Bool.not_eq_false]
56455645
exists n + 1, by omega
5646-
· have h3 : 1 + x.clzAux n = n + 1 + 1 ↔ x.clzAux n = n + 1 := by omega
5647-
simp only [clzAux, hn1, Bool.false_eq_true, ↓reduceIte, h3, ihn]
5646+
· simp only [clzAux, hxn, Bool.false_eq_true, ↓reduceIte,
5647+
show 1 + x.clzAux n = n + 1 + 1 ↔ x.clzAux n = n + 1 by omega, ihn]
56485648
constructor
5649-
· intro h i hin
5649+
· intro hc i hin
56505650
by_cases hi : i ≤ n
5651-
· apply h
5652-
omega
5653-
· simp only [Bool.not_eq_true] at hn1
5654-
simp [show i = n + 1 by omega, hn1]
5655-
· intro h i hin
5656-
apply h
5651+
· apply hc; omega
5652+
· simp [show i = n + 1 by omega, hxn]
5653+
· intro hc i hin
5654+
apply hc
56575655
omega
56585656

56595657
theorem clzAux_le {x : BitVec w} {n : Nat} :
56605658
clzAux x n ≤ n + 1 := by
56615659
induction n
56625660
· case zero =>
5663-
by_cases hx0 : x.getLsbD 0
5661+
cases hx0 : x.getLsbD 0
56645662
<;> simp [clzAux, hx0]
56655663
· case succ n ihn =>
56665664
by_cases hxn : x.getLsbD (n + 1)
@@ -5689,8 +5687,7 @@ theorem clzAux_eq_iff_forall_of_clzAux_lt {x : BitVec w} (hlt : (clzAux x n < n
56895687
rcases k
56905688
· case zero => simp [clzAux_eq_zero_iff]
56915689
· case succ k =>
5692-
unfold clzAux at hlt
5693-
unfold clzAux
5690+
simp only [clzAux, Nat.reduceSubDiff] at *
56945691
by_cases hxn : x.getLsbD (n + 1)
56955692
· simp only [hxn, ↓reduceIte, Nat.right_eq_add, Nat.add_eq_zero, Nat.succ_ne_self, and_false,
56965693
Nat.reduceSubDiff, false_iff, _root_.not_and, Bool.not_eq_true]

0 commit comments

Comments
 (0)