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:
1 parent
a54a5f82f8
commit
af318a7d32
51 files changed
+2542
-1357
No files matched your search
@@ -23,7 +23,6 @@ complete clamping cell) from the reported and intermediate keys (convexity).
|
||||
|
||||
open FormalConflictRange
|
||||
|
||||
set_option maxHeartbeats 1200000
|
||||
|
||||
namespace FormalConflictRange
|
||||
|
||||
@@ -38,7 +37,7 @@ abbrev negCrossTruncClampNoGapTop (r : RangeRead) (res : Result) : Prop :=
|
||||
reportedBelowBegin r res ≤ beginSlack r
|
||||
|
||||
/-- The closed form for the no-gap clamping cell: `[⊥, begin.key)`. -/
|
||||
noncomputable def closedFormNegCrossTruncClampNoGapTop (r : RangeRead) (res : Result) :
|
||||
noncomputable def closedFormNegCrossTruncClampNoGapTop (r : RangeRead) (_res : Result) :
|
||||
ConflictRange :=
|
||||
⟨((↑([] : Key) : WithTop Key)), r.begin.key⟩
|
||||
|
||||
@@ -114,7 +113,7 @@ theorem necessary_below_head_of_negCross_trunc_clamp {r : RangeRead} {res : Resu
|
||||
hlast_lt_res₁
|
||||
have hcomp₁ : RangeRead.Compatible db₁ r res := by
|
||||
refine ⟨hcomp₀.1, Or.inl ⟨hmore, ?_, hne⟩⟩
|
||||
simpa [hck₁] using (List.prefix_refl (res.keys))
|
||||
simp [hck₁]
|
||||
let db₂ : DB := db₁.insert k hk_not
|
||||
have hagree : AgreeOn cr db₁ db₂ :=
|
||||
(ConflictRange.keys_insert_of_not_mem cr db₁ hk_not hkcr).symm
|
||||
@@ -757,7 +756,7 @@ abbrev negCrossTruncClampNoGap (r : RangeRead) (res : Result) : Prop :=
|
||||
reportedBelowBegin r res ≤ beginSlack r
|
||||
|
||||
/-- The closed form for the arbitrary-end no-gap clamping cell: `[⊥, begin.key)`. -/
|
||||
noncomputable def closedFormNegCrossTruncClampNoGap (r : RangeRead) (res : Result) :
|
||||
noncomputable def closedFormNegCrossTruncClampNoGap (r : RangeRead) (_res : Result) :
|
||||
ConflictRange :=
|
||||
⟨((↑([] : Key) : WithTop Key)), r.begin.key⟩
|
||||
|
||||
@@ -1045,7 +1044,7 @@ theorem compatible_iff_noGapRead_of_gapLow {r : RangeRead} {res : Result}
|
||||
(cnt db (((keyAfter last : Key)) : WithTop Key) : ℤ) - (beginSlack r : ℤ) - 1 := by
|
||||
have hs : beginSlack (noGapRead r res) = beginSlack r := rfl
|
||||
rw [anchor_eq_count_sub_slack db (noGapRead r res) (le_of_lt hbegin), hs]
|
||||
simp [cnt, noGapRead, hlastD, hlastD']
|
||||
simp [cnt, noGapRead, hlastD']
|
||||
have h_eq_r : r.begin.anchor db =
|
||||
(cnt db r.begin.key : ℤ) - (beginSlack r : ℤ) - 1 := by
|
||||
rw [anchor_eq_count_sub_slack db r (le_of_lt hbegin)]
|
||||
@@ -1170,7 +1169,7 @@ theorem compatible_iff_noGapRead_of_gapLow {r : RangeRead} {res : Result}
|
||||
have htg_le : t + (between db (((keyAfter last : Key)) : WithTop Key)
|
||||
r.begin.key).length ≤ beginSlack r := by
|
||||
have hgl : (between db (((keyAfter last : Key)) : WithTop Key)
|
||||
r.begin.key).length < beginSlack r + 1 - t := ENat.coe_lt_coe.mp hg_lt
|
||||
r.begin.key).length < beginSlack r + 1 - t := ENat.natCast_lt_natCast.mp hg_lt
|
||||
omega
|
||||
have hanc_r : r.begin.anchor db < 0 := by
|
||||
have h_eq_r : r.begin.anchor db =
|
||||
@@ -1396,7 +1395,7 @@ theorem compatible_iff_noGapRead_of_gapBotMid {r : RangeRead} {res : Result}
|
||||
(cnt db (((keyAfter last : Key)) : WithTop Key) : ℤ) - (beginSlack r : ℤ) - 1 := by
|
||||
have hs : beginSlack (noGapRead r res) = beginSlack r := rfl
|
||||
rw [anchor_eq_count_sub_slack db (noGapRead r res) (le_of_lt hbegin), hs]
|
||||
simp [cnt, noGapRead, hlastD, hlastD']
|
||||
simp [cnt, noGapRead, hlastD']
|
||||
rw [h_eq, hcntKA']
|
||||
have h1 : (t : ℤ) ≤ (q : ℤ) := by exact_mod_cast htq
|
||||
rw [← hq]; omega
|
||||
@@ -1409,7 +1408,8 @@ theorem compatible_iff_noGapRead_of_gapBotMid {r : RangeRead} {res : Result}
|
||||
simp [noGapRead]
|
||||
rw [compatible_iff_truncated_keys (db := db) (r := noGapRead r res) hrev hmore hne]
|
||||
rw [compatible_iff_truncated_keys (db := db) (r := r) hrev hmore hne] at hcomp
|
||||
exact ⟨by change RangeRead.withinLimit r res.keys; exact hcomp.1, by rw [hck_eq_ng]; exact hcomp.2⟩
|
||||
exact ⟨by change RangeRead.withinLimit r res.keys; exact hcomp.1, by rw [hck_eq_ng]; exact
|
||||
hcomp.2⟩
|
||||
· -- Reverse: the lowered read resolves to `⊥`; the capacity bound keeps `r`'s anchor
|
||||
-- nonpositive, and `⊥` is stored, so `r` resolves to `⊥` too.
|
||||
intro hcompNG
|
||||
@@ -1478,7 +1478,7 @@ theorem compatible_iff_noGapRead_of_gapBotMid {r : RangeRead} {res : Result}
|
||||
rw [hcard_add, hcard_one]
|
||||
exact add_comm _ _
|
||||
_ ≤ (((q + 1 - t) + 1 : ℕ) : ℕ∞) := by simpa [hlastD', hq, ht] using hcap
|
||||
have hg1 : g + 1 ≤ (q + 1 - t) + 1 := ENat.coe_le_coe.mp hcap'
|
||||
have hg1 : g + 1 ≤ (q + 1 - t) + 1 := ENat.natCast_le_natCast.mp hcap'
|
||||
have htg : t + g ≤ q + 1 := by omega
|
||||
have hanchor : r.begin.anchor db =
|
||||
(cnt db r.begin.key : ℤ) - (beginSlack r : ℤ) - 1 := by
|
||||
@@ -1509,7 +1509,7 @@ theorem compatible_iff_noGapRead_of_gapBotMid {r : RangeRead} {res : Result}
|
||||
simp [noGapRead]
|
||||
rw [compatible_iff_truncated_keys (db := db) (r := r) hrev hmore hne]
|
||||
rw [compatible_iff_truncated_keys (db := db) (r := noGapRead r res) hrev hmore hne] at hcompNG
|
||||
exact ⟨by change RangeRead.withinLimit r res.keys; exact hcompNG.1, by rw [← hck_eq]; exact hcompNG.2⟩
|
||||
exact ⟨by exact hcompNG.1, by rw [← hck_eq]; exact hcompNG.2⟩
|
||||
|
||||
/-- The lowered read satisfies the no-gap clamping cell whenever the original read is in
|
||||
the empty-head middle gap cell. -/
|
||||
@@ -1592,7 +1592,7 @@ abbrev negCrossTruncClampGapHighBot (r : RangeRead) (res : Result) : Prop :=
|
||||
intervalCard (((res.keys.getLastD ([] : Key)) : Key) : WithTop Key) r.begin.key
|
||||
|
||||
/-- The closed form for the empty-head high-capacity gap cell: `[⊥, begin.key)`. -/
|
||||
noncomputable def closedFormNegCrossTruncClampGapHighBot (r : RangeRead) (res : Result) :
|
||||
noncomputable def closedFormNegCrossTruncClampGapHighBot (r : RangeRead) (_res : Result) :
|
||||
ConflictRange :=
|
||||
⟨((↑([] : Key) : WithTop Key)), r.begin.key⟩
|
||||
|
||||
@@ -1727,7 +1727,7 @@ theorem compatible_of_append_gapKeys_highBot {r : RangeRead} {res : Result} {db
|
||||
(hlastE : (((res.keys.getLastD ([] : Key)) : Key)) < r.end_.key)
|
||||
(hgap : (((keyAfter (res.keys.getLastD ([] : Key)) : Key)) : WithTop Key) <
|
||||
r.begin.key)
|
||||
(hsort : res.keys.SortedLT) (hJ : J.SortedLT)
|
||||
(hsort : res.keys.SortedLT) (_hJ : J.SortedLT)
|
||||
(hJrange : ∀ x ∈ J, (((keyAfter (res.keys.getLastD ([] : Key)) : Key)) : WithTop Key) ≤
|
||||
((x : Key) : WithTop Key) ∧ ((x : Key) : WithTop Key) < r.begin.key)
|
||||
(hJlen : J.length = beginSlack r + 1 - res.keys.length)
|
||||
@@ -1784,7 +1784,6 @@ theorem compatible_of_append_gapKeys_highBot {r : RangeRead} {res : Result} {db
|
||||
rw [anchor_eq_count_sub_slack db r (le_of_lt hbegin)]
|
||||
change ((cnt db r.begin.key : ℕ) : ℤ) - (beginSlack r : ℤ) - 1 = 0
|
||||
rw [hcntB, ← hq]
|
||||
change ((t + T : ℕ) : ℤ) - (q : ℤ) - 1 = 0
|
||||
rw [hT]
|
||||
omega
|
||||
have hbot_mem : ([] : Key) ∈ db.keys := by
|
||||
@@ -2070,7 +2069,7 @@ theorem compatible_of_append_gapKeys_high {r : RangeRead} {res : Result} {db : D
|
||||
(r.end_.offset - 1).toNat)
|
||||
(hgap : (((keyAfter (res.keys.getLastD ([] : Key)) : Key)) : WithTop Key) <
|
||||
r.begin.key)
|
||||
(hsort : res.keys.SortedLT) (hJ : J.SortedLT)
|
||||
(hsort : res.keys.SortedLT) (_hJ : J.SortedLT)
|
||||
(hJrange : ∀ x ∈ J, (((keyAfter (res.keys.getLastD ([] : Key)) : Key)) : WithTop Key) ≤
|
||||
((x : Key) : WithTop Key) ∧ ((x : Key) : WithTop Key) < r.begin.key)
|
||||
(hJlen : J.length = beginSlack r + 1 - res.keys.length)
|
||||
@@ -2127,7 +2126,6 @@ theorem compatible_of_append_gapKeys_high {r : RangeRead} {res : Result} {db : D
|
||||
rw [anchor_eq_count_sub_slack db r (le_of_lt hbegin)]
|
||||
change ((cnt db r.begin.key : ℕ) : ℤ) - (beginSlack r : ℤ) - 1 = 0
|
||||
rw [hcntB, ← hq]
|
||||
change ((t + T : ℕ) : ℤ) - (q : ℤ) - 1 = 0
|
||||
rw [hT]
|
||||
omega
|
||||
have hhead_mem : head ∈ res.keys := by rw [hhead]; exact List.head_mem hne
|
||||
@@ -2212,7 +2210,7 @@ abbrev negCrossTruncClampGapHigh (r : RangeRead) (res : Result) : Prop :=
|
||||
intervalCard (((res.keys.getLastD ([] : Key)) : Key) : WithTop Key) r.begin.key
|
||||
|
||||
/-- The closed form for the nonempty-head high-capacity gap cell: `[⊥, begin.key)`. -/
|
||||
noncomputable def closedFormNegCrossTruncClampGapHigh (r : RangeRead) (res : Result) :
|
||||
noncomputable def closedFormNegCrossTruncClampGapHigh (r : RangeRead) (_res : Result) :
|
||||
ConflictRange :=
|
||||
⟨((↑([] : Key) : WithTop Key)), r.begin.key⟩
|
||||
|
||||
@@ -2229,7 +2227,7 @@ theorem compatible_of_nil_cons_gapKeys_high {r : RangeRead} {res : Result} {db :
|
||||
(hlastE : (((res.keys.getLastD ([] : Key)) : Key)) < r.end_.key)
|
||||
(hgap : (((keyAfter (res.keys.getLastD ([] : Key)) : Key)) : WithTop Key) <
|
||||
r.begin.key)
|
||||
(hsort : res.keys.SortedLT) (hJ : J.SortedLT)
|
||||
(hsort : res.keys.SortedLT) (_hJ : J.SortedLT)
|
||||
(hJrange : ∀ x ∈ J, (((keyAfter (res.keys.getLastD ([] : Key)) : Key)) : WithTop Key) ≤
|
||||
((x : Key) : WithTop Key) ∧ ((x : Key) : WithTop Key) < r.begin.key)
|
||||
(hJlen : J.length = beginSlack r + 1 - res.keys.length)
|
||||
@@ -2361,7 +2359,7 @@ theorem compatible_of_nil_cons_gapKeys_high {r : RangeRead} {res : Result} {db :
|
||||
rw [Bool.and_eq_true, Bool.and_eq_true] at hcon
|
||||
exact (not_le.mpr (lt_of_le_of_ne (nil_le_key head) (Ne.symm hheadne')))
|
||||
(of_decide_eq_true hcon.2.1)
|
||||
rw [if_neg hnil_pred]
|
||||
rw [ite_eq_right hnil_pred]
|
||||
have h1 : res.keys.filter (fun k : Key => decide (k ≤ last) && (decide (head ≤ k) &&
|
||||
decide (((k : Key) : WithTop Key) < resolve db r.end_))) = res.keys := by
|
||||
rw [List.filter_eq_self]
|
||||
@@ -2715,7 +2713,7 @@ theorem necessary_gap_high {r : RangeRead} {res : Result} {k : Key}
|
||||
· intro x
|
||||
simp only [List.mem_filter, decide_eq_true_eq]
|
||||
have hdbiff : x ∈ db1.keys ↔ x = k ∨ x ∈ db0.keys := by
|
||||
show x ∈ ([] : Key) :: (res.keys ++ J) ↔
|
||||
change x ∈ ([] : Key) :: (res.keys ++ J) ↔
|
||||
x = k ∨ x ∈ ([] : Key) :: (res.keys ++ dbJ.keys)
|
||||
unfold J
|
||||
simp only [List.mem_cons, List.mem_append, List.mem_orderedInsert]
|
||||
|
||||
Reference in new issue
Block a user