Skip to content

Commit 1aa761f

Browse files
committed
chore: wip
1 parent 4f05b9f commit 1aa761f

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/Init/Data/BitVec/Bitblast.lean

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3141,6 +3141,35 @@ theorem addRecAux_extractAndExtendPopulate_setWidth_eq {x : BitVec (w + 1)} (h :
31413141
omega
31423142
· simp [hk0]
31433143

3144+
theorem addRecAux_extractAndExtendPopulateAux_le_of_le {x : BitVec w} (hn : n ≤ w) :
3145+
((extractAndExtendPopulate w x).addRecAux n 0#w).toNat ≤ n := by
3146+
induction n
3147+
· case zero =>
3148+
simp
3149+
· case succ n ihn =>
3150+
rcases w with _|_|w
3151+
· omega
3152+
· simp
3153+
have : n = 0 := by omega
3154+
subst this
3155+
simp
3156+
omega
3157+
· simp [addRecAux_succ]
3158+
rw [← addRecAux_zero_add]
3159+
have : (extractLsb' (n * (w + 1 + 1)) (w + 1 + 1) (extractAndExtendPopulate (w + 1 + 1) x)).toNat ≤ 1 := by
3160+
rw [extractLsb'_extractAndExtendPopulate_eq (x := x) (w := (w + 1 + 1)) (i := n) (len := (w + 1 + 1))]
3161+
simp
3162+
have := mod_lt (y := 2) (x := x.toNat >>> n) (by omega)
3163+
have : 2 < 2 ^ ((w + 1 + 1)) := by
3164+
omega
3165+
rw [Nat.mod_eq_of_lt (b := 2 ^ ((w + 1 + 1))) (by omega)]
3166+
omega
3167+
simp only [toNat_add, -extractLsb'_toNat, add_mod_mod, ge_iff_le]
3168+
rw [Nat.mod_eq_of_lt]
3169+
· omega
3170+
· have := Nat.lt_two_pow_self (n := w + 1 + 1)
3171+
omega
3172+
31443173
theorem thm1 {x : BitVec (w' + 1)} (hn : n ≤ w'):
31453174
(extractAndExtendPopulate (w' + 1) x).addRecAux n 0#(w' + 1) =
31463175
((extractAndExtendPopulate w' x).addRecAux n 0#w').setWidth (w' + 1) := by
@@ -3160,7 +3189,8 @@ theorem thm1 {x : BitVec (w' + 1)} (hn : n ≤ w'):
31603189
rw [hext2]
31613190
simp
31623191
apply eq_of_toNat_eq
3163-
simp
3192+
simp only [toNat_add, -toNat_setWidth, Nat.lt_add_one, toNat_mod_cancel_of_lt,
3193+
-extractLsb'_toNat, Nat.pow_one, add_mod_mod]
31643194

31653195
sorry
31663196
· simp [show n' = w' + 1 by omega]

0 commit comments

Comments
 (0)