Fix all Lean build warnings
- Update deprecated lemmas (ite_eq_left/right, ENat casts, List.Sublist, ...) - Replace push_neg with push Not and resolve unused-variable warnings - Convert flexible simp/simp_all calls to explicit simp only lists - Remove unscoped maxHeartbeats options, open scoped Classical, and unused tactics - Add missing module docstrings and clean up style linter hits - Wrap over-long lines and flatten the deeply nested minimal_conflictRangeClosedForm_total proof `lake build` now completes with zero warnings.
This commit is contained in:
1 parent
a54a5f82f8
commit
af318a7d32
51 files changed
+2542
-1357
No files matched your search
@@ -174,7 +174,7 @@ private theorem keys_lo_keyAfter_eq_filter_le {db : DB} {lo : WithTop Key} {last
|
||||
/-- In the finite branch the candidate range contains exactly the reported keys,
|
||||
reversed. -/
|
||||
theorem crossed_rev_finite_keys_eq {db : DB} {r : RangeRead} {res : Result}
|
||||
(hcomp : RangeRead.Compatible db r res) (hmore : res.more = true)
|
||||
(hcomp : RangeRead.Compatible db r res) (_hmore : res.more = true)
|
||||
(hrev : r.reverse = true) (hbegin : r.begin.offset = 1)
|
||||
(hcross : r.end_.key < r.begin.key) (hend : 1 ≤ r.end_.offset)
|
||||
(hne : res.keys ≠ [])
|
||||
@@ -261,8 +261,8 @@ theorem crossed_rev_res_ge_begin {db : DB} {r : RangeRead} {res : Result}
|
||||
the first `e` keys at or above `E` are those reported keys and the gap `[E, B)` is
|
||||
empty. -/
|
||||
theorem take_above_eq_of_range_keys_eq {db : DB} {r : RangeRead} {res : Result}
|
||||
(hrev : r.reverse = true) (hbegin : r.begin.offset = 1)
|
||||
(hcross : r.end_.key < r.begin.key) (hend : 1 ≤ r.end_.offset)
|
||||
(_hrev : r.reverse = true) (_hbegin : r.begin.offset = 1)
|
||||
(hcross : r.end_.key < r.begin.key) (_hend : 1 ≤ r.end_.offset)
|
||||
(hne : res.keys ≠ [])
|
||||
(ht : res.keys.length = (r.end_.offset - 1).toNat)
|
||||
(hBR : ∀ k ∈ res.keys, r.begin.key ≤ (k : WithTop Key))
|
||||
@@ -577,7 +577,7 @@ theorem crossed_rev_insert_between_incompatible {db : DB} {r : RangeRead} {res :
|
||||
rw [hinskeys, hJeq, List.getElem?_insertIdx]
|
||||
have hlt : ¬ j + 1 < db.keys.countP (fun x => decide (x < k)) := by omega
|
||||
have heq : ¬ j + 1 = db.keys.countP (fun x => decide (x < k)) := by omega
|
||||
rw [if_neg hlt, if_neg heq, Nat.add_sub_cancel, List.getElem?_eq_getElem hjlt, hj]
|
||||
rw [ite_eq_right hlt, ite_eq_right heq, Nat.add_sub_cancel, List.getElem?_eq_getElem hjlt, hj]
|
||||
obtain ⟨_, hnewget⟩ := List.getElem?_eq_some_iff.mp hnewget?
|
||||
have hHresolve : resolve (db.insert k hk0) r.end_ = ((H : Key) : WithTop Key) := by
|
||||
rw [resolve_eq_getElem (anchor_nonneg_of_one_le (by omega)) hnewlen]
|
||||
@@ -620,7 +620,8 @@ theorem crossed_rev_no_key_between {db : DB} {r : RangeRead} {res : Result}
|
||||
hcross (by omega) ⟨db, hcomp⟩
|
||||
rw [← hcount]
|
||||
exact ht
|
||||
have hT := crossed_rev_finite_keys_eq (db := db) hcomp hmore hrev hbegin hcross (by omega) hne htlen
|
||||
have hT := crossed_rev_finite_keys_eq (db := db) hcomp hmore hrev hbegin hcross (by omega) hne
|
||||
htlen
|
||||
have hmem : k ∈ (⟨r.end_.key,
|
||||
(keyAfter (res.keys.head hne) : WithTop Key)⟩ : ConflictRange).keys db := by
|
||||
rw [ConflictRange.mem_keys_iff]
|
||||
@@ -724,7 +725,7 @@ theorem completeKeys_filter_ge_crossed_rev_of_room {db : DB} {r : RangeRead}
|
||||
or above `begin.key`. -/
|
||||
theorem completeKeys_crossed_rev_eq_take_above_begin {db : DB} {r : RangeRead}
|
||||
(hrev : r.reverse = true) (hbegin : r.begin.offset = 1)
|
||||
(hcross : r.end_.key < r.begin.key) (hend : 1 ≤ r.end_.offset) :
|
||||
(_hcross : r.end_.key < r.begin.key) (hend : 1 ≤ r.end_.offset) :
|
||||
RangeRead.completeKeys db r =
|
||||
((above db r.begin.key).take
|
||||
(min (cnt db r.end_.key + (r.end_.offset - 1).toNat) db.keys.length -
|
||||
@@ -960,7 +961,7 @@ theorem sound_truncatedRevCrossed_top_last {r : RangeRead} {res : Result}
|
||||
|
||||
theorem crossed_rev_pad_top_necessary {r : RangeRead} {res : Result}
|
||||
(hread : Readable r res) (hmore : res.more = true) (hrev : r.reverse = true)
|
||||
(hbegin : r.begin.offset = 1) (hcross : r.end_.key < r.begin.key)
|
||||
(hbegin : r.begin.offset = 1) (_hcross : r.end_.key < r.begin.key)
|
||||
(hend : 2 ≤ r.end_.offset) (hne : res.keys ≠ [])
|
||||
{E : Key} (hE : r.end_.key = (E : WithTop Key))
|
||||
(hEL : (E : WithTop Key) < ((res.keys.getLast hne : Key) : WithTop Key))
|
||||
@@ -1041,7 +1042,8 @@ theorem crossed_rev_pad_top_necessary {r : RangeRead} {res : Result}
|
||||
have hP_sorted : P.SortedLT := by
|
||||
rw [hPdef]
|
||||
exact List.sortedLT_iff_pairwise.mpr
|
||||
(List.Pairwise.take (i := n) (List.Pairwise.erase k (List.sortedLT_iff_pairwise.mp hS_sorted)))
|
||||
(List.Pairwise.take (i := n) (List.Pairwise.erase k (List.sortedLT_iff_pairwise.mp
|
||||
hS_sorted)))
|
||||
have hP_sub : P ⊆ S := by
|
||||
intro x hx
|
||||
rw [hPdef] at hx
|
||||
@@ -1343,7 +1345,8 @@ theorem minimal_topRevCrossed_begin_last {r : RangeRead} {res : Result}
|
||||
· have hLno : L ≤ keyAfterN n E :=
|
||||
le_trans hLE (keyAfterN_le_self E n)
|
||||
refine (minimal_iff_sound_and_necessary).mpr
|
||||
⟨sound_truncatedRevCrossed_top_last hmore hrev hbegin hcross (by omega) hne hE hL hn' hLno, ?_⟩
|
||||
⟨sound_truncatedRevCrossed_top_last hmore hrev hbegin hcross (by omega) hne hE hL hn' hLno,
|
||||
?_⟩
|
||||
intro k hk
|
||||
have hLk : L ≤ k := WithTop.coe_le_coe.mp hk.1
|
||||
by_cases hkH : k ≤ res.keys.head hne
|
||||
@@ -1421,12 +1424,12 @@ theorem minimal_closedForm_of_offset_one_truncated_rev_fullC_crossed
|
||||
(r.end_.offset - 1).toNat := by
|
||||
rw [hcount]; exact hlen_le_e
|
||||
unfold closedFormOffsetOneTruncatedRevFullC
|
||||
rw [if_neg (by omega : ¬ r.end_.offset ≤ 1)]
|
||||
rw [ite_eq_right (by omega : ¬ r.end_.offset ≤ 1)]
|
||||
dsimp only
|
||||
by_cases ht : res.keys.countP
|
||||
(fun k : Key => decide (r.end_.key ≤ (k : WithTop Key))) =
|
||||
(r.end_.offset - 1).toNat
|
||||
· rw [if_pos ht]
|
||||
· rw [ite_eq_left ht]
|
||||
have htlen : res.keys.length = (r.end_.offset - 1).toNat := by
|
||||
rw [← hcount]; exact ht
|
||||
have hEL : r.end_.key ≤ ((res.keys.getLastD ([] : Key) : Key) : WithTop Key) := by
|
||||
@@ -1438,7 +1441,7 @@ theorem minimal_closedForm_of_offset_one_truncated_rev_fullC_crossed
|
||||
r.end_.key := min_eq_right hEL
|
||||
rw [hmin_eq]
|
||||
exact minimal_truncatedRevCrossed_finite hread' hmore hrev hbegin hcross hend hne htlen
|
||||
· rw [if_neg ht]
|
||||
· rw [ite_eq_right ht]
|
||||
have hlt : res.keys.countP
|
||||
(fun k : Key => decide (r.end_.key ≤ (k : WithTop Key))) <
|
||||
(r.end_.offset - 1).toNat := lt_of_le_of_ne hcount_le ht
|
||||
@@ -1454,14 +1457,14 @@ theorem minimal_closedForm_of_offset_one_truncated_rev_fullC_crossed
|
||||
by_cases hroom : keyAfterN ((r.end_.offset - 1).toNat -
|
||||
res.keys.countP (fun k : Key => decide ((↑E : WithTop Key) ≤ (k : WithTop Key))) - 1)
|
||||
E < res.keys.getLastD ([] : Key)
|
||||
· rw [if_pos hroom]
|
||||
· rw [ite_eq_left hroom]
|
||||
have hroom' : keyAfterN ((r.end_.offset - 1).toNat -
|
||||
res.keys.countP (fun k : Key => decide ((↑E : WithTop Key) ≤ (k : WithTop Key))) - 1)
|
||||
E < res.keys.getLast hne := by
|
||||
rw [← hlast]; exact hroom
|
||||
exact minimal_topRevCrossed_begin_end hread' hmore hrev hbegin hcross hend hne hkey
|
||||
rfl (by rw [hkey]) hlt hroom'
|
||||
· rw [if_neg hroom]
|
||||
· rw [ite_eq_right hroom]
|
||||
have hge : res.keys.getLastD ([] : Key) ≤ keyAfterN ((r.end_.offset - 1).toNat -
|
||||
res.keys.countP (fun k : Key => decide ((↑E : WithTop Key) ≤ (k : WithTop Key))) - 1)
|
||||
E := le_of_not_gt hroom
|
||||
|
||||
Reference in new issue
Block a user