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$.

Consider the following four cases for the value of $f(x)$ in $\overline{\R}$:


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


 * $f \left({x}\right) \in \left({-\infty \,.\,.\, 0}\right)$
 * Since $f \left({x}\right) < 0$, it follows that:
 * $f^+ \left({x}\right) = \max \left\{{0, f \left({x}\right)}\right\} = 0$
 * $f^- \left({x}\right) = - \min \left\{{0, f \left({x}\right)}\right\}= - f \left({x}\right)$
 * Thence it immediately follows that:
 * $f^+ \left({x}\right) - f^- \left({x}\right) = 0 - \left({- f \left({x}\right)}\right) = f \left({x}\right)$


 * $f \left({x}\right) \in \left[{0 \,.\,.\, \infty}\right)$
 * Since $f \left({x}\right) \geq 0$, we obtain:
 * $f^+ \left({x}\right) = \max \left\{{0, f \left({x}\right)}\right\} = f \left({x}\right)$
 * $f^- \left({x}\right) = - \min \left\{{0, f \left({x}\right)}\right\} = 0$
 * Then, these imply immediately imply:
 * $f^+ \left({x}\right) - f^- \left({x}\right) = f \left({x}\right) - 0 = f \left({x}\right)$


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

In all cases, $f^+ \left({x}\right) - f^- \left({x}\right) = f \left({x}\right)$.

As $x\in X$ was arbitrary, we may conclude that:


 * $\forall x \in X: f^+ \left({x}\right) - f^- \left({x}\right) = f \left({x}\right)$

That is, we have shown:


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