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

+23 -25
View File
@@ -29,7 +29,6 @@ the reversed reported keys.
open FormalConflictRange
set_option maxHeartbeats 1200000
namespace FormalConflictRange
@@ -59,7 +58,7 @@ theorem completeKeys_count_ge_eq_general_rev {db : DB} {r : RangeRead}
/-- The reversed window count in terms of the begin/end counts and the over/under
offsets. -/
private theorem completeKeys_count_ge_eq_min_rev {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 : 1 ≤ r.begin.offset)
(hcross : r.begin.key ≤ r.end_.key) (hend : 1 ≤ r.end_.offset) :
residualT r res ≤
@@ -85,7 +84,7 @@ overshoot. This is the reversed truncation counterpart of
`residual_dt_le_e`. -/
theorem residualD_add_T_le_E {r : RangeRead} {res : Result} {g : ℕ∞}
(hread : Readable r res) (hmore : res.more = true) (hrev : r.reverse = true)
(hne : res.keys ≠ []) (htpos : 0 < residualT r res)
(_hne : res.keys ≠ []) (htpos : 0 < residualT r res)
(hbegin : 2 ≤ r.begin.offset) (hcross : r.begin.key ≤ r.end_.key)
(hend : 2 ≤ r.end_.offset)
(hcard : intervalCard r.begin.key r.end_.key = g) :
@@ -134,8 +133,8 @@ theorem residualD_add_T_le_E {r : RangeRead} {res : Result} {g : ℕ∞}
/-- The deficit plus the reported over-count never exceeds the number of stored keys
at or above `end_.key`. -/
theorem residualD_add_T_le_count_ge {r : RangeRead} {res : Result} {g : ℕ∞}
(hread : Readable r res) (hmore : res.more = true) (hrev : r.reverse = true)
(hne : res.keys ≠ []) (htpos : 0 < residualT r res)
(_hread : Readable r res) (hmore : res.more = true) (hrev : r.reverse = true)
(_hne : res.keys ≠ []) (htpos : 0 < residualT r res)
(hbegin : 2 ≤ r.begin.offset) (hcross : r.begin.key ≤ r.end_.key)
(hend : 2 ≤ r.end_.offset)
(hcard : intervalCard r.begin.key r.end_.key = g)
@@ -213,8 +212,7 @@ theorem completeKeys_crossfree_rev_eq {db : DB} {r : RangeRead}
rw [completeKeys_rev_eq_reverse db r hrev]
rw [completeKeys_eq_filter_ge_drop_take (db := db) (r := { r with reverse := false })
(by simp) hbegin hend]
simp only [show ({ r with reverse := false } : RangeRead).end_.offset = r.end_.offset from rfl,
show ({ r with reverse := false } : RangeRead).begin.offset = r.begin.offset from rfl]
simp only []
rw [show db.keys.filter (fun k : Key => decide (r.begin.key ≤ (k : WithTop Key))) = above db B
from by rw [hB]; rfl]
rw [← hB, ← hE, ← hb, ← he]
@@ -234,7 +232,7 @@ theorem completeKeys_crossfree_rev_eq {db : DB} {r : RangeRead}
/-- Filtering a sorted list at or below the `m`-th element gives its first `m`
elements. -/
theorem filter_le_eq_take_of_window' {A : List Key} (hs : A.SortedLT)
{b m : Nat} (hbm : b < m) (hm : m ≤ A.length) {H : Key}
{b m : Nat} (hbm : b < m) (_hm : m ≤ A.length) {H : Key}
(hlast : A[m - 1]? = some H) :
A.filter (fun k : Key => decide (k ≤ H)) = A.take m := by
have hmpos : 0 < m := Nat.lt_of_le_of_lt (Nat.zero_le b) hbm
@@ -442,11 +440,11 @@ def crossFreeSlack (r : RangeRead) : ℕ :=
keys at or above `end_.key`, and the stored keys at or above the begin key and at or
below the reported head are exactly the `g + e` keys consumed by the window. -/
theorem finite_consequences {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 : 1 ≤ r.begin.offset)
(hend : 1 ≤ r.end_.offset) (hcross : r.begin.key ≤ r.end_.key)
(hne : res.keys ≠ [])
(hHE : r.end_.key ≤ ((res.keys.head hne : Key) : WithTop Key))
(_hHE : r.end_.key ≤ ((res.keys.head hne : Key) : WithTop Key))
(hfin : crossFreeResidualT r res + crossFreeSlack r ≥ (r.end_.offset - 1).toNat) :
(r.end_.offset - 1).toNat ≤ (above db r.end_.key).length ∧
((above db r.begin.key).filter
@@ -495,7 +493,7 @@ theorem finite_consequences {db : DB} {r : RangeRead} {res : Result}
have hle : ((b : ℕ∞) - intervalCard B E) ≤ ((b : ℕ∞) - (g : ℕ∞)) :=
tsub_le_tsub_left hgcard (b : ℕ∞)
have hto := ENat.toNat_le_toNat hle (by simp)
rw [ENat.toNat_sub (by simp : ((g : ℕ∞)) ≠ ⊤), ENat.toNat_coe, ENat.toNat_coe] at hto
rw [ENat.toNat_sub (by simp : ((g : ℕ∞)) ≠ ⊤), ENat.toNat_natCast, ENat.toNat_natCast] at hto
simpa [hB, hE, hb] using hto
have hfin' : e ≤ T + (b - g) :=
le_trans hfin (Nat.add_le_add_left hSle T)
@@ -557,7 +555,7 @@ theorem crossFreeSlack_eq_residualD (r : RangeRead) :
by_cases hg : intervalCard r.begin.key r.end_.key = (⊤ : ℕ∞)
· simp [hg]
· obtain ⟨n, hn⟩ := ENat.ne_top_iff_exists.mp hg
rw [← hn, if_neg (by simp : (↑n : ℕ∞) ≠ ⊤), ENat.toNat_sub (by simp),
rw [← hn, ite_eq_right (by simp : (↑n : ℕ∞) ≠ ⊤), ENat.toNat_sub (by simp),
ENat.toNat_natCast, ENat.toNat_natCast]
rfl
@@ -694,12 +692,12 @@ theorem chain_filter_lt_length_add_residualD {v E : Key} (b : ℕ) (g : ℕ∞)
(if g = ⊤ then 0 else b - g.toNat) = b := by
by_cases hg : g = ⊤
· rw [hg] at hcard
rw [if_pos hg, chain_filter_lt_length_top b hcard]
rw [ite_eq_left hg, chain_filter_lt_length_top b hcard]
omega
· obtain ⟨n, hn⟩ := ENat.ne_top_iff_exists.mp hg
have hcard' : intervalCard (↑v : WithTop Key) (↑E : WithTop Key) = (n : ℕ∞) := by
rw [hn]; exact hcard
rw [if_neg hg, ← hn, ENat.toNat_natCast, chain_filter_lt_length_coe b hcard']
rw [ite_eq_right hg, ← hn, ENat.toNat_natCast, chain_filter_lt_length_coe b hcard']
omega
/-! ### Begin-key necessity -/
@@ -1259,16 +1257,16 @@ theorem necessary_above_head_crossfree_residual {r : RangeRead} {res : Result}
have hp_le_c : ((p : ℕ) : ℕ∞) ≤ c := by
rw [hp]
by_cases hc' : c = ⊤
· rw [if_pos hc']; simp [hc']
· rw [if_neg hc']
· rw [ite_eq_left hc']; simp [hc']
· rw [ite_eq_right hc']
obtain ⟨n, hn⟩ := ENat.ne_top_iff_exists.mp hc'
rw [← hn, ENat.toNat_natCast]
exact_mod_cast Nat.min_le_right b n
have hDp_le : (((b - p : ℕ)) : ℕ∞) ≤ intervalCard E (↑L) := by
rw [hp]
by_cases hc' : c = ⊤
· rw [if_pos hc']; simp
· rw [if_neg hc']
· rw [ite_eq_left hc']; simp
· rw [ite_eq_right hc']
obtain ⟨n, hn⟩ := ENat.ne_top_iff_exists.mp hc'
have hp_eq : min b c.toNat = min b n := by rw [← hn, ENat.toNat_natCast]
rw [hp_eq]
@@ -1285,7 +1283,7 @@ theorem necessary_above_head_crossfree_residual {r : RangeRead} {res : Result}
rw [← hm]
have hbm : b ≤ n + m := by
rw [← Nat.cast_add] at hbL
exact ENat.coe_le_coe.mp hbL
exact ENat.natCast_le_natCast.mp hbL
exact_mod_cast (by omega : b - min b n ≤ m)
obtain ⟨pad1, hpad1In, hpad1len⟩ :=
exists_db_keysIn (B := B) (E := E) (m := p) hp_le_c
@@ -1308,8 +1306,8 @@ theorem necessary_above_head_crossfree_residual {r : RangeRead} {res : Result}
have hpleb : p ≤ b := by
rw [hp]
by_cases hc' : c = ⊤
· simp [hp, hc']
· rw [if_neg hc']; exact Nat.min_le_left b _
· simp [ hc']
· rw [ite_eq_right hc']; exact Nat.min_le_left b _
have hPlen : P.length = b := by
rw [hPdef, List.length_append, hP1len, hP2len]
omega
@@ -1382,13 +1380,13 @@ theorem necessary_above_head_crossfree_residual {r : RangeRead} {res : Result}
simpa [c, e, B, E, residualE] using htop
rw [hp]
by_cases hc' : c = ⊤
· rw [if_pos hc']
rw [residualD, if_pos hc'] at htop'
· rw [ite_eq_left hc']
rw [residualD, ite_eq_left hc'] at htop'
omega
· rw [if_neg hc']
· rw [ite_eq_right hc']
obtain ⟨n, hn⟩ := ENat.ne_top_iff_exists.mp hc'
have hD : residualD r c = b - n := by
rw [residualD, if_neg hc', ← hn, ENat.toNat_natCast, residualB, ← hb]
rw [residualD, ite_eq_right hc', ← hn, ENat.toNat_natCast, residualB, ← hb]
rw [hD] at htop'
rw [← hn, ENat.toNat_natCast]
omega