\section{Conjugate Functions}
\label{section:legendre}

\begin{definition}[Affine Minorant]
\label{definition:affine-minorant}
    Let $\dpn{E, F}{\lambda}$ be a duality over $\real$, $f: E \to (-\infty, \infty]$, and $(\phi, \alpha) \in F \times \real$, then the pair $(\phi, \alpha)$ is an \textbf{affine minorant} of $f$, denoted $(\phi, \alpha) \le f$, if
    \[
    \dpn{x, \phi}{\lambda} - \alpha \le f(x) \quad \forall x \in E
    \]
\end{definition}


\begin{definition}[Conjugate Function]
\label{definition:conjugate-function}
    Let $\dpn{E, F}{\lambda}$ be a duality over $\real$ and $f: E \to (-\infty, \infty]$ with $f \ne \infty$, then for each $\phi \in F$, 
    \[
    \sup_{x \in E}\dpn{x, \phi}{\lambda} - f(x) = \inf\bracsn{\alpha \in \real| (\phi, \alpha) \le f}
    \]

    The mapping
    \[
    f^*: F \to (-\infty, \infty] \quad \phi \mapsto \sup_{x \in E}\dpn{x, \phi}{\lambda} - f(x)
    \]

    is the \textbf{conjugate function} of $f$ with respect to the duality $\dpn{E, F}{\lambda}$. 
\end{definition}
\begin{proof}
    Fix $\phi \in F$. Let $\alpha \in  \real$ such that $\dpn{x, \phi}{\lambda} - \alpha \le f(x)$ for all $x \in E$, then for any $x \in E$,  
    \[
    \dpn{x, \phi}{\lambda} - f(x) \le \dpn{x, \phi}{\lambda} - \dpn{x, \phi}{\lambda} + \alpha = \alpha
    \]

    so
    \[
    \sup_{x \in E}\dpn{x, \phi}{\lambda} - f(x) \le \inf\bracsn{\alpha \in \real| (\phi, \alpha) \le f}
    \]

    On the other hand, suppose that $\alpha = \sup_{x \in E} \dpn{x, \phi}{\lambda} - f(x) < \infty$, then
    \[
    \dpn{x, \phi}{\lambda} - \alpha \le f(x)
    \]

    for all $x \in E$. Therefore
    \[
    \sup_{x \in E}\dpn{x, \phi}{\lambda} - f(x) = \inf\bracsn{\alpha \in \real| (\phi, \alpha) \le f}
    \]
\end{proof}
\begin{lemma}
\label{lemma:conjugate-minorant}
    Let $\dpn{E, F}{\lambda}$ be a duality over $\real$ and $f: E \to (-\infty, \infty]$, then the following are equivalent:
    \begin{enumerate}
        \item $f^* \ne \infty$. 
        \item There exists $(\phi, \alpha) \in F \times \real$ with $(\phi, \alpha) \le f$. 
    \end{enumerate}
\end{lemma}
\begin{proof}
    (1) $\Rightarrow$ (2): Let $\phi \in \bracsn{f^* < \infty}$, then by \autoref{definition:conjugate-function}, $(\phi, f^*(\phi)) \le f$. 

    (2) $\Rightarrow$ (1): By \autoref{definition:conjugate-function}, $f^*(\phi) \le \alpha$.   
\end{proof}


\begin{lemma}
\label{lemma:conjugate-function-gymnatics}
    Let $\dpn{E, F}{\lambda}$ be a duality over $\real$ and $f, g: E \to (-\infty, \infty]$ with $f, g \ne \infty$, then
    \begin{enumerate}
        \item $f^*$ is convex and lower semicontinuous. 
        \item If $f \le g$, then $f^* \ge g^*$. 
        \item If $f^* \ne \infty$, then $f^{**} \le f$. 
    \end{enumerate}
