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

+14 -10
View File
@@ -162,7 +162,7 @@ private theorem keys_lo_keyAfter_eq_filter_le {db : DB} {lo : WithTop Key} {last
rw [decide_eq_decide, WithTop.coe_lt_coe, lt_keyAfter_iff]
private theorem filter_ge_last_eq_filter_of_keys_eq {db : DB} {E B : WithTop Key} {last : Key}
(hEB : E ≤ B) (hBlast : B ≤ (last : WithTop Key)) :
(hEB : E ≤ B) (_hBlast : B ≤ (last : WithTop Key)) :
(db.keys.filter (fun k : Key => decide (B ≤ (k : WithTop Key)))).filter
(fun k : Key => decide (k ≤ last)) =
((⟨E, (keyAfter last : Key)⟩ : ConflictRange).keys db).filter
@@ -180,7 +180,7 @@ private theorem filter_ge_last_eq_filter_of_keys_eq {db : DB} {E B : WithTop Key
exact ⟨hl, hB⟩
private theorem between_eq_filter_of_keys_eq {db : DB} {E B : WithTop Key} {last : Key}
(hEB : E ≤ B) (hBlast : B ≤ (last : WithTop Key)) :
(_hEB : E ≤ B) (hBlast : B ≤ (last : WithTop Key)) :
between db E B =
((⟨E, (keyAfter last : Key)⟩ : ConflictRange).keys db).filter
(fun k : Key => decide ((k : WithTop Key) < B)) := by
@@ -188,7 +188,8 @@ private theorem between_eq_filter_of_keys_eq {db : DB} {E B : WithTop Key} {last
simp only [List.filter_filter]
unfold between
rw [show db.keys.filter (fun k : Key => decide (E ≤ (k : WithTop Key) ∧ (k : WithTop Key) < B)) =
db.keys.filter (fun k : Key => decide ((k : WithTop Key) < B) && decide (E ≤ (k : WithTop Key))) from
db.keys.filter (fun k : Key => decide ((k : WithTop Key) < B) && decide (E ≤ (k : WithTop
Key))) from
List.filter_congr fun k _ => by rw [Bool.decide_and, Bool.and_comm]]
apply List.filter_congr
intro k _
@@ -248,7 +249,8 @@ theorem completeKeys_filter_le_eq_of_agree_crossed {r : RangeRead} {last : Key}
have hCtake : C = A.take q := by
rw [hCdef, hq]
exact filter_le_eq_take_countP hAs last
have hqC : C.length = q := by rw [hCtake, List.length_take, Nat.min_eq_left (by rw [hq]; exact List.countP_le_length)]
have hqC : C.length = q := by rw [hCtake, List.length_take, Nat.min_eq_left (by rw [hq]; exact
List.countP_le_length)]
have hCAlen : C.length ≤ A.length := by rw [hCtake]; exact (List.take_sublist q A).length_le
have hcB : l.countP (fun k : Key => decide ((k : WithTop Key) < r.begin.key)) =
l.countP (fun k : Key => decide ((k : WithTop Key) < r.end_.key)) +
@@ -257,7 +259,8 @@ theorem completeKeys_filter_le_eq_of_agree_crossed {r : RangeRead} {last : Key}
have hM : min (l.countP (fun k : Key => decide ((k : WithTop Key) < r.end_.key)) + e)
l.length - l.countP (fun k : Key => decide ((k : WithTop Key) < r.begin.key)) =
min (e - (between db r.end_.key r.begin.key).length) A.length := by
have hA_eq : A = l.drop (l.countP (fun k : Key => decide ((k : WithTop Key) < r.begin.key))) := by
have hA_eq : A = l.drop (l.countP (fun k : Key => decide ((k : WithTop Key) < r.begin.key)))
:= by
rw [hA]
have hdrop := filter_not_lt_eq_drop_countP hls r.begin.key
rw [← hdrop]
@@ -265,7 +268,8 @@ theorem completeKeys_filter_le_eq_of_agree_crossed {r : RangeRead} {last : Key}
intro k _
rw [decide_eq_decide]
exact not_lt.symm
have hAlen : A.length = l.length - l.countP (fun k : Key => decide ((k : WithTop Key) < r.begin.key)) := by
have hAlen : A.length = l.length - l.countP (fun k : Key => decide ((k : WithTop Key) <
r.begin.key)) := by
rw [hA_eq, List.length_drop]
rw [hcB, hAlen]
omega
@@ -338,7 +342,7 @@ private theorem enat_succ_le_of_lt {s : ℕ} {h : ℕ∞} (hs : (s : ℕ∞) < h
cases h with
| top => exact le_top
| coe n =>
rw [ENat.coe_lt_coe] at hs
rw [ENat.natCast_lt_natCast] at hs
exact_mod_cast Nat.succ_le_of_lt hs
/-- **Gap-key necessity for the forward truncated crossed read.** When the gap
@@ -471,7 +475,7 @@ theorem necessary_of_mem_gap_crossed_truncated {r : RangeRead} {res : Result} {k
exact le_trans (le_of_lt hcross)
(le_trans hlast_ge_B (WithTop.coe_le_coe.mpr hCge))
have hcB₂ : cnt db₂ r.begin.key = s := by
show db₂.keys.countP (fun x : Key => decide ((x : WithTop Key) < r.begin.key)) = s
change db₂.keys.countP (fun x : Key => decide ((x : WithTop Key) < r.begin.key)) = s
rw [hdb₂, List.countP_append, List.countP_append]
have hHc : dbH.keys.countP
(fun x : Key => decide ((x : WithTop Key) < r.begin.key)) = dbH.keys.length :=
@@ -723,9 +727,9 @@ theorem minimal_truncatedForwardClosed_of_crossed {r : RangeRead} {res : Result}
unfold truncatedForwardClosed
by_cases hbig : intervalCard r.end_.key r.begin.key ≤
(((r.end_.offset - 1).toNat - res.keys.length : ℕ) : ℕ∞)
· rw [if_pos hbig]
· rw [ite_eq_left hbig]
exact minimal_truncatedRange_of_crossed_B hread hmore hrev hne hbegin hcross hend hbig
· rw [if_neg hbig]
· rw [ite_eq_right hbig]
exact minimal_truncatedForward_of_crossed hread hmore hrev hne hbegin hcross hend
(not_le.mp hbig)