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 -15
View File
@@ -138,7 +138,8 @@ theorem compactCompleteForward_eq_crossFree {r : RangeRead} {res : Result}
dsimp only
rw [ite_eq_right ht']
by_cases hbelow : ∀ k ∈ res.keys, ((k : Key) : WithTop Key) < r.end_.key
· simp [closedFormCompleteCrossFree, topRange, hend, hcross, ht, hoff]
· simp only [hend, ↓reduceIte, hcross, ht, List.getLastD_eq_getLast?,
closedFormCompleteCrossFree, false_or, hoff, topRange]
rw [ite_eq_left hbelow, ite_eq_left hbelow]
· simpa [closedFormCompleteCrossFree, truncatedRange, topRange, hend, hcross, ht,
hbelow] using htail.symm
@@ -779,7 +780,7 @@ theorem compactForwardTruncatedNonpos_minimal_bottom {r : RangeRead} {res : Resu
exact absurd hhead_res (not_lt.mpr (coe_nil_le_key_withTop _))
have hcb : clampNonposBottom r res :=
clampNonposBottom_of_le_resolve_end hend hRne hB_le_R hclamp
rw [ite_eq_left hend, if_neg (not_lt_of_ge hBE), ite_eq_left hcb]
rw [ite_eq_left hend, ite_eq_right (not_lt_of_ge hBE), ite_eq_left hcb]
exact minimal_closedForm_of_nonpos_fwdTruncNonpos hread'
⟨hmore, hrev, hbegin, hloD, hend⟩
· have hendpos : 1 ≤ r.end_.offset := by omega
@@ -1254,7 +1255,7 @@ theorem compactForwardTruncatedNonpos_minimal_of_not_residual {r : RangeRead} {r
ite_eq_left hend, ite_eq_right hnotlt, ite_eq_left hcb]
have hcf : closedFormNegCrossTruncTopTop r res =
⟨(([] : Key) : WithTop Key), (⊤ : WithTop Key)⟩ := by
rw [closedFormNegCrossTruncTopTop, if_neg hnotH]
rw [closedFormNegCrossTruncTopTop, ite_eq_right hnotH]
rw [hEq, NegCrossTruncTopTop.hEtop hT, ← hcf]
exact minimal_closedForm_of_negCross_trunc_topTop hread hT
· by_cases hS : r.end_.key = (⊤ : WithTop Key) ∧
@@ -1981,7 +1982,7 @@ theorem closedFormZeroCrossResidual_eq_under {r : RangeRead} {res : Result}
/-- In the long cells the shared form is the certified long rule. -/
theorem closedFormZeroCrossResidual_eq_long {r : RangeRead} {res : Result}
(hnot : ¬ zeroCrossUnderEnd r res)
(h : zeroCrossLongTop r res ∨ zeroCrossLongFinite r res) :
(_h : zeroCrossLongTop r res ∨ zeroCrossLongFinite r res) :
closedFormZeroCrossResidual r res = closedFormZeroCrossLong r res := by
unfold closedFormZeroCrossResidual
rw [ite_eq_right hnot]
@@ -2397,7 +2398,7 @@ theorem nonposCompleteForward_false {r : RangeRead} {res : Result}
· exact h_ov ⟨h0, hmore, hrev, ⟨hend2, hne, hhi⟩, hcrossL⟩
· have hElast : r.end_.key ≤
((res.keys.getLastD ([] : Key) : Key) : WithTop Key) := by
push_neg at hhi
push Not at hhi
obtain ⟨k, hk, hkge⟩ := hhi
exact le_trans hkge (hlastle k hk)
by_cases hBE : r.begin.key ≤ r.end_.key
@@ -2439,7 +2440,7 @@ theorem nonposCompleteForward_false {r : RangeRead} {res : Result}
· exact h_ov2 ⟨hrev, hneg, hmore, hne, hend2, hhi, hcross⟩
· have hElast : r.end_.key ≤
((res.keys.getLastD ([] : Key) : Key) : WithTop Key) := by
push_neg at hhi
push Not at hhi
obtain ⟨k, hk, hkge⟩ := hhi
exact le_trans hkge (hlastle k hk)
by_cases hEH : r.end_.key < ((res.keys.headD ([] : Key) : Key) : WithTop Key)
@@ -2765,6 +2766,7 @@ theorem negCrossTruncRevUnder_or_belowEnd_of_top {r : RangeRead} {res : Result}
exact WithTop.coe_lt_top _
set_option maxHeartbeats 0 in
-- This declaration performs an expensive finite case analysis.
/-- **The residual dispatcher is minimal on the residual region.** The residual is
crossed and either complete or reversed truncated, so all forward-truncated, clamped and
cross-free branches have already been discharged by the compact certificates. -/
@@ -2872,14 +2874,19 @@ theorem minimal_conflictRangeClosedFormResidualCompleteFwd {r : RangeRead} {res
(fun h => h4 (Or.inl h))
(fun h => h4 (Or.inr (Or.inl h)))
(fun h => h4 (Or.inr (Or.inr h)))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr (Or.inl h))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr
(Or.inl h))))))
(fun h => h9 (Or.inr (Or.inr (Or.inr (Or.inl h)))))
(fun h => h9 (Or.inr (Or.inr (Or.inr (Or.inr (Or.inl h))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inl h))))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr
(Or.inr (Or.inr (Or.inl h))))))))
(fun h => h9 (Or.inr (Or.inr (Or.inr (Or.inr (Or.inr h))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inr h)))))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inl h)))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inr (Or.inl h)))))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr
(Or.inr (Or.inr (Or.inr (Or.inr h)))))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr
(Or.inr (Or.inl h)))))))
(fun h => h2 ((crossedCompleteEndLeOne_iff r res).mpr (Or.inr (Or.inr (Or.inr
(Or.inr (Or.inr (Or.inr (Or.inl h)))))))))
(fun h => h9 (Or.inl h))
(fun h => h1 (Or.inr h))
(fun h => by
@@ -2931,7 +2938,8 @@ theorem minimal_conflictRangeClosedFormResidualRevTruncLeOne {r : RangeRead} {re
unfold negCrossTruncRevResidualFiniteUnderCrossed negCrossTruncRevResidualFiniteUnder at h
omega
have hfunc : ¬ negCrossTruncRevResidualFiniteUnderNotCrossed r res := fun h => by
unfold negCrossTruncRevResidualFiniteUnderNotCrossed negCrossTruncRevResidualFiniteUnder at h
unfold negCrossTruncRevResidualFiniteUnderNotCrossed negCrossTruncRevResidualFiniteUnder
at h
omega
have hfo : ¬ negCrossTruncRevResidualFiniteOver r res := fun h => by
unfold negCrossTruncRevResidualFiniteOver at h
@@ -3089,8 +3097,8 @@ theorem compactCrossed_minimal {r : RangeRead} {res : Result}
/-- The single closed form denotes the same key set as the residual dispatcher. -/
theorem compactCrossed_toSet_eq_residual {r : RangeRead} {res : Result}
(hread : Readable r res) (hbegin : r.begin.offset ≤ 0) (hempty : res.keys ≠ [])
(hcross : ((leastReported r res : Key) : WithTop Key) < r.begin.key) :
(_hread : Readable r res) (_hbegin : r.begin.offset ≤ 0) (_hempty : res.keys ≠ [])
(_hcross : ((leastReported r res : Key) : WithTop Key) < r.begin.key) :
(compactCrossed r res).toSet = (conflictRangeClosedFormResidual r res).toSet := by
rw [compactCrossed_eq_residual r res]
@@ -3142,7 +3150,7 @@ noncomputable def compact (r : RangeRead) (res : Result) : ConflictRange :=
/-- The residual branch is literally the residual-only dispatcher. -/
theorem compact_eq_closedFormClosed_of_residual {r : RangeRead} {res : Result}
(h : compactResidual r res) :
(_h : compactResidual r res) :
compact r res = conflictRangeClosedFormClosed r res :=
rfl