\section{Proofs for Chapter 4}
\label{sec:a13chapter4}

\disableornamentsfornextheadingtrue
\subsection{Combinatorial Proof of the Combination Technique}
\label{sec:a131proofCombiTechnique}

\addtocontents{lop}{\protect\fi}

\begin{definition}[binomial coefficient for integer parameters]
  \label{def:binomialCoefficient}
  The binomial coefficient $\binom{n}{k}$ is defined for
  $n \in \natz$ and $k \in \integer$ as
  \begin{equation}
    \binom{n}{k}
    \ceq
    \begin{cases}
      \frac{n (n - 1) \dotsm (n - (k-1))}{k!},&0 < k < n,\\
      1,&(k = 0) \lor (k = n),\\
      0,&(k < 0) \lor (k > n).
    \end{cases}
  \end{equation}
\end{definition}

\begin{lemma}[inclusion-exclusion counting lemma]
  \label{lemma:inclusionExclusionCountingLemma}
  For $a \in \natz$, $r \ge a$, and $s \in \integer$, we have
  \begin{equation}
    \sum_{q=0}^a (-1)^q \binom{a}{q} \binom{r-q}{s}
    = \binom{r-a}{s-a}.
  \end{equation}
\end{lemma}

\begin{proof}
  We apply the upper negation formula
  (see Eq. (5.14) of \cite{Graham94Concrete})
  to the second binomial of the \lhs:
  \begin{subequations}
    \begin{align}
      \sum_{q=0}^a (-1)^q \binom{a}{q} \binom{r-q}{s}
      &= (-1)^s \sum_{q=0}^a \binom{a}{0+q} \binom{(s-r-1)+q}{s} (-1)^q.\\
      \intertext{%
        This sum can be simplified using the identity
        in Eq.\ (5.24) of \cite{Graham94Concrete}
        (the sum has already been written in the same way as in
        \cite{Graham94Concrete}):%
      }
      \cdots
      &= (-1)^{s+a} \binom{s-r-1}{s-a}.\\
      \intertext{%
        Applying the upper negation formula again,%
      }
      \cdots
      &= \binom{r-a}{s-a},
    \end{align}
  \end{subequations}
  we obtain the desired quantity.
\end{proof}

\addtocontents{lop}{\protect\iffalse}

\propCombiTechniqueOne*

