l3lab/ntp-mathlib huggingface dataset:
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    

Proof state:
case intro.zero
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
hN : ∀ b ≥ Nat.zero, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
⊢ ↑↑μ s = 0

Next tactic:
simpa using hN 0 le_rfl
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  

Proof state:
case intro.succ
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
ihN : (∀ b ≥ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0) → False
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
⊢ False

Next tactic:
rw [imp_false] at ihN
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  

Proof state:
case intro.succ
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
ihN : ¬∀ b ≥ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
⊢ False

Next tactic:
push_neg at ihN
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  

Proof state:
case intro.succ
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
ihN : ∃ b ≥ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) ≠ 0
⊢ False

Next tactic:
rcases ihN with ⟨n, hn, hμn⟩
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  

Proof state:
case intro.succ.intro.intro
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
⊢ False

Next tactic:
set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  

Proof state:
case intro.succ.intro.intro
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
⊢ False

Next tactic:
have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  

Proof state:
case intro.succ.intro.intro
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
⊢ False

Next tactic:
have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    rw [← inter_iUnion₂]
    rfl
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    

Proof state:
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
⊢ ↑↑μ T = 0

Next tactic:
convert (measure_biUnion_null_iff <| to_countable _).2 hN
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    

Proof state:
case h.e'_2.h.e'_3
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
⊢ T = ⋃ i ∈ fun i => Nat.le (Nat.succ N) i, s ∩ f^[i] ⁻¹' s

Next tactic:
rw [← inter_iUnion₂]
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    rw [← inter_iUnion₂]
    

Proof state:
case h.e'_2.h.e'_3
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
⊢ T = s ∩ ⋃ i ∈ fun i => Nat.le (Nat.succ N) i, f^[i] ⁻¹' s

Next tactic:
rfl
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    rw [← inter_iUnion₂]
    rfl
  

Proof state:
case intro.succ.intro.intro
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
hμT : ↑↑μ T = 0
⊢ False

Next tactic:
have : μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0 := by rwa [measure_diff_null hμT]
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    rw [← inter_iUnion₂]
    rfl
  have : μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0 := by 

Proof state:
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
hμT : ↑↑μ T = 0
⊢ ↑↑μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0

Next tactic:
rwa [measure_diff_null hμT]
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    rw [← inter_iUnion₂]
    rfl
  have : μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0 := by rwa [measure_diff_null hμT]
  

Proof state:
case intro.succ.intro.intro
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
hμT : ↑↑μ T = 0
this : ↑↑μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0
⊢ False

Next tactic:
rcases hf.exists_mem_iterate_mem ((hs.inter (hf.measurable.iterate n hs)).diff hT) this with
    ⟨x, ⟨⟨hxs, _⟩, hxT⟩, m, hm0, ⟨_, hxm⟩, _⟩
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    rw [← inter_iUnion₂]
    rfl
  have : μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0 := by rwa [measure_diff_null hμT]
  rcases hf.exists_mem_iterate_mem ((hs.inter (hf.measurable.iterate n hs)).diff hT) this with
    ⟨x, ⟨⟨hxs, _⟩, hxT⟩, m, hm0, ⟨_, hxm⟩, _⟩
  

Proof state:
case intro.succ.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
hμT : ↑↑μ T = 0
this : ↑↑μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0
x : α
hxT : x ∉ T
hxs : x ∈ s
right✝¹ : x ∈ f^[n] ⁻¹' s
m : ℕ
hm0 : m ≠ 0
right✝ : f^[m] x ∉ T
left✝ : f^[m] x ∈ s
hxm : f^[m] x ∈ f^[n] ⁻¹' s
⊢ False

Next tactic:
refine' hxT ⟨hxs, mem_iUnion₂.2 ⟨n + m, _, _⟩⟩
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    rw [← inter_iUnion₂]
    rfl
  have : μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0 := by rwa [measure_diff_null hμT]
  rcases hf.exists_mem_iterate_mem ((hs.inter (hf.measurable.iterate n hs)).diff hT) this with
    ⟨x, ⟨⟨hxs, _⟩, hxT⟩, m, hm0, ⟨_, hxm⟩, _⟩
  refine' hxT ⟨hxs, mem_iUnion₂.2 ⟨n + m, _, _⟩⟩
  · 

Proof state:
case intro.succ.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.refine'_1
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
hμT : ↑↑μ T = 0
this : ↑↑μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0
x : α
hxT : x ∉ T
hxs : x ∈ s
right✝¹ : x ∈ f^[n] ⁻¹' s
m : ℕ
hm0 : m ≠ 0
right✝ : f^[m] x ∉ T
left✝ : f^[m] x ∈ s
hxm : f^[m] x ∈ f^[n] ⁻¹' s
⊢ n + m ≥ N + 1

