Sorry if the title of this question is vague--I'm open to suggestions. For this question, we're working in a probability space $(X, \mathcal{M}, \mu)$. In a proof of "ergodic Roth's theorem" given near the ends of this blog post and this paper, we use the Koopman-von Neumann lemma to decompose a characteristic function for a set of positive measure $A$, which we'll denote by $1_{A}$. So, we get that $1_{A} = f + g$ where $f$ is compact and $g$ is weak-mixing. Compactness of $f$ means $\lbrace U_{T}^{i}f : i \in \mathbb{Z} \rbrace \text{ is precompact in } L^{2}(X, \mu)$, where $U_{T}^{i}f(x) := f(T^{i}(x))$ for $T$ a measure-preserving transformation. The weak-mixing property of $g$ means $$ \lim_{N \to \infty} \frac{1}{N} \sum_{i=1}^{N-1} \left| \int_{X} f (U_{T}^{i}g) \ d \mu \right| = 0 \hspace{0.5cm} \text{ for all } f \in L^{2}(X,\mu). $$ These definitions were taken from the paper. It's worth noting that the definitions of weak-mixing functions are pretty different depending on which source you look at (the blog post replaces that arbitrary $f \in L^{2}$ with $g$ itself). Now, in order to use another lemma, we'd really like to have $f(x) \in (0,1]$ almost everywhere. The argument given in the blog post is that if $f(x) \notin (0,1]$ a.e., then $\max (\min(f,1),0)$ is also compact and would be closer in norm to $1_{A}$.
Firstly, I don't see why $\max (\min(f,1),0)$ would necessarily be closer to $1_{A}$ in norm. Secondly, even if it were, I don't see why that matters as we still have to care about how $g$ looks like. I think I might be missing a basic property of weak-mixing functions. Any insight is appreciated.
Ok, nevermind. Just forgot (also to mention) that the space of compact functions is the orthogonal complement to the space of weak-mixing functions, so $f$ is necessarily the closest compact function in norm to $1_{A}$. Also I now believe that $\max(\min(f,1),0)$ is closer in norm to $1_{A}$ than $f$ if $f(x) \notin [0,1]$ a.e. (not bad).