Lean library · module TopologyByExample.Theorems.MathiasEnvelope

Ramsey envelopes and countable trees

Source file

Every family of infinite subsets has a completely Ramsey envelope whose measurable excess is null. Applying these envelopes to a countable tree gives the closure argument needed for analytic partitions.

This file was written by Codex (OpenAI's AI model) working under the direction of David R. MacIver, who reviews it and is responsible for it.

Imports

theorem exists_envelope

TopologyByExample.Mathias.exists_envelope

Every set has a completely Ramsey envelope with no non-null completely Ramsey subset in its excess.

theorem exists_envelope {U : Ultrafilter ℕ} (hU : IsSelective U)
    (hfree : (U : Filter ℕ) ≤ cofinite) (S : Set (Set ℕ)) :
    ∃ B : Set (Set ℕ), CompletelyRamsey U B ∧ S ⊆ B ∧
      ∀ C, CompletelyRamsey U C → C ⊆ B \ S → RamseyNull U C
Proof
:= by
  classical
  let : MeasurableSpace (Set ℕ) := measurableSpace U hU hfree
  have hc (s : Finset ℕ) : ∃ A ∈ U, CanForce U s Sᶜ → cone s A ⊆ Sᶜ := by
    by_cases h : CanForce U s Sᶜ
    · obtain ⟨A, hA, ha⟩ := h
      exact ⟨A, hA, fun _ ↦ ha⟩
    · exact ⟨univ, univ_mem, fun hs ↦ (h hs).elim⟩
  choose A hA hAS using hc
  let O : Set (Set ℕ) := ⋃ s : {s : Finset ℕ // CanForce U s Sᶜ}, cone s.val (A s.val)
  have hO : MeasurableSet O := MeasurableSet.iUnion
    (fun s ↦ completelyRamsey_cone hU hfree s.val (A s.val))
  refine ⟨Oᶜ, hO.compl, ?_, fun C hC hCB ↦ ?_⟩
  · intro X hXS hXO
    obtain ⟨s, hs⟩ := mem_iUnion.mp hXO
    exact hAS s.val s.property hs hXS
  · apply hC.ramseyNull_of_not_canForce
    intro s hs
    obtain ⟨D, hD, hDC⟩ := hs
    have hforce : CanForce U s Sᶜ := ⟨D, hD, fun X hx ↦ (hCB (hDC hx)).2⟩
    obtain ⟨X, hxD, hxA⟩ := cone_inter_nonempty hfree s hD (hA s)
    exact (hCB (hDC hxD)).1 (mem_iUnion.mpr ⟨⟨s, hforce⟩, hxA⟩)

theorem completelyRamsey_of_tree

TopologyByExample.Mathias.completelyRamsey_of_tree

A countable tree of completely Ramsey approximations determines a completely Ramsey set when branches characterize its root.

theorem completelyRamsey_of_tree {U : Ultrafilter ℕ} (hU : IsSelective U)
    (hfree : (U : Filter ℕ) ≤ cofinite) (A S : List ℕ → Set (Set ℕ))
    (hA : ∀ s, CompletelyRamsey U (A s)) (hSA : ∀ s, S s ⊆ A s)
    (hchildren : ∀ s, S s = ⋃ k : ℕ, S (k :: s))
    (hbranch : ∀ f : ℕ → ℕ, (⋂ n, A (PiNat.res f n)) ⊆ S []) :
    CompletelyRamsey U (S [])
Proof
:= by
  classical
  let : MeasurableSpace (Set ℕ) := measurableSpace U hU hfree
  choose B hB hSB hmin using fun s ↦ exists_envelope hU hfree (S s)
  let N (s : List ℕ) : Set (Set ℕ) := B s \ (A s ∩ ⋃ k : ℕ, B (k :: s))
  have hN (s : List ℕ) : RamseyNull U (N s) := by
    have hm : MeasurableSet (N s) := MeasurableSet.diff (hB s : MeasurableSet (B s))
      (MeasurableSet.inter (hA s : MeasurableSet (A s))
        (MeasurableSet.iUnion fun k ↦ hB (k :: s)))
    apply hmin s _ hm
    intro X hX
    refine ⟨hX.1, fun hxS ↦ hX.2 ⟨hSA s hxS, ?_⟩⟩
    rw [hchildren s] at hxS
    obtain ⟨k, hk⟩ := mem_iUnion.mp hxS
    exact mem_iUnion.mpr ⟨k, hSB (k :: s) hk⟩
  have hNull : RamseyNull U (⋃ s, N s) := RamseyNull.iUnion_countable hU hfree hN
  apply (hB []).of_sdiff_null (hSB [])
  apply hNull.mono
  intro X hX
  by_contra hXexc
  have hstep (s : List ℕ) (hs : X ∈ B s) : X ∈ A s ∧ ∃ k : ℕ, X ∈ B (k :: s) := by
    have hn : X ∉ N s := fun hn ↦ hXexc (mem_iUnion.mpr ⟨s, hn⟩)
    have hh : X ∈ A s ∩ ⋃ k : ℕ, B (k :: s) := by
      by_contra hh
      exact hn ⟨hs, hh⟩
    exact ⟨hh.1, mem_iUnion.mp hh.2⟩
  let next (s : List ℕ) : ℕ := if hs : X ∈ B s then (hstep s hs).2.choose else 0
  let g : ℕ → List ℕ := Nat.rec [] (fun _ s ↦ next s :: s)
  have hg (n : ℕ) : X ∈ B (g n) := by
    induction n with
    | zero => exact hX.1
    | succ n ih =>
      change X ∈ B (next (g n) :: g n)
      simpa only [next, dite_eq_left ih] using (hstep (g n) ih).2.choose_spec
  let f : ℕ → ℕ := fun n ↦ next (g n)
  have hres (n : ℕ) : PiNat.res f n = g n := by
    induction n with
    | zero => rfl
    | succ n ih => simp only [PiNat.res_succ, ih]; rfl
  apply hX.2
  apply hbranch f
  apply mem_iInter.mpr
  intro n
  rw [hres n]
  exact (hstep (g n) (hg n)).1