Lean / Reader
Lean readerDecayForcing.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports DecayClassification, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import DecayClassificationnamespace DecayClassification/-- Every M-set contains a late edge. Count the pairs consisting of an M-setand a late edge it contains. -/theorem finite_density {n M : ℕ} (hM : 2 ≤ M) (hn : M ≤ n)(late : Finset (Fin n × Fin n)) (ordered : late ⊆ edges n)(hit : ∀ s : Finset (Fin n), s.card = M → ∃ e ∈ late, e.1 ∈ s ∧ e.2 ∈ s) :n.choose 2 ≤ late.card * M.choose 2 := byclassicallet sets := (Finset.univ : Finset (Fin n)).powersetCard Mlet family (e : Fin n × Fin n) := sets.filter fun s => e.1 ∈ s ∧ e.2 ∈ shave cover : sets ⊆ late.biUnion family := byintro s hsobtain ⟨e,he,hes⟩ := hit s (Finset.mem_powersetCard.mp hs).2exact Finset.mem_biUnion.mpr ⟨e,he,Finset.mem_filter.mpr ⟨hs,hes⟩⟩have counts : ∀ e ∈ late, (family e).card ≤ (n-2).choose (M-2) := byintro e hehave hlt : e.1 < e.2 := (Finset.mem_filter.mp (ordered he)).2let pair : Finset (Fin n) := {e.1,e.2}have cp : pair.card = 2 := by simp [pair,hlt.ne]let residual := (Finset.univ \ pair).powersetCard (M-2)have maps {s} (hs : s ∈ family e) : pair ⊆ s := byobtain ⟨_,hx,hy⟩ := Finset.mem_filter.mp hsintro x hsimp only [pair, Finset.mem_insert, Finset.mem_singleton] at hrcases h with rfl | rfl <;> assumptionhave bound : (family e).card ≤ residual.card := byapply Finset.card_le_card_of_injOn (fun s => s \ pair)· intro s hschange s ∈ (Finset.univ.powersetCard M).filter (fun u => e.1 ∈ u ∧ e.2 ∈ u) at hschange s \ pair ∈ (Finset.univ \ pair).powersetCard (M-2)apply Finset.mem_powersetCard.mprrefine ⟨Finset.sdiff_subset_sdiff (Finset.subset_univ _) (by rfl),?_⟩rw [Finset.card_sdiff_of_subset (maps hs),cp]exact congrArg (· - 2) (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hs).1).2· intro s hs t ht eqhave h := congrArg (fun a : Finset (Fin n) => a ∪ pair) eqsimpa only [Finset.sdiff_union_of_subset (maps hs), Finset.sdiff_union_of_subset (maps ht)] using hsimpa [residual,Finset.card_powersetCard,Finset.card_sdiff_of_subset (Finset.subset_univ pair),cp] using boundhave hcount : n.choose M ≤ late.card * (n-2).choose (M-2) := bycalc_ = sets.card := by simp [sets]_ ≤ (late.biUnion family).card := Finset.card_le_card cover_ ≤ ∑ e ∈ late, (family e).card := Finset.card_biUnion_le_ ≤ ∑ _ ∈ late, (n-2).choose (M-2) := Finset.sum_le_sum counts_ = _ := by simphave times := Nat.mul_le_mul_right (M.choose 2) hcountrw [Nat.choose_mul hM] at timeshave pos := Nat.choose_pos (show M-2 ≤ n-2 by omega)exact Nat.le_of_mul_le_mul_right (by simpa only [mul_assoc,mul_comm,mul_left_comm] using times) postheorem edge_count_le (n : ℕ) : (edges n).card ≤ n.choose 2 := byclassicallet dst := (Finset.univ : Finset (Fin n)).powersetCard 2have maps : (edges n).card ≤ dst.card := byapply Finset.card_le_card_of_injOn (fun x => ({x.1,x.2} : Finset (Fin n)))· intro e hehave lt : e.1 < e.2 := (Finset.mem_filter.mp he).2change ({e.1,e.2} : Finset (Fin n)) ∈ Finset.univ.powersetCard 2exact Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _,by simp [lt.ne]⟩· intro a ha b hb hhave la : a.1 < a.2 := (Finset.mem_filter.mp ha).2have lb : b.1 < b.2 := (Finset.mem_filter.mp hb).2change ({a.1,a.2} : Finset (Fin n)) = {b.1,b.2} at hhave ma : a.1 ∈ ({b.1,b.2} : Finset (Fin n)) := by rw [← h]; simphave mb : a.2 ∈ ({b.1,b.2} : Finset (Fin n)) := by rw [← h]; simpsimp only [Finset.mem_insert,Finset.mem_singleton] at ma mbexact Prod.ext (by rcases ma with h | h <;> rcases mb with h' | h' <;> omega)(by rcases ma with h | h <;> rcases mb with h' | h' <;> omega)simpa [dst] using mapstheorem late_budget {n : ℕ} (a : ℕ → ℝ) (c : Fin n × Fin n → ℕ) (r : ℕ) (u : ℝ)(hb : Bounded a c) (hu : ∀ l, ∑ i ∈ Finset.Ico r l, a i ≤ u) :(((edges n).filter (fun e => r ≤ c e)).card : ℝ) ≤ u*(edges n).card := bylet E := edges nlet l := E.sup c + 1let T := Finset.Ico r lhave heq : E.filter (fun e => c e ∈ T) = E.filter (fun e => r ≤ c e) := byext esimp only [Finset.mem_filter, T, Finset.mem_Ico]constructor· exact fun h => ⟨h.1,h.2.1⟩· intro hexact ⟨h.1,h.2,Nat.lt_succ_of_le (Finset.le_sup h.1)⟩have hc := Finset.sum_card_fiberwise_eq_card_filter E T crw [heq] at hcchange ((E.filter (fun e => r ≤ c e)).card : ℝ) ≤ u*E.cardrw [← hc,Nat.cast_sum]apply (Finset.sum_le_sum (fun i (_ : i ∈ T) => hb i)).transrw [← Finset.sum_mul]exact mul_le_mul_of_nonneg_right (hu l) (by positivity)/-- A finite Ramsey bound supplies a front-color clique on any M-set if noedge of that set uses the tail palette. -/def RamseySupplier : Prop :=∀ r k : ℕ, 2 ≤ r → 2 ≤ k → ∃ M : ℕ, 2 ≤ M ∧ M ≤ r^(r*k) ∧∀ n (c : Fin n × Fin n → ℕ) (s : Finset (Fin n)), s.card = M →(∀ x ∈ s, ∀ y ∈ s, x < y → c (x,y) < r) → MonoClique k ctheorem forcing_of_tail (ramsey : RamseySupplier) (a : ℕ → ℝ) (test : TailTest a) :DecayRamsey a := byclassicalintro k hkobtain ⟨r,hr,u,hu,hpartial⟩ := test (2*k) (by omega) 2have hr2 : 2 ≤ r := by omegahave u0 : 0 ≤ u := by simpa using hpartial robtain ⟨M,hM,hm,force⟩ := ramsey r k hr2 hkrefine ⟨M,?_⟩intro n hn c budgetby_contra nolet late := (edges n).filter fun e => r ≤ c ehave hit : ∀ s : Finset (Fin n), s.card = M → ∃ e ∈ late, e.1 ∈ s ∧ e.2 ∈ s := byintro s hsby_contra! failapply no (force n c s hs ?_)intro x hx y hy hxyby_contra! highexact fail (x,y) (Finset.mem_filter.mpr ⟨by simpa [edges] using hxy,high⟩) hx hyhave lower := finite_density hM hn late (Finset.filter_subset _ _) hithave lreal : (n.choose 2 : ℝ) ≤ (late.card : ℝ) * (M.choose 2 : ℝ) := by exact_mod_cast lowerhave upper := late_budget a c r u budget hpartialchange (late.card : ℝ) ≤ u*(edges n).card at upperhave esc : ((edges n).card : ℝ) ≤ (n.choose 2 : ℝ) := by exact_mod_cast edge_count_le nhave cm : M.choose 2 ≤ M*M := byrw [Nat.choose_two_right]exact (Nat.div_le_self _ _).trans (Nat.mul_le_mul_left _ (Nat.sub_le ..))have cp : M.choose 2 ≤ r^((2*k)*r) := bycalc_ ≤ M*M := cm_ ≤ r^(r*k)*r^(r*k) := Nat.mul_le_mul hm hm_ = _ := by rw [← pow_add]; congr 1; ringhave p0 : (0:ℝ) < (n.choose 2 : ℝ) := by exact_mod_cast Nat.choose_pos (hM.trans hn)have cp' : (M.choose 2 : ℝ) ≤ (r : ℝ)^((2*k)*r) := by exact_mod_cast cphave ur := mul_lt_mul_of_pos_right hu p0have est := mul_le_mul (upper.trans (mul_le_mul_of_nonneg_left esc u0)) cp'(show (0:ℝ) ≤ (M.choose 2 : ℝ) by positivity) (by positivity)nlinarithend DecayClassification