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
@@ -59,7 +59,8 @@ theorem countP_lt_eq_add_filter_withTop (l : List Key) (hnd : l.Nodup) {a : Key}
|
||||
((ke : Key) : WithTop Key))) = l.countP (fun k : Key => decide (k < ke)) :=
|
||||
countP_lt_coe ke
|
||||
have hf : (l.filter (fun k : Key => decide ((a : WithTop Key) ≤
|
||||
((k : Key) : WithTop Key) ∧ ((k : Key) : WithTop Key) < ((ke : Key) : WithTop Key)))).length =
|
||||
((k : Key) : WithTop Key) ∧ ((k : Key) : WithTop Key) < ((ke : Key) : WithTop
|
||||
Key)))).length =
|
||||
(l.filter (fun x : Key => decide (a ≤ x ∧ x < ke))).length := by
|
||||
congr 1
|
||||
apply List.filter_congr
|
||||
@@ -450,7 +451,8 @@ theorem minimal_closedForm_of_negCross_lowFwd {r : RangeRead} {res : Result}
|
||||
have hhead_lt_E : ((head : Key) : WithTop Key) < r.end_.key :=
|
||||
lt_of_lt_of_le hhead_lt_res hres_le
|
||||
have hR : resolve db₂ r.end_ = resolve db₁ r.end_ := by
|
||||
rcases resolve_eq_nil_or_eq_top_or_mem (db := db₁) (s := r.end_) with hn | ht | ⟨q, hqdb, hqeq⟩
|
||||
rcases resolve_eq_nil_or_eq_top_or_mem (db := db₁) (s := r.end_) with hn | ht | ⟨q, hqdb,
|
||||
hqeq⟩
|
||||
· rw [hn] at hhead_lt_res
|
||||
exact absurd hhead_lt_res (not_lt.mpr (coe_nil_le_key_withTop _))
|
||||
· exact absurd ht (resolve_ne_top_of_offset_nonpos hend)
|
||||
@@ -688,20 +690,20 @@ theorem resolve_begin_insert_gt {db : DB} {r : RangeRead} {head k : Key}
|
||||
have hcB' : (db'.keys.countP (fun x : Key => decide (((x : Key) : WithTop Key) <
|
||||
r.begin.key))) = cB + 1 := by
|
||||
rw [hdb']
|
||||
show (db.keys.orderedInsert (· ≤ ·) k).countP _ = cB + 1
|
||||
change (db.keys.orderedInsert (· ≤ ·) k).countP _ = cB + 1
|
||||
rw [List.Perm.countP_eq _ (List.perm_orderedInsert (· ≤ ·) k db.keys)]
|
||||
rw [List.countP_cons]
|
||||
simp only [decide_eq_true_eq, hk_lt, if_true]
|
||||
simp only [decide_eq_true_eq, hk_lt, ite_true]
|
||||
rw [hcB]
|
||||
have hcH' : (db'.keys.countP (fun x : Key => decide (x < head))) = cH := by
|
||||
rw [hdb']
|
||||
show (db.keys.orderedInsert (· ≤ ·) k).countP _ = cH
|
||||
change (db.keys.orderedInsert (· ≤ ·) k).countP _ = cH
|
||||
rw [List.Perm.countP_eq _ (List.perm_orderedInsert (· ≤ ·) k db.keys)]
|
||||
rw [List.countP_cons]
|
||||
have hkf : (decide (k < head)) = false := by
|
||||
rw [decide_eq_false_iff_not]
|
||||
exact not_lt.mpr (le_of_lt hk_gt)
|
||||
simp only [hkf, Bool.false_eq_true, if_false]
|
||||
simp only [hkf, Bool.false_eq_true, ite_false]
|
||||
rw [hcH]
|
||||
omega
|
||||
have hanchor : r.begin.anchor db' = ((cH : ℤ) + 1) := by
|
||||
@@ -1193,10 +1195,10 @@ theorem clampEndOne_end_le_begin_of_upper_begin (hcell : negCrossClampEndOne r r
|
||||
by_cases hc : ((clampEndOneSlack r res : ℕ∞) ≤ clampEndOneCap r) ∧
|
||||
(((clampEndOneSlack r res : ℕ∞) < clampEndOneCap r) ∨
|
||||
res.keys.headD ([] : Key) ≠ [])
|
||||
· rw [if_pos hc] at hupper
|
||||
· rw [ite_eq_left hc] at hupper
|
||||
rw [hzero] at hc
|
||||
exact absurd hc.1 (not_le.mpr (by exact_mod_cast hs))
|
||||
· rw [if_neg hc] at hupper
|
||||
· rw [ite_eq_right hc] at hupper
|
||||
exact absurd hupper (ne_of_lt hlt).symm
|
||||
|
||||
end Structural
|
||||
@@ -1207,7 +1209,7 @@ section CountBounds
|
||||
|
||||
variable {db : DB} {r : RangeRead} {res : Result}
|
||||
|
||||
theorem clampEndOne_reported_eq_length (hcell : negCrossClampEndOne r res)
|
||||
theorem clampEndOne_reported_eq_length (_hcell : negCrossClampEndOne r res)
|
||||
(hEB : r.end_.key ≤ r.begin.key)
|
||||
(hres_lt_E : ∀ k ∈ res.keys, ((k : Key) : WithTop Key) < r.end_.key) :
|
||||
reportedBelowBegin r res = res.keys.length := by
|
||||
@@ -1220,7 +1222,7 @@ theorem clampEndOne_reported_eq_length (hcell : negCrossClampEndOne r res)
|
||||
theorem clampEndOne_count_le_of_between_bound {db : DB} {r : RangeRead} {res : Result}
|
||||
(hfilter : db.keys.filter (fun k : Key => decide (((k : Key) : WithTop Key) < r.end_.key)) =
|
||||
res.keys)
|
||||
(hm : reportedBelowBegin r res = res.keys.length)
|
||||
(_hm : reportedBelowBegin r res = res.keys.length)
|
||||
(hEB : r.end_.key ≤ r.begin.key) :
|
||||
db.keys.countP (fun k : Key => decide (((k : Key) : WithTop Key) < r.begin.key)) =
|
||||
res.keys.length +
|
||||
@@ -1231,12 +1233,14 @@ theorem clampEndOne_count_le_of_between_bound {db : DB} {r : RangeRead} {res : R
|
||||
have hEB' : (⊤ : WithTop Key) ≤ r.begin.key := by rw [← hEtop]; exact hEB
|
||||
have hB : r.begin.key = (⊤ : WithTop Key) := le_antisymm le_top hEB'
|
||||
rw [hB]
|
||||
have hcnt : db.keys.countP (fun k : Key => decide (((k : Key) : WithTop Key) < (⊤ : WithTop Key))) =
|
||||
have hcnt : db.keys.countP (fun k : Key => decide (((k : Key) : WithTop Key) < (⊤ : WithTop
|
||||
Key))) =
|
||||
db.keys.length := countP_lt_top
|
||||
have hlen : res.keys.length = db.keys.length := by
|
||||
conv_rhs => rw [← hcnt]
|
||||
rw [← hfilter, hEtop, List.countP_eq_length_filter]
|
||||
have hempty : db.keys.filter (fun k : Key => decide ((⊤ : WithTop Key) ≤ ((k : Key) : WithTop Key) ∧
|
||||
have hempty : db.keys.filter (fun k : Key => decide ((⊤ : WithTop Key) ≤ ((k : Key) : WithTop
|
||||
Key) ∧
|
||||
((k : Key) : WithTop Key) < (⊤ : WithTop Key))) = [] := by
|
||||
rw [List.filter_eq_nil_iff]
|
||||
intro k _; simp
|
||||
@@ -1281,7 +1285,8 @@ theorem clampEndOne_count_le_slack_of_cap_lt (hcell : negCrossClampEndOne r res)
|
||||
omega
|
||||
· -- `begin.key < end_.key`: no room above `end_.key`, and all reported keys are below it.
|
||||
have hlt : r.begin.key < r.end_.key := lt_of_not_ge hEB
|
||||
have h₁ : (db.keys.filter (fun k : Key => decide (((k : Key) : WithTop Key) < r.end_.key))).filter
|
||||
have h₁ : (db.keys.filter (fun k : Key => decide (((k : Key) : WithTop Key) <
|
||||
r.end_.key))).filter
|
||||
(fun k : Key => decide (((k : Key) : WithTop Key) < r.begin.key)) =
|
||||
db.keys.filter (fun k : Key => decide (((k : Key) : WithTop Key) < r.begin.key)) := by
|
||||
rw [List.filter_filter]
|
||||
@@ -1452,7 +1457,7 @@ selector clamps to the empty key, so the complete window is exactly those stored
|
||||
-/
|
||||
theorem clampEndOne_compat_of_filter {r : RangeRead} {res : Result} {db : DB}
|
||||
(hcell : negCrossClampEndOne r res)
|
||||
(hlong : r.end_.key < r.begin.key)
|
||||
(_hlong : r.end_.key < r.begin.key)
|
||||
(hcond : clampEndOneCap r < (clampEndOneSlack r res : ℕ∞) ∨
|
||||
(clampEndOneCap r = (clampEndOneSlack r res : ℕ∞) ∧
|
||||
res.keys.headD ([] : Key) = ([] : Key)))
|
||||
@@ -1545,7 +1550,7 @@ theorem clampEndOne_filter_eq_of_compat {r : RangeRead} {res : Result} {db : DB}
|
||||
| some k' =>
|
||||
rw [h] at hkres
|
||||
have hk' : k' = k := WithTop.coe_inj.mp hkres
|
||||
simpa [hk'] using h
|
||||
simp [hk']
|
||||
have hlt : (r.begin.anchor db).toNat < db.keys.length :=
|
||||
List.getElem?_eq_some_iff.mp hget |>.1
|
||||
have hk_eq : db.keys[(r.begin.anchor db).toNat] = k :=
|
||||
@@ -1637,7 +1642,8 @@ theorem clampEndOne_filter_eq_of_compat {r : RangeRead} {res : Result} {db : DB}
|
||||
have hkE : k < E := WithTop.coe_lt_coe.mp (by rw [hE] at hlt'; exact hlt')
|
||||
exact lt_countP_of_getElem_lt db.sorted hlt (by rw [hk_eq]; exact hkE)
|
||||
have hdropk : D.filter
|
||||
(fun x : Key => decide (((k : Key) : WithTop Key) ≤ ((x : Key) : WithTop Key))) = D.drop a := by
|
||||
(fun x : Key => decide (((k : Key) : WithTop Key) ≤ ((x : Key) : WithTop Key))) = D.drop a
|
||||
:= by
|
||||
have h := filter_not_lt_eq_drop_countP hDsorted ((k : Key) : WithTop Key)
|
||||
rw [hDa] at h
|
||||
rw [← h]
|
||||
@@ -1693,12 +1699,12 @@ theorem clampEndOne_neg_cond {r : RangeRead} {res : Result}
|
||||
· exfalso
|
||||
apply hU
|
||||
unfold clampEndOneUpper
|
||||
rw [if_pos ⟨hle, Or.inl hstrict⟩]
|
||||
rw [ite_eq_left ⟨hle, Or.inl hstrict⟩]
|
||||
· by_cases hhead : res.keys.headD ([] : Key) ≠ ([] : Key)
|
||||
· exfalso
|
||||
apply hU
|
||||
unfold clampEndOneUpper
|
||||
rw [if_pos ⟨hle, Or.inr hhead⟩]
|
||||
rw [ite_eq_left ⟨hle, Or.inr hhead⟩]
|
||||
· exact Or.inr ⟨le_antisymm (not_lt.mp hstrict) hle, not_not.mp hhead⟩
|
||||
· exact Or.inl (not_le.mp hle)
|
||||
|
||||
@@ -1724,9 +1730,9 @@ theorem sound_clampEndOne {r : RangeRead} {res : Result}
|
||||
by_cases hP : (clampEndOneSlack r res : ℕ∞) ≤ clampEndOneCap r ∧
|
||||
((clampEndOneSlack r res : ℕ∞) < clampEndOneCap r ∨
|
||||
res.keys.headD ([] : Key) ≠ ([] : Key))
|
||||
· rw [if_pos hP] at hU
|
||||
· rw [ite_eq_left hP] at hU
|
||||
exact absurd rfl hU
|
||||
· rw [if_neg hP] at hU ⊢
|
||||
· rw [ite_eq_right hP] at hU ⊢
|
||||
have hagree' : AgreeOn ⟨(([] : Key) : WithTop Key), r.end_.key⟩ db₁ db₂ := by
|
||||
simpa [closedFormNegCrossClampEndOne, hU'] using hagree
|
||||
by_cases hshort : r.begin.key ≤ r.end_.key
|
||||
@@ -1786,7 +1792,7 @@ theorem clampEndOne_res_db_compat {r : RangeRead} {res : Result}
|
||||
refine ⟨hcomp.1, Or.inr ⟨hmore, ?_⟩⟩
|
||||
show res.keys = RangeRead.completeKeys ⟨res.keys, hs⟩ r
|
||||
rw [completeKeys_eq_filter_of_end_one hrev hend]
|
||||
show res.keys = (res.keys.filter
|
||||
change res.keys = (res.keys.filter
|
||||
(fun k : Key => decide (((k : Key) : WithTop Key) < r.end_.key))).filter
|
||||
(fun k : Key => decide (resolve ⟨res.keys, hs⟩ r.begin ≤ ((k : Key) : WithTop Key)))
|
||||
rw [hD, hnil]
|
||||
@@ -1894,7 +1900,7 @@ theorem clampEndOne_gap_db {r : RangeRead} {res : Result} {L : List Key}
|
||||
refine ⟨hcomp.1, Or.inr ⟨hmore, ?_⟩⟩
|
||||
show res.keys = RangeRead.completeKeys ⟨res.keys ++ L, hAppSorted⟩ r
|
||||
rw [completeKeys_eq_filter_of_end_one hrev hend]
|
||||
show res.keys = ((res.keys ++ L).filter
|
||||
change res.keys = ((res.keys ++ L).filter
|
||||
(fun x : Key => decide (((x : Key) : WithTop Key) < r.end_.key))).filter
|
||||
(fun x : Key => decide (resolve ⟨res.keys ++ L, hAppSorted⟩ r.begin ≤
|
||||
((x : Key) : WithTop Key)))
|
||||
@@ -2110,7 +2116,7 @@ theorem clampEndOne_gap_db_extra {r : RangeRead} {res : Result} {L : List Key}
|
||||
refine ⟨hcomp.1, Or.inr ⟨hmore, ?_⟩⟩
|
||||
show res.keys = RangeRead.completeKeys ⟨(([] : Key) :: res.keys) ++ L, hAppSorted⟩ r
|
||||
rw [completeKeys_eq_filter_of_end_one hrev hend]
|
||||
show res.keys = (((([] : Key) :: res.keys) ++ L).filter
|
||||
change res.keys = (((([] : Key) :: res.keys) ++ L).filter
|
||||
(fun x : Key => decide (((x : Key) : WithTop Key) < r.end_.key))).filter
|
||||
(fun x : Key => decide (resolve ⟨(([] : Key) :: res.keys) ++ L, hAppSorted⟩ r.begin ≤
|
||||
((x : Key) : WithTop Key)))
|
||||
@@ -2215,7 +2221,7 @@ theorem countP_erase_add_one {l : List Key} {k : Key} {p : Key → Bool}
|
||||
have hpos : 0 < l.countP p :=
|
||||
List.countP_pos_iff.mpr ⟨k, hk, hp⟩
|
||||
have h := List.countP_erase p l k
|
||||
rw [if_pos ⟨hk, hp⟩] at h
|
||||
rw [ite_eq_left ⟨hk, hp⟩] at h
|
||||
omega
|
||||
|
||||
/-- A database with the extra bottom key and the full gap list, compatible with begin
|
||||
@@ -2224,7 +2230,7 @@ to bottom and the extra bottom key enters the complete result. -/
|
||||
theorem clampEndOne_erase_extra_not_compat {r : RangeRead} {res : Result} {dbA : DB}
|
||||
{k : Key} {L : List Key}
|
||||
(hread : Readable r res) (hcell : negCrossClampEndOne r res)
|
||||
(hlong : r.end_.key < r.begin.key)
|
||||
(_hlong : r.end_.key < r.begin.key)
|
||||
(hheadne : res.keys.headD ([] : Key) ≠ ([] : Key))
|
||||
(hAkeys : dbA.keys = (([] : Key) :: res.keys) ++ L)
|
||||
(hLlo : ∀ x ∈ L, r.end_.key ≤ ((x : Key) : WithTop Key))
|
||||
@@ -2420,7 +2426,7 @@ theorem minimal_closedForm_of_negCross_clampEndOne {r : RangeRead} {res : Result
|
||||
((clampEndOneSlack r res : ℕ∞) < clampEndOneCap r ∨
|
||||
res.keys.headD ([] : Key) ≠ ([] : Key))
|
||||
· exact hP
|
||||
· rw [if_neg hP] at hU
|
||||
· rw [ite_eq_right hP] at hU
|
||||
exact absurd hU (ne_of_lt hEB)
|
||||
by_cases hstrict : (clampEndOneSlack r res : ℕ∞) < clampEndOneCap r
|
||||
· exact clampEndOne_necessary_gap_of_cap_lt hread hcell hstrict hkE' hkltB
|
||||
@@ -2436,9 +2442,9 @@ theorem minimal_closedForm_of_negCross_clampEndOne {r : RangeRead} {res : Result
|
||||
by_cases hP : (clampEndOneSlack r res : ℕ∞) ≤ clampEndOneCap r ∧
|
||||
((clampEndOneSlack r res : ℕ∞) < clampEndOneCap r ∨
|
||||
res.keys.headD ([] : Key) ≠ ([] : Key))
|
||||
· rw [if_pos hP] at hU
|
||||
· rw [ite_eq_left hP] at hU
|
||||
exact absurd rfl hU
|
||||
· rw [if_neg hP] at hU ⊢
|
||||
· rw [ite_eq_right hP] at hU ⊢
|
||||
have hkE : (k : WithTop Key) < r.end_.key := by
|
||||
simpa [closedFormNegCrossClampEndOne, hU'] using hhi
|
||||
exact clampEndOne_necessary_below_end hread hcell hkE
|
||||
|
||||
Reference in new issue
Block a user