Theorem: MeasureTheory.Conservative.iterate
File: Mathlib/Dynamics/Ergodic/Conservative.lean

tactic: cases' n with n
state_before: ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
⊢ Conservative (f^[n]) μ

tactic: refine' ⟨hf.1.iterate _, fun s hs hs0 => _⟩
state_before: case succ
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
⊢ Conservative (f^[Nat.succ n]) μ

tactic: rcases(hf.frequently_ae_mem_and_frequently_image_mem hs hs0).exists with ⟨x, _, hx⟩
state_before: case succ
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
⊢ ∃ x, x ∈ s ∧ ∃ m x_1, (f^[Nat.succ n]^[m]) x ∈ s

tactic: rw [Nat.frequently_atTop_iff_infinite] at hx
state_before: case succ.intro.intro
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : ∃ᶠ (n : ℕ) in atTop, (f^[n]) x ∈ s
⊢ ∃ x, x ∈ s ∧ ∃ m x_1, (f^[Nat.succ n]^[m]) x ∈ s

tactic: rcases Nat.exists_lt_modEq_of_infinite hx n.succ_pos with ⟨k, hk, l, hl, hkl, hn⟩
state_before: case succ.intro.intro
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
⊢ ∃ x, x ∈ s ∧ ∃ m x_1, (f^[Nat.succ n]^[m]) x ∈ s

tactic: set m := (l - k) / (n + 1)
state_before: case succ.intro.intro.intro.intro.intro.intro.intro
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
⊢ ∃ x, x ∈ s ∧ ∃ m x_1, (f^[Nat.succ n]^[m]) x ∈ s

tactic: have : (n + 1) * m = l - k := by
  apply Nat.mul_div_cancel'
  exact (Nat.modEq_iff_dvd' hkl.le).1 hn
state_before: case succ.intro.intro.intro.intro.intro.intro.intro
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
⊢ ∃ x, x ∈ s ∧ ∃ m x_1, (f^[Nat.succ n]^[m]) x ∈ s

tactic: refine' ⟨(f^[k]) x, hk, m, _, _⟩
state_before: case succ.intro.intro.intro.intro.intro.intro.intro
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
this : (n + 1) * m = l - k
⊢ ∃ x, x ∈ s ∧ ∃ m x_1, (f^[Nat.succ n]^[m]) x ∈ s

tactic: exact Conservative.id μ
state_before: case zero
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s : Set α
μ : Measure α
hf : Conservative f μ
⊢ Conservative (f^[Nat.zero]) μ

tactic: apply Nat.mul_div_cancel'
state_before: ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
⊢ (n + 1) * m = l - k

tactic: exact (Nat.modEq_iff_dvd' hkl.le).1 hn
state_before: case H
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
⊢ n + 1 ∣ l - k

tactic: intro hm
state_before: case succ.intro.intro.intro.intro.intro.intro.intro.refine'_1
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
this : (n + 1) * m = l - k
⊢ m ≠ 0

tactic: rw [hm, MulZeroClass.mul_zero, eq_comm, tsub_eq_zero_iff_le] at this
state_before: case succ.intro.intro.intro.intro.intro.intro.intro.refine'_1
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
this : (n + 1) * m = l - k
hm : m = 0
⊢ False

tactic: exact this.not_lt hkl
state_before: case succ.intro.intro.intro.intro.intro.intro.intro.refine'_1
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
this : l ≤ k
hm : m = 0
⊢ False

tactic: rwa [← iterate_mul, this, ← iterate_add_apply, tsub_add_cancel_of_le]
state_before: case succ.intro.intro.intro.intro.intro.intro.intro.refine'_2
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
this : (n + 1) * m = l - k
⊢ (f^[Nat.succ n]^[m]) ((f^[k]) x) ∈ s

tactic: exact hkl.le
state_before: case succ.intro.intro.intro.intro.intro.intro.intro.refine'_2
ι : Type ?u.77532
α : Type u_1
inst✝ : MeasurableSpace α
f : α → α
s✝ : Set α
μ : Measure α
hf : Conservative f μ
n : ℕ
s : Set α
hs : MeasurableSet s
hs0 : ↑↑μ s ≠ 0
x : α
left✝ : x ∈ s
hx : Set.Infinite {n | (f^[n]) x ∈ s}
k : ℕ
hk : k ∈ {n | (f^[n]) x ∈ s}
l : ℕ
hl : l ∈ {n | (f^[n]) x ∈ s}
hkl : k < l
hn : k ≡ l [MOD Nat.succ n]
m : ℕ := (l - k) / (n + 1)
this : (n + 1) * m = l - k
⊢ k ≤ l