\subsection{Peak Estimation and Occupation Measures}
\label{sec:peak}

The standard (no uncertainty) peak estimation setting involves a trajectory $x(t \mid x_0)$ starting at the initial point $x_0 \in X_0 \subset X$ evolving according to dynamics $\dot{x}(t) = f(t, x(t))$ in a space $X$. The program to find the maximum value of a state function $p(x)$ along trajectories is,
\begin{equation}
    \begin{aligned}
    P^* = & \max_{t \in [0, T],\, x_0 \in X_0} p(x(t \mid x_0)),  &\label{eq:peak_traj_std} \dot{x}(t) = f(t, x(t))
    \end{aligned}
\end{equation}

% \begin{equation}
%     \begin{aligned}
%     P^* = & \max_{t \in [0, T],\, x_0 \in X_0} p(x(t \mid x_0)) &\label{eq:peak_traj_std}\\
%     & \dot{x}(t) = f(t, x(t))
%     \end{aligned}
% \end{equation}

% \urg{I'm trying to skip fixed terminal time to go straight to free terminal time. This may be a mistake. This section is now in the uncertain paper, may swap with uncertain to split into `occupation measures' and `peak estimation' }

The extremum $P^*$ may be bounded through the use of occupation measure relaxations \cite{cho2002linear}. 
An optimal trajectory satisfying $P^* = p(x^*) = p(x(t^* \mid x_0^*))$ is described by a triple $( x_0^*, t^*, x^*)$ \cite{miller2020recovery}.
The initial probability measure $\mu_0 \in \Mp{X_0}$ is distributed over the set of initial conditions. The peak probability measure $\mu_p \in \Mp{[0, T] \times X}$ is a free-time terminal measure. 
% An occupation measure is a measure that describes information about the su
For an optimal stopping time $t^*$ and subsets $A \subseteq [0, t^*], \ B \subseteq X$, the $\mu_0$-averaged occupation measure $\mu \in \Mp{[0, T] \times X}$ has a definition \cite{cho2002linear},
\begin{equation}
    \label{eq:avg_free_occ}
    \mu(A \times B) = \int_{[0, t^*] \times X_0} I_{A \times B}\left((t, x(t \mid x_0))\right) dt \, d\mu_0(x_0)
\end{equation}
The measure $\mu(A \times B)$ yields the average amount of time a trajectory with initial condition $x_0$ drawn from $\mu_0$ will spend in the region $A \times B$.

The Lie derivative operator $\Lie_f$ may be defined for all test functions $v \in C^1([0, T]\times X)$,
\begin{equation}
    \Lie_f v(t, x) = \partial_t v(t,x) + f(t,x) \cdot \nabla_x v(t,x)
\end{equation}
The three measures ($\mu_0, \ \mu_p, \ \mu$) are linked by Liouville's equation for all test functions, 
\begin{align}
\inp{v(t, x)}{\mu_p} &= \inp{v(0, x)}{\mu_0} + \inp{\Lie_f v(t,x)}{\mu} \label{eq:liou_int}
\end{align}

Liouville's equation ensures that initial conditions distributed as $\mu_0$ are connected to terminal points distributed as $\mu_p$ by trajectories following the polynomial vector field $f$.
Two consequences of \eqref{eq:liou_mom} are that $\inp{1}{\mu_0} = \inp{1}{\mu_p}$ ($v(t,x) = 1$) and that $\inp{1}{\mu} = \inp{t}{\mu_p}$ ($v(t, x) = t$).
Equation \eqref{eq:liou_int} may be expressed in a weak sense using the adjoint relaton $\inp{\Lie_f v}{\mu} = \inp{v}{\Lie^\dagger_f \mu}$,
\begin{align}
\mu_p &= \delta_0 \otimes \mu_0 + \Lie_f^\dagger \mu. \label{eq:liou_mom}
\end{align}
% Equation \eqref{eq:liou_mom} is an equivalent statement for Liouville's equation where the adjoint $\inp{\Lie_f v}{\mu} = \inp{v}{\Lie^\dagger_f \mu}$.
% Moments of $\mu$  can be computed by evaluating $\inp{v(t,x)}{\mu}$ where the test function $v$ is a monomial.  Equation \eqref{eq:liou_mom} is an infinite set of linear constraints in terms of moments of $\mu_0, \mu_T, \mu$.

A convex measure relaxation of problem \eqref{eq:peak_traj_std} is,
\begin{subequations}
\label{eq:peak_meas}
\begin{align}
p^* = & \ \textrm{max} \quad \inp{p(x)}{\mu_p} \label{eq:peak_meas_obj} \\
    & \mu_p = \delta_0 \otimes\mu_0 + \Lie_f^\dagger \mu \label{eq:peak_meas_flow}\\
    & \inp{1}{\mu_0} = 1 \label{eq:peak_meas_prob}\\
    & \mu, \mu_p \in \Mp{[0, T] \times X} \label{eq:peak_meas_peak}\\
    & \mu_0 \in \Mp{X_0}. \label{eq:peak_meas_init}
\end{align}
\end{subequations}
Constraint \eqref{eq:peak_meas_prob} ensures that both $\mu_0$ and $\mu_p$ are probability measures. The objective \eqref{eq:peak_meas_obj} is the expectation of $p(x)$ with respect to the peak measure $\mu_p$. Program \eqref{eq:peak_meas} has a dual problem  over continuous functions, 
\begin{subequations}
\label{eq:peak_cont}
\begin{align}
    d^* = & \ \min_{\gamma \in \R} \quad \gamma & \\
    & {\gamma} \geq {v(0, x)}  &  & \forall x \in X_0 \label{eq:peak_cont_init}\\
    & \Lie_f v(t, x) \leq 0 & & \forall (t, x) \in [0, T] \times X \label{eq:peak_cont_f}\\
    & v(t, x) \geq p(x) & & \forall (t, x) \in [0, T] \times X \label{eq:peak_cont_p} \\
    &v \in C^1([0, T]\times X) \label{eq:peak_cont_v}&
\end{align}
\end{subequations}

The variable $v(t,x)$ is termed an auxiliary function in \cite{fantuzzi2020bounding}, and is an upper bound on the cost function $p(x)$ by \eqref{eq:peak_cont_p}. The graph $(t, x(t \mid x_0))$ is contained in the sublevel set $\{(t, x) \mid v(t, x) \leq \gamma\}$ for all $x_0 \in X_0$. Programs \eqref{eq:peak_meas} and \eqref{eq:peak_cont} satisfy strong duality ($p^* = d^*$) when the set $[0, T] \times X$ is compact (Theorem C.20 of \cite{lasserre2009moments}). The measure solution produces an upper bound $p^* \geq P^*$, and this bound is tight with $p^* = P^*$ when the set $[0, T] \times X$ is compact (Sec. 2.3 of \cite{fantuzzi2020bounding} and \cite{lewis1980relaxation}).


% The bound $p^* = P^*$ is tight with the assumption that $[0, T] \times X$ is compact, and $p^* \geq P^*$ is an upper bound when $[0, T] \times X$ is noncompact (Sec. 2.3 of \cite{fantuzzi2020bounding} and \cite{lewis1980relaxation}). 

The work in \cite{cho2002linear} approximates  Problems \eqref{eq:peak_meas} and \eqref{eq:peak_cont} by a discretized linear program over a fine mesh. The method in \cite{fantuzzi2020bounding} bounds \eqref{eq:peak_cont} with a sum-of-squares (SOS) relaxation of polynomial nonnegativity constraints. The SOS relaxation produces a converging sequence of upper bounds to $p^*=d^*$ when $[0, T] \times X$ is compact. Optimal trajectories can be  localized by sublevel sets of  $v(t,x)$ and $\Lie_f v(t, x)$  following the method in \cite{fantuzzi2020bounding}.
% Near-optimal trajectories extremizing $p(x)$ may be recovered from if the SOS solutions matrices obey rank conditions \cite{miller2020recovery}. These trajectories may also be localized by sublevel sets of the dual $v(t,x)$ following the method in \cite{fantuzzi2020bounding}. 
% This SOS formulation is dual to LMIs arising from finite truncation of \eqref{eq:peak_meas} the moment-SOS hierarchy (discussed in the next section).
% Near-optimal trajectories extremizing $p(x)$ may be recovered from LMI solutions if the matrices obey rank conditions \cite{miller2020recovery}. 
% moments of occupation measures formed by a 
% This SOS formulation is dual to LMIs in moments of occupation measures formed by a finite truncation of \eqref{eq:peak_meas} \cite{lasserre2009moments}. 
% Problems \eqref{eq:peak_meas} and \eqref{eq:peak_cont} are a pair of infinite-dimensional linear programs. The work in \cite{cho2002linear} approximates these problems by a discretized linear program over a fine mesh. The method in \cite{fantuzzi2020bounding} bounds \eqref{eq:peak_cont} with a sum-of-squares (SOS) relaxation of polynomial nonnegativity constraints. The SOS relaxation produces a converging sequence of upper bounds to $d^*$ when $[0, T] \times X$ is compact. This SOS formulation is dual to LMIs in moments of occupation measures formed by a finite truncation of \eqref{eq:peak_meas} \cite{lasserre2009moments}. 
% The degree-$d$ moment matrix for $\mu_p$ defined over the $1+N_x $ variables $(t, x)$ is a symmetric PSD matrix of size $\binom{1+N_x+d}{d}$. 
% Near-optimal trajectories extremizing $p(x)$ may be recovered from LMI solutions if the moment matrices obey rank conditions \cite{miller2020recovery}. These trajectories may also be localized by sublevel sets of the dual $v(t,x)$ following the method in \cite{fantuzzi2020bounding}.