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

+17 -21
View File
@@ -27,7 +27,6 @@ last then keeps that sentinel and adds the key to the complete window.
open FormalConflictRange
set_option maxHeartbeats 1200000
namespace FormalConflictRange
@@ -133,7 +132,7 @@ theorem completeKeys_filter_ge_eq_db_filter {db : DB} {r : RangeRead} {res : Res
{last : Key} (hcomp : RangeRead.Compatible db r res) (hrev : r.reverse = false)
(hmore : res.more = false) (hne : res.keys ≠ [])
(hlast : last = res.keys.getLast hne)
(hbegin : r.begin.offset ≤ 0) (hstart : resolve db r.begin ≤ r.end_.key) :
(_hbegin : r.begin.offset ≤ 0) (hstart : resolve db r.begin ≤ r.end_.key) :
(RangeRead.completeKeys db r).filter
(fun k : Key => decide (r.end_.key ≤ (k : WithTop Key))) =
(db.keys.filter (fun k : Key => decide (r.end_.key ≤ (k : WithTop Key)))).filter
@@ -305,7 +304,6 @@ theorem completeKeys_eq_res_of_agree_nonpos_complete {db₁ db₂ : DB} {r : Ran
k ≤ last)) := by
unfold RangeRead.completeKeys RangeRead.inRange
rw [hrev]
simp only [if_false]
rw [hbegineq]
apply List.filter_congr
intro k hk
@@ -377,8 +375,8 @@ nonpositive read with `end.offset ≥ 2`, if the end selector resolves to a genu
then the number of reported keys at or above `end_.key` is exactly `end.offset - 1`. -/
theorem residualT_eq_residualE_of_resolve_end_ne_top {db : DB} {r : RangeRead}
{res : Result} (hcomp : RangeRead.Compatible db r res) (hrev : r.reverse = false)
(hmore : res.more = false) (hne : res.keys ≠ [])
(hbegin : r.begin.offset ≤ 0) (hstart : resolve db r.begin ≤ r.end_.key)
(hmore : res.more = false) (_hne : res.keys ≠ [])
(_hbegin : r.begin.offset ≤ 0) (hstart : resolve db r.begin ≤ r.end_.key)
(hend : 2 ≤ r.end_.offset)
(htop : resolve db r.end_ ≠ (⊤ : WithTop Key)) :
residualT r res = residualE r := by
@@ -590,7 +588,6 @@ theorem necessary_above_last_of_nonpos_top {r : RangeRead} {res : Result}
omega
have htlt' : Q.length < (r.end_.offset - 1).toNat := by
rw [← hTQ]; exact htlt
unfold residualE at htlt'
rw [hQlen] at htlt'
omega
have hEins := resolve_end_eq_top_of_insert_top hx0 hL_lt hend
@@ -643,20 +640,20 @@ theorem minimal_completeNonposCrossFree {r : RangeRead} {res : Result}
(hlo : r.begin.key ≤ ((res.keys.head hne : Key) : WithTop Key)) :
Minimal r res (completeNonposCrossFree r res) := by
unfold completeNonposCrossFree
rw [if_neg hne]
rw [ite_eq_right hne]
by_cases hend1 : r.end_.offset ≤ 1
· rw [if_pos hend1]
· rw [ite_eq_left hend1]
exact minimal_bottomRange_of_nonpos_underEnd_nonempty hread hrev hmore hne hbegin hend1 hlo
· rw [if_neg hend1]
· rw [ite_eq_right hend1]
have hend : 2 ≤ r.end_.offset := by omega
by_cases hte : residualT r res = residualE r
· rw [if_pos hte]
· rw [ite_eq_left hte]
have hlast : res.keys.getLastD ([] : Key) = res.keys.getLast hne := by
rw [List.getLastD_eq_getLast?, List.getLast?_eq_some_getLast hne]; rfl
rw [hlast]
exact minimal_truncatedRangeBottom_of_nonpos_complete_finite hread hrev hmore hne hbegin
hlo hend hte
· rw [if_neg hte]
· rw [ite_eq_right hte]
obtain ⟨db₀, hcomp₀⟩ := hread
have hstart₀ : resolve db₀ r.begin ≤ r.end_.key := by
rw [resolve_eq_nil_of_complete_begin_le_head hcomp₀ hrev hmore hne hbegin hlo]
@@ -713,7 +710,7 @@ theorem minimal_closedForm_of_complete_nonpos_crossFree {r : RangeRead} {res : R
unfold closedFormCompleteNonposCrossFree
cases hrev : r.reverse with
| false =>
rw [ite_eq_right (by simp [hrev])]
rw [ite_eq_right (by simp [])]
have hlo : r.begin.key ≤ ((res.keys.head hne : Key) : WithTop Key) := by
have hloD' : r.begin.key ≤
((res.keys.headD ([] : Key) : Key) : WithTop Key) := by
@@ -723,7 +720,7 @@ theorem minimal_closedForm_of_complete_nonpos_crossFree {r : RangeRead} {res : R
rwa [← hhead]
exact minimal_completeNonposCrossFree hread hrev hmore hne hbegin hlo
| true =>
rw [ite_eq_left (by simp [hrev])]
rw [ite_eq_left (by simp [])]
have hlo : r.begin.key ≤ ((res.keys.getLast hne : Key) : WithTop Key) := by
have hloD' : r.begin.key ≤
((res.keys.getLastD ([] : Key) : Key) : WithTop Key) := by
@@ -903,7 +900,7 @@ abbrev nonposFwdTrunc (r : RangeRead) (res : Result) : Prop :=
1 ≤ r.end_.offset
/-- The cross-free nonpositive-begin forward truncated closed form. -/
noncomputable def closedFormNonposFwdTrunc (r : RangeRead) (res : Result) : ConflictRange :=
noncomputable def closedFormNonposFwdTrunc (_r : RangeRead) (res : Result) : ConflictRange :=
truncatedRangeBottom (res.keys.getLastD ([] : Key))
/-- **The cross-free nonpositive-begin forward truncated closed form is minimal.** -/
@@ -927,7 +924,6 @@ theorem minimal_closedForm_of_nonpos_fwdTrunc {r : RangeRead} {res : Result}
exact minimal_truncatedRangeBottom_of_nonpos_more hread' hrev hmore hne hbegin hlo hge
set_option maxHeartbeats 2400000
/-- Splitting a count below `b` at a threshold `a < b`. -/
theorem countP_lt_split {l : List Key} {a b : WithTop Key} (hab : a < b) :
@@ -955,9 +951,9 @@ theorem countP_lt_split {l : List Key} {a b : WithTop Key} (hab : a < b) :
there are at least `(1 - end_.offset)` stored keys strictly between the reported last
and `end_.key`. -/
theorem filler_count_nonpos_more_nonpos_end {db : DB} {r : RangeRead} {res : Result}
(hcomp : RangeRead.Compatible db r res) (hrev : r.reverse = false)
(hmore : res.more = true) (hne : res.keys ≠ [])
(hbegin : r.begin.offset ≤ 0) (hend : r.end_.offset ≤ 0) :
(hcomp : RangeRead.Compatible db r res) (_hrev : r.reverse = false)
(_hmore : res.more = true) (hne : res.keys ≠ [])
(_hbegin : r.begin.offset ≤ 0) (hend : r.end_.offset ≤ 0) :
(1 - r.end_.offset).toNat ≤
(db.keys.filter (fun (k : Key) => decide (res.keys.getLast hne < k ∧
((k : WithTop Key) < r.end_.key)))).length := by
@@ -1212,7 +1208,7 @@ theorem exists_witness_nonpos_more_nonpos_end {db : DB} {r : RangeRead} {res : R
have hDget? : dbw.keys[res.keys.length]? = some (F.head hFne) := by
change D[res.keys.length]? = some (F.head hFne)
rw [hD, 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 [hFlen]; omega), List.head_eq_getElem hFne]
have hre : resolve dbw r.end_ = ((F.head hFne : Key) : WithTop Key) := by
rw [resolve, ite_eq_right (by rw [hanchor_end]; omega)]
@@ -1304,7 +1300,7 @@ theorem exists_witness_nonpos_more_nonpos_end {db : DB} {r : RangeRead} {res : R
rw [hanchor_end', hEqInt, Int.toNat_natCast]
have hD'get? : (dbw.erase k).keys[res.keys.length - 1]? = some last := by
rw [hD', List.getElem?_append]
rw [if_pos (by omega : res.keys.length - 1 < res.keys.length)]
rw [ite_eq_left (by omega : res.keys.length - 1 < res.keys.length)]
rw [List.getElem?_eq_getElem (by omega : res.keys.length - 1 < res.keys.length)]
congr 1
rw [hlast, List.getLast_eq_getElem hne]
@@ -1413,7 +1409,7 @@ abbrev nonposFwdTruncNonpos (r : RangeRead) (res : Result) : Prop :=
r.end_.offset ≤ 0
/-- The cross-free nonpositive-begin forward truncated nonpositive-end closed form. -/
noncomputable def closedFormNonposFwdTruncNonpos (r : RangeRead) (res : Result) :
noncomputable def closedFormNonposFwdTruncNonpos (r : RangeRead) (_res : Result) :
ConflictRange :=
⟨((↑([] : Key) : WithTop Key)), r.end_.key⟩