Skip to content

Commit 253d802

Browse files
committed
chore: progress on proof
1 parent 54475b2 commit 253d802

File tree

1 file changed

+38
-13
lines changed

1 file changed

+38
-13
lines changed

src/Init/Data/BitVec/Bitblast.lean

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,17 +2136,6 @@ theorem aandRec_iff' {x y : BitVec w} (k : Nat) (hk : k < w) (hk' : 0 < k) :
21362136
aandRec x y k hk hk' ↔ (y[k] = true ∧ x.toNat ≥ 2^(w - 1 - (k - 1))) := by
21372137
simp [aandRec, show ¬ k = 0 by omega]
21382138

2139-
theorem aandRec_iff_le {x y : BitVec w} (k : Nat) (hk : k < w) (hk' : 0 < k) :
2140-
aandRec x y k hk hk' ↔ (∃ j, k ≤ j ∧ j < w ∧ 2 ^ j * 2 ^ (w - 1 - (j - 1)) ≤ y.toNat * x.toNat) := by
2141-
constructor
2142-
· intro h
2143-
exists 2
2144-
sorry
2145-
· intros hj
2146-
obtain ⟨j, hkj, hjw, hjxy⟩ := hj
2147-
simp [aandRec, show ¬ k = 0 by omega]
2148-
sorry
2149-
21502139
/--
21512140
Count the number of leading zeroes downward from the 'n'th bit to the '0'th bit.
21522141
-/
@@ -2175,8 +2164,44 @@ theorem of_le_clzAux {w} {k : Nat} (x : BitVec w) (hn : n < w)
21752164
simp [show n < w by omega] at ihn
21762165
by_cases hh : k ≤ x.clzAux n
21772166
· simp [hh, hi] at ihn
2178-
sorry
2179-
· sorry
2167+
specialize ihn i
2168+
simp [hi] at ihn
2169+
rw [getLsbD_eq_getElem (by omega)] at ihn
2170+
cases k
2171+
· simp_all
2172+
· case pos.succ k =>
2173+
unfold clzAux at hk
2174+
by_cases hlsb : x.getLsbD (n + 1)
2175+
· simp [hlsb] at hk
2176+
· simp [hlsb] at hk
2177+
unfold clzAux at hh hk
2178+
induction i
2179+
· case neg.zero =>
2180+
simp_all
2181+
· case neg.succ i ihi =>
2182+
simp_all
2183+
rcases n
2184+
· simp_all
2185+
have h: 1 - i = 11 - i = 0 := by omega
2186+
rcases h with h|h
2187+
· rw [getLsbD_eq_getElem (by omega)]
2188+
simp [h, ihn]
2189+
· rw [getLsbD_eq_getElem (by omega)]
2190+
simp [h, ihn]
2191+
· case succ n =>
2192+
simp_all
2193+
by_cases h : x.getLsbD (n + 1)
2194+
· simp [h] at hh hk
2195+
· simp [h] at hh hk
2196+
rw [getLsbD_eq_getElem (by omega)]
2197+
simp [show i < k + 1 by omega] at ihi
2198+
simp_all
2199+
apply Classical.byContradiction
2200+
intro hcontra
2201+
simp at hcontra
2202+
simp [hcontra] at ihi
2203+
simp_all
2204+
sorry
21802205

21812206
/-- Count the number of leading zeroes. -/
21822207
def clz {w : Nat} (x : BitVec w) : Nat :=

0 commit comments

Comments
 (0)