\end{lemma}
\begin{proof}
    (1): By \autoref{proposition:convex-extension} and \autoref{proposition:semicontinuous-properties}. 

    (3): For each $x \in E$ and $\phi \in F$, 
    \begin{align*}
        \dpn{x, \phi}{\lambda} - f^*(\phi) &= \dpn{x, \phi}{\lambda} - \braks{\sup_{z \in E}\dpn{z, \phi}{\lambda} - f(z)} \\
        &= \dpn{x, \phi}{\lambda} + \braks{\inf_{z \in E}f(z) - \dpn{z, \phi}{\lambda}} \\
        &\le \dpn{x, \phi}{\lambda} + f(x) - \dpn{x, \phi}{\lambda} = f(x)
    \end{align*}

    As the above holds for all $\phi \in F$, $f^{**} \le f$.     
\end{proof}

\begin{theorem}[Fenchel's Inequality]
\label{theorem:fenchel-inequality}
    Let $\dpn{E, F}{\lambda}$ be a duality over $\real$ and $f: E \to (-\infty, \infty]$ with $f \ne \infty$, then for any $x \in E$ and $\phi \in F$, 
    \[
    \dpn{x, \phi}{\lambda} \le f(x) + f^*(\phi)
    \]

    with equality if and only if $\phi \in \partial f(x)$. 
\end{theorem}
\begin{proof}
    Let $x \in E$ and $\phi \in F$. Assume without loss of generality that $f(x) < \infty$, then
    \[
        f(x) + f^*(\phi) \ge f(x) + \dpn{x, \phi}{\lambda} - f(x) = \dpn{x, \phi}{\lambda}
    \]

    Now let $x \in E$ and $\phi \in F$ such that $\dpn{x, \phi}{\lambda} = f(x) + f^*(\phi)$, then $f(x), f^*(\phi) < \infty$ and
    \begin{align*}
        f(x) + f^*(\phi) &= \dpn{x, \phi}{\lambda} \\
        f^*(\phi) &= \dpn{x, \phi}{\lambda} - f(x) 
    \end{align*}

    By definition, 
    \[
    \dpn{x, \phi}{\lambda} - f(x)  = f^*(\phi) = \sup_{h \in E}\dpn{x+h, \phi}{\lambda} - f(x+h)
    \]

    so for every $h \in E$, 
    \begin{align*}
        \dpn{x, \phi}{\lambda} - f(x) &\ge \dpn{x+h, \phi}{\lambda} - f(x+h) \\
        f(x + h) - f(x) &\ge \dpn{h, \phi}{\lambda} 
    \end{align*}

    Thus $\phi$ satisfies the subgradient inequality, and $\phi \in \partial f(x)$. 

    On the other hand, if $f(x) < \infty$ and $\phi \in \partial f(x)$, then $f(x + h) - f(x) \ge \dpn{h, \phi}{\lambda}$ for all $h \in E$, and
    \begin{align*}
    f^*(\phi) &= \sup_{h \in E}\dpn{x+h, \phi}{\lambda} - f(x+h) = \dpn{x, \phi}{\lambda} - f(x) \\
    f^*(\phi) + f(x) &=  \dpn{x, \phi}{\lambda}
    \end{align*}
    
\end{proof}

\begin{lemma}
\label{lemma:closed-convex-epigraph}
    Let $E$ be a locally convex space over $\real$ and $f: E \to (-\infty, \infty]$ with $f \ne \infty$, then for each $(x, \alpha) \in \ol{\text{Conv}}(\text{epi}(f))$, $\bracs{x} \times [\alpha, \infty) \subset \ol{\text{Conv}}(\text{epi}(f))$. 
\end{lemma}
\begin{proof}
    Let
    \[
    A = \bracsn{(\phi, \alpha) \in \ol{\text{Conv}}(\text{epi}(f))| \bracs{x} \times [\alpha, \infty) \subset \ol{\text{Conv}}(\text{epi}(f))}
    \]

    For each $(x, \alpha), (y, \beta) \in A$, $t \in [0, 1]$, and $\gamma \ge (1 - t)\alpha + t\beta$, there exists $\alpha' \ge \alpha$ and $\beta' \ge \beta$ such that $\gamma = (1 - t)\alpha' + t\beta'$. In which case, 
    \[
    ((1 - t)x + ty, \gamma) = ((1 - t)x + ty, (1 - t)\alpha' + t\beta') \in \ol{\text{Conv}}(\text{epi}(f))
    \]

    so $\bracs{(1 - t)x + ty} \times [\gamma, \infty) \subset \ol{\text{Conv}}(\text{epi}(f))$, $(1 - t)(x + \alpha) + t(y, \beta) \in A$, and $A$ is convex. 

    Let $(x, \alpha) \in \ol A$, then there exists a net $\langle (x_\gamma, \alpha_\gamma) \rangle_{\gamma \in C} \subset A$ with $(x_\gamma, \alpha_\gamma) \to (x, \alpha)$. In which case, for each $r > 0$, $\langle (x_\gamma, \alpha_\gamma + r) \rangle_{\gamma \in C} \subset A$ and $(x_\gamma, \alpha_\gamma + r) \to (x, \alpha + r)$, so $(x, \alpha + r) \in \ol{\text{Conv}}(\text{epi}(f))$ and
    \[
    \bracs{x} \times [\alpha, \infty) \subset \ol{\text{Conv}}(\text{epi}(f))
    \]

    Thus $(x, \alpha) \in A$ and $A$ is closed. 

    Since $A$ is a closed convex set containing $\text{epi}(f)$, $A = \ol{\text{Conv}}(\text{epi}(f))$. 
\end{proof}

\begin{lemma}[Almost Subgradient]
\label{lemma:lsc-affine-minorant}
    Let $\dpn{E, F}{\lambda}$ be a duality over $\real$, $f: E \to (-\infty, \infty]$ be convex and $\sigma(E, F)$-lower semicontinuous, $x \in \bracs{f < \infty}$, and $\alpha < f(x)$, then there exists $(\phi, \gamma) \in E \times \real$ such that:
    \begin{enumerate}
        \item $(\phi, \gamma) \le f$. 
        \item $\dpn{x, \phi}{\lambda} - \gamma = \alpha$. 
    \end{enumerate}

    In particular, $f^{*} \ne \infty$. 
\end{lemma}
\begin{proof}
    (1): Since $f$ is convex and $\sigma(E, F)$-lower semicontinuous, $\text{epi}(f)$ is $\sigma(E \times \real, F \times \real)$-closed and convex. By the \hyperref[Hahn-Banach Theorem]{theorem:hahn-banach-geometric-2}, there exists $\phi \in F$ and $\mu \in \real$ such that
    \[
    \sup_{(y, \beta) \in \text{epi}(f)}\dpn{y, \phi}{E} - \mu \beta < \dpn{x, \phi}{E} - \mu \alpha
    \]

    For any $(y, \beta) \in \text{epi}(f)$, $\beta$ may be arbitrarily large, $\mu \ge 0$. In particular, since $(x, f(x)) \in \text{epi}(f)$, the strict inequality implies that $\mu > 0$. Thus for each $y \in \bracs{f < \infty}$, 
    \begin{align*}
        \dpn{x, \phi}{E} - \mu\alpha &> \dpn{y, \phi}{E} - \mu f(y) \\
        -\dpn{y, \phi}{E} + \dpn{x, \phi}{E} - \mu\alpha &> -\mu f(y)\\
        \dpn{y, \mu^{-1}\phi}{E} - \dpn{x, \mu^{-1}\phi}{E} + \alpha &< f(y)
    \end{align*}

    so $(\mu^{-1}\phi, \dpn{x, \mu^{-1}\phi}{E} - \alpha) \le f$ and
    \[
    \dpn{x, \mu^{-1}\phi}{E} - \dpn{x, \mu^{-1}\phi}{E} + \alpha = \alpha
    \]
\end{proof}


\begin{theorem}[Fenchel-Moreau]
\label{theorem:fenchel-moreau}
    Let $\dpn{E, F}{\lambda}$ be a duality over $\real$, and $f: E \to (-\infty, \infty]$ with $f \ne \infty$ and $f^{*} \ne \infty$, then:
    \begin{enumerate}
        \item For each $x \in E$,  
        \[
        f^{**}(x) = \sup\bracs{\dpn{x, \phi}{\lambda} - \alpha|(\phi, \alpha) \in F \times \real, (\phi, \alpha) \le f}
        \]
        \item $\text{epi}(f^{**})$ is the $\sigma(E \times \real, F \times \real)$-closed convex hull of $\text{epi}(f)$. 
        \item $f^{**}$ is the greatest convex and $\sigma(E, F)$-lower semicontinuous function bounded above by $f$. 
        \item $f = f^{**}$ if and only if $f$ is convex and $\sigma(E, F)$-lower semicontinuous.  
    \end{enumerate}
\end{theorem}
\begin{proof}
    (1): Let $\phi \in F$ such that $f^*(\phi) < \infty$, then for each $x \in E$, 
    \[
    \dpn{x, \phi}{\lambda} - f^*(\phi) \le f(x)
    \]

    so $\dpn{\cdot, \phi}{\lambda} - f^*(\phi) \le f$, and
    \begin{align*}
    f^{**}(x) &= \sup_{\phi \in F} \dpn{x, \phi}{\lambda} - f^*(\phi) = \sup_{\substack{\phi \in F \\ f^*(\phi) < \infty}} \dpn{x, y}{\lambda} - f^*(\phi) \\
    &\le \sup\bracs{\dpn{x, \phi}{\lambda} - \alpha|(\phi, \alpha) \in F \times \real, (\phi, \alpha) \le f}
    \end{align*}
    
    On the other hand, let $\phi \in F$ and $\alpha \in \real$ such that $(\phi, \alpha) \le f$, then $f^*(\phi) \le \alpha$, and
    \[
    f^{**}(x) \ge \dpn{x, \phi}{\lambda} - f^*(\phi) \ge \dpn{x, \phi}{\lambda} - \alpha
    \]

    Therefore
    \[
        f^{**}(x) \ge \sup\bracs{\dpn{x, \phi}{\lambda} - \alpha| \phi \in F, \alpha \in \real, \dpn{\cdot, y}{\lambda} - \alpha \le f}
    \]

    (2): By \autoref{lemma:conjugate-function-gymnatics}, $f^{**}$ is lower semicontinuous and convex with $f^{**} \le f$, so $\text{epi}(f^{**}) \supset \text{epi}(f)$ and $\text{epi}(f^{**}) \supset \ol{\text{Conv}}(\text{epi}(f))$. Thus it is sufficient to show that $\text{epi}(f^{**}) \subset \ol{\text{Conv}}(\text{epi}(f))$, or equivalently, 
    \[
    E \times \real \setminus \ol{\text{Conv}}(\text{epi}(f)) \subset E \times \real \setminus \text{epi}(f)
    \]
    
    To this end, let $A = \ol{\text{Conv}}(\text{epi}(f))$ and $(x, \alpha) \in E \times \real \setminus A$. By the \hyperref[Hahn-Banach Theorem]{theorem:hahn-banach-geometric-2}, there exists $\phi \in F$ and $\mu \in \real$ such that
    \[
    \sup_{(y, \beta) \in A}\dpn{y, \phi}{\lambda} - \mu \beta < \dpn{x, \phi}{\lambda} - \mu \alpha
    \]

    Given that the inequality is strict, there exists $\alpha_0 \in (\alpha, \infty)$ such that
    \[
    \sup_{(y, \beta) \in A}\dpn{y, \phi}{\lambda} - \mu \beta \le \dpn{x, \phi}{\lambda} - \mu\alpha_0
    \]

    For any $(y, \beta) \in A$, $\beta$ may be arbitrarily large by \autoref{lemma:closed-convex-epigraph}, so $\mu \ge 0$. 

    In the case that $\mu > 0$, for each $y \in \bracs{f < \infty}$, 
    \begin{align*}
        \dpn{x, \phi}{\lambda} - \mu\alpha_0 &\ge \dpn{y, \phi}{\lambda} - \mu f(y) \\
        -\dpn{y, \phi}{\lambda} + \dpn{x, \phi}{\lambda} - \mu\alpha_0 &\le - \mu f(y) \\
        \dpn{y, \mu^{-1}\phi}{\lambda} - \dpn{x, \mu^{-1}\phi}{\lambda} + \alpha_0 &\le f(y)
    \end{align*}

    so $(\mu^{-1}\phi, \dpn{x, \mu^{-1}\phi}{\lambda} - \alpha_0) \le f$ and
    \[
    f^{**}(x) \ge \dpn{x, \mu^{-1}\phi}{\lambda} - \dpn{x, \mu^{-1}\phi}{\lambda} + \alpha_0 > \alpha
    \]

    Now suppose that $\mu = 0$. Given that $f^* \ne \infty$, there exists at least one pair $(\phi_0, \gamma_0) \in F \times \real$ such that $(\phi_0, \gamma_0) \le f$. Let
    \[
    \gamma = \sup_{(y, \beta) \in A}\dpn{y, \phi}{\lambda} < \dpn{x, \phi}{\lambda}
    \]

    For each $t > 0$, let $\Phi_t = \phi_0 + t\phi$ and $\Gamma_t = \gamma_0 + t\gamma$, then for each $y \in \bracs{f < \infty}$, 
    \[
    \dpn{y, \Phi_t}{\lambda} - \Gamma_t \le f(y) + t\underbrace{(\dpn{y, \phi}{\lambda} - \gamma)}_{\le 0} \le f(y)
    \]

    so $(\Phi_t, \Gamma_t) \le f$. By (1), 
    \[
        f^{**}(x) \ge \dpn{x, \Phi_t}{\lambda} - \Gamma_t = \dpn{x, \phi_0}{\lambda} - \gamma_0  + t\underbrace{(\dpn{x, \phi}{\lambda} - \gamma)}_{> 0}
    \]

    As the above holds for all $t > 0$, $f^{**}(x) = \infty > \alpha$. 
    
    Thus $f^{**}(x) > \alpha$ and $(x, \alpha) \not\in \text{epi}(f^{**})$ for all $(x, \alpha) \in E \times \real \setminus A$. Therefore
    \[
    E \times \real \setminus A \subset E \times \real \setminus \text{epi}(f^{**})
    \]
    
    and $\text{epi}(f^{**}) \subset \ol{\text{Conv}}(\text{epi}(f))$. 

     
\end{proof}

\begin{corollary}
\label{corollary:separable-legendre}
    Let $\dpn{E, F}{\lambda}$ be a duality over $\real$ and $f: E \to (-\infty, \infty]$ with $f \ne \infty$ be convex and lower semicontinuous, then there exists $\seq{(\phi_n, \alpha_n)} \subset F \times \real$ such that for each $x \in E$, 
    \[
    f(x) = \sup_{n \in \natp} \dpn{x, \phi_n}{\lambda} - \alpha_n
    \]
\end{corollary}
\begin{proof}
    For each $(\phi, \alpha) \in F \times \real$, denote $(\phi, \alpha) \le f$ if $\dpn{\cdot, \phi}{\lambda} - \alpha \le f$. By the \hyperref[Fenchel-Moreau Theorem]{theorem:fenchel-moreau},  
    \[
    f(x) = f^{**}(x) = \sup\bracs{\dpn{x, \phi}{\lambda} - \alpha|(\phi, \alpha) \in F \times \real, (\phi, \alpha) \le f}
    \]

    for all $x \in E$. By \autoref{proposition:separable-dual},
    \[
    S = \bracs{(\phi, \alpha) \in F \times \real| (\phi, \alpha) \le f}
    \]

    is separable with respect to $\sigma(F \times \real, E \times \real)$. Therefore there exists $\seq{(\phi_n, \alpha_n)} \subset S$ such that for each $x \in E$, 
    \[
    f(x) = \sup_{n \in \natp} \dpn{x, \phi_n}{\lambda} - \alpha_n
    \]
\end{proof}