Next tactic:
exact add_le_add hn (Nat.one_le_of_lt <| pos_iff_ne_zero.2 hm0)
/-- If `f` is a conservative map and `s` is a measurable set of nonzero measure, then
for infinitely many values of `m` a positive measure of points `x ∈ s` returns back to `s`
after `m` iterations of `f`. -/
theorem frequently_measure_inter_ne_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (h0 : μ s ≠ 0) : ∃ᶠ m in atTop, μ (s ∩ f^[m] ⁻¹' s) ≠ 0 := by
  by_contra H
  simp only [not_frequently, eventually_atTop, Ne.def, Classical.not_not] at H
  rcases H with ⟨N, hN⟩
  induction' N with N ihN
  · apply h0
    simpa using hN 0 le_rfl
  rw [imp_false] at ihN
  push_neg at ihN
  rcases ihN with ⟨n, hn, hμn⟩
  set T := s ∩ ⋃ n ≥ N + 1, f^[n] ⁻¹' s
  have hT : MeasurableSet T :=
    hs.inter (MeasurableSet.biUnion (to_countable _) fun _ _ => hf.measurable.iterate _ hs)
  have hμT : μ T = 0 := by
    convert (measure_biUnion_null_iff <| to_countable _).2 hN
    rw [← inter_iUnion₂]
    rfl
  have : μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0 := by rwa [measure_diff_null hμT]
  rcases hf.exists_mem_iterate_mem ((hs.inter (hf.measurable.iterate n hs)).diff hT) this with
    ⟨x, ⟨⟨hxs, _⟩, hxT⟩, m, hm0, ⟨_, hxm⟩, _⟩
  refine' hxT ⟨hxs, mem_iUnion₂.2 ⟨n + m, _, _⟩⟩
  · exact add_le_add hn (Nat.one_le_of_lt <| pos_iff_ne_zero.2 hm0)
  · 

Proof state:
case intro.succ.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.refine'_2
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
h0 : ↑↑μ s ≠ 0
N : ℕ
hN : ∀ b ≥ Nat.succ N, ↑↑μ (s ∩ f^[b] ⁻¹' s) = 0
n : ℕ
hn : n ≥ N
hμn : ↑↑μ (s ∩ f^[n] ⁻¹' s) ≠ 0
T : Set α := s ∩ ⋃ n, ⋃ (_ : n ≥ N + 1), f^[n] ⁻¹' s
hT : MeasurableSet T
hμT : ↑↑μ T = 0
this : ↑↑μ ((s ∩ f^[n] ⁻¹' s) \ T) ≠ 0
x : α
hxT : x ∉ T
hxs : x ∈ s
right✝¹ : x ∈ f^[n] ⁻¹' s
m : ℕ
hm0 : m ≠ 0
right✝ : f^[m] x ∉ T
left✝ : f^[m] x ∈ s
hxm : f^[m] x ∈ f^[n] ⁻¹' s
⊢ x ∈ f^[n + m] ⁻¹' s

Next tactic:
rwa [Set.mem_preimage, ← iterate_add_apply] at hxm
/-- Poincaré recurrence theorem: given a conservative map `f` and a measurable set `s`, the set
of points `x ∈ s` such that `x` does not return to `s` after `≥ n` iterations has measure zero. -/
theorem measure_mem_forall_ge_image_not_mem_eq_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (n : ℕ) : μ ({ x ∈ s | ∀ m ≥ n, f^[m] x ∉ s }) = 0 := by
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
n : ℕ
⊢ ↑↑μ {x | x ∈ s ∧ ∀ m ≥ n, f^[m] x ∉ s} = 0

Next tactic:
by_contra H
/-- Poincaré recurrence theorem: given a conservative map `f` and a measurable set `s`, the set
of points `x ∈ s` such that `x` does not return to `s` after `≥ n` iterations has measure zero. -/
theorem measure_mem_forall_ge_image_not_mem_eq_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (n : ℕ) : μ ({ x ∈ s | ∀ m ≥ n, f^[m] x ∉ s }) = 0 := by
  by_contra H
  

Proof state:
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
n : ℕ
H : ¬↑↑μ {x | x ∈ s ∧ ∀ m ≥ n, f^[m] x ∉ s} = 0
⊢ False

Next tactic:
have : MeasurableSet (s ∩ { x | ∀ m ≥ n, f^[m] x ∉ s }) := by
    simp only [setOf_forall, ← compl_setOf]
    exact
      hs.inter (MeasurableSet.biInter (to_countable _) fun m _ => hf.measurable.iterate m hs.compl)
/-- Poincaré recurrence theorem: given a conservative map `f` and a measurable set `s`, the set
of points `x ∈ s` such that `x` does not return to `s` after `≥ n` iterations has measure zero. -/
theorem measure_mem_forall_ge_image_not_mem_eq_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (n : ℕ) : μ ({ x ∈ s | ∀ m ≥ n, f^[m] x ∉ s }) = 0 := by
  by_contra H
  have : MeasurableSet (s ∩ { x | ∀ m ≥ n, f^[m] x ∉ s }) := by
    

Proof state:
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
n : ℕ
H : ¬↑↑μ {x | x ∈ s ∧ ∀ m ≥ n, f^[m] x ∉ s} = 0
⊢ MeasurableSet (s ∩ {x | ∀ m ≥ n, f^[m] x ∉ s})

Next tactic:
simp only [setOf_forall, ← compl_setOf]
/-- Poincaré recurrence theorem: given a conservative map `f` and a measurable set `s`, the set
of points `x ∈ s` such that `x` does not return to `s` after `≥ n` iterations has measure zero. -/
theorem measure_mem_forall_ge_image_not_mem_eq_zero (hf : Conservative f μ) (hs : MeasurableSet s)
    (n : ℕ) : μ ({ x ∈ s | ∀ m ≥ n, f^[m] x ∉ s }) = 0 := by
  by_contra H
  have : MeasurableSet (s ∩ { x | ∀ m ≥ n, f^[m] x ∉ s }) := by
    simp only [setOf_forall, ← compl_setOf]
    

Proof state:
ι : Type u_1
α : Type u_2
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
hs : MeasurableSet s
n : ℕ
H : ¬↑↑μ {x | x ∈ s ∧ ∀ m ≥ n, f^[m] x ∉ s} = 0
⊢ MeasurableSet (s ∩ ⋂ i, ⋂ (_ : i ≥ n), {a | f^[i] a ∈ s}ᶜ)

Next tactic:
exact
      hs.inter (MeasurableSet.biInter (to_countable _) fun m _ => hf.measurable.iterate m hs.compl)