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

@@ -255,7 +255,6 @@ end FormalConflictRange
namespace FormalConflictRange
open scoped Classical
/-- Padding the reported keys with `f = D + 1 - g` keys in `(last, begin.key)` and the
`g` keys of `[begin.key, end_.key)` gives a compatible database: the end selector
@@ -380,7 +379,7 @@ theorem exists_padDb_crossFree {r : RangeRead} {res : Result} {dbF1 dbF2 : DB} {
exact List.append_ne_nil_of_left_ne_nil hF1ne _
have hDget? : (res.keys ++ F)[res.keys.length]? = some (F.head hFne) := by
rw [List.getElem?_append]
rw [if_neg (not_lt.mpr (le_refl _)), Nat.sub_self]
rw [ite_eq_right (not_lt.mpr (le_refl _)), Nat.sub_self]
rw [List.getElem?_eq_getElem (by rw [hF, List.length_append]; omega),
List.head_eq_getElem hFne]
have hre : resolve dbw r.end_ = ((F.head hFne : Key) : WithTop Key) := by
@@ -433,7 +432,7 @@ theorem exists_padDb_crossFree {r : RangeRead} {res : Result} {dbF1 dbF2 : DB} {
-- the complete keys are exactly the reported keys
have hck : RangeRead.completeKeys dbw r = res.keys := by
unfold RangeRead.completeKeys RangeRead.inRange
rw [if_neg (by simp [hrev])]
rw [ite_eq_right (by simp [hrev])]
rw [hkeyw, List.filter_append, List.filter_append]
have hres : res.keys.filter (fun k : Key => decide
(resolve dbw r.begin ≤ ((k : Key) : WithTop Key) ∧
@@ -466,7 +465,6 @@ theorem exists_padDb_crossFree {r : RangeRead} {res : Result} {dbF1 dbF2 : DB} {
exact ⟨hlim, Or.inl ⟨hmore, by rw [hck], hne⟩⟩
open scoped Classical
/-- Padding a compatible database with a list `F` of keys strictly above the reported
last and strictly below the end key, whose length is `clampNonposD + 1`, and where the
@@ -503,7 +501,7 @@ theorem erase_incompatible_of_pad
have hcntErase : cnt (dbw.erase k) r.end_.key = (dbw.erase k).keys.length :=
cnt_eq_length_of_forall_lt _ hEraseLt
have hlenErase : (dbw.erase k).keys.length = res.keys.length + clampNonposD r := by
rw [herase_keys, List.length_append, List.length_erase, if_pos hkF, hFlen]
rw [herase_keys, List.length_append, List.length_erase, ite_eq_left hkF, hFlen]
omega
have hoff : r.end_.offset = -(clampNonposD r : ℤ) := by
rw [clampNonposD_eq]
@@ -550,7 +548,6 @@ theorem erase_incompatible_of_pad
rw [hfilt]; exact List.getLast_mem hne
exact hlast_not_ck (List.mem_of_mem_filter hlast_in_filt)
open scoped Classical
/-- A database of `f` keys in `(last, begin.key)`. -/
theorem exists_dbF1_crossFree {r : RangeRead} {res : Result} {f : ℕ} {b : Key}
@@ -576,7 +573,7 @@ theorem exists_dbF1_crossFree {r : RangeRead} {res : Result} {f : ℕ} {b : Key}
rw [hb]; exact WithTop.coe_lt_coe.mpr h.2
/-- A database of `g` keys in `[begin.key, end_.key)`. -/
theorem exists_dbF2_crossFree {r : RangeRead} {res : Result} {g : ℕ} {b e : Key}
theorem exists_dbF2_crossFree {r : RangeRead} {_res : Result} {g : ℕ} {b e : Key}
(hb : r.begin.key = ((b : Key) : WithTop Key))
(he : r.end_.key = ((e : Key) : WithTop Key))
(hcap : (g : ℕ∞) ≤ intervalCard r.begin.key r.end_.key) :
@@ -656,7 +653,7 @@ theorem exists_dbF1_mem_crossFree {r : RangeRead} {res : Result} {f : ℕ} {k b
· exact DB.mem_insert_self dbB k hBk
/-- A database of `g - 1` keys in `[begin.key, end_.key)` avoiding a chosen key. -/
theorem exists_dbF2_avoid_crossFree {r : RangeRead} {res : Result} {g : ℕ} {k b e : Key}
theorem exists_dbF2_avoid_crossFree {r : RangeRead} {_res : Result} {g : ℕ} {k b e : Key}
(hb : r.begin.key = ((b : Key) : WithTop Key))
(he : r.end_.key = ((e : Key) : WithTop Key))
(hg : 1 ≤ g)
@@ -692,7 +689,7 @@ theorem exists_dbF2_mem_crossFree {r : RangeRead} {res : Result} {g : ℕ} {k b
(∀ x ∈ dbF2.keys, (x : WithTop Key) < r.end_.key) ∧
dbF2.keys.length = g ∧ k ∈ dbF2.keys := by
obtain ⟨dbB, hBB, hBE, hBlen, hBk⟩ :=
exists_dbF2_avoid_crossFree (r := r) (res := res) (g := g) (k := k) (b := b) (e := e)
exists_dbF2_avoid_crossFree (r := r) (_res := res) (g := g) (k := k) (b := b) (e := e)
hb he hg hcap
let dbF2 : DB := dbB.insert k hBk
have hkey : dbF2.keys = dbB.keys.orderedInsert (· ≤ ·) k := DB.insert_keys dbB k hBk
@@ -715,7 +712,6 @@ end FormalConflictRange
namespace FormalConflictRange
open scoped Classical
/-- In the cross-free low-capacity gap cell the interval capacity is finite and at most
`clampNonposD`. -/
@@ -924,7 +920,6 @@ theorem crossFree_pad_hanc0 {r : RangeRead} {res : Result}
open scoped Classical
/-- In the cross-free low-capacity gap cell, a key strictly between the reported last and
`end_.key` has an erase witness. -/
@@ -1026,7 +1021,7 @@ theorem exists_witness_last_end_crossFree {r : RangeRead} {res : Result} {k : Ke
exists_dbF1_mem_crossFree (r := r) (res := res) (f := f) (k := k) (b := b)
hne hb hf hroom' hkgt hkB
obtain ⟨dbF2, hF2B, hF2E, hF2len⟩ :=
exists_dbF2_crossFree (r := r) (res := res) (g := g) (b := b) (e := e) hb he hcap2
exists_dbF2_crossFree (r := r) (_res := res) (g := g) (b := b) (e := e) hb he hcap2
exact finish dbF1 dbF2 (List.mem_append.mpr (Or.inl hkF1)) hF1gt hF1B hF1len
hF2B hF2E hF2len
· -- k belongs to the second filler
@@ -1128,7 +1123,7 @@ theorem exists_witness_below_head_crossFree {r : RangeRead} {res : Result} {k :
obtain ⟨dbF1, hF1gt, hF1B, hF1len⟩ :=
exists_dbF1_crossFree (r := r) (res := res) (f := f) (b := b) hne hb hroom'
obtain ⟨dbF2, hF2B, hF2E, hF2len⟩ :=
exists_dbF2_crossFree (r := r) (res := res) (g := g) (b := b) (e := e) hb he hcap2
exists_dbF2_crossFree (r := r) (_res := res) (g := g) (b := b) (e := e) hb he hcap2
have hF1len' : dbF1.keys.length = clampNonposD r + 1 - g := by
rw [hF1len, hfdef]
have hanc0 : res.keys.length + (clampNonposD r + 1 - g) ≤ beginSlack r + 1 := by
@@ -1190,7 +1185,7 @@ theorem exists_witness_below_head_crossFree {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 + f + 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 + f : ℤ) ≤ (beginSlack r : ℤ) := by
@@ -1257,7 +1252,7 @@ theorem minimal_closedForm_of_negCross_trunc_nonposGap_crossFree
· have hclosed : closedFormNegCrossTruncNonposGapCrossFree r res =
(⟨(([] : Key) : WithTop Key), r.end_.key⟩ : ConflictRange) := by
unfold closedFormNegCrossTruncNonposGapCrossFree closedFormNegCrossTruncNonposGap
rw [if_pos hbot, max_eq_right hB_le_E]
rw [ite_eq_left hbot, max_eq_right hB_le_E]
rw [hclosed]
refine minimal_iff_sound_and_necessaryRange.mpr
⟨sound_bottomEnd_crossFree hbegin hend hB_le_E, ?_⟩
@@ -1286,7 +1281,7 @@ theorem minimal_closedForm_of_negCross_trunc_nonposGap_crossFree
have hheadD : res.keys.headD ([] : Key) = res.keys.head hne :=
list_headD_eq_head hne
unfold closedFormNegCrossTruncNonposGapCrossFree closedFormNegCrossTruncNonposGap
rw [if_neg hbot, max_eq_right hB_le_E]
rw [ite_eq_right hbot, max_eq_right hB_le_E]
exact congrArg (fun k : WithTop Key => (⟨k, r.end_.key⟩ : ConflictRange))
(congrArg (fun k : Key => ((k : Key) : WithTop Key)) hheadD)
rw [hclosed]