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

@@ -312,7 +312,7 @@ theorem exists_witness_below_head_A2aBottom {r : RangeRead} {res : Result} {k :
have hcount_ins : (dbw.insert k hk_not_dbw).keys.countP
(fun x : Key => decide ((x : WithTop Key) < r.begin.key)) =
res.keys.length + (clampNonposD r + 1) + 1 := by
rw [hins_keys, List.countP_cons, decide_eq_true_eq.mpr hk_lt_B, if_pos rfl, hrescnt]
rw [hins_keys, List.countP_cons, decide_eq_true_eq.mpr hk_lt_B, ite_eq_left rfl, hrescnt]
have hanchor_ins : r.begin.anchor (dbw.insert k hk_not_dbw) ≤ 0 := by
rw [anchor_eq_count_sub_slack _ r (le_of_lt hbegin), hcount_ins]
have hcast : (res.keys.length + (clampNonposD r + 1) : ℤ) ≤ (beginSlack r : ℤ) := by
@@ -458,7 +458,7 @@ theorem exists_witness_last_end_A2aBottom {r : RangeRead} {res : Result} {k : Ke
rw [decide_eq_true_eq]; exact hkE
have h2 : (dbF.keys.erase k).countP
(fun x : Key => decide ((x : WithTop Key) < r.end_.key)) = clampNonposD r := by
rw [List.countP_erase, if_pos ⟨hk_in_F, hktrue⟩, hFall, hFlen]
rw [List.countP_erase, ite_eq_left ⟨hk_in_F, hktrue⟩, hFall, hFlen]
omega
rw [h1, h2]
have hoff : r.end_.offset = -(clampNonposD r : ℤ) := by
@@ -482,7 +482,7 @@ theorem exists_witness_last_end_A2aBottom {r : RangeRead} {res : Result} {k : Ke
((res.keys.getLast hne : Key) : WithTop Key) := by
have h0 : 0 ≤ r.end_.anchor (dbw.erase k) := by rw [hanchor_erase]; omega
have hlenErase : (dbw.erase k).keys.length = res.keys.length + clampNonposD r := by
rw [herase_keys, List.length_append, List.length_erase, if_pos hk_in_F, hFlen]
rw [herase_keys, List.length_append, List.length_erase, ite_eq_left hk_in_F, hFlen]
omega
have hlt : (r.end_.anchor (dbw.erase k)).toNat < (dbw.erase k).keys.length := by
rw [hanchor_erase, hlenErase]
@@ -513,7 +513,7 @@ theorem exists_witness_last_end_A2aBottom {r : RangeRead} {res : Result} {k : Ke
((hsort.pairwise.imp le_of_lt).rel_getLast hx)) hlast_lt_B
· exact lt_of_lt_of_le (hFend x (List.mem_of_mem_erase hx)) (le_of_lt hEB)
have hlenErase : (dbw.erase k).keys.length = res.keys.length + clampNonposD r := by
rw [herase_keys, List.length_append, List.length_erase, if_pos hk_in_F, hFlen]
rw [herase_keys, List.length_append, List.length_erase, ite_eq_left hk_in_F, hFlen]
omega
rw [hcountB, hlenErase]
have hcast : (res.keys.length + clampNonposD r : ℤ) ≤ (beginSlack r : ℤ) := by
@@ -657,7 +657,7 @@ theorem exists_witness_gap_ne_head_A2aBottom {r : RangeRead} {res : Result} {k :
have hcond' : ((beginSlack r + 1 : ℕ) : ℕ∞) ≤ (res.keys.length : ℕ∞) +
intervalCard (((keyAfter last : Key)) : WithTop Key) r.begin.key := by
have := hcond
rw [hheadD, if_neg hhead, Nat.add_zero, hlastD] at this
rw [hheadD, ite_eq_right hhead, Nat.add_zero, hlastD] at this
exact this
-- `t + (D+1) ≤ q`
have hBE0 : intervalCard r.begin.key r.end_.key = 0 := intervalCard_eq_zero_of_le (le_of_lt hEB)
@@ -716,7 +716,8 @@ theorem exists_witness_gap_ne_head_A2aBottom {r : RangeRead} {res : Result} {k :
let dbG : DB := dbB.insert k hBk
have hGlen : dbG.keys.length = fa := by
rw [DB.insert_keys, List.orderedInsert_length, hBlen]; omega
have hGmem : ∀ x ∈ dbG.keys, r.end_.key ≤ (x : WithTop Key) ∧ (x : WithTop Key) < r.begin.key := by
have hGmem : ∀ x ∈ dbG.keys, r.end_.key ≤ (x : WithTop Key) ∧ (x : WithTop Key) < r.begin.key :=
by
intro x hx
rw [DB.mem_insert_iff hBk] at hx
rcases hx with rfl | hx
@@ -833,7 +834,7 @@ theorem exists_witness_gap_ne_head_A2aBottom {r : RangeRead} {res : Result} {k :
omega
have hlast_eq_D : dbw.keys[t]'(by rw [hDlen]; omega) = last := by
rw [List.getElem_of_eq hDkeys, List.getElem_cons]
rw [dif_neg (by have : 0 < t := List.length_pos_iff.mpr hne; omega)]
rw [dite_eq_right (by have : 0 < t := List.length_pos_iff.mpr hne; omega)]
rw [List.getElem_append_left (i := t - 1) (h := by
have : 0 < t := List.length_pos_iff.mpr hne
omega)]
@@ -900,7 +901,8 @@ theorem exists_witness_gap_ne_head_A2aBottom {r : RangeRead} {res : Result} {k :
refine ⟨hlim, ?_⟩
rw [← hld]
exact hfilt_eq
· rw [hDkeys]; exact List.mem_cons_of_mem _ (List.mem_append_right _ (List.mem_append_right _ hkG))
· rw [hDkeys]; exact List.mem_cons_of_mem _ (List.mem_append_right _ (List.mem_append_right _
hkG))
· intro hcomp'
obtain ⟨-, hfilt'⟩ := (compatible_iff_truncated_keys hrev hmore hne).mp hcomp'
have hknil : k ≠ ([] : Key) :=
@@ -1436,7 +1438,8 @@ theorem gap_slack_bound_A2aBottom {db : DB} {r : RangeRead} {res : Result}
res.keys.length +
(between db (((keyAfter last : Key)) : WithTop Key) r.begin.key).length := by
rw [← hgap, hkey]
have hlen_le : (((between db (((keyAfter last : Key)) : WithTop Key) r.begin.key).length : ℕ) : ℕ∞) ≤
have hlen_le : (((between db (((keyAfter last : Key)) : WithTop Key) r.begin.key).length : ℕ) :
ℕ∞) ≤
intervalCard (((keyAfter last : Key)) : WithTop Key) r.begin.key :=
between_length_le_intervalCard (keyAfter_le_of_lt hlastB')
calc ((beginSlack r + 1 : ℕ) : ℕ∞)
@@ -1492,7 +1495,7 @@ theorem resolve_begin_eq_nil_of_low_A2aBottom {r : RangeRead} {res : Result} {db
have hheadD_ne : res.keys.headD ([] : Key) ≠ [] := by
rw [List.headD_eq_head?, List.head?_eq_some_head hne]
exact hne_head
rw [if_neg hheadD_ne] at hnot'
rw [ite_eq_right hheadD_ne] at hnot'
exact hnot' (by simpa using hbound)
rw [hres, hhead_nil]
· exact resolve_eq_nil (not_le.mp hanc)
@@ -1601,7 +1604,7 @@ theorem sound_bottomEnd_A2aBottom {r : RangeRead} {res : Result}
have hheadD : res.keys.headD ([] : Key) = [] := by
rw [hδdef] at hδ1
by_contra h
rw [if_neg h] at hδ1
rw [ite_eq_right h] at hδ1
omega
have hhead_nil : head = [] := by
rw [List.headD_eq_head?, List.head?_eq_some_head hne] at hheadD
@@ -1674,7 +1677,7 @@ theorem minimal_closedForm_of_negCross_trunc_nonposGap_A2aBottom
by_cases hhi : negCrossTruncNonposGapA2aBottomHigh r res
· have hclosed : closedFormNegCrossTruncNonposGapA2aBottom r res =
⟨(([] : Key) : WithTop Key), r.begin.key⟩ := by
unfold closedFormNegCrossTruncNonposGapA2aBottom; rw [if_pos hhi]
unfold closedFormNegCrossTruncNonposGapA2aBottom; rw [ite_eq_left hhi]
rw [hclosed]
refine minimal_iff_sound_and_necessaryRange.mpr ⟨?_, ?_⟩
· have hs := sound_bottomLong_of_nonpos (r := r) (res := res) hle_begin hend
@@ -1694,7 +1697,7 @@ theorem minimal_closedForm_of_negCross_trunc_nonposGap_A2aBottom
by rw [toggle_eq_erase_of_mem hkdbw]; exact hnot⟩
· have hclosed : closedFormNegCrossTruncNonposGapA2aBottom r res =
⟨(([] : Key) : WithTop Key), r.end_.key⟩ := by
unfold closedFormNegCrossTruncNonposGapA2aBottom; rw [if_neg hhi]
unfold closedFormNegCrossTruncNonposGapA2aBottom; rw [ite_eq_right hhi]
rw [hclosed]
refine minimal_iff_sound_and_necessaryRange.mpr ⟨sound_bottomEnd_A2aBottom hcellKeep hhi, ?_⟩
intro k _ hkE
@@ -1754,7 +1757,7 @@ theorem a2b_high : negCrossTruncNonposGapA2aBottomHigh a2bRead a2bRes := by
theorem a2b_clampLongUpper :
clampLongUpper a2bRead a2bRes = ((a2bThree : Key) : WithTop Key) := by
unfold clampLongUpper
rw [if_pos]
rw [ite_eq_left]
· rfl
· decide
@@ -1763,7 +1766,7 @@ theorem a2b_closedForm :
closedFormNegCrossTruncNonposGapA2aBottom a2bRead a2bRes =
⟨(([] : Key) : WithTop Key), ((a2bFour : Key) : WithTop Key)⟩ := by
unfold closedFormNegCrossTruncNonposGapA2aBottom
rw [if_pos a2b_high]
rw [ite_eq_left a2b_high]
rfl
/-- The old clamped branch `[⊥, clampLongUpper]` is not the gap-cell closed form on the