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
@@ -98,7 +98,7 @@ theorem endPad_cast (h : negCrossTruncTopTop r res) :
|
||||
|
||||
/-- The empty window never reports a truncated nonempty prefix. -/
|
||||
theorem not_compatible_of_resolve_end_nil {db : DB} {r : RangeRead} {res : Result}
|
||||
(hrev : r.reverse = false) (hmore : res.more = true) (hne : res.keys ≠ [])
|
||||
(_hrev : r.reverse = false) (_hmore : res.more = true) (hne : res.keys ≠ [])
|
||||
(hE : resolve db r.end_ = (([] : Key) : WithTop Key)) :
|
||||
¬ RangeRead.Compatible db r res := by
|
||||
intro hc
|
||||
@@ -107,7 +107,7 @@ theorem not_compatible_of_resolve_end_nil {db : DB} {r : RangeRead} {res : Resul
|
||||
obtain ⟨a, ha⟩ : ∃ a, a ∈ RangeRead.completeKeys db r := by
|
||||
cases hW : RangeRead.completeKeys db r with
|
||||
| nil => exact absurd hW hneW
|
||||
| cons a t => exact ⟨a, by simp [hW]⟩
|
||||
| cons a t => exact ⟨a, by simp []⟩
|
||||
have hlt := (RangeRead.mem_completeKeys.mp ha).2.2
|
||||
rw [hE, WithTop.coe_lt_coe] at hlt
|
||||
exact absurd hlt (List.not_lt_nil a)
|
||||
@@ -175,7 +175,7 @@ theorem completeKeys_eq_drop_take {db : DB} {r : RangeRead}
|
||||
rw [hlen]
|
||||
omega
|
||||
rw [RangeRead.completeKeys, ite_eq_right (by simp [hrev])]
|
||||
show l.filter (fun k : Key => decide (resolve db r.begin ≤ (↑k : WithTop Key) ∧
|
||||
change l.filter (fun k : Key => decide (resolve db r.begin ≤ (↑k : WithTop Key) ∧
|
||||
(↑k : WithTop Key) < resolve db r.end_)) = _
|
||||
have hsplit : l.filter (fun k : Key => decide (resolve db r.begin ≤ (↑k : WithTop Key) ∧
|
||||
(↑k : WithTop Key) < resolve db r.end_)) =
|
||||
@@ -209,7 +209,7 @@ theorem completeKeys_eq_take_of_size_beginSlack {db : DB} {r : RangeRead} {res :
|
||||
have hanE0 : 0 ≤ r.end_.anchor db := by rw [hanE]; omega
|
||||
have hanE_toNat : (r.end_.anchor db).toNat = q - p := by
|
||||
rw [hanE]
|
||||
rw [show (q : ℤ) - (p : ℤ) = ((q - p : ℕ) : ℤ) by push_cast; omega]
|
||||
rw [show (q : ℤ) - (p : ℤ) = ((q - p : ℕ) : ℤ) by omega]
|
||||
exact Int.toNat_natCast _
|
||||
have hanE_lt : (r.end_.anchor db).toNat < db.keys.length := by
|
||||
rw [hanE_toNat, hN, hq]; omega
|
||||
@@ -245,7 +245,7 @@ theorem completeKeys_length_le_topTop {db : DB} {r : RangeRead}
|
||||
(by rw [← hp, ← hN]; exact hpN) (by rw [← hq, ← hN]; exact hqN)
|
||||
rw [hdt, List.length_take, List.length_drop]
|
||||
omega
|
||||
· push_neg at hqN
|
||||
· push Not at hqN
|
||||
-- `N ≤ q`: the begin clamps to the bottom
|
||||
have hanB : r.begin.anchor db < 0 := by
|
||||
rw [anchor_begin_top hBtop hbo]
|
||||
@@ -258,7 +258,8 @@ theorem completeKeys_length_le_topTop {db : DB} {r : RangeRead}
|
||||
rw [show RangeRead.inRange db.keys (resolve db r.begin) (resolve db r.end_) =
|
||||
db.keys.filter (fun k : Key => decide (resolve db r.begin ≤ (↑k : WithTop Key) ∧
|
||||
(↑k : WithTop Key) < resolve db r.end_)) from rfl, hresB]
|
||||
rw [show db.keys.filter (fun k : Key => decide (((↑([] : Key)) : WithTop Key) ≤ (↑k : WithTop Key) ∧
|
||||
rw [show db.keys.filter (fun k : Key => decide (((↑([] : Key)) : WithTop Key) ≤ (↑k :
|
||||
WithTop Key) ∧
|
||||
(↑k : WithTop Key) < resolve db r.end_)) =
|
||||
db.keys.filter (fun k : Key => decide ((↑k : WithTop Key) < resolve db r.end_)) from by
|
||||
apply List.filter_congr
|
||||
@@ -269,7 +270,7 @@ theorem completeKeys_length_le_topTop {db : DB} {r : RangeRead}
|
||||
rw [← List.countP_eq_length_filter]
|
||||
rw [hlen, countP_lt_resolve, anchor_end_top hEtop hend, ← hN, ← hp]
|
||||
omega
|
||||
· push_neg at hpN
|
||||
· push Not at hpN
|
||||
-- `p > N`: the end resolves below the bottom, so the window is empty
|
||||
have hanE : r.end_.anchor db < 0 := by
|
||||
rw [anchor_end_top hEtop hend]
|
||||
@@ -304,8 +305,8 @@ theorem completeKeys_eq_nil_of_anchor_end_neg {db : DB} {r : RangeRead}
|
||||
exact not_lt.mpr (WithTop.coe_le_coe.mpr (nil_le_key k))
|
||||
rw [RangeRead.completeKeys]
|
||||
by_cases hrev : r.reverse = true
|
||||
· rw [if_pos hrev]; exact List.reverse_eq_nil_iff.mpr hempty
|
||||
· rw [if_neg hrev]; exact hempty
|
||||
· rw [ite_eq_left hrev]; exact List.reverse_eq_nil_iff.mpr hempty
|
||||
· rw [ite_eq_right hrev]; exact hempty
|
||||
|
||||
/-- Readability forces the both-sentinel counts to fit: `t + p ≤ q + 1`. -/
|
||||
theorem readable_counts_topTop (h : negCrossTruncTopTop r res) (hread : Readable r res) :
|
||||
@@ -391,7 +392,7 @@ theorem exists_filter_head_decomp_of_compatible {db : DB} (h : negCrossTruncTopT
|
||||
· have hb : ¬ (resolve db r.begin ≤ ((k : Key) : WithTop Key)) := by
|
||||
intro hb
|
||||
have hkck : k ∈ RangeRead.completeKeys db r := by
|
||||
rw [RangeRead.completeKeys, if_neg (by simp [h.2.1])]
|
||||
rw [RangeRead.completeKeys, ite_eq_right (by simp [h.2.1])]
|
||||
rw [show RangeRead.inRange db.keys (resolve db r.begin) (resolve db r.end_) =
|
||||
db.keys.filter (fun x : Key => decide (resolve db r.begin ≤ (↑x : WithTop Key) ∧
|
||||
(↑x : WithTop Key) < resolve db r.end_)) from rfl, List.mem_filter]
|
||||
@@ -402,7 +403,7 @@ theorem exists_filter_head_decomp_of_compatible {db : DB} (h : negCrossTruncTopT
|
||||
have hR : db.keys.filter (fun k : Key => decide
|
||||
(resolve db r.begin ≤ (↑k : WithTop Key)) &&
|
||||
decide ((↑k : WithTop Key) < resolve db r.end_)) = res.keys := by
|
||||
rw [hckeq, RangeRead.completeKeys, if_neg (by simp [h.2.1]), RangeRead.inRange]
|
||||
rw [hckeq, RangeRead.completeKeys, ite_eq_right (by simp [h.2.1]), RangeRead.inRange]
|
||||
simp only [Bool.decide_and]
|
||||
exact hcongr.trans hR
|
||||
have hFD : (db.keys.drop (N - p)).filter (fun k : Key => decide
|
||||
@@ -563,7 +564,7 @@ theorem exists_witness_above_last_branchH {r : RangeRead} {res : Result} {k : Ke
|
||||
rw [hdbw_keys]; exact List.mem_append.mpr (Or.inr hGmem)
|
||||
have hk_not_res : k ∉ res.keys := fun hx => absurd (hle_last k hx) (not_le.mpr hkgt)
|
||||
have hkeys' : (dbw.erase k).keys = res.keys ++ G.erase k := by
|
||||
rw [DB.erase_keys, hdbw_keys, List.erase_append, if_neg hk_not_res]
|
||||
rw [DB.erase_keys, hdbw_keys, List.erase_append, ite_eq_right hk_not_res]
|
||||
have hN' : (dbw.erase k).keys.length = t + p - 1 := by
|
||||
rw [hkeys', List.length_append, List.length_erase_of_mem hGmem, hGlen, ← ht]
|
||||
omega
|
||||
@@ -571,7 +572,6 @@ theorem exists_witness_above_last_branchH {r : RangeRead} {res : Result} {k : Ke
|
||||
rw [hN', hq]
|
||||
have hanB' : r.begin.anchor (dbw.erase k) < 0 := by
|
||||
rw [anchor_begin_eq h (dbw.erase k), hNq']
|
||||
push_cast
|
||||
omega
|
||||
have hrb' : resolve (dbw.erase k) r.begin = ((↑([] : Key)) : WithTop Key) :=
|
||||
resolve_eq_nil hanB'
|
||||
@@ -592,7 +592,7 @@ theorem exists_witness_above_last_branchH {r : RangeRead} {res : Result} {k : Ke
|
||||
have hlen : t - 1 < res.keys.length := by rw [← ht]; omega
|
||||
rw [List.getElem?_eq_getElem hlen, hlast, List.getLast_eq_getElem hne]
|
||||
rw [resolve, ite_eq_right (not_lt.mpr h0), hkeys', List.getElem?_append,
|
||||
if_pos (by rw [hidx, ← ht]; omega), hidx, hlastIdx]
|
||||
ite_eq_left (by rw [hidx, ← ht]; omega), hidx, hlastIdx]
|
||||
have hckE : RangeRead.completeKeys (dbw.erase k) r = res.keys.dropLast := by
|
||||
rw [completeKeys_eq_of_resolve_nil_coe (db := dbw.erase k) (w := last) hrev
|
||||
h.2.2.2.2.2.2 hrb' hre', hkeys', List.filter_append]
|
||||
@@ -655,7 +655,7 @@ theorem minimal_top_head_of_branchH {r : RangeRead} {res : Result}
|
||||
by_cases hklast : ((k : Key) : WithTop Key) ≤ ((res.keys.getLast hne : Key) : WithTop Key)
|
||||
· exact necessary_of_between_result hread (List.head_mem hne) (List.getLast_mem hne)
|
||||
(WithTop.coe_le_coe.mp hklo) (WithTop.coe_le_coe.mp hklast)
|
||||
· push_neg at hklast
|
||||
· push Not at hklast
|
||||
exact necessary_above_last_branchH hread h hH (WithTop.coe_lt_coe.mp hklast)
|
||||
|
||||
/-- Inserting a key above every element of the first list distributes over append. -/
|
||||
@@ -666,7 +666,7 @@ theorem orderedInsert_append_of_forall_lt {l₁ l₂ : List Key} {k : Key}
|
||||
| nil => rfl
|
||||
| cons a t ih =>
|
||||
rw [List.cons_append, List.orderedInsert_cons,
|
||||
if_neg (not_le.mpr (h a (List.mem_cons_self ..))),
|
||||
ite_eq_right (not_le.mpr (h a (List.mem_cons_self ..))),
|
||||
ih (fun x hx => h x (List.mem_cons_of_mem a hx))]
|
||||
exact (List.cons_append).symm
|
||||
|
||||
@@ -966,7 +966,7 @@ def negCrossTruncTopTopEq (r : RangeRead) (res : Result) : Prop :=
|
||||
|
||||
/-- The closed form of the equality branch: the reported keys are the complete window, so
|
||||
the minimal range is `[head, ⊤)`. -/
|
||||
noncomputable def closedFormNegCrossTruncTopTopEq (r : RangeRead) (res : Result) :
|
||||
noncomputable def closedFormNegCrossTruncTopTopEq (_r : RangeRead) (res : Result) :
|
||||
ConflictRange :=
|
||||
⟨((res.keys.headD ([] : Key) : Key) : WithTop Key), (⊤ : WithTop Key)⟩
|
||||
|
||||
@@ -1009,7 +1009,7 @@ def negCrossTruncTopTopStrict (r : RangeRead) (res : Result) : Prop :=
|
||||
res.keys.length + (1 - r.end_.offset).toNat < beginSlack r + 1
|
||||
|
||||
/-- The closed form of the strict branch: the full range `[⊥, ⊤)`. -/
|
||||
noncomputable def closedFormNegCrossTruncTopTopStrict (r : RangeRead) (_res : Result) :
|
||||
noncomputable def closedFormNegCrossTruncTopTopStrict (_r : RangeRead) (_res : Result) :
|
||||
ConflictRange :=
|
||||
⟨(([] : Key) : WithTop Key), (⊤ : WithTop Key)⟩
|
||||
|
||||
@@ -1028,11 +1028,11 @@ theorem minimal_closedForm_of_negCross_trunc_topTop {r : RangeRead} {res : Resul
|
||||
(hread : Readable r res) (h : negCrossTruncTopTop r res) :
|
||||
Minimal r res (closedFormNegCrossTruncTopTop r res) := by
|
||||
by_cases hH : res.keys.length + (1 - r.end_.offset).toNat = beginSlack r + 1
|
||||
· rw [closedFormNegCrossTruncTopTop, if_pos hH]
|
||||
· rw [closedFormNegCrossTruncTopTop, ite_eq_left hH]
|
||||
exact minimal_closedForm_of_negCross_trunc_topTop_eq hread ⟨h, hH⟩
|
||||
· have hle := NegCrossTruncTopTop.readable_counts_topTop h hread
|
||||
have hF : res.keys.length + (1 - r.end_.offset).toNat < beginSlack r + 1 := by omega
|
||||
rw [closedFormNegCrossTruncTopTop, if_neg hH]
|
||||
rw [closedFormNegCrossTruncTopTop, ite_eq_right hH]
|
||||
exact NegCrossTruncTopTop.minimal_full_of_branchF hread h hF
|
||||
|
||||
end FormalConflictRange
|
||||
Reference in new issue
Block a user