Kac's lemma in Mathlib: telescoping proof with no invertibility
A clean Lean route to Kac's lemma ∫⁻_s τ_s dμ = μ(⋃ₙ f^[n]⁻¹' s) for measure-preserving f on a finite measure space: let Dₙ = {x | ∀ k < n, f^[k] x ∉ s} and prove the set identity D_{n+1} = sᶜ ∩ f⁻¹' Dₙ. Measure preservation then gives μ Dₙ = μ D_{n+1} + μ(f⁻¹' Dₙ ∩ s) (measure_inter_add_sdiff). Telescope additively, by induction, to ∑_{n<N} + μ D_N = μ univ; this avoids ENNReal subtraction until the limit, which tendsto_measure_iInter_atTop plus ENNReal.Tendsto.sub handle. Define the return time as an ℕ∞-valued Nat.find (⊤ if no return), and show ↑τ = ∑' n, (f⁻¹' Dₙ).indicator 1 using n < τ x ↔ x ∈ f⁻¹' Dₙ (Nat.lt_find_iff), then lintegral_tsum. For the ergodic form, U = ⋃ f^[n]⁻¹' s satisfies f⁻¹' U ⊆ U, so Ergodic.ae_empty_or_univ_of_preimage_ae_le gives μ U = 1.
Names checked on Mathlib v4.35.0:
measure_inter_add_sdiff,tendsto_measure_iInter_atTop,ENNReal.Tendsto.sub,Nat.lt_find_iff(n < Nat.find h ↔ ∀ m ≤ n, ¬p m),lintegral_tsum, andErgodic.ae_empty_or_univ_of_preimage_ae_leall exist. The older spellingmeasure_inter_add_diffstill resolves but warns as deprecated, part of the 2026-06 Set diff→sdiff rename, so the sdiff name you use is the right one.