Difference of Positive and Negative Parts

Theorem
Let $X$ be a set, and let $f: X \to \overline{\R}$ be an extended real-valued function.

Let $f^+, f^-: X \to \overline{\R}$ be the positive and negative parts of $f$, respectively.

Then $f = f^+ - f^-$.

Proof
Let $x\in X$. We consider four distinct cases for the value of $f(x)$ in $\overline{\R}$.


 * $f(x)=-\infty$
 * By ordering on extended reals,
 * $f^+(x)=\max \left\{{0, f \left({x}\right)}\right\}=\max \left\{{0, -\infty}\right\}=0$ and,
 * $f^-(x)=-\min \left\{{0, f \left({x}\right)}\right\}=-\min \left\{{0, -\infty}\right\}=+\infty$
 * By extended real subtraction, $f^+(x)-f^-(x)=0-\infty=-\infty=f(x)$


 * $f(x)\in(-\infty . . 0)$
 * Since $f(x)<0$,
 * $f^+(x)=\max \left\{{0, f \left({x}\right)}\right\}=0$, and
 * $f^-(x)=-\min \left\{{0, f \left({x}\right)}\right\}=-f(x)$
 * Then, $f^+(x)-f^-(x)=0-(-f(x))=f(x)$


 * $f(x)\in[0 . . \infty)$
 * Since $f(x)\geq 0$,
 * $f^+(x)=\max \left\{{0, f \left({x}\right)}\right\}=f(x)$, and
 * $f^-(x)=-\min \left\{{0, f \left({x}\right)}\right\}=0$
 * Then, $f^+(x)-f^-(x)=f(x)-0=f(x)$


 * $f(x)=-\infty$
 * By ordering on extended reals,
 * $f^+(x)=\max \left\{{0, f \left({x}\right)}\right\}=\max \left\{{0, +\infty}\right\}=+\infty$ and,
 * $f^-(x)=-\min \left\{{0, f \left({x}\right)}\right\}=-\min \left\{{0, +\infty}\right\}=0$
 * By extended real subtraction, $f^+(x)-f^-(x)=+\infty-0=+\infty=f(x)$

In all cases, $f^+(x)-f^-(x)=f(x)$.

As $x\in X$ was arbitrary, we may conclude that $\forall x\in X:f^+(x)-f^-(x)=f(x)$, hence,


 * $f = f^+ - f^-$.