Lean / Reader
Lean reader

AffineIP.lean

180 lines9 declarationsno sorryimports Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset Mathlib.Data.Finset.Powerset Mathlib.Order.Preorder.Finite Mathlib.Probability.BorelCantelli Mathlib.Tactic
  1. import Mathlib.Algebra.Order.BigOperators.GroupWithZero.Finset
  2. import Mathlib.Data.Finset.Powerset
  3. import Mathlib.Order.Preorder.Finite
  4. import Mathlib.Probability.BorelCantelli
  5. import Mathlib.Tactic
  6. namespace AffineIP
  7. /-- Simultaneously extend finitely many translates and positive dilates. -/
  8. def Rich (A : Set ℕ) : Prop :=
  9. ∀ (S P : Finset ℕ) (M : ℕ), ∃ x > M,
  10. (∀ s ∈ S, x + s ∈ A) ∧ (∀ p ∈ P, 0 < p → x * p ∈ A)
  11. def Good (A : Set ℕ) (s : Finset ℕ) : Prop :=
  12. (∀ i ∈ s, 0 < i) ∧ ∀ t ⊆ s, t.Nonempty →
  13. (∑ i ∈ t, i) ∈ A ∧ (∏ i ∈ t, i) ∈ A
  14. private theorem extend {A : Set ℕ} (h : Rich A) {s : Finset ℕ}
  15. (hs : Good A s) (M : ℕ) :
  16. ∃ x > M, Good A (insert x s) := by
  17. classical
  18. let S := s.powerset.image (fun t => ∑ i ∈ t, i)
  19. let P := s.powerset.image (fun t => ∏ i ∈ t, i)
  20. obtain ⟨x, hx, hS, hP⟩ := h S P M
  21. refine ⟨x, hx, ?_, ?_⟩
  22. · intro i hi
  23. rcases Finset.mem_insert.mp hi with rfl | hi
  24. · omega
  25. · exact hs.1 i hi
  26. · intro t ht hne
  27. by_cases hxt : x ∈ t
  28. · let u := t.erase x
  29. have hus : u ⊆ s := by
  30. intro i hi
  31. have hmem := Finset.mem_erase.mp hi
  32. exact (Finset.mem_insert.mp (ht hmem.2)).resolve_left hmem.1
  33. have hp : u ∈ s.powerset := Finset.mem_powerset.mpr hus
  34. have ha := hS (∑ i ∈ u, i) (Finset.mem_image.mpr ⟨u, hp, rfl⟩)
  35. have hb := hP (∏ i ∈ u, i) (Finset.mem_image.mpr ⟨u, hp, rfl⟩)
  36. (Finset.prod_pos (fun i hi => hs.1 i (hus hi)))
  37. have hn : x ∉ u := Finset.notMem_erase x t
  38. have heq : insert x u = t := Finset.insert_erase hxt
  39. rw [← heq, Finset.sum_insert hn, Finset.prod_insert hn]
  40. exact ⟨ha, hb⟩
  41. · apply hs.2 t _ hne
  42. intro i hi
  43. exact (Finset.mem_insert.mp (ht hi)).resolve_left (fun e => hxt (e ▸ hi))
  44. /-- One infinite set of positive integers has both kinds of finite reductions in A. -/
  45. theorem infinite_sums_and_products {A : Set ℕ} (h : Rich A) :
  46. ∃ B : Set ℕ, B.Infinite ∧ (∀ i ∈ B, 0 < i) ∧
  47. ∀ t : Finset ℕ, (↑t : Set ℕ) ⊆ B → t.Nonempty →
  48. (∑ i ∈ t, i) ∈ A ∧ (∏ i ∈ t, i) ∈ A := by
  49. classical
  50. let G := {s : Finset ℕ // Good A s}
  51. let val (n : ℕ) (s : G) := (extend h s.property n).choose
  52. have spec (n : ℕ) (s : G) : n < val n s ∧ Good A (insert (val n s) s.val) :=
  53. (extend h s.property n).choose_spec
  54. have he : Good A ∅ := by simp [Good]
  55. let T : ℕ → G := Nat.rec ⟨∅, he⟩ (fun n s => ⟨insert (val n s) s.val, (spec n s).2⟩)
  56. have grow (n : ℕ) : (T n).val ⊆ (T (n+1)).val := Finset.subset_insert _ _
  57. have mono : Monotone (fun n => (T n).val) := monotone_nat_of_le_succ grow
  58. let B : Set ℕ := {i | ∃ n, i ∈ (T n).val}
  59. refine ⟨B, Set.infinite_of_forall_exists_gt ?_, ?_, ?_⟩
  60. · intro n
  61. refine ⟨val n (T n), ⟨n+1, ?_⟩, (spec n (T n)).1⟩
  62. exact Finset.mem_insert_self _ _
  63. · rintro i ⟨n, hn⟩
  64. exact (T n).property.1 i hn
  65. · intro t ht hne
  66. have bounded (u : Finset ℕ) (hu : (↑u : Set ℕ) ⊆ B) : ∃ n, u ⊆ (T n).val := by
  67. induction u using Finset.induction_on with
  68. | empty => exact ⟨0, Finset.empty_subset _⟩
  69. | @insert a s ha ih =>
  70. obtain ⟨j,hj⟩ := hu (Finset.mem_insert_self a s)
  71. obtain ⟨k,hk⟩ := ih (fun i hi => hu (Finset.mem_insert_of_mem hi))
  72. refine ⟨max j k, Finset.insert_subset ?_ ?_⟩
  73. · exact mono (le_max_left j k) hj
  74. · exact hk.trans (mono (le_max_right j k))
  75. obtain ⟨n, hn⟩ := bounded t ht
  76. exact (T n).property.2 t hn hne
  77. open MeasureTheory ProbabilityTheory Filter
  78. open scoped ENNReal
  79. private def block (S P : Finset ℕ) (x : ℕ) : Finset ℕ :=
  80. S.image (x + ·) ∪ (P.filter (0 < ·)).image (x * ·)
  81. private lemma le_of_mem_block {S P : Finset ℕ} {x y : ℕ} (hy : y ∈ block S P x) : x ≤ y := by
  82. rcases Finset.mem_union.mp hy with h | h
  83. · obtain ⟨i, _, rfl⟩ := Finset.mem_image.mp h
  84. omega
  85. · obtain ⟨i, hi, rfl⟩ := Finset.mem_image.mp h
  86. exact Nat.le_mul_of_pos_right _ (Finset.mem_filter.mp hi).2
  87. private lemma block_events {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}
  88. {E : ℕ → Set Ω} (hm : ∀ i, MeasurableSet (E i)) (hi : iIndepSet E μ)
  89. (b : ℕ → Finset ℕ) (hd : Pairwise (fun i j => Disjoint (b i) (b j))) :
  90. iIndepSet (fun n => ⋂ j ∈ b n, E j) μ := by
  91. classical
  92. apply (iIndepSet_iff_meas_biInter (fun _ => MeasurableSet.iInter (fun _ =>
  93. MeasurableSet.iInter (fun _ => hm _)))).2
  94. intro s
  95. have he : (⋂ i ∈ s, ⋂ j ∈ b i, E j) = ⋂ j ∈ s.biUnion b, E j := by
  96. ext w
  97. simp only [Set.mem_iInter, Finset.mem_biUnion]
  98. aesop
  99. rw [he, hi.meas_biInter, Finset.prod_biUnion (fun i _ j _ hij => hd hij)]
  100. exact Finset.prod_congr rfl (fun i _ => (hi.meas_biInter (b i)).symm)
  101. private theorem ae_extension {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}
  102. [IsProbabilityMeasure μ] {E : ℕ → Set Ω} (hm : ∀ i, MeasurableSet (E i))
  103. (hi : iIndepSet E μ) {p : ℝ≥0∞} (hp : 0 < p) (hle : p ≤ 1) (hprob : ∀ i, 0 < i → p ≤ μ (E i))
  104. (S P : Finset ℕ) (M : ℕ) :
  105. ∀ᵐ w ∂μ, ∃ x > M, (∀ s ∈ S, w ∈ E (x+s)) ∧ (∀ t ∈ P, 0 < t → w ∈ E (x*t)) := by
  106. classical
  107. let trials : ℕ → ℕ := Nat.rec (M+1) (fun _ x => max x ((block S P x).sup id) + 1)
  108. have hstep (n : ℕ) : trials n < trials (n+1) := Nat.lt_succ_of_le (le_max_left _ _)
  109. have hstrict := strictMono_nat_of_lt_succ hstep
  110. let b (n : ℕ) := block S P (trials n)
  111. have disj (i j : ℕ) (hij : i < j) : Disjoint (b i) (b j) := by
  112. refine Finset.disjoint_left.mpr (fun {y} hy hy' => ?_)
  113. have h1 : y ≤ (block S P (trials i)).sup id := Finset.le_sup (f := id) hy
  114. have h2 : (block S P (trials i)).sup id < trials (i+1) := Nat.lt_succ_of_le (le_max_right _ _)
  115. have h3 : trials (i+1) ≤ trials j := hstrict.monotone hij
  116. have h4 : trials j ≤ y := le_of_mem_block hy'
  117. omega
  118. have hd : Pairwise (fun i j => Disjoint (b i) (b j)) := by
  119. intro i j hij
  120. rcases lt_or_gt_of_ne hij with h | h
  121. · exact disj i j h
  122. · exact (disj j i h).symm
  123. let events (n : ℕ) := ⋂ j ∈ b n, E j
  124. have hmeas (n : ℕ) : MeasurableSet (events n) := MeasurableSet.iInter
  125. (fun _ => MeasurableSet.iInter (fun _ => hm _))
  126. have bound (n : ℕ) : p^(S.card+P.card) ≤ μ (events n) := by
  127. have hcard : (b n).card ≤ S.card+P.card :=
  128. (Finset.card_union_le _ _).trans (Nat.add_le_add Finset.card_image_le
  129. (Finset.card_image_le.trans (Finset.card_filter_le _ _)))
  130. change _ ≤ μ (⋂ j ∈ b n, E j)
  131. rw [hi.meas_biInter]
  132. calc
  133. _ ≤ p^(b n).card := pow_le_pow_of_le_one hp.le hle hcard
  134. _ = ∏ _j ∈ b n, p := by simp
  135. _ ≤ _ := Finset.prod_le_prod' (fun i hi' => hprob i (lt_of_lt_of_le
  136. (lt_of_lt_of_le (Nat.succ_pos M) (hstrict.monotone (Nat.zero_le n)))
  137. (le_of_mem_block hi')))
  138. have hts : (∑' n, μ (events n)) = ∞ := by
  139. apply top_unique
  140. calc
  141. ∞ = ∑' _n : ℕ, p^(S.card+P.card) := (ENNReal.tsum_const_eq_top_of_ne_zero (pow_ne_zero _ hp.ne')).symm
  142. _ ≤ _ := ENNReal.tsum_le_tsum bound
  143. have hfull := measure_limsup_eq_one hmeas (block_events hm hi b hd) hts
  144. have hae : limsup events atTop ∈ ae μ := (mem_ae_iff_prob_eq_one (MeasurableSet.measurableSet_limsup hmeas)).2 hfull
  145. filter_upwards [hae] with w hw
  146. obtain ⟨n, hn⟩ := (mem_limsup_iff_frequently_mem.mp hw).exists
  147. have hh : ∀ j ∈ b n, w ∈ E j := by simpa [events] using hn
  148. refine ⟨trials n, lt_of_lt_of_le (Nat.lt_succ_self M) (hstrict.monotone (Nat.zero_le n)), ?_, ?_⟩
  149. · intro s hs
  150. exact hh _ (Finset.mem_union_left _ (Finset.mem_image.mpr ⟨s,hs,rfl⟩))
  151. · intro t ht htpos
  152. exact hh _ (Finset.mem_union_right _ (Finset.mem_image.mpr ⟨t,Finset.mem_filter.mpr ⟨ht,htpos⟩,rfl⟩))
  153. /-- Independent membership events with a common positive lower bound almost surely
  154. contain all finite sums and products of one infinite set of positive generators. -/
  155. theorem ae_infinite_sums_and_products {Ω : Type*} [MeasurableSpace Ω] {μ : Measure Ω}
  156. [IsProbabilityMeasure μ] {E : ℕ → Set Ω} (hm : ∀ i, MeasurableSet (E i))
  157. (hi : iIndepSet E μ) {p : ℝ≥0∞} (hp : 0 < p) (hle : p ≤ 1) (hprob : ∀ i, 0 < i → p ≤ μ (E i)) :
  158. ∀ᵐ w ∂μ, ∃ B : Set ℕ, B.Infinite ∧ (∀ i ∈ B, 0 < i) ∧
  159. ∀ t : Finset ℕ, (↑t : Set ℕ) ⊆ B → t.Nonempty →
  160. w ∈ E (∑ i ∈ t, i) ∧ w ∈ E (∏ i ∈ t, i) := by
  161. have rich : ∀ᵐ w ∂μ, Rich {i | w ∈ E i} :=
  162. ae_all_iff.2 (fun S => ae_all_iff.2 (fun P => ae_all_iff.2
  163. (fun M => ae_extension hm hi hp hle hprob S P M)))
  164. filter_upwards [rich] with w hw
  165. exact infinite_sums_and_products hw
  166. #print axioms ae_infinite_sums_and_products
  167. end AffineIP