\begin{proof}
  Let $q = 0, \dotsc, d - 1$ and $\gp{\*l,\*i} \in \regsgset{n}{d}$, i.e.,
  $\normone{\*l} \le n$ and $\*i \in \hiset{\*l}$.
  Note that for $\*l' \in \natz^d$, we have
  $\fgset{\*l'} \ni \gp{\*l,\*i} \iff \*l' \ge \*l$.
  Hence,
  \begin{subequations}
    \begin{align}
      \setsize{
        \{\*l' \mid \normone{\*l'} = n - q,\; \fgset{\*l'} \ni \gp{\*l,\*i}\}
      }
      &= \setsize{
        \{\*l' \mid \normone{\*l'} = n - q,\; \*l' \ge \*l\}
      }\\
      &= \setsize{
        \{\*a \in \natz^d \mid \normone{\*a} = n - q - \normone{\*l}\}
      }\\
      \intertext{%
        by mapping $\*a \ceq \*l' - \*l$.
        The size of the last set is
        known as the number of \term{weak compositions}
        of $n - q - \normone{\*l}$ into $d$ parts
        and can be computed as%
      }
      \cdots
      &= \binom{n - q - \normone{\*l} + d - 1}{d - 1},
    \end{align}
  \end{subequations}
  see Theorem 2.2 of \cite{Bona15Introduction}.
  Now, we can use \cref{lemma:inclusionExclusionCountingLemma}
  with the values
  $a \ceq s \ceq d - 1$ and
  $r \ceq n - \normone{\*l} + d - 1$
  to conclude that the \lhs of the assertion
  \eqref{eq:combiTechniqueOne} equals
  \begin{equation}
    \sum_{q=0}^{d-1} (-1)^q \binom{d-1}{q} \cdot
    \binom{n - q - \normone{\*l} + d - 1}{d - 1}
    = \binom{n - \normone{\*l}}{0}
    = 1,
  \end{equation}
  proving the proposition.
\end{proof}

\addtocontents{lop}{\protect\fi}

\begin{shortlemma}[relation is equivalence relation]
  \label{lemma:combiTechniqueEquivalenceRelation}
  $\eq$ is an equivalence relation.
\end{shortlemma}

\begin{proof}
  We check reflexivity, symmetry, and transitivity of $\eq$:
  \begin{itemize}
    \item
    \emph{Reflexivity:}
    Using the same level $\*l' = \*l''$ implies
    $T_{\*l',\*l'} = \{t \mid l'_t < l_t\}$.
    For all $t \notin T_{\*l',\*l'}$, we have $l'_t \ge l_t$.
    Consequently, $\*l' \eq \*l'$.

    \item
    \emph{Symmetry:}
    We have
    $\*l' \eq \*l'' \iff \*l'' \eq \*l'$, since
    $T_{\*l',\*l''} = T_{\*l'',\*l'}$ and
    $\min\{l'_t, l''_t\} = \min\{l''_t, l'_t\}$.

    \item
    \emph{Transitivity:}
    Let $\*l' \eq \hat{\*l}$, $\hat{\*l} \eq \*l''$, and
    $t \notin T_{\*l',\*l''}$.
    From the definition of $T_{\*l',\*l''}$,
    it holds that either $l'_t \not= l''_t$ or $l'_t = l''_t \ge l_t$.
    As $l'_t = l''_t \ge l_t$ already implies $\min\{l'_t, l''_t\} \ge l_t$,
    we assume that $l'_t \not= l''_t$.
    Here, we have three cases:
    \begin{itemize}
      \item
      \mbox{\emph{Case 1:} ${l'_t \not= \hat{l}_t = l''_t}$.}
      $t \notin T_{\*l',\hat{\*l}}$ implies $l'_t \ge l_t$ and
      $l''_t = \hat{l}_t \ge l_t$.
      Therefore, $\min\{l'_t, l''_t\} \ge l_t$.

      \item
      \mbox{\emph{Case 2:} ${l'_t = \hat{l}_t \not= l''_t}$.}
      Analogously to the first case, we conclude $\min\{l'_t, l''_t\} \ge l_t$.

      \item
      \mbox{\emph{Case 3:} ${l'_t \not= \hat{l}_t \not= l''_t}$.}
      $t \notin T_{\*l',\hat{\*l}}$ implies $l'_t \ge l_t$ and
      $t \notin T_{\*l'',\hat{\*l}}$ implies $l''_t \ge l_t$.
      Hence, $\min\{l'_t, l''_t\} \ge l_t$.
    \end{itemize}
    Therefore, it holds that $\min\{l'_t, l''_t\} \ge l_t$
    for all $t \notin T_{\*l',\*l''}$, i.e., $\*l' \eq \*l''$.
  \end{itemize}
  This shows that $\eq$ is an equivalence relation.
\end{proof}

\addtocontents{lop}{\protect\iffalse}

\lemmaCombiTechniqueIdenticalValues*

\begin{proof}
  First, we note that $T_{\*l',\*l''} \not= \emptyset$.
  Otherwise, for $T_{\*l',\*l''} = \emptyset$,
  we have $\min\{l'_t, l''_t\} \ge l_t$
  for all $t = 1, \dotsc, d$, which implies $\*l' \ge \*l$, i.e.,
  $\fgset{\*l'} \ni \gp{\*l,\*i}$.
  This contradicts the fact that $\*l' \in L$, where $L$ is defined
  in \eqref{eq:combiTechniqueSpecialLevelSet}
  (which holds as our equivalence relation is only defined on $L$).
  Therefore, $T_{\*l',\*l''} \not= \emptyset$ must hold.
  Without loss of generality,
  we assume that $T_{\*l',\*l''} = \{1, \dotsc, m\}$
  for some $m \in \{1, \dotsc, d\}$.

  Let
  \begin{equation}
    S \ceq \gp{\*l,\*i} + \spn\{\stdbasis{1}, \dotsc, \stdbasis{m}\}
    = \{\gp{\*l,\*i} + \textstyle\sum_{t=1}^m c_t \stdbasis{t} \mid
    c_1, \dotsc, c_m \in \real\}
  \end{equation}
  be the $m$-dimensional affine subspace of $\real^d$
  through $\gp{\*l, \*i}$
  parallel to the dimensions $1, \dotsc, m$,
  where $\stdbasis{t}$ is the $t$-th standard basis vector.
  It holds that $S \cap \fgset{\*l'} = S \cap \fgset{\*l''}$ due to
  $l'_t = l''_t$ for $t \le m$.%
  \footnote{%
    In more detail:
    If we have an $\gp{\hat{\*l},\hat{\*i}} \in S \cap \fgset{\*l'}$,
    then $\fa{t \le m}{\hat{l}_t \le l'_t = l''_t}$ and
    $\fa{t > m}{\hat{l}_t = l_t \le l''_t}$, i.e.,
    $\hat{\*l} \le \*l''$ and therefore
    $\gp{\hat{\*l},\hat{\*i}} \in S \cap \fgset{\*l''}$.%
  }

  On this $m$-dimensional grid $S \cap \fgset{\*l'} = S \cap \fgset{\*l''}$,
  the full grid interpolants $\fgintp{\*l'}$ and $\fgintp{\*l''}$
  coincide, as both interpolate the function values given by
  the objective function $\objfun$:
  \begin{equation}
    \label{eq:proofCombiTechniqueIdenticalValues1}
    \restrictfcn{\fgintp{\*l'}}{S \cap \fgset{\*l'}}
    = \restrictfcn{\objfun}{S \cap \fgset{\*l'}}
    =  \restrictfcn{\fgintp{\*l''}}{S \cap \fgset{\*l'}}.
  \end{equation}
  However, this does not suffice to conclude
  $\fgintp{\*l'}(\gp{\*l,\*i}) = \fgintp{\*l''}(\gp{\*l,\*i})$,
  since $\gp{\*l,\*i} \notin \fgset{\*l'}$.

  To this end, we recall from \eqref{eq:interpFullGridMV} that
  \begin{equation}
    \fgintp{\*l'}
    = \sum_{\*i'=\*0}^{\*2^{\*l'}} \interpcoeff{\*l',\*i'}
    \basis{\*l',\*i'},\quad
    \interpcoeff{\*l',\*i'} \in \real.
  \end{equation}
  This implies that the $m$-variate restricted interpolant
  $\restrictfcn{\fgintp{\*l'}}{S \cap \clint{\*0, \*1}}$ can be written as
  \begin{subequations}
    \begin{align}
      (\restrictfcn{\fgintp{\*l'}}{S \cap \clint{\*0, \*1}})
      (\*x_{\range{1}{m}})
      &\mathrel{\righthphantom{=}{\ceq}}
      \sum_{\*i'_{\range{1}{m}}=\*0}^{\*2^{\*l'_{\range{1}{m}}}}
      \interpcoefftilde{\*l'_{\range{1}{m}},\*i'_{\range{1}{m}}}
      \basis{\*l'_{\range{1}{m}},\*i'_{\range{1}{m}}}(\*x_{\range{1}{m}}),\quad
      \*x_{\range{1}{m}} \in \clint{0, 1}^m,\\
      \interpcoefftilde{\*l'_{\range{1}{m}},\*i'_{\range{1}{m}}}
      &\ceq \sum_{\*i'_{\range{m+1}{d}}=\*0}^{\*2^{\*l'_{\range{m+1}{d}}}}
      \interpcoeff{\*l',\*i'}
      \basis{\*l'_{\range{m+1}{d}},\*i'_{\range{m+1}{d}}}%
      (\gp{\*l_{\range{m+1}{d}},\*i_{\range{m+1}{d}}})
    \end{align}
  \end{subequations}
  by factoring out tensor product factors corresponding to dimensions
  $m + 1, \dotsc, d$.
  The subscripts $\range{1}{m}$ and $\range{m+1}{d}$ denote
  the entries with respect to the dimensions $1, \dotsc, m$ and
  $m + 1, \dotsc, d$, respectively.
  As a result,
  both $\restrictfcn{\fgintp{\*l'}}{S \cap \clint{\*0, \*1}}$
  and, analogously,
  $\restrictfcn{\fgintp{\*l''}}{S \cap \clint{\*0, \*1}}$
  are interpolants of $\objfun$ in
  $\ns{\*l'_{\range{1}{m}}} = \ns{\*l''_{\range{1}{m}}}$.
  Due to \thmref{lemma:tensorProductLinearIndependence},
  it follows from \eqref{eq:proofCombiTechniqueIdenticalValues1}
  that they must be the same:
  \begin{equation}
    \restrictfcn{\fgintp{\*l'}}{S \cap \clint{\*0, \*1}}
    = \restrictfcn{\fgintp{\*l''}}{S \cap \clint{\*0, \*1}}.
  \end{equation}
  Consequently, $\fgintp{\*l'}(\gp{\*l,\*i}) = \fgintp{\*l''}(\gp{\*l,\*i})$
  as $\gp{\*l,\*i} \in S \cap \clint{\*0, \*1}$.
\end{proof}

\lemmaCombiTechniqueCharacterization*

\begin{proof}
  ``$\subset$'':
  Let $\*l' \in L_0$.
  We have to prove that
  $\fa{t \in T_{L_0}}{l'_t = l^\ast_t}$ and
  $\fa{t \notin T_{L_0}}{l'_t \ge l_t}$.
  The first statement is clear by the definition of $T_{L_0}$.
  Therefore, let $t \notin T_{L_0}$.
  By the definition of $T_{L_0}$,
  we have either
  $\ex{\hat{\*l} \in L_0}{l'_t \not= \hat{l}_t}$ or
  $\fa{\hat{\*l} \in L_0}{l'_t = \hat{l}_t \ge l_t}$.
  In the latter case, we obtain $l'_t \ge l_t$
  (e.g., by setting $\hat{\*l}$ to $\*l'$).
  In the former case, there is an $\hat{\*l} \in L_0$ such that
  $l'_t \not= \hat{l}_t$.
  Due to $\*l' \eq \hat{\*l}$
  (since $\*l'$ and $\hat{\*l}$ are both contained in the same
  equivalence class $L_0$) and $t \notin T_{\*l',\hat{\*l}}$,
  we have $\min\{l'_t, \hat{l}_t\} \ge l_t$.
  This implies $\fa{t \notin T_{L_0}}{l'_t \ge l_t}$, as desired.

  ``$\supset$'':
  Let $\*l' \in L$ such that
  $\fa{t \in T_{L_0}}{l'_t = l^\ast_t}$ and
  $\fa{t \notin T_{L_0}}{l'_t \ge l_t}$.
  Furthermore,
  let $\*l'' \in L_0$ be an arbitrary representative of $L_0$.
  We prove that $\*l' \eq \*l''$ (i.e., $\*l' \in L_0$).
  Note that $T_{L_0} \subset T_{\*l',\*l''}$,
  as $t \in T_{L_0}$ implies
  $l''_t = l^\ast_t < l_t$, which can be combined with $l'_t = l^\ast_t$
  to $l'_t = l''_t < l_t$, i.e., $t \in T_{\*l',\*l''}$.

  To prove the equivalence of $\*l'$ and $\*l''$,
  let $t \notin T_{\*l',\*l''}$,
  i.e., $t \notin T_{L_0}$.
  By assumption on $\*l'$, it holds $l'_t \ge l_t$.
  Hence, it remains to show that $l''_t \ge l_t$ as well.
  Again, by definition of $T_{L_0}$, we have either
  $\ex{\hat{\*l} \in L_0}{l''_t \not= \hat{l}_t}$ or
  $\fa{\hat{\*l} \in L_0}{l''_t = \hat{l}_t \ge l_t}$.
  In the second case, it holds $l''_t \ge l_t$.
  In the first case, there is an $\hat{\*l} \in L_0$ such that
  $l''_t \not= \hat{l}_t$.
  Due to $\*l'' \eq \hat{\*l}$
  (since $\*l''$ and $\hat{\*l}$ are both contained in the same
  equivalence class $L_0$) and $t \notin T_{\*l'',\hat{\*l}}$,
  we have $\min\{l''_t, \hat{l}_t\} \ge l_t$.
  In particular, $l''_t \ge l_t$.
  In total, we have $\min\{l'_t, l''_t\} \ge l_t$ for all
  $t \notin T_{\*l',\*l''}$, proving that $\*l'$ and $\*l''$ are equivalent,
  as asserted.
\end{proof}

\propCombiTechniqueZero*

\begin{proof}
  \Cref{lemma:combiTechniqueIdenticalValues}
  implies that the summands $\fgintp{\*l'}(\gp{\*l,\*i})$
  corresponding to levels $\*l'$ of the same equivalence class
  $L_0 \in \eqclasses{L}{\eq}$ are identical.
  Let $f_{L_0}$ denote the common function value.
  The sum in the \lhs of the assertion can be reordered to combine
  levels of the equivalence classes $L_0 \in \eqclasses{L}{\eq}$:
  \begin{subequations}
    \begin{align}
      &\sum_{q=0}^{d-1} (-1)^q \binom{d-1}{q} \cdot
      \sum_{\substack{\normone{\*l'} = n - q\\\fgset{\*l'} \notni \gp{\*l,\*i}}}
      \fgintp{\*l'}(\gp{\*l,\*i})\\
      \label{eq:proofCombiTechniqueIdenticalValues2}
      &= \sum_{L_0 \in \eqclasses{L}{\eq}} f_{L_0} \sum_{q=0}^{d-1}
      (-1)^q \binom{d-1}{q} \cdot
      \setsize{\{\*l' \in L_0 \mid \normone{\*l'} = n - q\}}.
    \end{align}
  \end{subequations}
  It now suffices to show that the inner sum vanishes
  for every equivalence class $L_0 \in \eqclasses{L}{\eq}$.

  To this end, we have to calculate
  $\setsize{\{\*l' \in L_0 \mid \normone{\*l'} = n - q\}}$
  for a fixed equivalence class $L_0$.
  Without loss of generality,
  let $T_{L_0} = \{1, \dotsc, m\}$ in the notation of
  \thmref{lemma:combiTechniqueCharacterization}
  with $1 \le m \le d$.
  Note that the case $m = 0$ is impossible:
  Otherwise, $T_{L_0} = \emptyset$ implies
  $\fa{\*l' \in L_0}{\*l' \ge \*l}$ by
  \cref{lemma:combiTechniqueCharacterization}, and
  as equivalence classes are non-empty,
  there is at least one $\*l' \in L_0$ with $\*l' \ge \*l$.
  However, this is equivalent to $\fgset{\*l'} \ni \gp{\*l,\*i}$,
  which contradicts $\*l' \in L$.
  Hence, we have $m > 0$.

  To enumerate all levels $\*l' \in L_0$ with $\normone{\*l'} = n - q$,
  we exploit the characterization of $L_0$ of
  \cref{lemma:combiTechniqueCharacterization}.
  For notational convenience, we define the vector
  \begin{equation}
    \hat{\*l}
    \ceq (l^\ast_1, \dotsc, l^\ast_m,\; l_{m+1}, \dotsc, l_d),
  \end{equation}
  where $\*l^\ast$ is given as in \cref{lemma:combiTechniqueCharacterization}.
  We show that $\*a \ceq (l'_t - l_t)_{t = m+1, \dotsc, d}$
  constitutes a bijection between
  \begin{equation}
    \{\*l' \in L_0 \mid \normone{\*l'} = n - q\}
    \quad\text{and}\quad
    \{\*a \in \natz^{d-m} \mid \normone{\*a} = n - q - \normone{\hat{\*l}}\}
    \colon
  \end{equation}
  \begin{itemize}
    \item
    Let $\*l' \in L_0$ with $\normone{\*l'} = n - q$.
    Then, $\fa{t=m+1,\dotsc,d}{l'_t - l_t \ge 0}$
    (by \cref{lemma:combiTechniqueCharacterization}), i.e.,
    $\*a \in \natz^{d-m}$, and
    \begin{equation}
      \normone{\*a}
      = \sum_{t=m+1}^d (l'_t - l_t)
      = \paren*{\normone{\*l'} - \sum_{t=1}^m l'_t} -
      \sum_{t=m+1}^d \hat{l}_t
      = n - q - \normone{\hat{\*l}}.
    \end{equation}

    \item
    Conversely, let $\*a \in \natz^{d-m}$ with
    $\normone{\*a} = n - q - \normone{\hat{\*l}}$.
    If we define $\*l'$ as
    \begin{equation}
      \*l'
      = (l^\ast_1, \dotsc, l^\ast_m,\;
      a_1 + l_{m+1}, \dotsc, a_{d-m} + l_d),
    \end{equation}
    then $\fa{t=1,\dotsc,m}{l'_t = l^\ast_t < l_t}$ and
    $\fa{t=m+1,\dotsc,d}{l'_t \ge l_t}$.
    By \cref{lemma:combiTechniqueCharacterization},
    we obtain $\*l' \in L_0$ and
    \begin{equation}
      \normone{\*l'}
      = \normone{\hat{\*l}} + \normone{\*a}
      = n - q.
    \end{equation}
  \end{itemize}
  This bijection implies that
  \begin{subequations}
    \begin{align}
      \setsize{\{\*l' \in L_0 \mid \normone{\*l'} = n - q\}}
      &= \setsize{
        \{\*a \in \natz^{d-m} \mid \normone{\*a} = n - q - \normone{\hat{\*l}}\}
      }.\\
      \intertext{%
        This is the number of weak decompositions of
        $n - q - \normone{\hat{\*l}}$ into $d - m$ parts:%
      }
      \cdots
      &= \binom{n - q - \normone{\hat{\*l}} + d - m - 1}{d - m - 1},
    \end{align}
  \end{subequations}
  see Theorem 2.2 of \cite{Bona15Introduction}.
  We insert this quantity into the inner sum of
  \eqref{eq:proofCombiTechniqueIdenticalValues2}:
  \begin{subequations}
    \label{eq:proofCombiTechniqueIdenticalValues3}
    \begin{align}
      &\sum_{q=0}^{d-1}
      (-1)^q \binom{d-1}{q} \cdot
      \setsize{\{\*l' \in L_0 \mid \normone{\*l'} = n - q\}}\\
      &= \sum_{q=0}^{d-1} (-1)^q \binom{d-1}{q} \cdot
      \binom{n - q - \normone{\hat{\*l}} + d - m - 1}{d - m - 1}.
    \end{align}
  \end{subequations}
  Again, we apply \thmref{lemma:inclusionExclusionCountingLemma}
  with the values $a \ceq d - 1$,
  $r \ceq n - \normone{\hat{\*l}} + d - m - 1$, and
  $s \ceq d - m - 1$ to infer that as claimed,
  \eqref{eq:proofCombiTechniqueIdenticalValues3} is equal to
  \begin{equation}
  \label{eq:proofCombiTechniqueIdenticalValues4}
    \binom{n - \normone{\hat{\*l}} - m}{-m}
    = 0
  \end{equation}
  by the convention for binomial coefficients in \cref{def:binomialCoefficient}
  as $-m < 0$.

  Note that for the calculation in
  \cref{%
    eq:proofCombiTechniqueIdenticalValues3,%
    eq:proofCombiTechniqueIdenticalValues4%
  }
  to be correct,
  we have to ensure that $n - \normone{\hat{\*l}} - m \ge 0$;
  otherwise, the binomial coefficients would not be well-defined.
  This is a direct consequence of the fact that $l^\ast_t < l_t$
  for all $t = 1, \dotsc, m$
  (see \cref{lemma:combiTechniqueCharacterization}) as
  \begin{equation}
    n - \normone{\hat{\*l}} - m
    = n - \sum_{t=1}^m l^\ast_t - \sum_{\mathclap{t=m+1}}^d l_t - m
    \ge n - \sum_{t=1}^m (l_t - 1) - \sum_{\mathclap{t=m+1}}^d l_t - m
    = n - \normone{\*l}
    \ge 0,
  \end{equation}
  where we have used $l^\ast_t \le l_t - 1$ for $t = 1, \dotsc, m$
  and $\normone{\*l} \le n$.
\end{proof}

\fillsubsectionornament
\subsection{Correctness Proof of the Method of Residual Interpolation}
\label{sec:a132proofResidualInterpolation}

\propInvariantResidualInterpolation*

\begin{proof}
  \newcommand*{\eqwithref}[1]{%
    \quad\;%
    \if\relax\detokenize{#1}\relax%
      \mathclap{=}%
    \else%
      \mathclap{\overset{\eqref{eq:propInvariantResidualInterpolation#1}}{=}}%
    \fi%
    \quad\;%
  }%
  %
  We prove the assertion by induction over $j = 1, \dotsc, m$.
  We will need the following two equations
  that directly follow from the algorithm
  (\cref{%
    line:algResidualInterpolation3,%
    line:algResidualInterpolation2,%
    line:algResidualInterpolation4%
  }, respectively):%
  \begin{subequations}
    \begin{alignat}{3}
      \label{eq:propInvariantResidualInterpolation5}
      r_{\*l^{(j)}}^{(j-1)}(\gp{\*l,\*i})
      &= r^{(j-1)}(\gp{\*l,\*i}),\quad
      &&\*l \le \*l^{(j)},\;\;
      &&\*i \in \hiset{\*l},\\
      \label{eq:propInvariantResidualInterpolation6}
      r^{(j)}(\gp{\*l,\*i})
      &= r^{(j-1)}(\gp{\*l,\*i}) - r_{\*l^{(j)}}^{(j-1)}(\gp{\*l,\*i}),\quad
      &&\*l \in L,\;\;
      &&\*i \in \hiset{\*l}.
    \end{alignat}
  \end{subequations}

  \vspace*{-2em}
  \pagebreak

  \noindent
  \textbf{Induction base case:}
  For $j = 1$, there is nothing to show for
  \eqref{eq:propInvariantResidualInterpolation1}.
  \Cref{eq:propInvariantResidualInterpolation2}
  can be proven as follows:
  \begin{equation}
    r^{(1)}(\gp{\*l,\*i})
    \eqwithref{6}
    r^{(0)}(\gp{\*l,\*i}) - r_{\*l^{(1)}}^{(0)}(\gp{\*l,\*i})
    \eqwithref{5} 0,\qquad
    \*l \le \*l^{(1)},\; \*i \in \hiset{\*l}.
  \end{equation}
  \Cref{eq:propInvariantResidualInterpolation3}
  holds as $r_{\*l^{(1)}}^{(0)} = f^{\sparse,(1)}$
  (by \cref{line:algResidualInterpolation2} in
  \cref{alg:residualInterpolation}) and, therefore,
  \begin{align}
    r^{(1)}(\gp{\*l,\*i})
    \eqwithref{6}
    r^{(0)}(\gp{\*l,\*i}) - r_{\*l^{(1)}}^{(0)}(\gp{\*l,\*i})
    = \fcnval{\*l,\*i} - f^{\sparse,(1)}(\gp{\*l,\*i}),\quad
    \*l \in L,\; \*i \in \hiset{\*l}.
  \end{align}

  \noindent
  \textbf{Induction step case:}
  We show the three statements for the induction step $j \to (j + 1)$.
  \begin{itemize}
    \item
    \emph{Showing \eqref{eq:propInvariantResidualInterpolation1} for $j + 1$:}
    Let $j' = 1, \dotsc, j$, $\*l \le \*l^{(j')}$,
    and $\*i \in \hiset{\*l}$.
    Due to the ordering of the levels $\*l^{(1)}, \dotsc, \*l^{(m)}$,
    we can conclude from $j + 1 > j'$ that
    $\normone{\*l^{(j+1)}} \le \normone{\*l^{(j')}}$.
    This implies that there must be a $t' \in \{1, \dotsc, d\}$
    such that $l_{t'}^{(j+1)} \le l_{t'}^{(j')}$.
    Let $S$ be the line in $\real^d$ defined by
    \begin{equation}
      S
      \ceq \gp{\*l,\*i} + \spn\{\stdbasis{t'}\},
    \end{equation}
    where $\stdbasis{t'}$ is the $t'$-th standard basis vector.
    It holds that $S \cap \fgset{\*l^{(j+1)}} \subset \fgset{\*l^{(j')}}$.
    To show this, let $\gp{\*l',\*i'} \in S \cap \fgset{\*l^{(j+1)}}$
    be arbitrary (with $\*i' \in \hiset{\*l'}$).
    Then, $\fa{t \not= t'}{l'_t = l_t \le l_t^{(j')}}$
    (due to $\gp{\*l',\*i'} \in S$) and
    $l'_{t'} \le l_{t'}^{(j+1)} \le l_{t'}^{(j')}$
    (due to $\gp{\*l',\*i'} \in \fgset{\*l^{(j+1)}}$).
    This means that $\*l' \le \*l^{(j')}$, which implies that
    $\gp{\*l',\*i'} \in \fgset{\*l^{(j')}}$.
    As $\gp{\*l',\*i'}$ is arbitrary,
    this shows $S \cap \fgset{\*l^{(j+1)}} \subset \fgset{\*l^{(j')}}$.

    Thus, we infer
    \begin{equation}
      \label{eq:proofPropInvariantResidualInterpolation2}
      r_{\*l^{(j+1)}}^{(j)}(\gp{\*l',\*i'})
      \eqwithref{5}
      r^{(j)}(\gp{\*l',\*i'})
      \eqwithref{2}
      0,\quad
      \gp{\*l',\*i'} \in S \cap \fgset{\*l^{(j+1)}}
      \subset \fgset{\*l^{(j')}},\;
      i' \in \hiset{\*l'},
    \end{equation}
    with the induction hypothesis
    \eqref{eq:propInvariantResidualInterpolation2} for $j$.
    Unfortunately, this does not suffice to directly conclude that
    $r_{\*l^{(j+1)}}^{(j)}(\gp{\*l,\*i}) = 0$ as
    $\gp{\*l,\*i}$ is in general not contained in $\fgset{\*l^{(j+1)}}$.

    As in the proof of \cref{lemma:combiTechniqueIdenticalValues},
    we exploit the tensor product nature of the basis functions and
    restrict $r_{\*l^{(j+1)}}^{(j)}$ to $S \cap \clint{0, 1}$:
    \begin{subequations}
      \begin{align}
        (\restrictfcn{r_{\*l^{(j+1)}}^{(j)}}{S \cap \clint{0, 1}})(x_{t'})
        &\mathrel{\righthphantom{=}{\ceq}}
        \sum_{l'_{t'}=0}^{l_{t'}^{(j+1)}}
        \sum_{i'_{t'} \in \hiset{l'_{t'}}}
        \surplustilde[(j+1)]{l'_{t'},i'_{t'}}
        \basis{l'_{t'},i'_{t'}}(x_{t'}),\quad
        x_{t'} \in \clint{0, 1},\\
        \surplustilde[(j+1)]{l'_{t'},i'_{t'}}
        &\ceq \sum_{\*l'_{-t'}=\*0}^{\*l^{(j+1)}_{-t'}}
        \sum_{\*i'_{-t'} \in \hiset{\*l'_{-t'}}}
        \surplus[(j+1)]{\*l',\*i'}
        \basis{\*l'_{-t'},\*i'_{-t'}}(\gp{\*l_{-t'},\*i_{-t'}}),
      \end{align}
    \end{subequations}
    where the subscript $-t'$ indicates all entries but the $t'$-th.
    As a consequence, this shows that
    $\restrictfcn{r_{\*l^{(j+1)}}^{(j)}}{S \cap \clint{0, 1}} \in
    \ns{l_{t'}^{(j+1)}}$ is an interpolant of the zero function
    (by \eqref{eq:proofPropInvariantResidualInterpolation2}).
    Due to the linear independence of the univariate basis functions,
    we conclude
    \begin{equation}
      \restrictfcn{r_{\*l^{(j+1)}}^{(j)}}{S \cap \clint{0, 1}}
      \equiv 0.
    \end{equation}
    Consequently, we obtain
    $r_{\*l^{(j+1)}}^{(j)}(\gp{\*l,\*i}) = 0$
    as $\gp{\*l,\*i} \in S \cap \clint{\*0, \*1}$.

    \item
    \emph{Showing \eqref{eq:propInvariantResidualInterpolation2} for $j + 1$:}
    Let $j' = 1, \dotsc, j + 1$, $\*l \le \*l^{(j')}$,
    and $\*i \in \hiset{\*l}$.
    For the case $j' \le j$, we obtain
    \begin{equation}
      \label{eq:proofPropInvariantResidualInterpolation1}
      r^{(j+1)}(\gp{\*l,\*i})
      \eqwithref{6}
      r^{(j)}(\gp{\*l,\*i}) - r_{\*l^{(j+1)}}^{(j)}(\gp{\*l,\*i})
      = 0
    \end{equation}
    due to $r^{(j)}(\gp{\*l,\*i}) = 0$ by induction hypothesis
    (\cref{eq:propInvariantResidualInterpolation2}) and
    $r_{\*l^{(j+1)}}^{(j)}(\gp{\*l,\*i}) = 0$ as shown above
    (\cref{eq:propInvariantResidualInterpolation1} for $j + 1$).

    For the case $j' = j + 1$,
    \cref{eq:proofPropInvariantResidualInterpolation1}
    still holds as the difference between
    $r^{(j)}(\gp{\*l,\*i})$ and $r_{\*l^{(j+1)}}^{(j)}(\gp{\*l,\*i})$
    vanishes due to \eqref{eq:propInvariantResidualInterpolation5}
    for $j + 1$
    (here, we need $\*l \le \*l^{(j+1)}$).

    \item
    \emph{Showing \eqref{eq:propInvariantResidualInterpolation3} for $j + 1$:}
    Let $\*l \in L$ and $\*i \in \hiset{\*l}$.
    Then,
    \begin{subequations}
      \begin{align}
        r^{(j+1)}(\gp{\*l,\*i})
        &\eqwithref{6}
        r^{(j)}(\gp{\*l,\*i}) - r_{\*l^{(j+1)}}^{(j)}(\gp{\*l,\*i}).\\
        \intertext{%
          The first term can replaced with the induction hypothesis
          (\eqref{eq:propInvariantResidualInterpolation3} for $j$).
          For the second term, note that
          $r_{\*l^{(j+1)}}^{(j)}
          = \sum_{\*l' \in \levelset} \sum_{\*i' \in \hiset{\*l'}}
          \surplus[(j+1)]{\*l',\*i'} \basis{\*l',\*i'}
          = f^{\sparse,(j+1)} - f^{\sparse,(j)}$ by definition.
          Hence, we obtain as desired%
        }
        \cdots
        &\eqwithref{} (\fcnval{\*l,\*i} - f^{\sparse,(j)}(\gp{\*l,\*i})) -
        (f^{\sparse,(j+1)}(\gp{\*l,\*i}) - f^{\sparse,(j)}(\gp{\*l,\*i}))\\
        &\eqwithref{} \fcnval{\*l,\*i} - f^{\sparse,(j+1)}(\gp{\*l,\*i}).
      \end{align}
    \end{subequations}
  \end{itemize}
  This shows the validity of the statements in
  \eqref{eq:propInvariantResidualInterpolationStatements}
  for $j + 1$.
\end{proof}

\subsection{Correctness Proof of Hierarchization with Breadth-First Search}
\label{sec:a133proofBFS}

\propInvariantBFS*

\begin{proof}
  We start with two observations:

  \begin{itemize}
    \item
    First, due to the breadth-first search nature of \cref{alg:BFS} and the
    hierarchical relation \eqref{eq:directAncestor},
    all grid points with level sum $< q$ are \pop{}ped before
    the first point with level sum $\ge q$ is \pop{}ped.

    \item
    Second, after \pop{}ping all grid points with
    level sum $< q$, the output values of the grid points with
    level sum $\le q$ remain unchanged for the rest of the algorithm:
    If \cref{line:algBFS2} of the algorithm updates the output value of a point
    $(\*l, \*i)$ in the iteration of $(\*l', \*i') \in \liset$ with
    $\normone{\*l'} \ge q$, then \cref{line:algBFS1} implies
    $\*l \ge \*l'$ and thus, $\normone{\*l} \ge \normone{\*l'} \ge q$.
    However, $\normone{\*l} = q$ is not possible as
    this would imply that $\normone{\*l} = \normone{\*l'}
    \implies (\*l, \*i) = (\*l', \*i')$ by \cref{line:algBFS1},
    but $(\*l, \*i) = (\*l', \*i')$ is explicitly excluded in the
    \texttt{\algorithmicfor} loop of \cref{line:algBFS1}.
    Therefore, we must have $\normone{\*l} > q$.
    Hence, if a point $(\*l, \*i)$ with level sum $\ge q$ has been \pop{}ped,
    only surpluses of points with level sum $> q$ may be updated.
  \end{itemize}

  \noindent
  Now, we prove the asserted claim by induction over $q$.

  \noindent
  \textbf{Induction base case:}
  For $q = 0$, \cref{alg:BFS} sets $\linout{\*l,\*i}$ to
  $\fcnval{\*l,\*i}$ in \cref{line:algBFS3}.
  As the sum in \eqref{eq:propInvariantBFS} is empty,
  the claim is correct for $q = 0$.

  \noindent
  \textbf{Induction step case:}
  Let $\linout[(q)]{\*l',\*i'}$ and
  $\linout[(q+1)]{\*l',\*i'}$
  be the surpluses after \pop{}ping all
  grid points with level sum $< q$ and $< q + 1$, respectively.
  We show the induction step $q \to (q + 1)$, i.e.,
  we assume that the assertion is true for $q$
  and prove that after \pop{}ping all grid points with level sum $< q + 1$,
  it holds
  \begin{equation}
    \label{eq:proofPropInvariantBFS1}
    \linout[(q+1)]{\*l,\*i}
    = \fcnval{\*l,\*i} -
    \largesum{\normone{\*l'} < q+1} \linout[(q+1)]{\*l',\*i'}
    \fundbasis{\*l',\*i'}(\gp{\*l,\*i}),\quad
    (\*l, \*i) \in \liset,\;\;
    \normone{\*l} = q+1.
  \end{equation}
  Therefore, let $(\*l, \*i) \in \liset$ fulfill $\normone{\*l} = q+1$.
  The update in \cref{line:algBFS2} can safely be applied
  with all grid points $(\*l', \*i')$ with level sum $q$.
  The grid points $(\*l', \*i')$ that do not satisfy the relation in the set in
  \cref{line:algBFS1} do not contribute as
  $\fundbasis{\*l',\*i'}(\gp{\*l,\*i}) = 0$
  due to the necessary condition \eqref{eq:fundamentalPropertyImplicationMV}.
  By summing all updates from \cref{line:algBFS2}, we obtain
  \begin{subequations}
    \begin{align}
      \linout[(q+1)]{\*l,\*i}
      &= \linout[(q)]{\*l,\*i} -
      \largesum{\normone{\*l'} = q} \linout[(q)]{\*l',\*i'}
      \fundbasis{\*l',\*i'}(\gp{\*l,\*i}).\\
      \intertext{%
        After inserting the induction hypothesis
        for the first $\linout[(q)]{\*l,\*i}$, we have%
      }
      \cdots
      &= \paren*{
        \fcnval{\*l,\*i} -
        \largesum{\normone{\*l'} < q} \linout[(q)]{\*l',\*i'}
        \fundbasis{\*l',\*i'}(\gp{\*l,\*i})
      } -
      \largesum{\normone{\*l'} = q} \linout[(q)]{\*l',\*i'}
      \fundbasis{\*l',\*i'}(\gp{\*l,\*i})\\
      &= \hphantom{\Biggl(}\fcnval{\*l,\*i} -
      \largesum{\normone{\*l'} < q + 1} \linout[(q)]{\*l',\*i'}
      \fundbasis{\*l',\*i'}(\gp{\*l,\*i}).
    \end{align}
  \end{subequations}
  As noted above, we have
  $\fa{(\*l', \*i'),\, \normone{\*l'} < q + 1}{
    \linout[(q)]{\*l',\*i'} = \linout[(q+1)]{\*l',\*i'}
  }$
  (the values of points with level sum $< q + 1$
  do not change after \pop{}ping all points with level sum $< q$).
  This shows the induction claim \eqref{eq:proofPropInvariantBFS1}.
\end{proof}

\disableornamentsfornextheadingtrue
\subsection{%
  Proof for the Correctness of the Unidirectional Principle on
  Spatially Adaptive Sparse Grids%
}
\label{sec:a134proofCorrectnessUnidirectionalPrincipleSASG}

\lemmaChainExistenceSufficient*

\begin{proof}
  We prove the assertion by induction over $j = 0, \dotsc, d$.

  For $j = 0$, the operator $\upop{\emptyset}$ is by definition
  \eqref{eq:upopProduct} the identity operator $\idop$.
  The assumption $(\upop{\emptyset})_{\*k'',\*k'} \not= 0$
  implies that $\*k' = \*k''$, since the identity matrix is diagonal.
  Therefore, the chain $(\chain{0})$ from $\*k'$ to $\*k''$ is given by
  $\chain{0} = \*k'$, which is contained in $\liset$.

  For the induction step $j \to (j+1)$, we split \cref{eq:upopProduct},
  i.e.,
  \begin{equation}
    \upop{t_1,\dotsc,t_{j+1}}
    = \upop{t_{j+1}} \upop{t_j} \dotsm \upop{t_1}
    = \upop{t_{j+1}} \upop{t_1,\dotsc,t_j},
  \end{equation}
  and infer by assumption
  \begin{equation}
    \label{eq:proofLemmaChainExistenceSufficient1}
    0
    \not= (\upop{t_1,\dotsc,t_{j+1}})_{\*k'',\*k'}
    = \sum_{\*k \in \liset} (\upop{t_{j+1}})_{\*k'',\*k}
    (\upop{t_1,\dotsc,t_j})_{\*k,\*k'}.
  \end{equation}
  Consequently,
  there is at least one summation index $\*k$
  for which both factors do not vanish.
  The first factor $(\upop{t_{j+1}})_{\*k'',\*k}$ can by definition
  only be non-zero if $\*k \samepole{t_{j+1}} \*k''$.
  The second factor $(\upop{t_1,\dotsc,t_j})_{\*k,\*k'}$ being
  non-zero implies that by induction hypothesis,
  $\liset$ contains the chain $(\chain{0}, \dotsc, \chain{j})$
  from $\*k'$ to $\*k$ with respect to $(t_1, \dotsc, t_j)$.
  The combination of both statements leads to
  the chain $(\chain{0}, \dotsc, \chain{j}, \chain{j+1})$ from $\*k'$
  to $\*k''$ with respect to $(t_1, \dotsc, t_{j+1})$.
  All points of the chain are contained in $\liset$.
\end{proof}

\lemmaChainExistenceNecessary*

\begin{proof}
  Again, we prove the claim by induction over $j = 0, \dotsc, d$.

  For $j = 0$, the operator $\upop{\emptyset}$ is the identity operator.
  Therefore, the \lhs of \eqref{eq:lemmaChainExistenceNecessary} is one
  (due to $\chain{0} = \*k'$).
  The \rhs is by convention also one, as it is an empty product.

  \setlength{\abovedisplayskip}{9pt}%
  \setlength{\belowdisplayskip}{9pt}%
  For the induction step $j \to (j+1)$, we consider again
  \begin{equation}
    \label{eq:proofLemmaChainExistenceNecessary1}
    (\upop{t_1,\dotsc,t_{j+1}})_{\chain{j+1},\*k'}
    = \sum_{\*k \in \liset} (\upop{t_{j+1}})_{\chain{j+1},\*k}
    (\upop{t_1,\dotsc,t_j})_{\*k,\*k'}
  \end{equation}%
  similar to \eqref{eq:proofLemmaChainExistenceSufficient1}.
  Recall that
  \begin{subequations}
    \begin{alignat}{4}
      \chainuv{j}_t
      &= k''_t
      &&\;\;\text{and}\;\;
      &\chainuv{j+1}_t
      &= k''_t
      &&\quad\text{for } t \in \{t_1, \dotsc, t_j\},\\
      \label{eq:prooflemmaChainExistenceNecessary}
      \chainuv{j}_t
      &= k'_t
      &&\;\;\text{and}\;\;
      &\chainuv{j+1}_t
      &= k''_t
      &&\quad\text{for } t = t_{j+1},\\
      \chainuv{j}_t
      &= k'_t
      &&\;\;\text{and}\;\;
      &\chainuv{j+1}_t
      &= k'_t
      &&\quad\text{for } t \notin \{t_1, \dotsc, t_j, t_{j+1}\}.
    \end{alignat}
  \end{subequations}
  We now argue that all summands of
  \eqref{eq:proofLemmaChainExistenceNecessary1} vanish,
  except the summand with index $\chain{j}$.
  There are two cases for the summation index $\*k$,
  if we assume $\*k \not= \chain{j}$:
  \begin{itemize}
    \item
    If there is a $t \in \{t_1, \dotsc, t_j\}$ with $k_t \not= k''_t$,
    then we have $k_t \not= k''_t = \chainuv{j+1}_t$.
    Consequently, $\chain{j+1} \not\samepole{t_{j+1}} \*k$ and
    $(\upop{t_{j+1}})_{\chain{j+1},\*k} = 0$ due to \eqref{eq:upopEntries},
    i.e., the first factor of the $\*k$-th summand in
    \eqref{eq:proofLemmaChainExistenceNecessary1} vanishes.

    \item
    If there is a $t \notin \{t_1, \dotsc, t_j\}$ with $k_t \not= k'_t$,
    then the second factor $(\upop{t_1,\dotsc,t_j})_{\*k,\*k'}$
    of the $\*k$-th summand in
    \eqref{eq:proofLemmaChainExistenceNecessary1} vanishes.
    Indeed, if we assume the contrary,
    then \cref{lemma:chainExistenceSufficient} implies that there is
    a chain from $\*k'$ to $\*k$ with respect to $(t_1, \dotsc, t_j)$.
    However, by definition of the chain, this means that
    $\*k'$ and $\*k$ coincide in all other dimensions
    (which are not in $\{t_1, \dotsc, t_j\}$).
    This contradicts $k_t \not= k'_t$ and therefore
    $(\upop{t_1,\dotsc,t_j})_{\*k,\*k'}$ must vanish.
  \end{itemize}
  We infer that only the summand $\*k = \chain{j}$ remains in
  \eqref{eq:proofLemmaChainExistenceNecessary1}:
  \begin{equation}
    (\upop{t_1,\dotsc,t_{j+1}})_{\chain{j+1},\*k'}
    = (\upop{t_{j+1}})_{\chain{j+1},\chain{j}}
    (\upop{t_1,\dotsc,t_j})_{\chain{j},\*k'}.
  \end{equation}
  The first factor equals
  \begin{equation}
    (\upop{t_{j+1}})_{\chain{j+1},\chain{j}}
    = (\upopuv{t_{j+1}}{\eqclass{\chain{j+1}}{\samepole{t_{j+1}}}})%
    _{\chainuv{j+1}_{t_{j+1}},\chainuv{j}_{t_{j+1}}}
    = (\upopuv{t_{j+1}}{\eqclass{\chain{j+1}}{\samepole{t_{j+1}}}})%
    _{k''_{t_{j+1}},k'_{t_{j+1}}}
  \end{equation}
  by \cref{eq:upopEntries,eq:prooflemmaChainExistenceNecessary}
  (and due to $\chain{j} \samepole{t_{j+1}} \chain{j+1}$).
  The second factor equals
  \begin{equation}
    (\upop{t_1,\dotsc,t_j})_{\chain{j},\*k'}
    =
    (\upopuv{t_1}{\eqclass{\chain{1}}{\samepole{t_1}}})_{k''_{t_1},k'_{t_1}}
    \dotsm
    (\upopuv{t_j}{\eqclass{\chain{j}}{\samepole{t_j}}})_{k''_{t_j},k'_{t_j}}
  \end{equation}
  by induction hypothesis.
  Hence, the product of both factors is
  \begin{equation}
    (\upop{t_1,\dotsc,t_{j+1}})_{\chain{j+1},\*k'}
    =
    (\upopuv{t_1}{\eqclass{\chain{1}}{\samepole{t_1}}})_{k''_{t_1},k'_{t_1}}
    \dotsm
    (\upopuv{t_{j+1}}{\eqclass{\chain{j+1}}{\samepole{t_{j+1}}}})%
    _{k''_{t_{j+1}},k'_{t_{j+1}}}.
    \vspace*{-2.5em}
  \end{equation}
\end{proof}

\vspace*{1em}
\pagebreak

\propCorrectnessUPCharacterization*

\begin{proof}
  ``$\implies$'':
  Let the \up be correct for $\linop$ and $(t_1, \dotsc, t_d)$
  and $\*k', \*k'' \in \liset$ with $(\linop)_{\*k'',\*k'} \not= 0$.
  Then, we obtain
  \begin{equation}
    (\upop{t_1,\dotsc,t_d})_{\*k'',\*k'}
    = (\linop)_{\*k'',\*k'}
    \not= 0.
  \end{equation}
  By \cref{lemma:chainExistenceSufficient},
  this implies that $\liset$ contains the chain from $\*k'$ to $\*k''$
  with respect to $(t_1, \dotsc, t_d)$.

  ``$\impliedby$'':
  For the converse direction, we assume that there are chains
  from $\*k'$ to $\*k''$ with respect to $(t_1, \dotsc, t_d)$
  for all $\*k', \*k'' \in \liset$ with $(\linop)_{\*k'',\*k'} \not= 0$.
  Let $\*k', \*k'' \in \liset$ be arbitrary.
  There are two cases:
  \begin{itemize}
    \item
    ${(\linop)_{\*k'',\*k'} \not= 0}$:
    By assumption, $\liset$ contains the chain from $\*k'$ to $\*k''$
    with respect to $(t_1, \dotsc, t_d)$.
    We apply \cref{lemma:chainExistenceNecessary} with $j = d$
    to infer
    \begin{equation}
      (\upop{t_1,\dotsc,t_d})_{\*k'',\*k'}
      =
      (\upopuv{t_1}{\eqclass{\chain{1}}{\samepole{t_1}}})_{k''_{t_1},k'_{t_1}}
      \dotsm
      (\upopuv{t_d}{\eqclass{\chain{d}}{\samepole{t_d}}})_{k''_{t_d},k'_{t_d}}
      = (\linop)_{\*k'',\*k'}
    \end{equation}
    by the assumption \eqref{eq:tensorProductOperator} on
    the tensor product structure of $\linop$.

    \item
    ${(\linop)_{\*k'',\*k'} = 0}$:
    In this case, $(\upop{t_1,\dotsc,t_d})_{\*k'',\*k'}$ must vanish as well.
    Indeed, if we assume the contrary
    $(\upop{t_1,\dotsc,t_d})_{\*k'',\*k'} \not= 0$,
    then we can apply \cref{lemma:chainExistenceSufficient}
    to obtain that $\liset$ contains the chain from $\*k'$ to $\*k''$
    with respect to $(t_1, \dotsc, t_d)$.
    We conclude with \cref{lemma:chainExistenceNecessary} as in the first case
    that $(\upop{t_1,\dotsc,t_d})_{\*k'',\*k'} = (\linop)_{\*k'',\*k'} = 0$,
    which is a contradiction.
  \end{itemize}
  In any case, we obtain
  $(\upop{t_1,\dotsc,t_d})_{\*k'',\*k'} = (\linop)_{\*k'',\*k'}$,
  from which follows the correctness of the \up\punctfix{,}
  as $\*k'$ and $\*k''$ are arbitrary.
\end{proof}

\breakpagebeforenextheadingtrue
\subsection{Correctness Proof of Hermite Hierarchization}
\label{sec:a135proofHermiteHierarchization}

\propInvariantHermiteHierarchization*

\begin{proof}
  We prove the assertion by induction over $l = 0, \dotsc, n$.

  For the induction base case $l = 0$ and $i \in \{0, 1\}$, we have
  \begin{equation}
    \sum_{i'=0}^1
    \linout{0,i'} \deriv[q]{x}{\bspl[\wfs]{0,i'}{p}}(\gp{0,i})
    = \kronecker{q}{0} \cdot \fcnval{0,i} +
    \kronecker{q}{1} \cdot (\fcnval{0,1} - \fcnval{0,0})
    = \deriv[q]{x}{\fgintp{0}}(\gp{0,i})
  \end{equation}
  for $q = 0, \dotsc, \frac{p-1}{2}$ by
  \cref{%
    line:algHermiteHierarchization1,%
    line:algHermiteHierarchization3%
  }
  of \cref{alg:hermiteHierarchization}.

  For the induction step case $(l-1) \to l$,
  it suffices to show that
  \begin{equation}
    \label{eq:proofPropInvariantHermiteHierarchization1}
    \deriv[q]{x}{\fgintp{l-1}}(\gp{l,i})
    \overset{!}{=} \sum_{l'=0}^{l-1} \sum_{i' \in \hiset{l'}}
    \linout{l',i'} \deriv[q]{x}{\bspl[\wfs]{l',i'}{p}}(\gp{l,i}),\quad
    i = 0, \dotsc, 2^l,\;\;
    q = 0, \dotsc, \frac{p-1}{2}.
  \end{equation}
  Indeed, if \eqref{eq:proofPropInvariantHermiteHierarchization1} holds,
  then we obtain by
  \cref{line:algHermiteHierarchization6,line:algHermiteHierarchization8}
  of \cref{alg:hermiteHierarchization}
  \begin{subequations}
    \begin{align}
      \deriv[q]{x}{\fgintp{l}}(\gp{l,i})
      &= \deriv[q]{x}{\fgintp{l-1}}(\gp{l,i}) +
      \deriv[q]{x}{r^{(l)}_l}(\gp{l,i})\\
      &= \sum_{l'=0}^{l-1} \sum_{i' \in \hiset{l'}}
      \linout{l',i'} \deriv[q]{x}{\bspl[\wfs]{l',i'}{p}}(\gp{l,i}) +
      \sum_{i' \in \hiset{l}}
      \linout{l,i'} \deriv[q]{x}{\bspl[\wfs]{l,i'}{p}}(\gp{l,i})\\
      &= \sum_{l'=0}^l \sum_{i' \in \hiset{l'}}
      \linout{l',i'} \deriv[q]{x}{\bspl[\wfs]{l',i'}{p}}(\gp{l,i}),
    \end{align}
  \end{subequations}
  which is the desired relation
  \eqref{eq:propInvariantHermiteHierarchization}
  for level $l$.

  To prove \eqref{eq:proofPropInvariantHermiteHierarchization1},
  we separate two cases:
  \begin{itemize}
    \item
    \mbox{${i \notin \hiset{l}}$: In this case,}
    the ``true'' level of $\gp{l,i}$ is actually $\le l - 1$.
    Therefore, we can apply the induction hypothesis
    for \cref{eq:propInvariantHermiteHierarchization} to
    obtain \eqref{eq:proofPropInvariantHermiteHierarchization1}.

    \item
    \mbox{${i \in \hiset{l}}$: In this case,}
    we cannot directly apply the induction hypothesis,
    as it only holds for grid points of levels $\le l - 1$.
    However, we note that in
    \eqref{eq:proofPropInvariantHermiteHierarchization1},
    the term $\deriv[q]{x}{\fgintp{l-1}}(\gp{l,i})$
    is the $q$-th derivative of the Hermite interpolant of
    the data $\deriv[q']{x}{\fgintp{l-1}}(\gp{l,i\pm1})$
    ($q' = 0, \dotsc, \frac{p-1}{2}$),
    as determined in \cref{line:algHermiteHierarchization4}
    of \cref{alg:hermiteHierarchization}.
    The ``true'' level of the grid points $\gp{l,i\pm1}$ is
    actually $\le l - 1$ due to $i \in \hiset{l}$.
    Hence, we can apply the induction hypothesis
    for \cref{eq:propInvariantHermiteHierarchization}
    to conclude that the interpolated data of
    $\deriv[q]{x}{\fgintp{l-1}}(\gp{l,i})$ are given by
    \begin{equation}
      \deriv[q']{x}{\fgintp{l-1}}(\gp{l,i\pm1})
      = \deriv[q']{x}{
        \bracket*{
          \sum_{l'=0}^{l-1} \sum_{i' \in \hiset{l'}}
          \linout{l',i'} \bspl[\wfs]{l',i'}{p}
        }
      }(\gp{l,i\pm1}),\quad
      q' = 0, \dotsc, \frac{p-1}{2}.
    \end{equation}
    The linear combination in square brackets
    is a polynomial of degree $\le p$ on the interval
    $\clint{\gp{l,i-1}, \gp{l,i+1}}$
    by construction of the hierarchical basis functions
    $\bspl[\wfs]{l',i'}{p}$ ($l' = 0, \dotsc, l - 1$, $i' \in \hiset{l'}$).
    Due to the uniqueness of Hermite interpolation
    (\cref{lemma:hermiteInterpolation}),
    the interpolation polynomial of the data must
    coincide on $\clint{\gp{l,i-1}, \gp{l,i+1}}$
    with the term in square brackets.
    In particular, as $\gp{l,i} \in \clint{\gp{l,i-1}, \gp{l,i+1}}$,
    we obtain the claim \eqref{eq:proofPropInvariantHermiteHierarchization1}.
  \end{itemize}
  In both cases, we obtain the desired relation
  \eqref{eq:proofPropInvariantHermiteHierarchization1}.
\end{proof}

\corAlgHermiteHierarchizationCorrectness*

\begin{proof}
  By \cref{prop:invariantHermiteHierarchization} ($q = 0$), we have
  \begin{equation}
    \sum_{l'=0}^n \sum_{i' \in \hiset{l'}}
    \linout{l',i'} \bspl[\wfs]{l',i'}{p}(\gp{l,i})
    = \sum_{l'=0}^l \sum_{i' \in \hiset{l'}}
    \linout{l',i'} \bspl[\wfs]{l',i'}{p}(\gp{l,i})
    = \fgintp{l}(\gp{l,i}),\quad
    l \le n,\; i \in \hiset{l},
  \end{equation}
  as $\bspl[\wfs]{l',i'}{p}(\gp{l,i}) = 0$ if $l' > l$
  (weakly fundamental property \eqref{eq:weaklyFundamentalProperty}).
  \Cref{line:algHermiteHierarchization8} of
  \cref{alg:hermiteHierarchization} implies
  $\fgintp{l}(\gp{l,i})
  = \fgintp{l-1}(\gp{l,i}) + r^{(l)}_l(\gp{l,i})$, and by
  \cref{line:algHermiteHierarchization5,line:algHermiteHierarchization7},
  the second summand $r^{(l)}_l(\gp{l,i})$ equals
  $\fcnval{l,i} - \fgintp{l-1}(\gp{l,i})$,
  which cancels out the first summand, resulting in
  $\fgintp{l}(\gp{l,i}) = \fcnval{l,i}$.
  Combining these statements, we obtain
  \begin{equation}
    \sgintp(\gp{l,i})
    = \fcnval{l,i},\quad
    l \le n,\; i \in \hiset{l},
    \quad\text{where}\quad
    \sgintp
    \ceq \sum_{l'=0}^n \sum_{i' \in \hiset{l'}}
    \linout{l',i'} \bspl[\wfs]{l',i'}{p}.
  \end{equation}
  This means that $\sgintp$ is the correct hierarchical interpolant
  of the given function values
  (see \cref{eq:hierarchizationInterpolant}).
  Due to the uniqueness of hierarchical surpluses,
  the coefficients $\linout{l,i}$
  (which are the output of \cref{alg:hermiteHierarchization})
  must coincide with the surpluses $\surplus{l,i}$.
\end{proof}


%!TEX root = ../TTK18-Summary.tex
\section{Linear matrix inequalities for piecewise affine systems}

\subsection{Piecewise affine systems}
A piecewise affine system is a system where the state space $X$ is divided into non-overlapping partitions $X_i$ with distinct models in each partition:
%
\begin{itemize}
  \item Partitions containing the origin are linear:
  \begin{equation}
    \begin{split}
      x &= A_i x \\
      x_{k+1} &= A_i x_k
    \end{split}
  \end{equation}
  \item Partitions not containing the origin are affine:
  \begin{equation}
    \begin{split}
      x &= A_i x + a_i \\
      x_{k+1} &= A_i x_k + a_i
    \end{split}
  \end{equation}
\end{itemize}
%
The partitions are indexed, with an index set
%
\begin{equation}
  I = I_0 \cup I_1
\end{equation}
%
where $I_0$ are the parititions containing the origin, and $I_1$ are the partitions not containing the origin.

\subsection{Lyapunov stability}
Sometimes you can find a Lyapunov function for the whole PWA system:
%
\begin{itemize}
  \item If $a_i = 0 \forall i$ and there exists a $P = P^T > 0$ such that
  \begin{equation}
    A_i^T P + P A_i < 0 \quad \forall i \in I,
  \end{equation}
  then the origin is exponentially stable.
  \item If $a_i = 0 \forall i$ and there exists an $R_i > 0 \forall i \in I$ such that
  \begin{equation}
    \sum_{i \in I} (A_i^T R_i + R_i A_i) > 0,
  \end{equation}
  then a common Lyapunov function can be found.
\end{itemize}
%
When a common function cannot be found, we must look for one that depends on the partition.

\subsubsection{Notation}
\begin{equation}
  \bar{A}_i = \begin{bmatrix} A_i & a_i \\ 0 & 0 \end{bmatrix}
\end{equation}
%
Each partition is a polyhedron, so we can write
%
\begin{equation}
  \bar{E}_i = \begin{bmatrix} E_i & e_i \end{bmatrix}, \quad
  \bar{F}_i = \begin{bmatrix} F_i & f_i \end{bmatrix}
\end{equation}
%
where $e_i = 0$ and $f_i = 0$ for all $i \in I_0$ such that
%
\begin{gather}
  \bar{E}_i \begin{bmatrix} x \\ 1 \end{bmatrix} \geq 0 \quad \forall x \in X_i \forall i \in I \\
  \bar{F}_i \begin{bmatrix} x \\ 1 \end{bmatrix} = \bar{F}_j \begin{bmatrix} x \\ 1 \end{bmatrix} \quad \forall\; x \in X_i \cap X_j, \forall i, j \in I
\end{gather}
%
That is, $E_i x + e_i \geq 0$ for all values of $x$, and $F_i x + f_i = F_j x + f_j$ for all $x$ along borders between partitions.

\subsubsection{Lyapunov function}
\begin{equation}
  V(x) =
  \begin{cases}
    x\tp P_i x, &x \in X_i, i \in I_0 \\
    \bmat{x\\1}\tp \bar{P}_i \bmat{x\\1}, &x \in X_i, i \in I_1
  \end{cases}
\end{equation}
%
where
%
\begin{equation}\label{eq:pwa-lyapunov-matrix}
    P_i = F_i^T T F_i,\quad \bar{P}_i = \bar{F}_i^T T \bar{F}_i
\end{equation}
%
and $T$ is some symmetric matrix with positive elements.

\subsubsection{Relaxing the LF}
While $V(x) > 0$ is required for all $x$, we only need $P_i > 0$ for $x \in X_i$. The S-procedure can be used to alter the LF to reflect this:
%
\begin{equation}
  V(x) =
  \begin{cases}
    x\tp E_i\tp U_i E_i x, &x \in X_i, i \in I_0 \\
    \begin{bmatrix} x \\ 1 \end{bmatrix}\tp
    \bar{E}_i\tp U_i \bar{E}_i\tp
    \begin{bmatrix} x \\ 1 \end{bmatrix}, &x \in X_i, i \in I_1
  \end{cases}
\end{equation}
%
where $U_i$ has only non-negative elements. The condition $\dot{V}(x)<0$ only needs to hold within each partition, as well.

\subsubsection{Overall LF design}
Find symmetric matrices $T$, $U_i$, $W_i$ ($U_i$ and $W_i$ with no negative elements), such that
%
\begin{equation}
  \begin{split}
    \begin{rcases}
      A_i\tp P_i + P_i A_i + E_i\tp U_i E_i < 0 \\
      P_i - E_i\tp W_i E_i > 0
    \end{rcases} &i \in I_0 \\
    \begin{rcases}
      \bar{A}_i\tp \bar{P}_i + \bar{P}_i \bar{A}_i + \bar{E}_i\tp U_i \bar{E}_i < 0 \\
      \bar{P}_i - \bar{E}_i\tp W_i \bar{E}_i > 0
    \end{rcases} &i \in I_1
  \end{split}
\end{equation}
%
with \eqref{eq:pwa-lyapunov-matrix} still holding:
%
\begin{equation}
  P_i = F_i^T T F_i,\quad \bar{P}_i = \bar{F}_i^T T \bar{F}_i
\end{equation}

$\bar{E}_i$ and $\bar{F}_i$ can be determined e.g. with explicit formulas found in papers by Johansson and Ratzer.

\subsection{Discrete-time Lyapunov stability}
With discrete systems
%
\begin{itemize}
  \item we don't need a continuous LF,
  \item we use LF difference rather than LF differential,
  \item we must keep track of possible next-timestep partitions.
\end{itemize}

If there exists matrices $R_i > 0$ such that
%
\begin{equation}
  \sum_{i \in I} (A_i\tp R_i A_i - R_I) > 0
\end{equation}
%
then no common LF can be found for the PWL system.

\subsubsection{Stability criteria}
$f(X_i)$ is a quadratic function positive on $X_i$, such as
%
\begin{equation}
  f(X_i) =
  \begin{cases}
    x\tp E_i\tp U_i E_i x, & x \in I_0 \\
    \bsmat{x \\ 1}\tp \bar{E}_i\tp U_i \bar{E}_i \bsmat{x \\ 1}, & x \in I_1
  \end{cases}
\end{equation}

Rewrite the system
%
\begin{equation}
  \bar{x} = \bmat{x \\ 1}, \quad \bar{x}_{k+1} = \bar{A}_i \bar{x}_k
\end{equation}
%
where
%
\begin{equation}
  \bar{A}_i =
  \begin{cases}
    \bmat{A_i & a_i \\ 0 & 1},&
    \underbrace{x_k \in X_i, i \in I_1, x_{k+1} \in X_j, j \in I_1}
              _{x \text{ moving between } I_1 \text{ partitions}} \\
    \bmat{A_i & a_i \\ 0 & 0},&
    \underbrace{x_k \in X_i, i \in I_1, x_{k+1} \in X_j, j \in I_0}
              _{x \text{ moving from } I_1 \text{ to } I_0 \text{ partition}} \\
    \bmat{A_i & 0 \\ 0 & 0},&
    \underbrace{x_k \in X_i, i \in I_0, x_{k+1} \in X_j, j \in I_0}
              _{x \text{ moving between } I_0 \text{ partitions}}.
  \end{cases}
\end{equation}
%
This formulation requires that $\cup_{i \in I_0} X_i$ is positively invariant.\footnote{All trajectories in the set never leave it.} The system is then stable if
%
\begin{equation}
  \begin{split}
    P_i - f(X_i) > 0,\quad & \forall i \\
    P_i - \bar{A}_i\tp P_j \bar{A}_i - f(X_{ij}) > 0,\quad & \forall (i,j) \mbox{ with nonempty } X_{ij}
  \end{split}
\end{equation}
%
where $X_{ij} \subset X_i$ is the region where the state in the next timestep will move to $X_j$.

\subsubsection{Relaxations}
$R$ is a bounded polyhedron and $V(R)$ is its vertice set. Then this function is quadratic and positive over $R$:
\begin{equation}
  f(R) = \bsmat{x \\ 1}\tp H \bsmat{x \\ 1}
\end{equation}
%
where
%
\begin{equation}
  \begin{split}
    H &= \bar{H} + C \\
    \bar{H} &< 0 \\
    C &= \bsmat{0 & 0 \\ 0 & c} \\
    c &> 0 \\
    \bsmat{v_i \\ 1}\tp (\bar{H} + C) \bsmat{v_i \\ 1} &> 0,\quad \forall v_i \in V(R)
  \end{split}
\end{equation}

TTK18 Optimaliseringsbasert reguleringsdesign og analyse/tex/sec-lmis-for-pwa.tex


\documentstyle[11pt,reduce]{article}
\title{{\tt TRIGSIMP}\\
A REDUCE Package for the Simplification and Factorization of Trigonometric
and Hyperbolic Functions}
\date{}
\author{Wolfram Koepf\\
        Andreas Bernig\\
        Herbert Melenk\\
        ZIB Berlin \\
        email: {\tt  Koepf@ZIB-Berlin.de}}
\begin{document}
\maketitle
\section{Introduction}

The REDUCE package TRIGSIMP is a useful tool for all kinds of trigonometric and
hyperbolic simplification and factorization. There are three
procedures included in TRIGSIMP: trigsimp, trigfactorize and triggcd.
The first is for finding simplifications of trigonometric or
hyperbolic expressions with many options, the second for factorizing
them and the third
for finding the greatest common divisor of two trigonometric or
hyperbolic polynomials.

To start the package it must be loaded by:
{\small
\begin{verbatim}
1: load trigsimp;
\end{verbatim}
}\noindent

\section{\REDUCE{} operator {\tt trigsimp}}

As there is no normal form for trigonometric and hyperbolic functions, the same
function can convert in many different directions, e.g.
$\sin(2x) \leftrightarrow 2\sin(x)\cos(x)$.
The user has the possibility to give several parameters to the
procedure {\tt trigsimp} in order to influence the direction of transformations.
The decision whether a rational expression in trigonometric
and hyperbolic functions vanishes or not is possible.

To simplify a function {\tt f}, one uses {\tt trigsimp(f[,options])}. Example:
{\small
\begin{verbatim}
2: trigsimp(sin(x)^2+cos(x)^2);

1
\end{verbatim}
}\noindent

Possible options are (* denotes the default):
\begin{enumerate}
\item {\tt sin} (*) or {\tt cos}
\item {\tt sinh} (*) or {\tt cosh}
\item {\tt expand} (*) or {\tt combine} or {\tt compact}
\item {\tt hyp} or {\tt trig} or {\tt expon}
\item {\tt keepalltrig}
\end{enumerate}

From each group one can use at most one option, otherwise an error
message will occur. The first group fixes the preference used while
transforming a trigonometric expression:
{\small
\begin{verbatim}
3: trigsimp(sin(x)^2);

      2
sin(x)

4: trigsimp(sin(x)^2,cos);

         2
 - cos(x)  + 1
\end{verbatim}
}\noindent

The second group is the equivalent for the hyperbolic functions.
The third group determines the type of transformations. With
the default {\tt expand}, an expression is written in a form only using
single arguments and no sums of arguments:
{\small
\begin{verbatim}
5: trigsimp(sin(2x+y));

                                 2
2*cos(x)*cos(y)*sin(x) - 2*sin(x) *sin(y) + sin(y)
\end{verbatim}
}\noindent

With {\tt combine}, products of trigonometric functions are transformed to
trigonometric functions involving sums of arguments:
{\small
\begin{verbatim}
6: trigsimp(sin(x)*cos(y),combine);

 sin(x - y) + sin(x + y)
-------------------------
            2
\end{verbatim}
}\noindent

With {\tt compact}, the REDUCE operator {\tt compact} \cite{hearns}
is applied to {\tt f}.
This leads often to a simple form, but in contrast to {\tt expand} one
doesn't get a normal form. Example for {\tt compact}:
{\small
\begin{verbatim}
7: trigsimp((1-sin(x)**2)**20*(1-cos(x)**2)**20,compact);

      40       40
cos(x)  *sin(x)
\end{verbatim}
}\noindent

With the fourth group each expression is transformed to a
trigonometric, hyperbolic or exponential form:
{\small
\begin{verbatim}
8: trigsimp(sin(x),hyp);

 - sinh(i*x)*i

9: trigsimp(sinh(x),expon);

  2*x
 e    - 1
----------
      x
   2*e

10: trigsimp(e^x,trig);

     x          x
cos(---) + sin(---)*i
     i          i
\end{verbatim}
}\noindent

Usually, {\tt tan}, {\tt cot}, {\tt sec}, {\tt csc} are expressed in terms of
{\tt sin} and {\tt cos}. It can
be sometimes useful to avoid this, which is handled by the option
{\tt keepalltrig}:
{\small
\begin{verbatim}
11: trigsimp(tan(x+y),keepalltrig);

  - (tan(x) + tan(y))
----------------------
  tan(x)*tan(y) - 1
\end{verbatim}
}\noindent

It is possible to use the options of different groups simultaneously:
{\small
\begin{verbatim}
12: trigsimp(sin(x)**4,cos,combine);

 cos(4*x) - 4*cos(2*x) + 3
---------------------------
             8
\end{verbatim}
}\noindent

Sometimes, it is necessary to handle an expression in different steps:
{\small
\begin{verbatim}
13: trigsimp((sinh(x)+cosh(x))**n+(cosh(x)-sinh(x))**n,expon);

  2*n*x
 e      + 1
------------
     n*x
    e

14: trigsimp(ws,hyp);

2*cosh(n*x)

15: trigsimp((cosh(a*n)*sinh(a)*sinh(p)+cosh(a)*sinh(a*n)*sinh(p)+
    sinh(a - p)*sinh(a*n))/sinh(a));

cosh(a*n)*sinh(p) + cosh(p)*sinh(a*n)

16: trigsimp(ws,combine);

sinh(a*n + p)
\end{verbatim}
}\noindent

\section{\REDUCE{} operator {\tt trigfactorize}}

With {\tt trigfactorize(p,x)} one can factorize the trigonometric or
hyperbolic polynomial {\tt p} with respect to the argument x. Example:
{\small
\begin{verbatim}
17: trigfactorize(sin(x),x/2);

        x        x
{2,cos(---),sin(---)}
        2        2
\end{verbatim}
}\noindent

If the polynomial is not coordinated or balanced \cite{art},
the output will equal the input.
In this case, changing the value for x can help to find a factorization:
{\small
\begin{verbatim}
18: trigfactorize(1+cos(x),x);

{cos(x) + 1}

19: trigfactorize(1+cos(x),x/2);

        x        x
{2,cos(---),cos(---)}
        2        2
\end{verbatim}
}\noindent

The polynomial can consist of both trigonometric and hyperbolic functions:
{\small
\begin{verbatim}
20: trigfactorize(sin(2x)*sinh(2x),x);

{4, cos(x), sin(x), cosh(x), sinh(x)}
\end{verbatim}
}\noindent

\section{\REDUCE{} operator {\tt triggcd}}

The operator {\tt triggcd} is an application of {\tt trigfactorize}.
With its help the user can find the greatest common divisor of two
trigonometric or hyperbolic polynomials. It uses the method described
in \cite{art}. The syntax is: {\tt triggcd(p,q,x)}, where p and q
are the polynomials and x is the smallest unit to use. Example:

{\small
\begin{verbatim}
21: triggcd(sin(x),1+cos(x),x/2);

     x
cos(---)
     2

22: triggcd(sin(x),1+cos(x),x);

1
\end{verbatim}
}\noindent

The polynomials p and q can consist of both trigonometric and hyperbolic
functions:
{\small
\begin{verbatim}
23: triggcd(sin(2x)*sinh(2x),(1-cos(2x))*(1+cosh(2x)),x);

cosh(x)*sin(x)
\end{verbatim}
}\noindent

\section{Further Examples}

With the help of the package the user can create identities:
{\small
\begin{verbatim}
24: trigsimp(tan(x)*tan(y));

 sin(x)*sin(y)
---------------
 cos(x)*cos(y)

25: trigsimp(ws,combine);

 cos(x - y) - cos(x + y)
-------------------------
 cos(x - y) + cos(x + y)

26: trigsimp((sin(x-a)+sin(x+a))/(cos(x-a)+cos(x+a)));

 sin(x)
--------
 cos(x)

27: trigsimp(cosh(n*acosh(x))-cos(n*acos(x)),trig);

0

28: trigsimp(sec(a-b),keepalltrig);

  csc(a)*csc(b)*sec(a)*sec(b)
-------------------------------
 csc(a)*csc(b) + sec(a)*sec(b)

29: trigsimp(tan(a+b),keepalltrig);

  - (tan(a) + tan(b))
----------------------
  tan(a)*tan(b) - 1

30: trigsimp(ws,keepalltrig,combine);

tan(a + b)
\end{verbatim}
}\noindent

Some difficult expressions can be simplified:
{\small
\begin{verbatim}

31: df(sqrt(1+cos(x)),x,4);

                              4            2       2            2
(sqrt(cos(x) + 1)*( - 4*cos(x)  - 20*cos(x) *sin(x)  + 12*cos(x)

                      2                       4            2
     - 4*cos(x)*sin(x)  + 8*cos(x) - 15*sin(x)  + 16*sin(x) ))/(16

           4           3           2
   *(cos(x)  + 4*cos(x)  + 6*cos(x)  + 4*cos(x) + 1))

32: trigsimp(ws);

 sqrt(cos(x) + 1)
------------------
        16

33: load taylor;

34: taylor(sin(x+a)*cos(x+b),x,0,4);

cos(b)*sin(a) + (cos(a)*cos(b) - sin(a)*sin(b))*x

                                    2
 - (cos(a)*sin(b) + cos(b)*sin(a))*x

    2*( - cos(a)*cos(b) + sin(a)*sin(b))   3
 + --------------------------------------*x
                     3

    cos(a)*sin(b) + cos(b)*sin(a)   4      5
 + -------------------------------*x  + O(x )
                  3

35: trigsimp(ws,combine);

sin(a - b) + sin(a + b)                                2    2*cos(a + b)   3
------------------------- + cos(a + b)*x - sin(a + b)*x  - --------------*x
            2                                                    3

    sin(a + b)   4      5
 + ------------*x  + O(x )
        3
\end{verbatim}
}\noindent
Certain integrals whose calculation was not possible in REDUCE
(without preprocessing), are now computable:
{\small
\begin{verbatim}
36: int(trigsimp(sin(x+y)*cos(x-y)*tan(x)),x);

       2                                                         2
 cos(x) *x - cos(x)*sin(x) - 2*cos(y)*log(cos(x))*sin(y) + sin(x) *x
---------------------------------------------------------------------
                                  2

37: int(trigsimp(sin(x+y)*cos(x-y)/tan(x)),x);

                                   x  2
(cos(x)*sin(x) - 2*cos(y)*log(tan(---)  + 1)*sin(y)
                                   2

                      x
  + 2*cos(y)*log(tan(---))*sin(y) + x)/2
                      2
\end{verbatim}
}\noindent

Without the package, the integration fails, in the second case one doesn't
receive an answer for many hours.
{\small
\begin{verbatim}

38: trigfactorize(sin(2x)*cos(y)**2,y/2);

{2*cos(x)*sin(x),

      y          y
 cos(---) + sin(---),
      2          2

      y          y
 cos(---) + sin(---),
      2          2

      y          y
 cos(---) - sin(---),
      2          2

      y          y
 cos(---) - sin(---)}
      2          2

39: trigfactorize(sin(y)**4-x**2,y);

          2               2
{ - sin(y)  + x, - (sin(y)  + x)}

40: trigfactorize(sin(x)*sinh(x),x/2);

        x        x         x         x
{4,cos(---),sin(---),cosh(---),sinh(---)}
        2        2         2         2

41: triggcd(-5+cos(2x)-6sin(x),-7+cos(2x)-8sin(x),x/2);

       x        x
2*cos(---)*sin(---) + 1
       2        2

42: triggcd(1-2cosh(x)+cosh(2x),1+2cosh(x)+cosh(2x),x/2);

        x  2
2*sinh(---)  + 1
        2
\end{verbatim}
}

\begin{thebibliography}{99}

\bibitem{art}
Roach, Kelly: Difficulties with Trigonometrics. Notes of a talk.

\bibitem{hearns}
Hearn, A.C.: COMPACT User Manual.
\end{thebibliography}
\end{document}


\documentclass[jou]{apa6}

\usepackage[american]{babel}

\usepackage{csquotes}
\usepackage[style=apa,sortcites=true,sorting=nyt,backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\addbibresource{bibliography.bib}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Discrete Structures
%% The start of RBS stuff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Working internal and external links in PDF
\usepackage{hyperref}
% Extra math symbols in LaTeX
\usepackage{amsmath}
\usepackage{gensymb}
\usepackage{amssymb}
% Enumerations with (a), (b), etc.
\usepackage{enumerate}

\let\OLDitemize\itemize
\renewcommand\itemize{\OLDitemize\addtolength{\itemsep}{-6pt}}

\usepackage{etoolbox}
\makeatletter
\preto{\@verbatim}{\topsep=3pt \partopsep=3pt }
\makeatother

% These sizes redefine APA for A4 paper size
\oddsidemargin 0.0in
\evensidemargin 0.0in
\textwidth 6.27in
\headheight 1.0in
\topmargin -24pt
\headheight 12pt
\headsep 12pt
\textheight 9.19in

\title{Sample Quiz 4}
\author{Discrete Structures, Fall 2020}
\affiliation{RBS}

\leftheader{Discrete Sample Quiz 4}

\abstract{%
}

%\keywords{}

\begin{document}

%\thispagestyle{empty}

\section{Quiz 4: Sets}

\vspace{10pt}
{\bf Question 1.} Define the universe $U$ to be all possible remainders
when we divide by $360$: $\{ 0, 1, 2, \ldots, 359 \}$.
Also define $3$ subsets in this universe:
$$\left\{ \begin{array}{rcl}
K_2 & = & \{ x \in U \,\mid\, x\;\text{divisible by}\;2 \},\\
K_3 & = & \{ x \in U \,\mid\, x\;\text{divisible by}\;3 \},\\
K_5 & = & \{ x \in U \,\mid\, x\;\text{divisible by}\;5 \},\\
\end{array} \right.$$

Denote by $\Phi$ the subset of $U$ containing all numbers
that are mutually prime with $360$ (no common divisors greater than $1$):
$\Phi = \{1,7,11,13,\ldots,359\}$.
Which set equality is valid regarding the subset $\Phi$:

\noindent
{\bf (A)} $\Phi = \left( K_2 \cup K_3 \cup K_5 \right)$\\
{\bf (B)} $\Phi = \left( K_2 \cap K_3 \cap K_5 \right)$\\
{\bf (C)} $\Phi = \left( \overline{K_2} \cup \overline{K_3} \cup \overline{K_5} \right)$\\
{\bf (D)} $\Phi = \left( \overline{K_2} \cap \overline{K_3} \cap \overline{K_5} \right)$\\
{\bf (E)} $\Phi = \left( \overline{K_2 \cap K_3} \cup \overline{K_2 \cap K_5} \cup \overline{K_3 \cap K_5} \right)$

Pick your answer as a single letter like this: {\tt G}

\vspace{6pt}
{\bf Question 2.}
Find the size of the set you constructed in the previous example.

Write your answer as a single non-negative integer like this: {\tt 17}

\vspace{6pt}
{\bf Question 3.} We have the following sets:\\
$A$ is the set of all finite sequences of even positive positive numbers (such as $(6,22,10,14,2,6)$, and so on)\\
$B$ is the set of all infinite nondecreasing lists of even positive numbers (such as $(40 \leq 40 \leq 42 \leq 46 \leq \ldots)$, and so on)\\
$C$ is the set of all infinite nonincreasing lists of even positive numbers (such as $(64 \geq 58 \geq 58 \geq 54 \geq \ldots)$, and so on).\\
Clearly, all three sets are infinite. Determine their cardinalities - which list
of cardinalities is equal to the list  $(|A|,|B|,|C|)$?

\noindent
{\bf (A)} $\left( \left| \mathbb{N} \right|, \left| \mathbb{N} \right|, \left| \mathbb{N} \right| \right)$.
{\bf (B)} $\left( \left| \mathbb{N} \right|, \left| \mathbb{R} \right|, \left| \mathbb{N} \right| \right)$.
{\bf (C)} $\left( \left| \mathbb{N} \right|, \left| \mathbb{N} \right|, \left| \mathbb{R} \right| \right)$.
{\bf (D)} $\left( \left| \mathbb{N} \right|, \left| \mathbb{R} \right|, \left| \mathbb{R} \right| \right)$.
{\bf (E)} $\left( \left| \mathbb{R} \right|, \left| \mathbb{R} \right|, \left| \mathbb{R} \right| \right)$.

Pick your answer as a single letter like this: {\tt G}

\vspace{6pt}
{\bf Question 4.}
Let ${\displaystyle f(x) = (x^2)\;\mathbf{mod}\;11}$. Find the set $f(S)$ if $S = \{ 0,1,2,3,4,5,6,7,8,9,10 \}$.

Write the list of elements of $f(S)$ as a sorted list like this: {\tt 1,2,3}

\vspace{6pt}
{\bf Question 5.}
How many 2-element sets are there in the powerset $\mathcal{P}\left( \{ \{ \mathtt{A}, \mathtt{B} \}, \mathtt{C}, \mathtt{D}, \mathtt{E} \} \right)$?

Write your answer as a non-negative integer like this: {\tt 17}

\vspace{6pt}
{\bf Question 6.}
Given two sets $A = \{ x, y \}$ and $B = \{x, \{x \}\}$, check, if statements are true or false:\\
{\bf (A)} $x \subseteq B$.\\
{\bf (B)} $\emptyset \in \mathcal{P}(B)$.\\
{\bf (C)} $\{x\} \subseteq A - B$.\\
{\bf (D)} $|\mathcal{P}(A)| = 4$.

Write your answer as a sorted list of letters (which are true) like this: {\tt A,B,C,D}

\vspace{6pt}
{\bf Question 7.}
We define functions $g\,:\, A \rightarrow A$ and $f : A \rightarrow A$, where $A \{1, 2, 3, 4\}$ by
listing all argument-value pairs:
$f = \{(1, 2), (2, 3), (3, 4), (4, 1)\}$, $g = \{(1, 3), (2, 1), (3, 4), (4, 2)\}$.
Find the value pairs for the function $(f \circ g)^{-1}$.

Write your answer as a comma-separated list like this: {\tt (1,1),(2,2),(3,3),(4,4)}

\vspace{6pt}
{\bf Question 8.} Find the value of this infinite sum:
$1 - 1/3 + 1/9 - 1/27 + 1/81 - \ldots$.

Write your answer as a simple fraction: {\tt P/Q}

\vspace{6pt}
{\bf Question 9.} It is known that the function $f(n) = n^3 +88n^2 +3$ is in $O(n^3)$ \textendash{}
its asymptotic growth is as fast as the growth of the function $g(n) = n^3$.
$\exists C \in \mathbb{Z}^{+}\;\exists n_0 \in \mathbb{Z}^{+}\;\forall n \in \mathbb{Z}^{+},$\\
$(n > n_0 \rightarrow |f(n)| \leq C\cdot{}|g(n)|)$
Find the smallest positive integer $C$ that would satisfy the above definition,
and for your $C$ find the smallest possible $n_0$.

Write your answer $(C,n_0)$ as a pair of two numbers like this: {\tt 17,17}

\vspace{6pt}
{\bf Question 10.}
"Big O notation" allows to arrange functions according to the their
growth rate for large $n$.
Identify, which list of functions is such that
the first element of this list is in the big-O of the
next element of that list and so on. (Intuitively, the first element
in the list is the slowest growing function, the last element is the
fastest growing one.)

{\bf (1)} $\log (n^{10})$, {\bf (2)} $(\log n)^2$, {\bf (3)} $\log \log n$,
{\bf (4)} $n\log n$, {\bf (5)} $\log(n!)$, {\bf (6)} $\log 2^n$.

Write your answer as a comma-separated list like this: {\tt 1,2,3,4,5,6}

\vspace{6pt}
{\bf Question 11.} Digits of all rational numbers $P/Q$ in $(0;1)$
are eventually periodic: they infinitely repeat some group of digits (the period)
starting from some place. For example,
the fraction $11/205 = 0.05(36585)$ has period of 5 digits and a pre-period "05"
of just two digits.
Find the predicate logic expression that tells
that sequence of digits $d(1),d(2),d(3),\ldots$ is eventually periodic (it may have
pre-period of any length, including length zero).

\noindent
{\bf (A)} $\exists N \in \mathbb{Z}^{+}\;\exists T \in \mathbb{Z}^{+}\;\forall n \in \mathbb{Z}^{+},$\\
$\left(n \geq N - 1 \rightarrow d(n) = d(n+T)\right)$.\\
{\bf (B)} $\exists N \in \mathbb{Z}^{+}\;\forall n \in \mathbb{Z}^{+}\;\exists T \in \mathbb{Z}^{+},$\\
$\left(n \geq N - 1 \rightarrow d(n) = d(n+T)\right)$.\\
{\bf (C)} $\forall n \in \mathbb{Z}^{+}\;\exists N \in \mathbb{Z}^{+}\;\exists T \in \mathbb{Z}^{+},$\\
$\left(n \geq N - 1 \rightarrow d(n) = d(n+T)\right)$.\\
{\bf (D)} $\forall n \in \mathbb{Z}^{+}\;\forall N \in \mathbb{Z}^{+}\;\exists T \in \mathbb{Z}^{+},$\\
$\left(n \geq N - 1 \rightarrow d(n) = d(n+T)\right)$.

Pick your answer as a single letter like this: {\tt G}

\newpage

\subsection{Answers}

\vspace{6pt}
{\bf Question 1.} Answer {\bf (D)}.\\
Any number that is mutual prime with $360 = 2^3\cdot{}3^2\cdot{}5$
is not divisible by any of the primes $2,3,5$. And also vice versa.
This set is expressed as intersection of the complements:\\
$\Phi = \left( \overline{K_2} \cap \overline{K_3} \cap \overline{K_5} \right)$

\vspace{6pt}
{\bf Question 2.} Answer: {\tt 96}.\\
$${\displaystyle |\Phi| = 360 \cdot \left(1 - \frac{1}{2}\right) \cdot \left(1 - \frac{1}{3}\right) \cdot \left(1 - \frac{1}{5}\right) =}$$
$${\displaystyle  = 360 \cdot \frac{1}{2} \cdot \frac{2}{3} \cdot \frac{4}{5}  = 96}.$$
In the above formula we start with all $360$ elements; then we throw
out one half (all that are divisible by 2); then from the remaining ones
we throw out one third (all that are divisible by 3); finally from the remaining numbers we throw
out one fifth (all that are divisible by 5). Since divisibility by $2$ does not
affect divisibility by $3$ and $5$ (they are independent),
all the ratios can be multiplied.

Another solution: Since we know the sizes of each
set of numbers divisible by $2,3,5$:
$$|K_2| = 180,\; |K_3| = 120,\; |K_5| = 72.$$
We can express their union by {\em inclusion-exclusion principle}:
$$|K_2 \cup K_3 \cup K_5| \;=\; |K_2| \;+\; |K_3| \;+\; |K_5| \;-$$
$$-\;|K_2 \cap K_3|\;-\;|K_2 \cap K_5|\;-\;|K_3 \cap K_5| \;+\; |K_2 \cap K_3 \cap K_5|  \;=$$
$$=\; 180 + 120 + 72 - 60 - 36 - 24 +12 = 264.$$
We then apply De Morgan's law to find the count of all elements that are {\em outside}
that union of $K_2 \cup K_3 \cup K_5$:
$$ \left| \overline{K_2} \cap \overline{K_3} \cap \overline{K_5} \right| =
\left| \overline{K_2 \cup K_3 \cup K_5} \right| =360 - 264 =  96.$$

\vspace{6pt}
{\bf Question 3.} Answer: {\tt B}.
\begin{itemize}
\item $A$ (the set of all finite sequences of even natural numbers can be enumerated
with numbers from $\mathbb{N}$). You can encode
every such sequence in a finite alphabet of $13$ symbols,
using just digits, commas and parentheses. For example, {\tt (6, 22, 10, 14, 2, 6)}.
The shortest encoding is {\tt (1)} \textendash it consists of just three symbols:
two parentheses and a digit. There can be only finite number of such lists of
length $3$; we sort the all lexicographically (i.e. in some alphabetical order), and
assign them numbers.\\
After that we enumerate all lists writeable with 4 symbols (sorted lexicographically)
and so on. Eventually all the sequences will be sorted.
\item $B$ (the set of all infinite nondecreasing sequences of even numbers)
has cardinality $\mathbb{R}$. You can repeat the diagonalization argument:
Assume from the contrary that the elements from $B$ can be enumerated: we get
infinitely many infinite sequences $b_1,b_2,\ldots$.
Then take the first element from $b_1$ (and pick some even number that is bigger than that);
then take the second element from $b_2$ (and pick some even number that is bigger than
that; plus it is bigger than all the previously picked numbers), and so on.\\
You can also encode any subset $A \subseteq \mathbb{N}$ as such sequence (simply arrange all
the elements in increasing order and multiply them by $2$ to get even numbers).
We get that $B$ has at least as many elements as $\mathcal{P}(\mathbb{N})$.
\item $C$ (the set of all nonincreasing infinite sequences can be
enumerated). Since the sequence is non-increasing, it can have only finitely many
places where it actually decreases; since natural numbers cannot decrease infinitely.
We can encode all the ``constant runs'' of the sequence as pairs:\\
$$(64,58,58,54,50,50,50,50,2,2,\ldots) \rightarrow $$
$$\rightarrow \mathtt{((64,1),(58,2),(54,1),(50,4),(2,\infty))}.$$
As we saw before, all the finite sequences that are encoded in an alfabet
of $14$ symbols (10 digits, 2 parentheses, commas and infinity) can be enumerated.
\end{itemize}

\vspace{6pt}
{\bf Question 4.} Answer: {\tt 0,1,3,4,5,9}.\\
We can square each number, compute the remainder and sort the
results (and eliminate duplicates).

\vspace{6pt}
{\bf Question 5.} Answer: {\tt 6}.\\
The set $\{ \{ \mathtt{A}, \mathtt{B} \}, \mathtt{C}, \mathtt{D}, \mathtt{E} \}$
has $4$ elements ({\tt A}, {\tt B} are always glued together).
There are $6$ ways to select two out of four elements.
(Can be computed as a binomial coefficient $C_4^2 = \frac{4!}{2!2!}$ or simply
by listing all the $6$ pairs.

\vspace{6pt}
{\bf Question 6.} Answer: {\tt B,D}.\\
$x$ cannot be a subset of $A$ (since it is not a set itself).
$\{ x \}$ is not a subset of $A - B = \{ y \}$.

\vspace{6pt}
{\bf Question 7.}\\ Answer: {\tt (1,3),(2,2),(3,4),(4,1)}.\\
We first compute $f \circ g$ (to get $(f \circ g)(x) = f(g(x))$
we first apply $g$, then $f$):
$$f \circ g = \{(1,4),(2,2),(3,1),(4,3)\}.$$
The inverse happens, if we switch the order in all these pairs
($4$ maps back to $1$ etc.)\\
$$(f \circ g)^{-1} = \{(1,3),(2,2),(3,4),(4,1)\}.$$

\vspace{6pt}
{\bf Question 8.} Answer: {\tt 3/4}.\\
The sum of the infinite geometrical progression is $b_1/(1 - q)$.
In our case:
$$\frac{1}{1 - (-1/3)} = \frac{1}{4/3} = \frac{3}{4}.$$

\vspace{6pt}
{\bf Question 9.} Answer: {\tt 2,88}.
Clearly, $f(n) = |n^3 +88n^2 +3|$ cannot be smaller than $C\cdot{}|n^3|$,
if $C=1$, because $88n^2$ is always positive and makes $f(n)$ larger
than simply $n^3$.\\
If we take $C = 2$, then the inequality starts to hold for all $n>88$.
It is possible to prove that for such $n$:
$$n^3 +88n^2 +3 = n^2(n + 88) + 3 =$$
$$ = n^2(n+n) + n^2(88 -n) + 3  = 2n^3 + n^2(88-n) + 3 \leq 2n^3.$$
The last inequality is true, since $n^2(88-n) + 3 < 0$ for any
$n > 88$.

\vspace{6pt}
{\bf Question 10.} Answer: {\tt 3,1,2,6,4,5} (or {\tt 3,1,2,6,5,4}).\\
Logarithm of a logarithm is a very slowly growing function;
$\log n^{10}$ is just equal to $10$ times $\log n$.
$(\log n)^2 = \log^2 n$ is slightly faster than a logarithm.\\
Finally $\log 2^n$ is simply $n$; but both $\log (n!)$ and
$n \log n$ grow slightly faster than $n$; they are "Big-O" of each other:
$$n \log n \;\text{is in}\;O(\log n!);$$
$$\log n! \;\text{is in}\;O(n \log n).$$
It does not matter, in which order we list them.

To verify all these claims, you need to prove various limits:
$$\lim_{n \rightarrow \infty} \frac{\log\log n}{\log n} = 0,$$
$$\lim_{n \rightarrow \infty} \frac{\log n}{(\log n)^2} = 0,$$
and so on. Most of these limits are easy to find (L'Hospital's Rule and so on).
With $\log n!$ you might need to use integrals to estimate
the sum of $\log 1 + \log 2 + \ldots + \log n$.

{\em Note.} Unless noted otherwise, all logarithms in our course are base $2$.

\vspace{6pt}
{\bf Question 11.} Answer: {\tt A}.
Clearly the $N$ and $T$ should not depend on $n$; so they are the first quantifiers.\\
{\bf (B)} describes a sequence of digits where some digit repeats itself infinitely
often (which is true for any sequence of digits).\\
{\bf (C)} describes the set of all sequences; one can always pick $N$ that is larger than $n$,
then the condition is trivially true.\\
{\bf (D)} describes a sequence where each digit appears infinitely often.

\end{document}


% !TEX root = ../zeth-protocol-specification.tex

\chapter{Double spend attack on equivalent class}\label{appendix:dbspd}

The primary inputs of our zk-SNARK are elements of $\FFx{\rCURVE}$ and they can be written over $\fieldBitLen$ bits. Note that the projection of $\BB^\fieldBitLen$ onto $\FFx{\rCURVE}$ formed by interpreting elements in $\BB^\fieldBitLen$ as $\fieldBitLen$-bit numbers and reducing modulo $\rCURVE$, is surjective.

When we pass the primary inputs to the $\mixer$ contract, they are interpreted as elements of $\BB^\ethWordLen$, and $\BB^\fieldBitLen \subset \BB^\ethWordLen$. As previously noted, this means that there exist pairs of elements in $\BB^\ethWordLen$ with the same projection in $\FFx{\rCURVE}$. An adversary could make use of this to perform a double spend attack.

Indeed, to check that a note is not double spent, the contract stores the nullifiers of spent notes (as elements of $\BB^\ethWordLen$) and verifies that the nullifier of the note to be spent is not stored. The adversary could thus modify the nullifier to a different value with the same projection. As the SNARK verification operates in $\FFx{\rCURVE}$, the proof would still be valid. However, the value stored for this nullifier would be different from the adversarial one. Hence, the nullifier would be validated, the transaction would succeed and the note would be double spent.
In practice, the adversary can perform the attack by simply adding $\rCURVE$ to one of the elements representing the nullifier.

To prevent this attack, the contract checks that all primary inputs are elements of $\FFx{\rCURVE}$, that is to say that they are smaller than $\rCURVE$.
As one may see, the attack described above is not due to the packing of hash digests into field elements but to the contract storage of field elements as $\ethereum$ words.


\documentclass{article}
%\usepackage{fullpage}
%\usepackage{nopageno}
\usepackage[margin=1.5in]{geometry}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage[normalem]{ulem}
\usepackage{fancyhdr}
\usepackage{cancel}
%\renewcommand\headheight{12pt}
\pagestyle{fancy}
\lhead{April 16, 2014}
\rhead{Jon Allen}
\allowdisplaybreaks

\newcommand{\abs}[1]{\left\lvert #1 \right\rvert}

\begin{document}
Read Sections 7.2 and 7.3 and do the following problems from Chapter 7: \#16, 17, 18, 19, 22, 24(a)(b)(c) (be sure to write your answer in closed form), 26, 28, 50 (Grad: 49).
\begin{enumerate}
\setcounter{enumi}{15}
\item
Formulate a combinatorial problem for which the generating function is
\[(1+x+x^2)(1+x^2+x^4+x^6)(1+x^2+x^4+\cdots)(x+x^2+x^3+\cdots)\]

How many combinations of red, yellow, green and blue colored pencils are there in which there are at most 2 red pencils, an even number of at most six yellow pencils, an even number of green pencils and at least one blue pencil?
\item
Determine the generating function  for the number $h_n$ of bags of fruit of apples, oranges, bananas, and pears in which there are an even number of apples, at most two oranges, a multiple of three number of bananas, and at most one pear. Then find a formula for $h_n$ from the generating function.

\begin{align*}
  g(x)&=\underbrace{\left(\sum\limits_{n=0}^\infty{x^{2n}}\right)}_{\text{even apples}}\underbrace{\left(\sum\limits_{n=0}^2{x^n}\right)}_{\text{oranges}\le 2}\underbrace{\left(\sum\limits_{n=0}^\infty{x^{3n}}\right)}_{3\mid \text{bananas}}\underbrace{\left(\sum\limits_{n=0}^1{x^{n}}\right)}_{\text{pears}\le 1}\\
  &=\frac{1}{1-x^2}\left[\left(\sum\limits_{n=0}^\infty{x^n}\right)-\left(\sum\limits_{n=3}^\infty{x^n}\right)\right]\frac{1}{1-x^3}\left[\left(\sum\limits_{n=0}^\infty{x^n}\right)-\left(\sum\limits_{n=2}^\infty{x^n}\right)\right]\\
  &=\frac{1}{1-x^2}\left[\left(1-x^3\right)\left(\sum\limits_{n=0}^\infty{x^n}\right)\right]\frac{1}{1-x^3}\left[\left(1-x^2\right)\left(\sum\limits_{n=0}^\infty{x^n}\right)\right]\\
  &=\left(\frac{1}{1-x^2}\right)\left(\frac{1-x^3}{1-x}\right)\left(\frac{1}{1-x^3}\right)\left(\frac{1-x^2}{1-x}\right)\\
  &=\frac{1}{(1-x)^2}
  =\frac{\mathrm{d}}{\mathrm{d}x}\left(\frac{1}{1-x}\right)
  =\frac{\mathrm{d}}{\mathrm{d}x}\sum\limits_{n=0}^\infty{x^n}\\
  &=\sum\limits_{n=0}^\infty{nx^{n-1}}
  =\sum\limits_{n=-1}^\infty{(n+1)x^{n}}
  =0+\sum\limits_{n=0}^\infty{(n+1)x^{n}}\\
  h_n&=n+1
\end{align*}
\item
Determine the generating function for the number $h_n$ of nonnegative integral solutions of
\[2e_1+5e_2+e_3+7e_4=n\]
This is equivalent to saying how many ways can you pick $n$ items from the multiset $\{\infty\cdot e_1,\infty\cdot e_2,\infty\cdot e_3,\infty\cdot e_4\}$ where you have an even number of $e_1$'s, a multiple of 5 $e_2$'s and a multiple of 7 $e_4$'s.
\begin{align*}
  g(x)&=\left(\sum\limits_{n=0}^\infty{x^{2n}}\right)\left(\sum\limits_{n=0}^\infty{x^{5n}}\right)\left(\sum\limits_{n=0}^\infty{x^{n}}\right)\left(\sum\limits_{n=0}^\infty{x^{7n}}\right)\\
  &=\left(\frac{1}{1-x^2}\right)\left(\frac{1}{1-x^5}\right)\left(\frac{1}{1-x}\right)\left(\frac{1}{1-x^7}\right)
\end{align*}
\item
Let $h_0,h_1,h_2,\dots,h_n,\dots$ be the sequence defined by $h_n=\binom{n}{2},(n\ge0)$. Determine the generating function for the sequence.
\begin{align*}
  g(x)&=\sum\limits_{n=0}^\infty{\binom{n}{2}x^n}\\
  &=\sum\limits_{n=0}^\infty{\frac{n!}{2!(n-2)!}x^n}\\
  &=\frac{1}{2}\sum\limits_{n=0}^\infty{n(n-1)x^n}\\
  h_n&=\frac{1}{2}(n^2-n)
\end{align*}
\setcounter{enumi}{21}
\item
Determine the exponential generating function for the sequence of factorials: $0!,1!,2!,3!,\dots,n!,\dots$
\begin{align*}
  g^{(e)}(x)&=\sum\limits_{n=0}^\infty{n!\cdot\frac{x^n}{n!}}\\
  &=\sum\limits_{n=0}^\infty{x^n}\\
  &=\frac{1}{1-x}
\end{align*}
\setcounter{enumi}{23}
\item
Let $S$ denote the multiset $\{\infty\cdot e_1,\infty\cdot e_2,\dots,\infty\cdot e_k\}$. Determine the exponential generating function for the sequence $h_0,h_1,h_2,\dots,h_n,\dots$, where $h_0=1$ and, for $n\ge 1$
\begin{enumerate}
\item
$h_n$ equals the number of $n$-permutations of $S$ in which each object occurs an odd number of times.
\begin{align*}
  g^{(e)}(x)&=\left(x+\frac{x^3}{3!}+\frac{x^5}{5!}+\dots\right)^k\\
  &=\left[\left(1+x+\frac{x^2}{2!}+\frac{x^3}{3!}+\dots\right)+\left(-1+x-\frac{x^2}{2!}+\frac{x^3}{3!}+\dots\right)\right]^k\frac{1}{2^k}\\
  &=\left(\frac{1}{2}\sum\limits_{n=0}^\infty{\frac{x^n+(-x)^n}{n!}}\right)^k\\
  &=\left(\frac{e^x+e^{-x}}{2}\right)^k
\end{align*}
\item
$h_n$ equals the number of $n$-permutations of $S$ in which each object occurs at least four times.
\begin{align*}
  g^{(e)}(x)&=\left(\frac{x^4}{4!}+\frac{x^5}{5!}+\frac{x^6}{6!}+\dots\right)^k\\
  &=\left(\sum\limits_{n=4}^\infty{\frac{x^n}{n!}}\right)^k=\left(-\frac{x^3}{3!}+\sum\limits_{n=3}^\infty{\frac{x^n}{n!}}\right)^k\\
  &=\left(-1-x-\frac{x^2}{2!}-\frac{x^3}{3!}+\sum\limits_{n=3}^\infty{\frac{x^n}{n!}}\right)^k\\
  &=\left(e^x-1-x-\frac{x^2}{2!}-\frac{x^3}{3!}\right)^k
\end{align*}
\item
$h_n$ equals the number of $n$-permutations of $S$ in which $e_1$ occurs at least once, $e_2$ occurs at least twice, $\dots,e_k$ occurs at least $k$ times.
\begin{align*}
  g^{(e)}(x)&=\left(x+\frac{x^2}{2!}+\dots\right)\left(\frac{x^2}{2!}+\frac{x^3}{3!}+\dots\right)\dots\left(\frac{x^{k-1}}{(k-1)!}+\frac{x^k}{k!}+\dots\right)\\
  &=\prod_{i=1}^k{\left(\sum\limits_{n=i}^\infty{\frac{x^n}{n!}}\right)}\\
  &=\prod_{i=1}^k{\left(\sum\limits_{n=0}^\infty{\frac{x^n}{n!}}-\sum\limits_{n=0}^{i-1}{\frac{x^n}{n!}}\right)}\\
  &=\prod_{i=1}^k{\left(e^x-\sum\limits_{n=0}^{i-1}{\frac{x^n}{n!}}\right)}\\
\end{align*}
\end{enumerate}
\setcounter{enumi}{25}
\item
Determine the number of ways to color the squares of a 1-by-$n$ chessboard, using the colors red, blue, green, and orange if an even number of squares is to be colored red and an even number is to be colored green.
\begin{align*}
  g^{(e)}(x)&=\underbrace{\left(\sum\limits_{n=0}^\infty{\frac{x^{2n}}{(2n)!}}\right)^2}_{\text{red and green are even}}\cdot\overbrace{\left(\sum\limits_{n=0}^\infty{\frac{x^{n}}{n!}}\right)^2}^{\text{blue and orange are unrestricted}}\\
  &=\left(\frac{1}{2}\sum\limits_{n=0}^\infty{\frac{x^n+(-x)^n}{n!}}\right)\left(e^x\right)^2\\
  &=\frac{e^{2x}}{2}\left(\sum\limits_{n=0}^\infty{\frac{x^n}{n!}}+\sum\limits_{n=0}^\infty{\frac{(-x)^n}{n!}}\right)\\
  &=\frac{e^{2x}}{2}\left(e^x+e^{-x}\right)=\frac{e^{3x}+e^x}{2}\\
  &=\frac{1}{2}\sum\limits_{n=0}^\infty{\frac{(3x)^n+x^n}{n!}}=\sum\limits_{n=0}^\infty{\frac{3^n+1}{2}\cdot\frac{x^n}{n!}}
\end{align*}
So we can color the board $\frac{3^n+1}{2}$ ways
\setcounter{enumi}{27}
\item
Determine the number of $n$-digit numbers with all digits at least 4, such that 4 and 6 each occur an even number of times, and 5 and 7 each occur at least once, there being no restriction on the digits 8 and 9.
\begin{align*}
  g^{(e)}(x)&=\underbrace{\left(\sum\limits_{n=0}^\infty{\frac{x^{2n}}{(2n)!}}\right)^2}_{\text{4,6 are even}}\cdot\overbrace{\left(\sum\limits_{n=1}^\infty{\frac{x^n}{n!}}\right)^2}^{\text{5,7 occur at least once}}\cdot\underbrace{\left(\sum\limits_{n=0}^\infty{\frac{x^n}{n!}}\right)^2}_{\text{8,9 are unrestricted}}\\
  &=\left(\frac{1}{2}\sum\limits_{n=0}^\infty{\frac{x^n+(-x)^n}{n!}}\right)^2\left(-1+\sum\limits_{n=0}^\infty{\frac{x^n}{n!}}\right)^2\left(\sum\limits_{n=0}^\infty{\frac{x^n}{n!}}\right)^2\\
  &=\frac{e^{2x}}{4}\left(e^x+e^{-x}\right)^2(e^x-1)^2\\
  &=\frac{e^{2x}}{4}\left(e^{2x}+2+e^{-2x}\right)(e^{2x}-2e^x+1)\\
  &=\frac{e^{2x}}{4}\left(e^{4x}-2e^{3x}+e^{2x}+2e^{2x}-4e^x+2+1-2e^{-x}+e^{-2x}\right)\\
  &=\frac{e^{2x}}{4}\left(e^{4x}-2e^{3x}+3e^{2x}-4e^x+3-2e^{-x}+e^{-2x}\right)\\
  &=\frac{1}{4}\left(e^{6x}-2e^{5x}+3e^{4x}-4e^{3x}+3e^{2x}-2e^{x}+1\right)\\
  &=\frac{1}{4}+\frac{1}{4}\sum\limits_{n=0}^\infty{\frac{(6x)^n-2(5x)^n+3(4x)^n-4(3x)^n+3(2x)^n-2x^n}{n!}}\\
  &=\frac{1}{4}+\frac{1}{4}\sum\limits_{n=0}^\infty{\left[6^n-2(5^n)+3(4^n)-4(3^n)+3(2^n)-2\right]\frac{x^n}{n!}}
\end{align*}
So the number of $n$-digit numbers that meet the criteria is 0 when $n=0$ and $\frac{1}{4}\left[6^n-2(5^n)+3(4^n)-4(3^n)+3(2^n)-2\right]$ when $n\ge1$
\setcounter{enumi}{49}
\item
Call a subset of $S$ of the integers $\{1,2,\dots,n\}$ \emph{extraordinary} provided its smallest integer equals its size:
\[\min\{x:x\in S\}=\lvert S\rvert.\]
For example, $S=\{3,7,8\}$ is extraordinary. Let $g_n$ be the number of extraordinary subsets of $\{1,2,\dots,n\}$. Prove that
\[g_n=g_{n-1}+g_{n-2},\quad(n\ge3),\]
with $g_1=1$ and $g_2=1$.
\subsubsection*{proof}
The number of extraordinary subsets of $\{1,2,\dots,n\}$ is the sum of the number of extraordinary subsets of each size from 1 to $n$. A $k$ sized extraordinary subset of $\{1,2,\dots,n\}$ contains $k$ and $k-1$ elements of the set $\{k+1,k+2,\dots,n\}$. We can choose these $k-1$ elements in $\binom{n-(k+1)+1}{k-1}$ ways. Lets simplify a little:
\begin{align*}
  \binom{n-(k+1)+1}{k-1}&=\binom{n-k}{k-1}\\
  g_n&=\sum\limits_{k=1}^n{\binom{n-k}{k-1}}\\
  \binom{n+1}{k+1}&=\binom{n}{k}+\binom{n}{k+1}\\
  g_n&=\sum\limits_{k=1}^n{\binom{n-k-1}{k-1-1}}+\sum\limits_{k=1}^n{\binom{n-k-1}{k-1}}\\
  &=\binom{n-n-1}{n-2}+\sum\limits_{k=1}^{n-1}{\binom{n-k-1}{k-1-1}}+\binom{n-n-1}{n-1}+\sum\limits_{k=1}^{n-1}{\binom{n-k-1}{k-1}}\\
  &=\frac{(n-n-1)!}{(n-n-1-(n-2))!(n-2)!}+\frac{(n-n-1)!}{(n-n-1-(n-1))!(n-1)!}\\&\quad+\sum\limits_{k=1}^{n-1}{\binom{n-k-1}{k-1-1}}+\sum\limits_{k=1}^{n-1}{\binom{(n-1)-k}{k-1}}\\
  &=\frac{(-1)!}{(1-n)!(n-2)!}+\frac{(-1)!}{(-n)!(n-1)!}\\&\quad+\sum\limits_{k=1}^{n-1}{\binom{n-(k-1)}{(k-1)-1}}+g_{n-1}\\
  &=\frac{(-1)!(n-1)}{(1-n)!(n-1)!}+\frac{(-1)!(1-n)}{(1-n)!(n-1)!}\\&\quad+\sum\limits_{k=0}^{n-2}{\binom{n-k}{k-1}}+g_{n-1}\\
  &=\frac{(-1)!n-(-1)!+(-1)!-(-1)!n}{(1-n)!(n-1)!}\\&\quad+\binom{n}{-1}+\sum\limits_{k=1}^{n-2}{\binom{n-k}{k-1}}+g_{n-1}\\
  &=0+\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}-\binom{n-(n-1)}{(n-1)-1}-\binom{n-n}{n-1}+g_{n-1}\\
  &=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}-\binom{1}{n-2}-\binom{0}{n-1}+g_{n-1}\\
%  &=\sum\limits_{k=1}^{n-1}{\binom{n-k}{k-1}}+\binom{n-n}{n-1}
\end{align*}
%Now if we have $g_n$, then what is $g_{n-1}$? We have
%\begin{align*}
%  g_{n-1}&=\sum\limits_{k=1}^{n-1}{\binom{n-k-1}{k-1}}\\
%\end{align*}
%Now lets see what happens if we add $g_{n}$ and $g_{n+1}$
%\begin{align*}
%  \sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}+\sum\limits_{k=1}^{n+1}{\binom{(n+1)-k}{k-1}}&=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}+\sum\limits_{k=1}^{n}{\binom{(n+1)-k}{k-1}}+\binom{(n+1)-(n+1)}{(n+1)-1}
%\end{align*}
%lets make an assumption and see if it holds
%\begin{align*}
%  \sum\limits_{k=1}^{n+2}{\binom{(n+2)-k}{k-1}}&=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}+\sum\limits_{k=1}^{n}{\binom{(n+1)-k}{k-1}}+\binom{0}{n}\\
%  \sum\limits_{k=1}^{n}{\binom{(n+2)-k}{k-1}}+\binom{0}{n+1}+\binom{1}{n}-\sum\limits_{k=1}^{n}{\binom{(n+1)-k}{k-1}}&=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}\\
%  \sum\limits_{k=1}^{n}{\binom{(n+2)-k}{k-1}}-\sum\limits_{k=1}^{n}{\binom{(n+1)-k}{k-1}}&=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}\\
%  \sum\limits_{k=1}^{n}{\frac{((n+2)-k)!}{(k-1)!((n+2)-k-(k-1))!}}\qquad&\\
%  -\sum\limits_{k=1}^{n}{\frac{((n+1)-k)!}{(k-1)!((n+1)-k-(k-1))!}}&=\sum\limits_{k=1}^{n}{\frac{(n-k)!}{(k-1)!(n-k(k-1))!}}\\
%  \sum\limits_{k=1}^{n}{\frac{(n-k+2)!}{(k-1)!(n-2k+3)!}}\qquad&\\
%  -\sum\limits_{k=1}^{n}{\frac{(n-k+1)!}{(k-1)!(n-2k+2))!}}&=\sum\limits_{k=1}^{n}{\frac{(n-k)!}{(k-1)!(n-2k+1))!}}\\
%  \sum\limits_{k=1}^{n}{\frac{(n-k+2)(n-k+1)(n-k)!}{(k-1)!(n-2k+3)(n-2k+2)(n-2k+1)!}}\qquad&\\
%  -\sum\limits_{k=1}^{n}{\frac{(n-k+1)(n-k)!}{(k-1)!(n-2k+2)(n-2k+1)!}}&=\sum\limits_{k=1}^{n}{\frac{(n-k)!}{(k-1)!(n-2k+1))!}}\\
%  \sum\limits_{k=1}^{n}{\left[\begin{aligned}\frac{(n-k+2)(n-k+1)}{(n-2k+3)(n-2k+2)}\\-\frac{(n-k+1)}{(n-2k+2)}\end{aligned}\right]\frac{(n-k)!}{(k-1)!(n-2k+1))!}}&=\sum\limits_{k=1}^{n}{\frac{(n-k)!}{(k-1)!(n-2k+1))!}}\\
%  \sum\limits_{k=1}^{n}{\left[\frac{\begin{aligned}(n-k+2)(n-k+1)\\-(n-k+1)(n-2k+3)\end{aligned}}{(n-2k+3)(n-2k+2)}\right]\frac{(n-k)!}{(k-1)!(n-2k+1))!}}&=\sum\limits_{k=1}^{n}{\frac{(n-k)!}{(k-1)!(n-2k+1))!}}\\
%  \sum\limits_{k=1}^{n}{\left[\frac{(n-k+1)(n-k+2-n+2k-3)}{(n-2k+3)(n-2k+2)}\right]\frac{(n-k)!}{(k-1)!(n-2k+1))!}}&=\sum\limits_{k=1}^{n}{\frac{(n-k)!}{(k-1)!(n-2k+1))!}}\\
%  \sum\limits_{k=1}^{n}{\left[\frac{(n-k+1)(k-1)}{(n-2k+3)(n-2k+2)}\right]\frac{(n-k)!}{(k-1)!(n-2k+1))!}}&=\sum\limits_{k=1}^{n}{\frac{(n-k)!}{(k-1)!(n-2k+1))!}}\\
%  \sum\limits_{k=1}^{n}{\left[\frac{1}{(n-2k+3)(n-2k+2)}\right]\frac{(n-k+1)!}{k!(n-2k+1))!}}&=\sum\limits_{k=1}^{n}{\frac{(n-k)!}{(k-1)!(n-2k+1))!}}\\
%  \sum\limits_{k=1}^{n}{\left[\frac{1}{(n-2k+3)(n-2k+2)}\right]\binom{n-k+1}{k}}&=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}\\
%  \sum\limits_{k=2}^{n+1}{\left[\frac{\binom{(n-1)-(k-1)+1}{k-1}}{((n-1)-2(k-1)+3)((n-1)-2(k-1)+2)}\right]}&=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}\\
%  \sum\limits_{k=2}^{n+1}{\left[\frac{\binom{n-k+1}{k-1}}{(n-2k+4)(n-2k+3)}\right]}&=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}\\
%  \sum\limits_{k=1}^{n}{\left[\frac{\frac{n-k+1}{k}\binom{n-k}{k-1}}{(n-2k+3)(n-2k+2)}\right]}&=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}\\
%  &=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}+\sum\limits_{k=1}^{n}{\frac{(n+1-k)!}{(k-1)!(n-k+1-k+1)!}}+\binom{0}{n}\\
%  &=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}+\sum\limits_{k=1}^{n}{\frac{(n+1-k)(n-k)!}{(k-1)!(n-k+1-k+1)(n-k+1-k)!}}\\
%  &=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}+\sum\limits_{k=1}^{n}{\frac{(n+1-k)}{(n+2-2k)}\binom{n-k}{k-1}}\\
%  &=\sum\limits_{k=1}^{n}{\binom{n-k}{k-1}}+\sum\limits_{k=1}^{n}{\frac{(n-k+1)}{(n-2k+2)}\binom{n-k}{n-k+1}}\\
%\end{align*}
\end{enumerate}
\end{document}