Expected value as integral of survival function
Let $T$ be a positive random variable, $S(t)=\operatorname{P}(T\geq t)$. Prove that $$E[T]=\int^\infty_0 S(t)dt.$$ I have tried this unsuccessfully.
$$A_t=[T\geqslant t]\qquad S(t)=E[\mathbf 1_{A_t}]\qquad T=\int_0^\infty\mathbf 1_{A_t}\,\mathrm dt$$
Consider for any $n > 0$, $$\begin{align*} \int_{t=0}^n t f_T(t) \, dt &= \int_{t=0}^n \left(\int_{s=0}^t \, ds\right) f_T(t) \, dt \\ &= \int_{t=0}^n \int_{s=0}^t f_T(t) \, ds \, dt \\ &= \int_{s=0}^n \int_{t=s}^n f_T(t) \, dt \, ds \\ &= \int_{s=0}^n F_T(n) - F_T(s) \, ds. \end{align*}$$ Then as $n \to \infty$, $F_T(n) \to 1$ and we obtain $${\rm E}[T] = \int_{s=0}^\infty 1 - F_T(s) \, ds = \int_{s=0}^\infty S_T(s) \, ds.$$
Another way of thinking:
Consider $n>0$, integration by parts we have
$\int_{0}^{n}xF(dx)=nF(n)-\int_{0}^{n}F(x)dx = n-nS(n)-\int_{0}^{n}(1-S(x))dx$
$=\int_{0}^{n}S(x)dx-nS(n)$
where $S(x)=1-F(x)$ is the survival function.
As $n\to \infty$, the second part converges to zero. To see this, notice that $S(x)=\int_{x}^{\infty}f(t)dt$, providing $E(X)$ do exist,
$\lim_{x\to \infty}xS(x)=\lim_{x\to \infty} x\int_{x}^{\infty}f(t)dt \leq \lim_{x\to \infty} \int_{x}^{\infty}tf(t)dt=0$
Using integration by parts and the fact that $f(t)dt=dF(t)=-d(1-F(t))=-dS(t)$ $$ \begin{align*} E(T) = \int_0^\infty t f_T(t) \, dt &= \int_0^\infty -t\,dS(t) \\ &= \left. -tS(t) \right|_0^\infty - \int_0^\infty S(t) \, d(-t) \\ &= 0 + \int_0^\infty S(t) \, dt \\ &= \int_0^\infty S(t) \, dt. \end{align*} $$