-- Mathlib/MeasureTheory/Function/Intersectivity.lean
/-- **Bergelson Intersectivity Lemma**: In a finite measure space, a sequence of events that have
measure at least `r` has an infinite subset whose finite intersections all have positive volume. -/
lemma bergelson [Infinite ι] {s : ι → Set α} (hs : ∀ i, MeasurableSet (s i)) (hr₀ : r ≠ 0)
    (hr : ∀ i, r ≤ μ (s i)) :
    ∃ t : Set ι, t.Infinite ∧ ∀ ⦃u⦄, u ⊆ t → u.Finite → 0 < μ (⋂ i ∈ u, s i)

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
r : ℝ≥0∞
inst✝ : Infinite ι
s : ι → Set α
hs : ∀ (i : ι), MeasurableSet (s i)
hr₀ : r ≠ 0
hr : ∀ (i : ι), r ≤ μ (s i)
t : Set ℕ
ht : t.Infinite
h : ∀ ⦃u : Set ℕ⦄, u ⊆ t → u.Finite → 0 < μ (⋂ n ∈ u, s ((Infinite.natEmbedding ι) n))
⊢ ∃ t, t.Infinite ∧ ∀ ⦃u : Set ι⦄, u ⊆ t → u.Finite → 0 < μ (⋂ i ∈ u, s i)

Tactic:
refine ⟨_, ht.image <| (Infinite.natEmbedding _).injective.injOn, fun u hut hu ↦
  (h (preimage_subset_of_surjOn (Infinite.natEmbedding _).injective hut) <| hu.preimage
  (Embedding.injective _).injOn).trans_le <| measure_mono <| subset_iInter₂ fun i hi ↦ ?_⟩

Result:
case intro.intro
ι : Type u_1
α : Type u_2
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
r : ℝ≥0∞
inst✝ : Infinite ι
s : ι → Set α
hs : ∀ (i : ι), MeasurableSet (s i)
hr₀ : r ≠ 0
hr : ∀ (i : ι), r ≤ μ (s i)
t : Set ℕ
ht : t.Infinite
h : ∀ ⦃u : Set ℕ⦄, u ⊆ t → u.Finite → 0 < μ (⋂ n ∈ u, s ((Infinite.natEmbedding ι) n))
u : Set ι
hut : u ⊆ ⇑(Infinite.natEmbedding ι) '' t
hu : u.Finite
i : ι
hi : i ∈ u
⊢ ⋂ n ∈ ⇑(Infinite.natEmbedding ι) ⁻¹' u, s ((Infinite.natEmbedding ι) n) ⊆ s i

Proof state:
case intro.intro
ι : Type u_1
α : Type u_2
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
r : ℝ≥0∞
inst✝ : Infinite ι
s : ι → Set α
hs : ∀ (i : ι), MeasurableSet (s i)
hr₀ : r ≠ 0
hr : ∀ (i : ι), r ≤ μ (s i)
t : Set ℕ
ht : t.Infinite
h : ∀ ⦃u : Set ℕ⦄, u ⊆ t → u.Finite → 0 < μ (⋂ n ∈ u, s ((Infinite.natEmbedding ι) n))
u : Set ι
hut : u ⊆ ⇑(Infinite.natEmbedding ι) '' t
hu : u.Finite
i : ι
hi : i ∈ u
⊢ ⋂ n ∈ ⇑(Infinite.natEmbedding ι) ⁻¹' u, s ((Infinite.natEmbedding ι) n) ⊆ s i

Tactic:
obtain ⟨n, -, rfl⟩ := hut hi

Result:
case intro.intro.intro.intro
ι : Type u_1
α : Type u_2
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
r : ℝ≥0∞
inst✝ : Infinite ι
s : ι → Set α
hs : ∀ (i : ι), MeasurableSet (s i)
hr₀ : r ≠ 0
hr : ∀ (i : ι), r ≤ μ (s i)
t : Set ℕ
ht : t.Infinite
h : ∀ ⦃u : Set ℕ⦄, u ⊆ t → u.Finite → 0 < μ (⋂ n ∈ u, s ((Infinite.natEmbedding ι) n))
u : Set ι
hut : u ⊆ ⇑(Infinite.natEmbedding ι) '' t
hu : u.Finite
n : ℕ
hi : (Infinite.natEmbedding ι) n ∈ u
⊢ ⋂ n ∈ ⇑(Infinite.natEmbedding ι) ⁻¹' u, s ((Infinite.natEmbedding ι) n) ⊆ s ((Infinite.natEmbedding ι) n)

Proof state:
case intro.intro.intro.intro
ι : Type u_1
α : Type u_2
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
r : ℝ≥0∞
inst✝ : Infinite ι
s : ι → Set α
hs : ∀ (i : ι), MeasurableSet (s i)
hr₀ : r ≠ 0
hr : ∀ (i : ι), r ≤ μ (s i)
t : Set ℕ
ht : t.Infinite
h : ∀ ⦃u : Set ℕ⦄, u ⊆ t → u.Finite → 0 < μ (⋂ n ∈ u, s ((Infinite.natEmbedding ι) n))
u : Set ι
hut : u ⊆ ⇑(Infinite.natEmbedding ι) '' t
hu : u.Finite
n : ℕ
hi : (Infinite.natEmbedding ι) n ∈ u
⊢ ⋂ n ∈ ⇑(Infinite.natEmbedding ι) ⁻¹' u, s ((Infinite.natEmbedding ι) n) ⊆ s ((Infinite.natEmbedding ι) n)

Tactic:
exact iInter₂_subset n hi

Result:
no goals

Proof state:
ι : Type u_1
α : Type u_2
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
r : ℝ≥0∞
inst✝ : Infinite ι
s : ι → Set α
hs : ∀ (i : ι), MeasurableSet (s i)
hr₀ : r ≠ 0
hr : ∀ (i : ι), r ≤ μ (s i)
⊢ ∃ t, t.Infinite ∧ ∀ ⦃u : Set ι⦄, u ⊆ t → u.Finite → 0 < μ (⋂ i ∈ u, s i)

Tactic:
obtain ⟨t, ht, h⟩ := bergelson' (fun n ↦ hs <| Infinite.natEmbedding _ n) hr₀ (fun n ↦ hr _)

Result:
case intro.intro
ι : Type u_1
α : Type u_2
inst✝² : MeasurableSpace α
μ : Measure α
inst✝¹ : IsFiniteMeasure μ
r : ℝ≥0∞
inst✝ : Infinite ι
s : ι → Set α
hs : ∀ (i : ι), MeasurableSet (s i)
hr₀ : r ≠ 0
hr : ∀ (i : ι), r ≤ μ (s i)
t : Set ℕ
ht : t.Infinite
h : ∀ ⦃u : Set ℕ⦄, u ⊆ t → u.Finite → 0 < μ (⋂ n ∈ u, s ((Infinite.natEmbedding ι) n))
⊢ ∃ t, t.Infinite ∧ ∀ ⦃u : Set ι⦄, u ⊆ t → u.Finite → 0 < μ (⋂ i ∈ u, s i)