% \section{Peak Estimation with Uncertainty for Discrete-Time Systems}
\section{Discrete-Time Uncertain Peak Estimation}
\label{sec:discrete}
Uncertain peak estimation can be extended to discrete systems, including switched discrete-time systems. 
% \urg{Is this too much content? Is there enough content without the discrete material? Should discrete be saved for a possible journal version? I haven't yet seen moment-based discrete peak estimation published, possibly missed that.}
A discrete system from times $t = 0, 1, \ldots, T$ is considered for  dynamics $x_+ = f(x)$ where $x_+$ is the next state. A trajectory starting at the initial condition $x_0 \in X_0$ is $x_t(x_0)$ The uncertain peak estimation problem for discrete systems with uncertainties $(\theta, w_t)$ and  $N_s$ subsystems with switching sequence $S_t$ is,
    \begin{align}
    P^* = & \max_{t, \, x_0 \in X_0,\,  \theta \in \Theta,\,  w_t, \ S_t} p(x_t(x_0, \theta, w_t, S_t)) &\label{eq:peak_traj_disc}\\
    & x_+ = f_k(x_t, \theta, w_t) \textrm{ if } S_t =  k \nonumber\\
    & w_t \in W, \ S_t \in 1, \ldots, N_s  \qquad \forall t \in 0, \ldots, T. \nonumber
    \end{align}
    
\subsection{Discrete-Time Measure Background}
% \urg{more references}

% Discrete systems can be interpreted in the measure framework through the use of the pushforward operator $\#$ \cite{magron2017discrete}. 
Just as the Lie derivative $\Lie_f v$ yields the infinitesimal change in $v$ along continuous trajectories, the quantity $v(f(x)) - v(x)$ is the change in $v$ along a single discrete step. 
An occupation measure for sets $A \subseteq X$ with initial conditions distributed as $\mu_0 \in \Mp{X_0}$ may be defined for discrete systems,
\begin{equation}
    \label{eq:occ_discrete}
    \mu(A) = \int_{X_0} \sum_{t = 0}^T I_A(f^t (x_0)) d \mu_0.
\end{equation}
The quantity $\mu(A)$ is the averaged number of time steps that trajectories distributed as $\mu_0$ spend in the region $A$. For measures $\mu_0 \in \Mp{X_0}, \ \mu_p \in \Mp{X}, \ \mu \in \Mp{X}$, the strong and weak discrete Liouville equations for all $v$ are:
\begin{align}
    \inp{v(x)}{\mu_p} &= \inp{v(x)}{\mu_0} + \inp{v(f(x))}{\mu} - \inp{v(x)}{\mu}, \label{eq:liou_discrete_v} \\
    \mu_p &= \mu_0 + f_\# \mu - \mu . \label{eq:liou_discrete}
\end{align}
Time may be optionally included in system dynamics by setting a state $t_+ = t + 1$ and incorporating $t$ into dynamics. The pushforward term in \eqref{eq:liou_discrete} would then be $v(t+1, f(t,x)) - v(t,x)$.
Discrete systems with uncertainties $(\theta, w)$ have dynamics and Liouville equations according to,
\begin{align}
    x_{+} &= f(x_t, \theta, w_t),  & 
    \mu_p &= \mu_0 + \pi^{x \theta}_\#(f_\# \mu - \mu). \label{eq:liou_discrete_un}
\end{align}
The uncertainty $\theta \in \Theta$ is fixed, and the time-dependent uncertainty has $w_t \in W$ for every time step $t = 0, \ldots, T$. Switching uncertainty from Section \ref{sec:switching} with subsystems $f_k$ valid  over $X_k$ may be realized by defining occupation measures $\mu_k \in \Mp{X_k \times \Theta \times W}$ such that $\mu = \sum_k \mu_k$. 

% Unfortunately, there does not exist an analogue to box-uncertainty decomposition as in Section \ref{sec:box} for discrete systems. The box-uncertainty decomposition works because the operator $(f \cdot \nabla_x)$ is linear in $f$, while the operator $f_\#$ is generically nonlinear for arbitrary $v$,
% \begin{align}
%     (c_1 f_1 + c_2 f_2)_\# v(x) &= v(c_1 f_1(x) + c_2 f_2(x))\\
%      &\neq c_1 v(f_1(x)) + c_2 v(f_2(x)).
% \end{align}
% This difficulty is observed in Equation 3 of \cite{han2018controller} for reachability set-maximizing control of a control-affine system. 


\subsection{Discrete-Time Measure Program}
A measure program may be formulated to upper bound the peak-estimation task on discrete systems. The uncertainties available in this formulation are $(\theta, w)$ and switching between dynamics $f_k$ over $X_k$. 
% Similar to \eqref{eq:peak_meas_un} there may exist  constraints $\inp{h_i}{\mu} = \sum_{t=0}^T h(d_t) = e_i$ on the disturbance processes. 
The uncertain discrete peak estimation measure problem with variables $(\mu_0, 
\mu_k, \mu_p)$ is,
\begin{subequations}
% \vspace{-0.3cm}
\label{eq:peak_meas_un_disc}
\begin{align}
p^* = & \ \textrm{max} \quad \inp{p(x)}{\mu_p} \label{eq:peak_meas_un_disc_obj}&  \\
    & \mu_p = \mu_0 + \pi^{x \theta}_\#\left(\textstyle\sum_{k}( f_{k\#} \mu_{k} - \mu_k)\right) \label{eq:peak_meas_un_disc_flow}&    \\
    & \mu_0(X_0) = 1 & \label{eq:peak_meas_un_disc_prob}\\
    & T \geq \textstyle \sum_k \inp{1}{\mu_k} \label{eq:peak_meas_un_disc_time}\\
    & \mu_{k} \in \Mp{X_k \times \Theta \times W} & \forall k =1 , \ldots, N_s\\
    & \mu_p \in \Mp{X \times \Theta} & \\
    & \mu_0 \in \Mp{X_0 \times \Theta}.& \label{eq:peak_meas_un_disc_init}
\end{align}
\end{subequations}
\begin{rmk}
% \vspace{-0.6cm} 
The composition of pushforwards in \eqref{eq:peak_meas_un_disc_flow} acts as $\inp{v(x, \theta)}{\pi^{x \theta}_\# f_{k \#} \mu_k} = \inp{v(f_k(x, \theta, w), \theta)}{\mu_k}$ for all test functions $v(x, \theta) \in C(X \times \Theta)$.
\end{rmk}
\begin{thm}
The optimum $p^*$ of \eqref{eq:peak_meas_un_disc} is an upper bound for $P^*$ from discrete program \eqref{eq:peak_traj_disc}.
\label{thm:peak_meas_disc}
\end{thm}
\begin{proof}
This proof follows the same steps as the proof to theorem \ref{thm:peak_meas}. An trajectory achieving a peak value of $P^*$ solving \eqref{eq:peak_traj_disc} may be expressed as a tuple $(t^*, x_0^*, x_p^*, \theta^*, w_t^*, S_t^*)$ with $P^* = p(x^*_p) =  p(x_{t^*}(x_0^*, \theta^*, w_t ))$. Measures may be defined from this tuple to solve problem \eqref{eq:peak_meas_un_disc}. The probability distributions are $\mu_0 = \delta_{x=x_0^*}$ and $\mu_p = \delta_{x =  x_p^* } \otimes \delta_{\theta = \theta^*}$. Switching  measures $\mu_k$ may be chosen as the unique occupation measures satisfying,
\begin{equation}
% \vspace{-0.25cm}
    \inp{\tilde{v}_k}{\mu_k} = \sum_{t=0}^{t^*}\tilde{v}(x_{t}(x_0^*, \theta^*, w_t^*), \theta^*, w_t^*) I(S_t = k), \label{eq:proof_occ_disc}
\end{equation}
for all test functions $\tilde{v}_k \in C(X_k \times \Theta \times W)$ and for each $k = 1, \ldots, N_s$. The measures $(\mu_0, \mu_p, \mu_k)$ are feasible solutions to \eqref{eq:peak_meas_un_disc_flow}-\eqref{eq:peak_meas_un_disc_init} with objective value  $P^* = p(x_p^*) = \inp{p(x)}{\mu_p}$, so $p^* \geq P^*$ is a valid upper bound to \eqref{eq:peak_traj_disc}.
\end{proof}
%     & \inp{h_i(d)}{\textstyle\sum_{k}\mu_{k}} = e_i & \forall i \label{eq:peak_meas_un_disc_int}\\
% Problem \eqref{eq:peak_meas_un_disc} has the same form as \eqref{eq:peak_meas} with the discrete Liouville equation \eqref{eq:liou_discrete} in \eqref{eq:peak_meas_un_disc_flow}.
\begin{rmk}
Constraint \eqref{eq:peak_meas_un_disc_time} is a technique from \cite{magron2017discrete} ensuring that the maximal time in optimization is $T$ and that each $\mu_k$ has a bounded mass.
\end{rmk}

\subsection{Discrete-Time Function Program}
With dual variables $(v(x, \theta) \in C(X \times \Theta), \gamma \in \R)$ and a new dual variable $\alpha \geq 0$, the Lagrangian of \eqref{eq:peak_meas_un_disc} is,
% \begin{align}
%     L &= \inp{p(x)}{\mu_p} + \inp{v(x,w)}{\mu_0 - \mu_p} \nonumber \\
%     &+ \inp{v(x,w)}{\textstyle\sum_{k} f_{k\#} - \mu_{k}} + \gamma(\inp{1}{\mu_0} - 1)  \\ &+ \alpha(T - \inp{1}{\textstyle \sum_k \mu_k}) +\textstyle\sum_i(\inp{h_i(d)}{\textstyle\sum_{k}\mu_{k}} - e_i). \nonumber
% \end{align}
\begin{align}
    \scL &= \inp{p(x)}{\mu_p} + \inp{v(x,\theta)}{\mu_0 - \mu_p}+ \alpha(T - \inp{1}{\textstyle \sum_k \mu_k}) \nonumber \\
    &+ \inp{v(x,\theta)}{\pi^{x\theta}_\# \textstyle\sum_{k} f_{k\#} \mu_k- \mu_{k}} + \gamma(1 - \inp{1}{\mu_0}).\nonumber
\end{align}
The corresponding dual problem is,
\begin{subequations}
\label{eq:peak_cont_un_disc}
\begin{align}
    d^* = & \ \min_{\gamma \in \R, \ \alpha \geq 0} \quad \gamma + T \alpha \label{eq:peak_cont_un_disc_obj}\\
    & \forall (x, \theta) \in X_0 \times \Theta: \nonumber \\
    & \quad {\gamma} \geq {v(x, \theta)}  &   \label{eq:peak_cont_un_disc_init}\\
    & \forall (x, \theta, w) \in  X_k \times \Theta \times W: \quad \forall k \nonumber \\
    & \quad v(f_k(x, \theta, w), \theta) -v(x, \theta)  \leq  \alpha \label{eq:peak_cont_disc_flow}\\
    & \forall (x, \theta) \in X \times \Theta: \nonumber \\
    & \quad v(x, \theta) \geq  p(x) \label{eq:peak_cont_disc_p}  \\
    &v(x, \theta) \in C(X \times \Theta) \label{eq:peak_cont_un_disc_v}.
\end{align}
\end{subequations}
    % d^* = & \ \min \quad \gamma + \textstyle\sum_i e_i \lambda_i - T \alpha\\
        % & \quad v(f_k(x), w) -v(x, w)  + \textstyle\sum_i \lambda_i h_i(d)  \leq  \alpha \\
% It is no longer required that $v$ in \eqref{eq:peak_cont_un_v} must have continuous first derivatives. 
% \vspace{-0.5cm}
\begin{thm}
Strong duality $p^*=d^*$ between holds between \eqref{eq:peak_meas_un_disc} and \eqref{eq:peak_cont_un_disc} if $T<\infty$ and $X \times \Theta \times W$ is compact. 
\label{thm:peak_strong_disc} 
\end{thm}
% \vspace{-0.45cm}
\begin{proof}
This is affirmed by a similar process to Theorem \ref{thm:peak_strong}. All measures have bounded finite moments given that their masses are bounded and their supports are compact. The image of the affine map in constraints \eqref{eq:peak_meas_un_disc_flow}-\eqref{eq:peak_meas_un_disc_prob} is closed in the weak-* topology,  concluding the conditions for strong duality by Theorem C.20 of \cite{lasserre2009moments}.
\end{proof}  
%  \begin{rmk}
%  Note that $v(x,\theta)$ in \eqref{eq:peak_cont_un_disc_v} may have discontinuous first derivatives. 
%  \end{rmk}


% %Moved to discrete_lmi_brief.tex
%
%  \begin{rmk}
%  The LMI for Discrete-Time Uncertain Peak Estimation is similar to LMI \eqref{eq:peak_lmi_un} in Continuous time. If time is not included, support constraints \eqref{eq:peak_lmi_un_time}-\eqref{eq:peak_lmi_un_time2} are unnecessary. The Liouville operator $\textrm{Liou}_{\alpha \gamma}(y^0, y^p, y^k)$ is now the affine relation in moments  induced from Liouville's Equation \eqref{eq:peak_meas_un_disc_flow}  for every test function $v(x, \theta) = x^\alpha \theta^\gamma$,
%  \begin{align}
%  \label{eq:liou_disc_lmi_unc}
%     0&= \inp{x^\alpha \theta^\gamma}{ \delta_0 \otimes \mu_0} - \inp{x^\alpha  \theta^\gamma}{\mu_p} \\
%     &+ \textstyle \sum_k\inp{( f_{k}(x, \theta, w)^\alpha \theta^\gamma - x^\alpha \theta^\gamma}{\mu_k}. \nonumber
% \end{align}
%  \end{rmk}
% Tightness of $d^*$ to the true peak optimum may be attained if $v$ is discontinuous by extending results from  \cite{fantuzzi2020bounding}.

