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:
andrew committed 2026-11-17 10:04:35 -05:00
1 parent a54a5f82f8
commit af318a7d32
51 files changed
+2542 -1357

No files matched your search

+27 -23
View File
@@ -29,7 +29,7 @@ abbrev negCrossClampNonposInfinite (r : RangeRead) (res : Result) : Prop :=
/-- The closed form for the infinite-capacity negative-begin complete clamp cell:
`[⊥, end_.key)`. -/
noncomputable def closedFormNegCrossClampNonposInfinite (r : RangeRead) (res : Result) :
noncomputable def closedFormNegCrossClampNonposInfinite (r : RangeRead) (_res : Result) :
ConflictRange :=
⟨(([] : Key) : WithTop Key), r.end_.key⟩
@@ -160,11 +160,11 @@ theorem between_resolve_end_length {db : DB} {r : RangeRead}
cases hsome : L.reverse[d]? with
| none =>
rw [hsome] at hrev
simp at hrev
change resolve db r.end_ = (([] : Key) : WithTop Key) at hrev
exact absurd hrev hne
| some qv =>
rw [hsome] at hrev
simp at hrev
change resolve db r.end_ = ((qv : Key) : WithTop Key) at hrev
have hqv : resolve db r.end_ = ((qv : Key) : WithTop Key) := hrev
obtain ⟨hdlt, hget⟩ := List.getElem?_eq_some_iff.mp hsome
have hdlt' : d < L.length := by simpa using hdlt
@@ -176,7 +176,8 @@ theorem between_resolve_end_length {db : DB} {r : RangeRead}
countP_lt_eq_of_getElem hLsorted hilt higet
-- length of the filter of keys at or above qv
have hfilt : L.filter (fun k : Key => decide (qv ≤ k)) =
L.filter (fun k : Key => decide (¬ (((k : Key) : WithTop Key) < ((qv : Key) : WithTop Key)))) := by
L.filter (fun k : Key => decide (¬ (((k : Key) : WithTop Key) < ((qv : Key) : WithTop
Key)))) := by
apply List.filter_congr
intro k _
rw [decide_eq_decide]
@@ -214,9 +215,9 @@ theorem between_resolve_end_length {db : DB} {r : RangeRead}
theorem exists_clamp_compat_nonpos_infinite {r : RangeRead} {res : Result}
(hread : Readable r res) (hrev : r.reverse = false) (hmore : res.more = false)
(hne : res.keys ≠ []) (hbegin : r.begin.offset < 0)
(hend : r.end_.offset ≤ 0) (hB_le_E : r.begin.key ≤ r.end_.key)
(hend : r.end_.offset ≤ 0) (_hB_le_E : r.begin.key ≤ r.end_.key)
(hinf : intervalCard r.begin.key r.end_.key = ⊤)
(hcross : ((res.keys.headD ([] : Key) : Key) : WithTop Key) < r.begin.key)
(_hcross : ((res.keys.headD ([] : Key) : Key) : WithTop Key) < r.begin.key)
(hclamp : reportedBelowBegin r res ≤ beginSlack r) :
∃ db : DB, RangeRead.Compatible db r res ∧ r.begin.anchor db < 0 := by
obtain ⟨db₀, hcomp₀⟩ := hread
@@ -322,7 +323,8 @@ theorem exists_clamp_compat_nonpos_infinite {r : RangeRead} {res : Result}
have := hclamp; rw [hrepA] at this; exact_mod_cast this
omega
have hL_A : resolve dbA r.begin = (([] : Key) : WithTop Key) := resolve_eq_nil hanchorA
have hfilt_b : dbA.keys.filter (fun k : Key => decide ((k : WithTop Key) < (↑b : WithTop Key))) =
have hfilt_b : dbA.keys.filter (fun k : Key => decide ((k : WithTop Key) < (↑b : WithTop
Key))) =
res.keys := by
rw [hdbA]
rw [List.filter_append, List.filter_cons]
@@ -347,7 +349,7 @@ theorem exists_clamp_compat_nonpos_infinite {r : RangeRead} {res : Result}
exact hfilt_b
exact ⟨dbA, ⟨hlim, Or.inr ⟨hmore, hckA.symm⟩⟩, hanchorA⟩
· -- Option B: the reported last lies at or above `b`. Use the keys of `db₀` above it.
push_neg at hlastB
push Not at hlastB
have hres_eq₀ : res.keys = RangeRead.completeKeys db₀ r := by
rcases hcomp₀.2 with ⟨hm, _, _⟩ | ⟨-, heq⟩
· simp [hmore] at hm
@@ -363,7 +365,8 @@ theorem exists_clamp_compat_nonpos_infinite {r : RangeRead} {res : Result}
· exact absurd hn hR_ne_nil
· exact absurd ht (resolve_ne_top_of_offset_nonpos hend)
· exact ⟨q, hqeq⟩
have hlast_lt_r₀ : ((res.keys.getLast hne : Key) : WithTop Key) < ((r₀ : Key) : WithTop Key) := by
have hlast_lt_r₀ : ((res.keys.getLast hne : Key) : WithTop Key) < ((r₀ : Key) : WithTop Key)
:= by
rw [← hr₀]; exact hlast_lt_R₀
have hr₀_lt_E : ((r₀ : Key) : WithTop Key) < r.end_.key := by
rw [← hr₀]
@@ -426,7 +429,8 @@ theorem exists_clamp_compat_nonpos_infinite {r : RangeRead} {res : Result}
(k : WithTop Key) ∧ (k : WithTop Key) < r.end_.key)) = L := by
rw [hL, ← hr₀]
rfl
have hqspec : (db₀.keys.filter (fun k : Key => decide ((k : WithTop Key) < r.end_.key))).reverse[
have hqspec : (db₀.keys.filter (fun k : Key => decide ((k : WithTop Key) <
r.end_.key))).reverse[
(-r.end_.offset).toNat]? = some r₀ :=
resolve_filter_reverse_eq_some_of_ne_nil hend (by simpa [hr₀] using hR_ne_nil) hr₀
have hR_B : resolve dbB r.end_ = ((r₀ : Key) : WithTop Key) := by
@@ -495,12 +499,12 @@ theorem minimal_closedForm_of_negCross_clampNonpos_infinite {r : RangeRead} {res
intro k hkbot hkE
by_cases hkhead : ((k : Key) : WithTop Key) < ((res.keys.head hne : Key) : WithTop Key)
· exact necessary_below_head_of_anchor_nonpos_negCross db hcomp hrev hne hanchor hkhead
· push_neg at hkhead
· push Not at hkhead
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 hkhead) (WithTop.coe_le_coe.mp hklast)
· push_neg at hklast
· push Not at hklast
intro cr hs
exact necessary_last_to_end_key hread hrev hmore hne (by omega) cr hs
(le_of_lt (WithTop.coe_lt_coe.mp hklast)) hkE
@@ -513,7 +517,7 @@ abbrev negCrossClampNonposInfiniteRev (r : RangeRead) (res : Result) : Prop :=
reportedBelowBegin r res ≤ beginSlack r
/-- The closed form for the reversed cell: `[⊥, end_.key)`. -/
noncomputable def closedFormNegCrossClampNonposInfiniteRev (r : RangeRead) (res : Result) :
noncomputable def closedFormNegCrossClampNonposInfiniteRev (r : RangeRead) (_res : Result) :
ConflictRange :=
⟨(([] : Key) : WithTop Key), r.end_.key⟩
@@ -559,7 +563,7 @@ abbrev negCrossClampNonposLastGe (r : RangeRead) (res : Result) : Prop :=
reportedBelowBegin r res ≤ beginSlack r
/-- The closed form for the cell: `[⊥, end_.key)`. -/
noncomputable def closedFormNegCrossClampNonposLastGe (r : RangeRead) (res : Result) :
noncomputable def closedFormNegCrossClampNonposLastGe (r : RangeRead) (_res : Result) :
ConflictRange :=
⟨(([] : Key) : WithTop Key), r.end_.key⟩
@@ -729,12 +733,12 @@ theorem minimal_closedForm_of_negCross_clampNonpos_lastGe {r : RangeRead} {res :
intro k hkbot hkE
by_cases hkhead : ((k : Key) : WithTop Key) < ((res.keys.head hne : Key) : WithTop Key)
· exact necessary_below_head_of_anchor_nonpos_negCross db hcomp hrev hne hanchor hkhead
· push_neg at hkhead
· push Not at hkhead
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 hkhead) (WithTop.coe_le_coe.mp hklast)
· push_neg at hklast
· push Not at hklast
intro cr hs
exact necessary_last_to_end_key hread hrev hmore hne (by omega) cr hs
(le_of_lt (WithTop.coe_lt_coe.mp hklast)) hkE
@@ -750,7 +754,7 @@ abbrev negCrossClampNonposLastGeRev (r : RangeRead) (res : Result) : Prop :=
reportedBelowBegin r res ≤ beginSlack r
/-- The closed form for the reversed cell: `[⊥, end_.key)`. -/
noncomputable def closedFormNegCrossClampNonposLastGeRev (r : RangeRead) (res : Result) :
noncomputable def closedFormNegCrossClampNonposLastGeRev (r : RangeRead) (_res : Result) :
ConflictRange :=
⟨(([] : Key) : WithTop Key), r.end_.key⟩
@@ -803,7 +807,7 @@ theorem exists_pad_split {n : ℕ} {A C : ℕ∞}
· refine ⟨n, 0, by omega, ?_, by simp, ?_⟩
· rw [← hCeq]; exact_mod_cast hcn
· rw [← hCeq, ← ENat.natCast_sub, Nat.sub_eq_zero_of_le hcn]
· push_neg at hcn
· push Not at hcn
have hble : ((n - C.toNat : ℕ) : ℕ∞) ≤ A := by
rw [← hCeq] at h
rw [ENat.natCast_sub, tsub_le_iff_left, add_comm]
@@ -991,7 +995,7 @@ theorem exists_clamp_compat_nonpos_bottom {r : RangeRead} {res : Result}
exact hfilt_head
exact ⟨db, ⟨hlim, Or.inr ⟨hmore, hck.symm⟩⟩, hanchor⟩
· -- Case 2: pads split between `[X, begin.key)` and `[begin.key, end.key)`.
push_neg at hBX
push Not at hBX
have hXB : ((X : Key) : WithTop Key) < r.begin.key := hBX
have hadd : intervalCard ((X : Key) : WithTop Key) r.end_.key =
intervalCard ((X : Key) : WithTop Key) r.begin.key +
@@ -1149,7 +1153,7 @@ abbrev negCrossClampNonposBottom (r : RangeRead) (res : Result) : Prop :=
clampNonposBottom r res
/-- The closed form for the finite-capacity clamp cell: `[⊥, end_.key)`. -/
noncomputable def closedFormNegCrossClampNonposBottom (r : RangeRead) (res : Result) :
noncomputable def closedFormNegCrossClampNonposBottom (r : RangeRead) (_res : Result) :
ConflictRange :=
⟨(([] : Key) : WithTop Key), r.end_.key⟩
@@ -1165,12 +1169,12 @@ theorem minimal_closedForm_of_negCross_clampNonpos_bottom {r : RangeRead} {res :
intro k hkbot hkE
by_cases hkhead : ((k : Key) : WithTop Key) < ((res.keys.head hne : Key) : WithTop Key)
· exact necessary_below_head_of_anchor_nonpos_negCross db hcomp hrev hne hanchor hkhead
· push_neg at hkhead
· push Not at hkhead
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 hkhead) (WithTop.coe_le_coe.mp hklast)
· push_neg at hklast
· push Not at hklast
intro cr hs
exact necessary_last_to_end_key hread hrev hmore hne (by omega) cr hs
(le_of_lt (WithTop.coe_lt_coe.mp hklast)) hkE
@@ -1183,7 +1187,7 @@ abbrev negCrossClampNonposBottomRev (r : RangeRead) (res : Result) : Prop :=
clampNonposBottom r res
/-- The closed form for the reversed finite-capacity clamp cell. -/
noncomputable def closedFormNegCrossClampNonposBottomRev (r : RangeRead) (res : Result) :
noncomputable def closedFormNegCrossClampNonposBottomRev (r : RangeRead) (_res : Result) :
ConflictRange :=
⟨(([] : Key) : WithTop Key), r.end_.key⟩