Lean / Reader
Lean readerDecayRamseyUpper.lean
Lean 4 Web has Mathlib, so it can check files that import only Mathlib. This one also imports DecayForcing, which it does not have: you can read it there, but it will not check. Build the project itself to check it.
import DecayForcingimport Mathlib.Combinatorics.Pigeonholenamespace DecayClassification/-- Extract t vertices whose outgoing edges to later selected verticesdepend only on the earlier vertex. -/theorem extract_vertices {n : ℕ} (c : Fin n × Fin n → ℕ) (r : ℕ) (hr : 2 ≤ r) :∀ t (s : Finset (Fin n)), r^t ≤ s.card →(∀ x ∈ s, ∀ y ∈ s, x < y → c (x,y) < r) →∃ H ⊆ s, H.card = t ∧ ∃ label : Fin n → ℕ,(∀ x ∈ H, label x < r) ∧ ∀ x ∈ H, ∀ y ∈ H, x < y → c (x,y) = label x := byclassicalintro tinduction t with| zero =>intro s _ _exact ⟨∅,Finset.empty_subset _,rfl,fun _ => 0,by simp,by simp⟩| succ t ih =>intro s size coloredhave hpow : 0 < r^t := pow_pos (by omega) _have hn : s.Nonempty := Finset.card_pos.mp (lt_of_lt_of_le (pow_pos (by omega) _) size)let u := s.min' hnhave hu : u ∈ s := s.min'_mem hnlet R := s.erase uhave above (v : Fin n) (hv : v ∈ R) : u < v :=lt_of_le_of_ne (s.min'_le v (Finset.mem_of_mem_erase hv)) (Finset.ne_of_mem_erase hv).symmhave enough : (Finset.range r).card * (r^t-1) < R.card := bydsimp [R]; rw [Finset.card_erase_of_mem hu,Finset.card_range, Nat.mul_sub, Nat.mul_one]rw [pow_succ,mul_comm] at sizehave enough : r ≤ r*r^t := by nlinarith [Nat.mul_le_mul_left r (show 1 ≤ r^t by omega)]omegaobtain ⟨p,hp,hpcount⟩ := Finset.exists_lt_card_fiber_of_mul_lt_card_of_maps_to(f := fun v => c (u,v)) (s := R) (t := Finset.range r)(fun v hv => Finset.mem_range.mpr (colored _ hu _ (Finset.mem_of_mem_erase hv) (above v hv))) enoughlet T := R.filter fun v => c (u,v) = phave count : r^t ≤ T.card := by dsimp [T]; omegahave sub (x : Fin n) (hx : x ∈ T) : x ∈ s := Finset.mem_of_mem_erase (Finset.mem_filter.mp hx).1obtain ⟨H,hHT,hsize,f,hf,hedge⟩ :=ih T count (fun x hx y hy => colored x (sub x hx) y (sub y hy))have huH : u ∉ H := fun h => (lt_irrefl u) (above u (Finset.mem_filter.mp (hHT h)).1)refine ⟨insert u H,Finset.insert_subset hu (fun x hx => sub x (hHT hx)),by rw [Finset.card_insert_of_notMem huH,hsize], Function.update f u p, ?_, ?_⟩· intro x hxrcases Finset.mem_insert.mp hx with eq | hx· subst x; simpa using Finset.mem_range.mp hp· rw [Function.update_of_ne (by intro eq; exact huH (eq ▸ hx) : x ≠ u)]exact hf x hx· intro x hx y hy hxyrcases Finset.mem_insert.mp hx with eq | hx· subst xhave hyH := (Finset.mem_insert.mp hy).resolve_left hxy.ne'simpa using (Finset.mem_filter.mp (hHT hyH)).2· have yne : y ≠ u := byhave := above x (Finset.mem_filter.mp (hHT hx)).1exact (this.trans hxy).ne'have hyH := (Finset.mem_insert.mp hy).resolve_left ynerw [Function.update_of_ne (by intro eq; exact huH (eq ▸ hx) : x ≠ u)]exact hedge _ hx _ hyH hxytheorem ramsey_supplier : RamseySupplier := byintro r k hr hkhave hM : 2 ≤ r^(r*k) := byhave := pow_le_pow_right₀ (by omega : 1 ≤ r) (show 1 ≤ r*k by nlinarith)simpa using hr.trans (by simpa using this)refine ⟨r^(r*k),hM,le_rfl,?_⟩intro n c s hs coloredobtain ⟨H,_,hc,f,hf,hedge⟩ := extract_vertices c r hr (r*k) s hs.ge coloredobtain ⟨i,_,hcount⟩ := Finset.exists_le_card_fiber_of_mul_le_card_of_maps_to(f := f) (s := H) (t := Finset.range r)(fun x hx => Finset.mem_range.mpr (hf x hx))(Finset.nonempty_range_iff.mpr (by omega)) (by simpa using hc.ge : (Finset.range r).card*k ≤ H.card)obtain ⟨K,sub,hK⟩ := Finset.exists_subset_card_eq hcountrefine ⟨K,hK,i,?_⟩intro x hx y hy hxyexact (hedge x (Finset.mem_filter.mp (sub hx)).1 y (Finset.mem_filter.mp (sub hy)).1 hxy).trans(Finset.mem_filter.mp (sub hx)).2/-- Unconditional forcing direction of the classification, with finite integercolor counts and the paper's strict tail condition. -/theorem tail_implies_decay_ramsey (a : ℕ → ℝ) : TailTest a → DecayRamsey a :=forcing_of_tail ramsey_supplier a#print axioms tail_implies_decay_ramseyend DecayClassification