Skip to content

Commit 4f05b9f

Browse files
committed
chore: the theorem was useless lol
1 parent 32fce58 commit 4f05b9f

File tree

2 files changed

+41
-67
lines changed

2 files changed

+41
-67
lines changed

src/Init/Data/BitVec/Bitblast.lean

Lines changed: 40 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3049,42 +3049,54 @@ theorem cpopNatRec_cons_eq_cpopNatRec_of_le {x : BitVec w} {b : Bool} (hn : n
30493049

30503050
theorem getLsbD_extractAndExtendPopulate_add {x : BitVec w} (hk : k < w):
30513051
(x.extractAndExtendPopulate w).getLsbD (pos * w + k) = ((x.extractLsb' pos 1).zeroExtend w).getLsbD k := by
3052+
30523053
simp [← extractLsb'_extractAndExtendPopulate_eq (w := w) (len := w) (i := pos) (x := x)]
30533054
omega
30543055

3055-
theorem getLsbD_extractAndExtendPopulate {x : BitVec w} (hw : 0 < w) (hk : k ≤ w * w):
3056-
(x.extractAndExtendPopulate w).getLsbD k =
3057-
let idx := k % w
3058-
let pos := (k - idx)/w
3059-
(x.extractLsb' pos 1).getLsbD idx := by
3060-
simp
3061-
let idx := k % w
3062-
let pos := (k - idx) / w
3063-
have hk : k = pos * w + idx := by
3064-
subst pos idx
3065-
have : (k = (k - k % w) / w * w + k % w) ↔ (k - k % w = (k - k % w) / w * w) := by
3066-
sorry
3067-
sorry
3068-
have hidx : idx < w := by sorry
3069-
rw [hk]
3070-
rw [getLsbD_extractAndExtendPopulate_add (by omega)]
3071-
simp
3072-
by_cases hmod0 : idx = 0
3073-
· simp [hmod0, hw]
3074-
· simp [hmod0]
3075-
intros hmod
3076-
simp [hmod]
3077-
rw [Nat.add_div hw]
3078-
simp [hmod, show ¬ w = 0 by omega]
3079-
rw [Nat.mul_div_cancel (H := by omega)]
3080-
have : idx / w = 0 := by exact mod_div_self k w
3081-
simp [this]
3056+
theorem getLsbD_extractAndExtend_of_le_of_lt (w idx currIdx : Nat) (hw : 0 < w) (x : BitVec w)
3057+
(_hcurr : currIdx < w)
3058+
(hlt : idx < w * (currIdx + 1)) (hle : w * currIdx ≤ idx) :
3059+
(BitVec.zeroExtend w (BitVec.extractLsb' currIdx 1 x)).getLsbD (idx - w * currIdx) =
3060+
(BitVec.extractAndExtendPopulate w x).getLsbD idx := by
3061+
unfold BitVec.extractAndExtendPopulate
3062+
have ⟨res, proof⟩ := BitVec.extractAndExtendPopulateAux 0 w x (BitVec.cast (by omega) 0#0) (by omega) (by omega)
3063+
simp [Nat.mul_add] at hlt
3064+
simp [show idx - w * currIdx < w by omega]
3065+
by_cases h2 : idx - w * currIdx = 0
3066+
· have hidx : idx = currIdx * w := by rw [Nat.mul_comm]; omega
3067+
simp [h2]
3068+
simp [hidx]
3069+
specialize proof currIdx
3070+
have : res.getLsbD (currIdx * w) = (BitVec.extractLsb' (currIdx * w) w res)[0] := by
3071+
simp
3072+
simp [this, proof]
3073+
· have hidx : ∃ j, idx = currIdx * w + j := by
3074+
refine Nat.exists_eq_add_of_le (by rw [Nat.mul_comm]; omega)
3075+
obtain ⟨j, hj⟩ := hidx
3076+
simp [h2]
3077+
rw [hj]
3078+
specialize proof currIdx
3079+
have : res.getLsbD (currIdx * w + j) = (BitVec.extractLsb' (currIdx * w) w res).getLsbD j := by
3080+
simp
3081+
intros ht
3082+
by_cases hlt : j < w
3083+
· omega
3084+
· rw [Nat.mul_comm] at hj
3085+
omega
3086+
rw [this]
3087+
rw [proof]
3088+
simp
3089+
intros hj' hj''
3090+
subst hj''
3091+
simp
3092+
rw [Nat.mul_comm] at hj
3093+
omega
30823094

3083-
sorry
30843095

30853096
theorem th3 :
30863097
(extractAndExtendPopulate w (setWidth n x)).addRecAux n 0#w = (extractAndExtendPopulate w x).addRecAux n 0#w := by
30873098
have : extractAndExtendPopulate w (setWidth n x) = (extractAndExtendPopulate w x).setWidth (n * w) := by
3099+
generalize hgen : extractAndExtendPopulate w x = gen
30883100

30893101
sorry
30903102

@@ -3150,7 +3162,6 @@ theorem thm1 {x : BitVec (w' + 1)} (hn : n ≤ w'):
31503162
apply eq_of_toNat_eq
31513163
simp
31523164

3153-
31543165
sorry
31553166
· simp [show n' = w' + 1 by omega]
31563167
have hext1 := extractLsb'_extractAndExtendPopulate_eq (w := w' + 1) (len := w' + 1) (i := w') (x := x)

src/Std/Tactic/BVDecide/Bitblast/BVExpr/Circuit/Lemmas/Operations/Cpop.lean

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -95,44 +95,7 @@ theorem blastExtractAndExtend_denote_mem_prefix {w : Nat} (aig : AIG α) (curr :
9595
· intros
9696
apply extractAndExtend_le_size
9797

98-
theorem BitVec.getLsbD_extractAndExtend_of_le_of_lt (w idx currIdx : Nat) (hw : 0 < w) (x : BitVec w)
99-
(_hcurr : currIdx < w)
100-
(hlt : idx < w * (currIdx + 1)) (hle : w * currIdx ≤ idx) :
101-
(BitVec.zeroExtend w (BitVec.extractLsb' currIdx 1 x)).getLsbD (idx - w * currIdx) =
102-
(BitVec.extractAndExtendPopulate w x).getLsbD idx := by
103-
unfold BitVec.extractAndExtendPopulate
104-
have ⟨res, proof⟩ := BitVec.extractAndExtendPopulateAux 0 w x (BitVec.cast (by omega) 0#0) (by omega) (by omega)
105-
simp [Nat.mul_add] at hlt
106-
simp [show idx - w * currIdx < w by omega]
107-
by_cases h2 : idx - w * currIdx = 0
108-
· have hidx : idx = currIdx * w := by rw [Nat.mul_comm]; omega
109-
simp [h2]
110-
simp [hidx]
111-
specialize proof currIdx
112-
have : res.getLsbD (currIdx * w) = (BitVec.extractLsb' (currIdx * w) w res)[0] := by
113-
simp
114-
simp [this, proof]
115-
· have hidx : ∃ j, idx = currIdx * w + j := by
116-
refine Nat.exists_eq_add_of_le (by rw [Nat.mul_comm]; omega)
117-
obtain ⟨j, hj⟩ := hidx
118-
simp [h2]
119-
rw [hj]
120-
specialize proof currIdx
121-
have : res.getLsbD (currIdx * w + j) = (BitVec.extractLsb' (currIdx * w) w res).getLsbD j := by
122-
simp
123-
intros ht
124-
by_cases hlt : j < w
125-
· omega
126-
· rw [Nat.mul_comm] at hj
127-
omega
128-
rw [this]
129-
rw [proof]
130-
simp
131-
intros hj' hj''
132-
subst hj''
133-
simp
134-
rw [Nat.mul_comm] at hj
135-
omega
98+
13699

137100
theorem denote_blastExtractAndExtendPopulate
138101
(assign : α → Bool)

0 commit comments

Comments
 (0)