[proofplan]
The proof proceeds via the maximal ergodic lemma: (1) establish the maximal ergodic lemma, which bounds the integral of $f$ over the set where maximal partial sums are positive; (2) use it to show that the set where $\liminf S_n(f)/n$ and $\limsup S_n(f)/n$ differ has measure zero, establishing a.e. convergence; (3) identify the limit as an invariant $L^1$ function using [Fatou's Lemma](/theorems/510) and measure preservation.
[/proofplan]
[step:Set up notation for ergodic sums and maximal functions]
Define $S_n(f) = \sum_{k=0}^{n-1} f \circ \Theta^k$ for $n \geq 1$ and $S_0(f) = 0$.
Define the maximal partial sum $M_n(f) = \max_{1 \leq k \leq n} S_k(f)$ and $M_n^+(f) = \max(M_n(f), 0) = \max_{0 \leq k \leq n} S_k(f)$.
[/step]
[step:Prove the maximal ergodic lemma]
[claim:Maximal Ergodic Lemma]
Let $\Theta$ be measure preserving on $(E, \mathcal{E}, \mu)$ and let $f \in L^1(\mu)$. For every $n \geq 1$,
\begin{align*}
\int_{\{M_n(f) > 0\}} f \, d\mu \geq 0.
\end{align*}
[/claim]
[proof]
The key observation is the pointwise inequality $f \geq M_n^+(f) - M_n^+(f) \circ \Theta$.
To verify this: if $M_n^+(f)(x) = S_j(f)(x)$ for some $j \geq 1$, then for any $k \leq n$, $S_k(f)(x) \leq M_n^+(f)(x)$ and $S_k(f)(x) = f(x) + S_{k-1}(f)(\Theta(x))$, so $f(x) \geq S_k(f)(x) - S_{k-1}(f)(\Theta(x))$ and taking the max gives $f(x) \geq M_n^+(f)(x) - M_n^+(f)(\Theta(x))$.
If $M_n^+(f)(x) = 0$, all partial sums $S_k(f)(x) \leq 0$, so $S_{k-1}(f)(\Theta(x)) = S_k(f)(x) - f(x) \leq -f(x)$, giving $M_n^+(f)(\Theta(x)) \geq -f(x)$, hence $f(x) \geq -M_n^+(f)(\Theta(x)) = 0 - M_n^+(f)(\Theta(x))$.
On $\{M_n(f) > 0\}$, $M_n^+(f) = M_n(f) > 0$, and the inequality $f \geq M_n^+(f) - M_n^+(f) \circ \Theta$ holds.
Integrating over $\{M_n(f) > 0\}$:
\begin{align*}
\int_{\{M_n(f) > 0\}} f \, d\mu &\geq \int_{\{M_n(f) > 0\}} M_n^+(f) \, d\mu - \int_{\{M_n(f) > 0\}} M_n^+(f) \circ \Theta \, d\mu \\
&\geq \int_E M_n^+(f) \, d\mu - \int_E M_n^+(f) \circ \Theta \, d\mu = 0,
\end{align*}
where the second inequality uses: the first integral equals $\int_E M_n^+(f) \, d\mu$ (since $M_n^+(f) = 0$ on $\{M_n(f) \leq 0\}$), and the second integral is at most $\int_E M_n^+(f) \circ \Theta \, d\mu$ (integrating over a subset).
Measure preservation gives the final equality.
[/proof]
[/step]
[step:Derive the maximal ergodic inequality]
[claim:Maximal Ergodic Inequality]
For any $f \in L^1(\mu)$ and $\alpha \in \mathbb{R}$,
\begin{align*}
\alpha \cdot \mu\!\left(\left\{\sup_{n \geq 1} \frac{S_n(f)}{n} > \alpha\right\}\right) \leq \int_{\{\sup_n S_n(f)/n > \alpha\}} f \, d\mu.
\end{align*}
[/claim]
[proof]
Apply the maximal ergodic lemma to $g = f - \alpha$.
Then $S_n(g) = S_n(f) - n\alpha$, so $\{M_n(g) > 0\} = \{\max_{1 \leq k \leq n} (S_k(f) - k\alpha) > 0\}$.
The lemma gives $\int_{\{M_n(g) > 0\}} g \, d\mu \geq 0$, i.e.,
\begin{align*}
\int_{\{M_n(g) > 0\}} f \, d\mu \geq \alpha \cdot \mu(\{M_n(g) > 0\}).
\end{align*}
The sets $\{M_n(g) > 0\}$ increase as $n \to \infty$ to $\{\sup_{n \geq 1} S_n(f)/n > \alpha\}$.
Taking $n \to \infty$ and applying the [Monotone Convergence Theorem](/theorems/509) and continuity from below gives the result.
[/proof]
[/step]
[step:Show $\liminf S_n(f)/n = \limsup S_n(f)/n$ almost everywhere]
[claim:Liminf Equals Limsup Almost Everywhere]
$\displaystyle\liminf_{n \to \infty} \frac{S_n(f)}{n} = \limsup_{n \to \infty} \frac{S_n(f)}{n}$ $\mu$-almost everywhere.
[/claim]
[proof]
For rational $\alpha < \beta$, define
\begin{align*}
A_{\alpha,\beta} = \left\{ x \in E : \liminf_{n} \frac{S_n(f)(x)}{n} < \alpha < \beta < \limsup_{n} \frac{S_n(f)(x)}{n} \right\}.
\end{align*}
This set is $\Theta$-invariant.
On $A_{\alpha,\beta}$, $\limsup S_n(f)/n > \beta$, so the maximal inequality gives $\beta \cdot \mu(A_{\alpha,\beta}) \leq \int_{A_{\alpha,\beta}} f \, d\mu$.
Applying the inequality to $-f$ on $A_{\alpha,\beta}$ gives $\int_{A_{\alpha,\beta}} f \, d\mu \leq \alpha \cdot \mu(A_{\alpha,\beta})$.
Combining: $\beta \cdot \mu(A_{\alpha,\beta}) \leq \alpha \cdot \mu(A_{\alpha,\beta})$.
Since $\alpha < \beta$, this forces $\mu(A_{\alpha,\beta}) = 0$.
Taking a countable union over all rational $\alpha < \beta$, the set where $\liminf < \limsup$ has measure zero.
[/proof]
Define $\bar{f} = \lim_{n \to \infty} S_n(f)/n$, which exists $\mu$-a.e. by the claim above.
[/step]
[step:Verify the limit is invariant and integrable]
[claim:Limit Is Invariant And Integrable]
$\bar{f} \circ \Theta = \bar{f}$ $\mu$-a.e., and $\int_E |\bar{f}| \, d\mu \leq \int_E |f| \, d\mu$.
[/claim]
[proof]
Since $S_n(f) \circ \Theta = S_n(f \circ \Theta) = S_{n+1}(f) - f$, we have
\begin{align*}
\bar{f} \circ \Theta = \lim_n \frac{S_n(f) \circ \Theta}{n} = \lim_n \frac{S_{n+1}(f) - f}{n} = \lim_n \frac{S_{n+1}(f)}{n} = \bar{f} \quad \mu\text{-a.e.},
\end{align*}
where the last equality holds because $S_{n+1}(f)/n = \frac{n+1}{n} \cdot S_{n+1}(f)/(n+1) \to \bar{f}$.
For integrability: $|S_n(f)|/n \leq \frac{1}{n}\sum_{k=0}^{n-1} |f| \circ \Theta^k = S_n(|f|)/n$.
By [Fatou's Lemma](/theorems/510),
\begin{align*}
\int_E |\bar{f}| \, d\mu \leq \liminf_n \int_E \frac{|S_n(f)|}{n} \, d\mu \leq \liminf_n \frac{1}{n} \sum_{k=0}^{n-1} \int_E |f| \circ \Theta^k \, d\mu = \int_E |f| \, d\mu,
\end{align*}
where the last equality uses $\int |f| \circ \Theta^k \, d\mu = \int |f| \, d\mu$ for all $k$ (measure preservation).
[/proof]
[/step]
[step:Identify the limit as a constant when $\Theta$ is ergodic]
If $\Theta$ is ergodic, every invariant function is a.e. constant (since the level sets $\{\bar{f} > c\}$ are invariant and must have measure $0$ or full measure).
So $\bar{f} = c$ a.e.
When $\mu(E) < \infty$, integrating $S_n(f)/n$ and using measure preservation gives $\int_E S_n(f)/n \, d\mu = \int_E f \, d\mu$ for all $n$.
By [Fatou's Lemma](/theorems/510) applied to $\bar{f}^+$ and $\bar{f}^-$, $c \cdot \mu(E) = \int_E f \, d\mu$, so $c = \frac{1}{\mu(E)}\int_E f \, d\mu$.
[/step]