[proofplan]
We prove both implications directly from the definitions. If $f$ is convex, then taking two points above the graph of $f$ and forming their convex combination preserves the required height inequality, so the convex combination remains in the epigraph. Conversely, if the epigraph is convex, then points just above $(x,f(x))$ and $(y,f(y))$ have convex combinations in the epigraph; sending the excess height to zero gives the convexity inequality for finite values, while cases involving $+\infty$ are immediate from the extended-real order.
[/proofplan]
[step:Show that convexity of $f$ forces convexity of its epigraph]
Assume that $f$ is convex. Let $(x,r),(y,s) \in \operatorname{epi} f$, where $x,y \in \mathbb{R}^n$ and $r,s \in \mathbb{R}$. Let $t \in [0,1]$. Since $(x,r),(y,s) \in \operatorname{epi} f$, we have $f(x) \le r$ and $f(y) \le s$. By convexity of $f$,
\begin{align*}
f(tx+(1-t)y) \le t f(x) + (1-t) f(y).
\end{align*}
Because $t \ge 0$ and $1-t \ge 0$, the inequalities $f(x) \le r$ and $f(y) \le s$ imply
\begin{align*}
t f(x) + (1-t) f(y) \le tr + (1-t)s.
\end{align*}
Therefore
\begin{align*}
f(tx+(1-t)y) \le tr + (1-t)s.
\end{align*}
Thus
\begin{align*}
t(x,r)+(1-t)(y,s) = (tx+(1-t)y, tr+(1-t)s) \in \operatorname{epi} f.
\end{align*}
Since the two epigraph points and the parameter $t \in [0,1]$ were arbitrary, $\operatorname{epi} f$ is convex.
[guided]
Assume that $f$ is convex. To prove that $\operatorname{epi} f$ is convex, we must show that every convex combination of two points in $\operatorname{epi} f$ is again in $\operatorname{epi} f$.
Let $(x,r),(y,s) \in \operatorname{epi} f$, with $x,y \in \mathbb{R}^n$ and $r,s \in \mathbb{R}$, and let $t \in [0,1]$. The condition $(x,r) \in \operatorname{epi} f$ means exactly that the height $r$ lies above the value $f(x)$:
\begin{align*}
f(x) \le r.
\end{align*}
Similarly, $(y,s) \in \operatorname{epi} f$ gives
\begin{align*}
f(y) \le s.
\end{align*}
Now use convexity of $f$ at the points $x$ and $y$ with weight $t$. This gives
\begin{align*}
f(tx+(1-t)y) \le t f(x) + (1-t) f(y).
\end{align*}
The right-hand side is bounded above by the corresponding convex combination of the heights $r$ and $s$, because $t$ and $1-t$ are nonnegative:
\begin{align*}
t f(x) + (1-t) f(y) \le tr + (1-t)s.
\end{align*}
Combining the two inequalities gives
\begin{align*}
f(tx+(1-t)y) \le tr + (1-t)s.
\end{align*}
This final inequality says precisely that the point
\begin{align*}
(tx+(1-t)y, tr+(1-t)s)
\end{align*}
belongs to $\operatorname{epi} f$. But this point is the convex combination
\begin{align*}
t(x,r)+(1-t)(y,s).
\end{align*}
Thus every convex combination of two points of $\operatorname{epi} f$ remains in $\operatorname{epi} f$, so $\operatorname{epi} f$ is convex.
[/guided]
[/step]
[step:Show that convexity of the epigraph forces convexity of $f$]
Assume that $\operatorname{epi} f$ is convex. Let $x,y \in \mathbb{R}^n$ and let $t \in [0,1]$. We prove
\begin{align*}
f(tx+(1-t)y) \le t f(x) + (1-t) f(y).
\end{align*}
If $t=0$ or $t=1$, the inequality is an equality in the extended-real order. Hence assume $0<t<1$.
If $f(x)=+\infty$ or $f(y)=+\infty$, then the right-hand side equals $+\infty$, so the desired inequality holds. It remains to consider the case $f(x),f(y) \in \mathbb{R}$.
Let $\varepsilon>0$. Define the real heights
\begin{align*}
r_\varepsilon := f(x)+\varepsilon
\end{align*}
and
\begin{align*}
s_\varepsilon := f(y)+\varepsilon.
\end{align*}
Then $(x,r_\varepsilon),(y,s_\varepsilon) \in \operatorname{epi} f$. Since $\operatorname{epi} f$ is convex,
\begin{align*}
(tx+(1-t)y, tr_\varepsilon+(1-t)s_\varepsilon) \in \operatorname{epi} f.
\end{align*}
Therefore
\begin{align*}
f(tx+(1-t)y) \le tr_\varepsilon+(1-t)s_\varepsilon.
\end{align*}
Substituting the definitions of $r_\varepsilon$ and $s_\varepsilon$ gives
\begin{align*}
f(tx+(1-t)y) \le t f(x)+(1-t)f(y)+\varepsilon.
\end{align*}
Since this holds for every $\varepsilon>0$, the order completeness of $\mathbb{R}$ gives
\begin{align*}
f(tx+(1-t)y) \le t f(x)+(1-t)f(y).
\end{align*}
Thus $f$ is convex.
[guided]
Assume that $\operatorname{epi} f$ is convex. We want to recover the convexity inequality for $f$, so fix arbitrary points $x,y \in \mathbb{R}^n$ and a weight $t \in [0,1]$.
The desired inequality is
\begin{align*}
f(tx+(1-t)y) \le t f(x) + (1-t) f(y).
\end{align*}
When $t=0$, this reads $f(y) \le f(y)$, and when $t=1$, it reads $f(x) \le f(x)$. Hence the endpoint cases hold. We now assume $0<t<1$.
If $f(x)=+\infty$ or $f(y)=+\infty$, then because $t>0$ and $1-t>0$, the extended-real expression $t f(x)+(1-t)f(y)$ is $+\infty$. The inequality then holds automatically in $(-\infty,+\infty]$. Thus the only substantive case is
\begin{align*}
f(x), f(y) \in \mathbb{R}.
\end{align*}
Why do we use heights slightly above $f(x)$ and $f(y)$ rather than the heights $f(x)$ and $f(y)$ themselves? The epigraph is a subset of $\mathbb{R}^n \times \mathbb{R}$, so its second coordinate must be real. In the present finite-valued case the exact heights are real, but using a positive excess $\varepsilon$ also makes the limiting argument explicit and matches the extended-real formulation.
Let $\varepsilon>0$. Define
\begin{align*}
r_\varepsilon := f(x)+\varepsilon
\end{align*}
and
\begin{align*}
s_\varepsilon := f(y)+\varepsilon.
\end{align*}
These are [real numbers](/page/Real%20Numbers), and they lie above the corresponding function values. Hence
\begin{align*}
(x,r_\varepsilon),(y,s_\varepsilon) \in \operatorname{epi} f.
\end{align*}
Since $\operatorname{epi} f$ is convex, the convex combination of these two epigraph points also belongs to $\operatorname{epi} f$:
\begin{align*}
t(x,r_\varepsilon)+(1-t)(y,s_\varepsilon) \in \operatorname{epi} f.
\end{align*}
Computing this convex combination in $\mathbb{R}^n \times \mathbb{R}$ gives
\begin{align*}
t(x,r_\varepsilon)+(1-t)(y,s_\varepsilon) = (tx+(1-t)y, tr_\varepsilon+(1-t)s_\varepsilon).
\end{align*}
Membership in the epigraph now translates back into the height inequality
\begin{align*}
f(tx+(1-t)y) \le tr_\varepsilon+(1-t)s_\varepsilon.
\end{align*}
Substitute the definitions of $r_\varepsilon$ and $s_\varepsilon$:
\begin{align*}
f(tx+(1-t)y) \le t(f(x)+\varepsilon)+(1-t)(f(y)+\varepsilon).
\end{align*}
Since $t+(1-t)=1$, this becomes
\begin{align*}
f(tx+(1-t)y) \le t f(x)+(1-t)f(y)+\varepsilon.
\end{align*}
This inequality holds for every $\varepsilon>0$. Therefore the left-hand side is bounded above by every number strictly larger than $t f(x)+(1-t)f(y)$. By the order completeness of $\mathbb{R}$,
\begin{align*}
f(tx+(1-t)y) \le t f(x)+(1-t)f(y).
\end{align*}
Since $x$, $y$, and $t$ were arbitrary, $f$ is convex.
[/guided]
[/step]
[step:Conclude the equivalence]
The first step proves that convexity of $f$ implies convexity of $\operatorname{epi} f$. The second step proves that convexity of $\operatorname{epi} f$ implies convexity of $f$. Therefore $f$ is convex if and only if $\operatorname{epi} f$ is a convex subset of $\mathbb{R}^{n+1}$.
[/step]