\section{Results and interpretation}
\label{sec:results}
Trying different network structures and extensive hyperparameter tuning results in a network which achieves an accuracy of $\SI{84.4}{\percent}$ on the validation set by using the
hyperparameter values shown in \autoref{tab:hyperparameters}.
An overview of the final network can be seen in \autoref{fig:best_model}.
\begin{table}
    \centering
    \caption{A CNN using these hyperparameters can solve our problem the best. *= In the first convolutional layer and doubling from layer to layer afterwards.}
    \label{tab:hyperparameters}
    \begin{tabular}{c c c c c c c}
        \toprule
        $N_\text{conv. layers}$ & ${\text{num}_\text{kernels}}^*$ & $N_\text{kernel}$ & $N_\text{dense layers}$ & $N_\text{dense nodes}$ & $r_\text{L2}$ & $r_\text{dropout}$ \\
        \midrule
        5 & 48 & 4 & 1 & 128 & \num{1e-5} & 0.3\\
        \bottomrule
    \end{tabular}
\end{table}

The final step of every machine-learing based work is the performance evaluation on data that was not used at any point in the work before.
After the preprocessing we split $\SI{15}{\percent}$ of our data into a test set for this purpose.
Using our best performing model we achieve
\begin{align}
    \text{accuracy}_\text{test} = \SI{79.9}{\percent}.
\end{align}
The significant gap between validation accuracy and test accuracy ($\SI{4.5}{\percent}$) might be due to the extensive hyperparameter tuning, while the validation and test datasets are quite small
(50 images of each flower species).
This might lead to manual overfitting on the validation set during hyperparameter tuning.

It is also helpful to examine the distribution of the predicted probability for a single species, while distinguishing between the images which truly show a flower(s) of this species and
all other images.
This is done in \autoref{fig:hist} for \enquote{Marguerite Daisy}.
Another import graphic for evaluating a classification is the \textit{confusion matrix} which can be seen in \autoref{fig:matrix}.
\begin{figure}
    \centering
    \begin{subfigure}{0.49\textwidth}
        \centering
        \includegraphics[width=0.99\textwidth]{../data/eval_plots_test/One_vs_all_histogram.pdf}
        \caption{Probability distribution for \enquote{Marguerite Daisy}.}
        \label{fig:hist}
    \end{subfigure}
    \hfill
    \begin{subfigure}{0.49\textwidth}
        \centering
        \includegraphics[width=0.99\textwidth]{../data/eval_plots_test/confusion_matrix.pdf}
        \caption{Confusion matrix.}
        \label{fig:matrix}
    \end{subfigure}
    \caption{The predicted probabilities for the class \enquote{Marguerite Daisy} and the confusion matrix based on the test data set help to illustrate the performance of our classification model.}
\end{figure}
The probability distribution shows that out network is generally pretty certain of its classification of Marguerite Daisies, as most images (regardless if correctly classified or not)
are in the highest or lowest bin.

If we look at both plots, we can see, that \enquote{Marguerite Daisy} is the class which gets misclassified the most as only 31 of 50 images of Marguerite Daisies in the test set get
classified as such.
They get confused with Waterlilies the most, which, looking at \autoref{fig:images}, might be caused by similarities in color and petal shape.
However, there are also images of Waterlilies with different colors in our dataset
So it might be the case, that Waterlilies are the species which is hard to correctly classify and the (weak) classification criteria for Waterlilies just happen to also apply to Marguerite Daisies
quite often.
Another interesting observation in \autoref{fig:matrix} is, that Butterfly Bushs get confused with Bee Balm flowers and Grape Hyacinths a lot.
Bee Balm flowers come in very similar colors to Butterfly Bushes and the tattered-looking blossoms of Bee Balm flowers can look very similar to Butterfly Bushs which have already lost some of their
blossoms.
The purple color and general shape of the flower head of Grape Hyacinths can make them look very much like Butterfly Bushs on images.
In reality the size of the flower head is very different, but this is not an information which our network has access to.
However, real images of Grape Hyacinths do not get misclassified at all within our test set.
This can be caused by the very distinctive ball-like petal-shape (see \autoref{fig:images}) which our network can probably detect very reliably in real images of Grape Hyacinths.
More interpretations like these for the other flower species are possible.

\begin{wrapfigure}{R}{0.75\textwidth}
    \centering
    \includegraphics[width=0.75\textwidth]{../data/eval_plots_test/biggest_errors.pdf}
    \caption{These six images get misclassified with the highest certainty in the wrong prediction.}
    \label{fig:errors}
\end{wrapfigure}
The six images which the network misclassifies with the highest certainty in its wrong prediction are shown in \autoref{fig:errors}.
The image in the top left looks very similar to a Blanket Flower (like the one in the top middle) and the bottom left, bottom middle and top right image are drawings and have
a white/ white-grey background which probably makes it harder for the network due to a lack of contrast.
The Waterlilies on the bottom right image are very small and its color is very similar to a Grape Hyacinth, so this misclassification is understandable.
The only strange misclassification is the image in the top middle.
A possible explanation is the network detecting something in the background of the image as resembling a Butterfly Bush.

\subsection{Alternative method}
In order to get a reference to compare the performance of our network to, we also try a different approach to the classification based on the eleven flower species.
We choose a \textit{k-Nearest Neighbor} Algorithm (kNN) for this task, because it is one of the simplest machine-learning algorithms (\textit{lazy learner}).
Suitable input data for the kNN is generated by looking at a histogram of the color intensity of all three RGB colors (red, green, blue) for all pixels in an image.
An example of this can be seen in \autoref{fig:kNN_hist}.
Then the mean and the standart deviation for each color channel are calculated and used as input data for the kNN.
This results in an reduction of $200\cdot 200 \cdot 3 = 120.000$ parameters for each image to only $6$ parameters for each image.

The main hyperparameters of the kNN algorithm is the number of neighbors $k$ to consider for the classification of a new datapoint, as well as the distance metric used to decide which points are
the nearest ones.
We use the implementation of a kNN classifier in \texttt{scikit-learn} \cite{scikit-learn} with its default \textit{Euclidean distance} as distance metric.
We then search for the optimal $k$ by looking at the accuracy the algorithm achieves on the validation data set for $k \in [1, 300]$ which can be seen in \autoref{fig:kNN_acc}.
\begin{wrapfigure}{r}{0.55\textwidth}
    \centering
    \includegraphics[width=0.55\textwidth]{../data/alternative_approach/accuracy_knn_threshold_300.pdf}
    \caption{The validation accuracy of the kNN algorithm for different $k$.}
    \label{fig:kNN_acc}
\end{wrapfigure}
We discard $k = 1, 2$, because there are images which are almost identical between the train and test set which distort the results for $k = 1, 2$.
Therefore, $k = 82$ results in the best validation accuracy of $\SI{39.0}{\percent}$.
Applying this kNN model on the test set achieves a classification accuracy of
\begin{align}
    \text{accuracy}_\text{test, kNN} = \SI{37.0}{\percent}.
\end{align}
Considering the simplicity of the approach, this result is within an expected margin.


\section{Parameter Optimization}

We discuss the following two topics concerning parameter optimization in more detail:
color spaces and controlling the number of superpixels in a consistent manner.
Overall, we find that together with Section \ref{sec:parameter-optimization},
the described parameter optimization procedure ensures fair comparison as far as possible.

\subsection{Color Spaces}

The used color space inherently influences the performance of superpixel algorithms as
the majority of superpixel algorithms depend on comparing pixels within this color space.
To ensure fair comparison, we included the color space in parameter optimization.
In particular, we ensured that all algorithms support RGB color space and considered
different color spaces only if reported in the corresponding publications or
supported by the respective implementation. While some algorithms may benefit from
different color spaces not mentioned in the corresponding publications, we decided to
not consider additional color spaces for simplicity and to avoid additional overhead
during parameter optimization. Parameter optimization yielded the color spaces
highlighted in Table \ref{table:algorithms}.

\subsection{Controlling the Number of Generated Superpixels}

\DeclarePairedDelimiter\ceil{\lceil}{\rceil}
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor}

Some implementations, for example \ERS and \POISE, control the number of superpixels directly
-- for example by stopping the merging of pixels as soon as the desired number of superpixels is met.
In contrast, clustering-based algorithms (except for \DASP), contour evolution algorithms, watershed-based algorithms
as well as path-based algorithms utilize a regular grid to initialize superpixels.
Some algorithms allow to adapt the grid in both horizontal and vertical direction,
while others require a Cartesian grid. We expected this difference to be reflected in
the experimental results, however, this is not the case. We standardized initialization in both cases.


\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\begin{document}

\section*{Powers and indices}

\[x^2\]

\[x_2\]

\[^tM^{2}_{1}\]

% The command \! removes a "loose" space for matrix transpose
\[^{t\!}M^{2}_{1}\]

\end{document}


%!TEX root = ../OGUSAdoc.tex

In \ogindia, the government enters by levying taxes on households, providing transfers to households, levying taxes on firms, spending resources on public goods, and making rule-based adjustments to stabilize the economy in the long-run. It is this last activity that is the focus of this chapter.

\section{Government Tax Revenue}\label{SecUnbalGBCrev}

  We see from the household's budget constraint that taxes $T_{s,t}$ and transfers $TR_{t}$ enter into the household's decision,
  \begin{equation}\tag{\ref{EqHHBC}}
    \begin{split}
      c_{j,s,t} + b_{j,s+1,t+1} &= (1 + r_{t})b_{j,s,t} + w_t e_{j,s} n_{j,s,t} + \zeta_{j,s}\frac{BQ_t}{\lambda_j\omega_{s,t}} + \eta_{j,s,t}\frac{TR_{t}}{\lambda_j\omega_{s,t}} - T_{s,t}  \\
      &\quad\forall j,t\quad\text{and}\quad s\geq E+1 \quad\text{where}\quad b_{j,E+1,t}=0\quad\forall j,t
    \end{split}
  \end{equation}
  where we defined the tax liability function $T_{s,t}$ in \eqref{EqTaxCalcLiabETR} as an effective tax rate times total income and the transfer distribution function $\eta_{j,s,t}$ is uniform across all households as in \eqref{EqTaxCalcEtajs}. And government revenue from the corporate income tax rate $\tau^{corp}$ and the tax on depreciation expensing $\tau^\delta$ enters the firms' profit function.
  \begin{equation}\tag{\ref{EqFirmsProfit}}
    PR_t = (1 - \tau^{corp})\bigl(Y_t - w_t L_t\bigr) - \bigl(r_t + \delta\bigr)K_t + \tau^{corp}\delta^\tau K_t \quad\forall t
  \end{equation}
  We define total government revenue from taxes as the following.
  \begin{equation}\label{EqUnbalGBCgovRev}
    Rev_t = \underbrace{\tau^{corp}\bigl[Y_t - w_t L_t\bigr] - \tau^{corp}\delta^\tau K_t}_{\text{corporate tax revenue}} + \underbrace{\sum_{s=E+1}^{E+S}\sum_{j=1}^J\lambda_j\omega_{s,t}\tau^{etr}_{s,t}\left(x_{j,s,t},y_{j,s,t}\right)\bigl(x_{j,s,t} + y_{j,s,t}\bigr)}_{\text{household tax revenue}} \quad\forall t
  \end{equation}

\section{Government Budget Constraint}\label{SecUnbalGBCbudgConstr}

  Let the level of government debt in period $t$ be given by $D_t$. The government budget constraint requires that government revenue $Rev_t$ plus the budget deficit ($D_{t+1} - D_t$) equal expenditures on interest of the debt, government spending on public goods $G_t$, and total transfer payments to households $TR_t$ every period $t$.
  \begin{equation}\label{EqUnbalGBCbudgConstr}
    D_{t+1} + Rev_t = (1 + r_t)D_t + G_t + TR_t \quad\forall t
  \end{equation}

  We assume that total government transfers to households are a fixed fraction $\alpha_{tr}$ of GDP each period.
  \begin{equation}\label{EqUnbalGBCtfer}
    TR_t = g_{tr,t}\:\alpha_{tr}\: Y_t \quad\forall t
  \end{equation}
  The time dependent multiplier $g_{tr,t}$ in front of the right-hand-side of \eqref{EqUnbalGBCtfer} will equal 1 in most initial periods. It will potentially deviate from 1 in some future periods in order to provide a closure rule that ensures a stable long-run debt-to-GDP ratio. We will discuss the closure rule in Section \ref{SecUnbalGBCcloseRule}.

  We also assume that government spending on public goods is a fixed fraction of GDP each period in the initial periods.
  \begin{equation}\label{EqUnbalGBC_Gt}
    G_t = g_{g,t}\:\alpha_{g}\: Y_t
  \end{equation}
  Similar to transfers $TR_t$, the time dependent multiplier $g_{g,t}$ in front of the right-hand-side of \eqref{EqUnbalGBC_Gt} will equal 1 in most initial periods. It will potentially deviate from 1 in some future periods in order to provide a closure rule that ensures a stable long-run debt-to-GDP ratio. We make this more specific in the next section.

\section{Interest Rate on Government Debt}\label{SecRateWedge}

Despite the model having no aggregate risk, it may be helpful to build in an interest rate differential between the rate of return on private capital and the interest rate on government debt.  Doing so helps to add realism by including a risk premium.  \ogindia allows users to set an exogenous wedge between these two rates.  The interest rate on government debt,

\begin{equation}\label{EqUnbalGBC_rate_wedge}
  r_{gov, t} = (1 - \tau_{d, t})r_{t} - \mu_{d}
\end{equation}

The two parameters, $\tau_{d,t}$ and $\mu_{d,t}$ can be used to allow for a government interest rate that is a percentage hair cut from the market rate or a government interest rate with a constant risk premia.

In the cases where there is a differential ($\tau_{d,t}$ or $\mu_{d,t} \neq 0$), then we need to be careful to specify how the household chooses government debt and private capital in its portfolio of asset holdings.  We make the assumption that under the exogenous interest rate wedge, the household is indifferent between holding its assets as debt and private capital. This amounts to an assumption that these two assets are perfect substitutes given the exogenous wedge in interest rates.  Given the indifference between government debt and private capital at these two interest rates, we assume that the household holds debt and capital in the same ratio that debt and capital are demanded by the government and private firms, respectively. The interest rate on the household portfolio of asset is thus given by:

\begin{equation}\label{EqUnbalGBC_rate_wedge}
  r_{hh,t} = \frac{r_{gov,t}D_{t} + r_{t}K_{t}}{D_{t} + K_{t}}
\end{equation}

\section{Budget Closure Rule}\label{SecUnbalGBCcloseRule}

  If total government transfers to households $TR_t$ and government spending on public goods $G_t$ are both fixed fractions of GDP, one can imagine corporate and household tax structures that cause the debt level of the government to either tend toward infinity or to negative infinity, depending on whether too little revenue or too much revenue is raised, respectively.

  A virtue of dynamic general equilibrium models is that the model must be stationary in order to solve it. That is, no variables can be indefinitely growing as time moves forward. The labor augmenting productivity growth $g_y$ from Chapter \ref{Chap_Firms} and the potential population growth $\tilde{g}_{n,t}$ from Chapter \ref{Chap_Demog} render the model nonstationary. But we show how to stationarize the model against those two sources of growth in Chapter \ref{Chap_Stnrz}. However, even after stationarizing the effects of productivity and population growth, the model could be rendered nonstationary and, therefore, not solvable if government debt were becoming too positive or too negative too quickly.

  The \ogindia model offers three different options for budget closure rules. Each rule uses some combination of changes in government spending on public goods $G_t$ and government transfers to households $TR_t$ to stabilize the debt-to-GDP ratio in the long-run.
  \begin{enumerate}
    \item Change only government spending on public goods $G_t$.
    \item Change only government transfers to households $TR_t$.
    \item Change both government spending $G_t$ and transfers $TR_t$ by the same percentage.
  \end{enumerate}

  \subsection{Change government spending only}\label{SecUnbalGBC_chgGt}

    We specify a closure rule that is automatically implemented after some period $T_{G1}$ to stabilize government debt as a percent of GDP (debt-to-GDP ratio). Let $\alpha_D$ represent the long-run debt-to-GDP ratio at which we want the economy to eventually settle.
    \begin{equation}\label{EqUnbalGBCclosure_Gt}
      \begin{split}
        &G_t = g_{g,t}\:\alpha_{g}\: Y_t \\
        &\text{where}\quad g_{g,t} =
          \begin{cases}
            1 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\:\:\:\,\text{if}\quad t < T_{G1} \\
            \frac{\left[\rho_{d}\alpha_{D}Y_{t} + (1-\rho_{d})D_{t}\right] - (1+r_{t})D_{t} - TR_{t} + Rev_{t}}{\alpha_g Y_t} \quad\text{if}\quad T_{G1}\leq t<T_{G2} \\
            \frac{\alpha_{D}Y_{t} - (1+r_{t})D_{t} - TR_{t} + Rev_{t}}{\alpha_g Y_t} \qquad\qquad\quad\:\:\:\,\text{if}\quad t \geq T_{G2}
          \end{cases} \\
        &\quad\text{and}\quad g_{tr,t} = 1 \quad\forall t
      \end{split}
    \end{equation}
    The first case in \eqref{EqUnbalGBCclosure_Gt} says that government spending $G_t$ will be a fixed fraction $\alpha_g$ of GDP $Y_t$ for every period before $T_{G1}$. The second case specifies that, starting in period $T_{G1}$ and continuing until before period $T_{G2}$, government spending be adjusted to set tomorrow's debt $D_{t+1}$ to be a convex combination between $\alpha_D Y_t$ and the current debt level $D_t$, where $\alpha_D$ is a target debt-to-GDP ratio and $\rho_d\in(0,1]$ is the percent of the way to jump toward the target $\alpha_D Y_t$ from the current debt level $D_t$. The last case specifies that, for every period after $T_{G2}$, government spending $G_t$ is set such that the next-period debt be a fixed target percentage $\alpha_D$ of GDP.

  \subsection{Change government transfers only}\label{SecUnbalGBC_chgTRt}

    If government transfers to households are specified by \eqref{EqUnbalGBCtfer} and the long-run debt-to-GDP ratio can only be stabilized by changing transfers, then the budget closure rule must be the following.
    \begin{equation}\label{EqUnbalGBCclosure_TRt}
      \begin{split}
        &TR_t = g_{tr,t}\:\alpha_{tr}\: Y_t \\
        &\text{where}\quad g_{tr,t} =
          \begin{cases}
            1 \qquad\qquad\qquad\qquad\qquad\qquad\qquad\:\text{if}\quad t < T_{G1} \\
            \frac{\left[\rho_{d}\alpha_{D}Y_{t} + (1-\rho_{d})D_{t}\right] - (1+r_{t})D_{t} - G_{t} + Rev_{t}}{\alpha_{tr} Y_t} \quad\text{if}\quad T_{G1}\leq t<T_{G2} \\
            \frac{\alpha_{D}Y_{t} - (1+r_{t})D_{t} - G_{t} + Rev_{t}}{\alpha_{tr} Y_t} \qquad\qquad\quad\:\:\:\:\text{if}\quad t \geq T_{G2}
          \end{cases} \\
        &\quad\text{and}\quad g_{g,t} = 1 \quad\forall t
      \end{split}
    \end{equation}
    The first case in \eqref{EqUnbalGBCclosure_TRt} says that government transfers $TR_t$ will be a fixed fraction $\alpha_{tr}$ of GDP $Y_t$ for every period before $T_{G1}$. The second case specifies that, starting in period $T_{G1}$ and continuing until before period $T_{G2}$, government transfers be adjusted to set tomorrow's debt $D_{t+1}$ to be a convex combination between $\alpha_D Y_t$ and the current debt level $D_t$. The last case specifies that, for every period after $T_{G2}$, government transfers $TR_t$ are set such that the next-period debt be a fixed target percentage $\alpha_D$ of GDP.

  \subsection{Change both government spending and transfers}\label{SecUnbalGBC_chgGtTRt}

    In some cases, changing only government spending $G_t$ or only government transfers $TR_t$ will not be enough. That is, there exist policies for which a decrease in government spending to zero after period $T_{G1}$ will not stabilize the debt-to-GDP ratio. And negative government spending on public goods does not make sense.\footnote{Negative values for government spending on public goods would mean that revenues are coming into the country from some outside source, which revenues are triggered by government deficits being too high in an arbitrary future period $T_{G2}$.} On the other hand, negative transfers do make sense. Notwithstanding, one might want the added stabilization ability of changing both government spending $G_t$ and transfers $TR_t$ to stabilize the long-run debt-to-GDP ratio.

    In our specific form of this joint option, we assume that the factor by which we scale government spending and transfers is the same $g_{g,t} = g_{tr,t}$ for all $t$. We label this single scaling factor $g_{trg,t}$.
    \begin{equation}\label{EqUnbalGBCclosure_gTRGt}
      g_{trg,t}\equiv g_{g,t} = g_{tr,t} \quad\forall t
    \end{equation}
    If government spending on public goods is specified by \eqref{EqUnbalGBC_Gt} and government transfers to households are specified by \eqref{EqUnbalGBCtfer} and the long-run debt-to-GDP ratio can only be stabilized by changing both spending and transfers, then the budget closure rule must be the following.
    \begin{equation}\label{EqUnbalGBCclosure_TRGt}
      \begin{split}
        &G_t + TR_t = g_{trg,t}\left(\alpha_g + \alpha_{tr}\right)Y_t \quad\Rightarrow\quad G_t = g_{trg,t}\:\alpha_g\: Y_t \quad\text{and}\quad TR_t = g_{trg,t}\:\alpha_{tr}\:Y_t \\
        &\text{where}\quad g_{trg,t} =
          \begin{cases}
            1 \qquad\qquad\qquad\qquad\qquad\qquad\:\:\:\,\text{if}\quad t < T_{G1} \\
            \frac{\left[\rho_{d}\alpha_{D}Y_{t} + (1-\rho_{d})D_{t}\right] - (1+r_{t})D_{t} + Rev_{t}}{\left(\alpha_g + \alpha_{tr}\right)Y_t} \quad\text{if}\quad T_{G1}\leq t<T_{G2} \\
            \frac{\alpha_{D}Y_{t} - (1+r_{t})D_{t} + Rev_{t}}{\left(\alpha_g + \alpha_{tr}\right)Y_t} \qquad\qquad\quad\:\:\:\:\text{if}\quad t \geq T_{G2}
          \end{cases}
      \end{split}
    \end{equation}
    The first case in \eqref{EqUnbalGBCclosure_TRGt} says that government spending and government transfers $Tr_t$ will their respective fixed fractions $\alpha_g$ and $\alpha_{tr}$ of GDP $Y_t$ for every period before $T_{G1}$. The second case specifies that, starting in period $T_{G1}$ and continuing until before period $T_{G2}$, government spending and transfers be adjusted by the same rate to set tomorrow's debt $D_{t+1}$ to be a convex combination between $\alpha_D Y_t$ and the current debt level $D_t$. The last case specifies that, for every period after $T_{G2}$, government spending and transfers are set such that the next-period debt be a fixed target percentage $\alpha_D$ of GDP.

    Each of these budget closure rules \eqref{EqUnbalGBCclosure_Gt}, \eqref{EqUnbalGBCclosure_TRt}, and \eqref{EqUnbalGBCclosure_TRGt} allows the government to run increasing deficits or surpluses in the short run (before period $T_{G1}$). But then the adjustment rule is implemented gradually beginning in period $t=T_{G1}$ to return the debt-to-GDP ratio back to its long-run target of $\alpha_D$. Then the rule is implemented exactly in period $T_{G2}$ by adjusting some combination of government spending $G_t$ and transfers $TR_t$ to set the debt $D_{t+1}$ such that it is exactly $\alpha_D$ proportion of GDP $Y_t$.

\section{Some Caveats and Alternatives}\label{SecUnbalGBCcaveat}

  \ogindia adjusts some combination of government spending $G_t$ and government transfers $TR_t$ as its closure rule instrument because of its simplicity and lack of distortionary effects. Since government spending does not enter into the household's utility function, its level does not affect the solution of the household problem. In contrast, government transfers do appear in the household budget constraint. However, household decisions do not individually affect the amount of transfers, thereby rendering government transfers as exogenous from the household's perspective. As an alternative, one could choose to adjust taxes to close the budget (or a combination of all of the government fiscal policy levers).

  There is no guarantee that any of our stated closure rules \eqref{EqUnbalGBCclosure_Gt}, \eqref{EqUnbalGBCclosure_TRt}, or \eqref{EqUnbalGBCclosure_TRGt} is sufficient to stabilize the debt-to-GDP ratio in the long run. For large and growing deficits, the convex combination parameter $\rho_d$ might be too gradual, or the budget closure initial period $T_{G1}$ might be too far in the future, or the target debt-to-GDP ratio $\alpha_D$ might be too high. The existence of any of these problems might be manifest in the steady state computation stage. However, it is possible for the steady-state to exist, but for the time path to never reach it. These problems can be avoided by choosing conservative values for $T_{G1}$, $\rho_d$, and $\alpha_D$ that close the budget quickly.

  And finally, in closure rules \eqref{EqUnbalGBCclosure_Gt} and \eqref{EqUnbalGBCclosure_TRGt} in which government spending is used to stabilize the long-run budget, it is also possible that government spending is forced to be less than zero to make this happen. This would be the case if tax revenues bring in less than is needed to financed transfers and interest payments on the national debt. None of the equations we've specified above preclude that result, but it does raise conceptual difficulties. Namely, what does it mean for government spending to be negative? Is the government selling off pubic assets? We caution those using this budget closure rule to consider carefully how the budget is closed in the long run given their parameterization. We also note that such difficulties present themselves across all budget closure rules when analyzing tax or spending proposals that induce structural budget deficits. In particular, one probably needs a different closure instrument if government spending must be negative in the steady-state to hit your long-term debt-to-GDP target.


\documentclass{article}
\usepackage{graphicx}
\usepackage{listings}
\def\lstxml{
  \lstset{language=XML,
    keywordstyle=\ttfamily,
    identifierstyle=\ttfamily,
    stringstyle=\ttfamily,
    showstringspaces=false,
    columns=[l]flexible,
    escapeinside={(@*}{*@)},
    morekeywords={encoding,
      mrow,math,mfrac,mi,msqrt,mo,mn,span,nobr,img}
  }
}

\def\lstjs{
  \lstset{language=Java,
    keywordstyle=\ttfamily,
    identifierstyle=\ttfamily\bfseries,
    stringstyle=\ttfamily,
    showstringspaces=false,
    columns=[l]flexible,
    morekeywords={cvox,Api,Math,defineRule}
  }
}
\setlength{\parindent}{0cm}
\pagestyle{empty}

\begin{document}

\section*{Fraction Example}

\textbf{Mathematics:}
\[ \frac{numerator}{denominator} \]

\textbf{MathML representation:}
\lstxml
\begin{lstlisting}
<mfrac>
  <mrow>Numerator</mrow>
  <mrow>Denominator</mrow>
</mfrac>
\end{lstlisting}

\textbf{JavaScript rule:}
\lstjs
\begin{lstlisting}
  defineRule(
      'mfrac', 'default.short',
          '[t] "Start Frac";
           [n] ./*[1];
           [t] "Over";
           [n] ./*[2];
           [t] "End Frac"',
      'self::mathml:mfrac');
\end{lstlisting}

\textbf{GUI Mock:}\vspace*{1ex}

\includegraphics[width=\linewidth]{Editor_Mock}

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:


\chapter{Conclusion}\label{conclusion}

\section{Concluding remarks}

Attacks on encrypted protocols that exploit compression methods applied on the
plaintext handled by those protocols have only recently been described.
Literature so far shows limited theoretical definitions of this new type of
attacks, while experimental results relate to a relatively small scope of
protocols used nowadays.

This work focused on assessing the threat of such attacks for widely used
protocols by expanding the theoretical definition and investigated the
success of methods designed for mitigation.

We introduced a cryptographical game for determining the property of
indistinguishability under partially chosen plaintext attacks. Also we provided
intuitive proofs for comparison to other indistinguishability properties, along
with scenarios of application of partially chosen plaintext attacks on
compressed encrypted protocols.

The need for practical description of our method resulted in the definition of
an attack model based on BREACH that initiates, automates and validates the
attack. We also revealed major vulnerabilities on the two systems that we
experimented on, Facebook Chat and Gmail, introducing new forms of secrets and
chosen plaintext an attacker could use.

We expanded the scope of the attack to block ciphers and we ulitized various
statistical methods that bypass known obstacles such as noise and padding.
Furthermore we proposed various optimization techniques that could reduce the
time and increase the efficiency of the attack posing a valid threat for
real-world systems.

In order to perform experiments and validate the efficiency of the attack, we
implemented a framework in Python that initiates the attack on a chosen
endpoint and parses the output in order to produce statistical results. From an
attacker's perspective, the framework must run on a machine inside the victim's
network, while the victim's machine is configured to send all traffic to the
endpoint to the attacker's machine and the victim also browses a website
controlled by the attacker.

Experimental results have shown that although the framework does not provide a
robust functionality, the attacker has a considerable advantage on
stealing a secret from the endpoints tested.

Finally we investigated the ability of previously proposed mitigation techniques
to stop the attack and proposed novel methods that could effectively minimize
the attack's success or even mitigate it completely.

\section{Future Work}

Although this work introduced the IND-PCPA property, formal definitions and
mathematical description is still necessary. Also this new property should be
formally evaluated compared to other known properties.

As far as the practical part of the attack, a consistency mechanism as
described in Section \ref{sec:persistence} is needed in order to take full
advantage of vulnerabilities of simple HTTP connections. Furthermore the
integration of MitM attacks, like the ones referenced in Section \ref{sec:mitm},
would result in a potential threat outside lab environment. It is also important
to implement a MitM proxy on TCP level that would be able to distinguish
packets of different records, minimizing the margin of error for overlapping
response or request streams.

Finally implementation of the two proposed mitigation techniques,
compressibility annotation [\ref{subsec:annotation}] and SOS headers
[\ref{subsec:sos}], is vital in order to secure systems against attacks that
utilize the findings of this work.


\subsection{RSA}


\documentclass[11pt]{article}
\usepackage{amsfonts,amssymb,amsthm,eucal,amsmath}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage{latexsym,url}
\usepackage{array}
\usepackage{subfig}
\usepackage{comment}
\usepackage{color}
\usepackage{tikz}
\usepackage{fancyvrb}
\usepackage{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}

\hypersetup{colorlinks=true,linkcolor=blue}
\newcommand{\myspace}{\vspace{.1in}\noindent}
\newcommand{\mymyspace}{\vspace{.1in}}
\usepackage[inner=30mm, outer=30mm, textheight=225mm]{geometry}
\creflabelformat{equation}{#2(#1)#3}
\crefname{equation}{}{}
\Crefname{equation}{}{}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{prop}[theorem]{Proposition}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{defn}[theorem]{Definition}
\newtheorem{notn}[theorem]{Notation}
\newtheorem{cond}[theorem]{Condition}
\newtheorem{ex}[theorem]{Example}
\newtheorem{rmk}[theorem]{Remark}

\newcommand{\TODO}{{\color{red} TODO}}

% Code and primitives
\newcommand{\cc}[1]{\texttt{#1}}
\newcommand{\Env}{\cc{Env}}
\newcommand{\Known}{\cc{Known}}
%\newcommand{\a}{\&\&}
%\newcommand{\c}[1]{\operatorname{#1}}
\newcommand{\Set}{\operatorname{Set}}
\newcommand{\empty}{\operatorname{empty}}

% Fix weird spacing issue in \cc.  For details, see
% https://tex.stackexchange.com/questions/118455/why-is-there-extra-space-after-in-texttt
%\makeatletter
%\let\ttfamily\relax % avoid a spurious warning
%\DeclareRobustCommand\ttfamily{\not@math@alphabet\ttfamily\mathtt\fontfamily\ttdefault\selectfont\frenchspacing}
%\makeatother

\title{A logic for computation}
\author{Geoffrey Irving\thanks{Email: irving@otherlab.com, Otherlab, San Francisco, CA, United States}}
\date{Version 1, \today}

\begin{document}
\maketitle

We want a logic that mixes computational objects with noncomputational objects, combining the
expressiveness of ZFC with programming.  We'll start by completely ignoring issues of soundness
and universes, then attempt to fix this later.  We will also ignore issues of size (sizeof),
by assuming that all computational types are word sized as in ocaml.  I believe that fixing
these issues will be relatively easy.

More importantly, we start out assuming a purely functional universe.  This assumption is much
harder to eliminate, but we have to start somewhere.

We use ASCII notation where possible to make it easy to translate into code.  In particular,
we use \cc{(:)} in place of $(\in)$ for set membership, \cc{<:} in place of $(\subset)$ for subset,
\cc{->} for function types, and \cc{x => ...} for anonymous functions.

\section{Primitives}

We have two universes \cc{Set} and \cc{Any}, where \cc{Set <: Any}.  \cc{Any} contains both sets
and immutable computational objects (booleans, lists, functions, etc.).  \cc{Set} is the ZFC
universe with individuals, where individuals include at least the computational objects.  We do
not assume the individuals include \emph{only} the computational objects, although that would
be a harmless assumption.

Aside: although \cc{Set} lives in some sense outside the computational universe, we allow
pointers to point directly to sets.  At machine runtime the logic will enforce that such a
pointer is used solely for pointer equality comparison.

The notion of a function is a bit slippery, since we want both the nice properties of ZFC
functions (concrete domain, concrete range, extensionality), and first class support for
partial vs. total and computable vs. noncomputable.  I believe we need two notions; since
the ZFC notion is emergent from sets in ZFC, only the second notion is necessary as a
separate primitive.  We'll curry, so actually what we want is not a notion of function, but
of value.  Since we allow pointers to reference sets, and general values have no properties
that sets don't, this second notion is actually just \cc{Any}.

The primitives in our logic are

\begin{enumerate}
\item $\empty : \Set$: The empty set: \cc{all Any (x => !(x : empty))}
\item \cc{Bool : Set}: The set of booleans
\item \cc{false,true : Bool}: The boolean individuals
\item \cc{(:) : Any}: The set membership function
\item \cc{(==) : Any}: Perfect structural equality over \cc{Any}
\item \cc{(!) : Any}: Boolean not: if \cc{b : Bool}, \cc{!b : Bool} is the other boolean
\item \cc{(\&\&) : Any}: Boolean and
\item \cc{all : Any}: Universal quantification over a set: if \cc{a : Set, f : a -> Bool}, \cc{all f a : Bool}
\item \cc{subsets : Any}: Power set: if \cc{a : Set}, \cc{subsets a : Set}
\item \cc{safe : Any}: Function safety at an argument: if \cc{f : Any, x : Any}, \cc{safe f x : Bool}
\item \cc{filter : Any}: Subset extraction: if \cc{a : Set, f : a -> Bool}, \cc{filter f a : Set}
\item \cc{choice : Any}: Global choice: if \cc{a : Set} is nonempty, \cc{choice a : a}
\end{enumerate}

Important: for now, we explicitly leave out a primitive notion of whether a function is ``computational''
at a value (whether it terminates).  This is because termination is not required for the logic to be
sound, and on a physical machine termination by itself is a useless construct.  Soundness matters, and
efficient execution matters, but little in between.  As with Milawa, we bail at runtime
if the system attempts to run a noncomputational function.

Based on these primitives, we define several derived notions:

\begin{enumerate}
\item Boolean or: \cc{a || b = !(!a \&\& !b)}
\item Function types: \cc{(a -> b) = filter (f => all (x => safe f x \&\& f x : b) a) Any}
\item Existential quantification: \cc{any f a = !(all (x => !(f x)) a)}
\item Function composition: \cc{f . g = (x => f (g x))}
\end{enumerate}

\section{Environments and knowledge}

A proposition is simply a boolean value, together with its definition as code.  Code is an
algebraic datatype
\begin{verbatim}
data Code =
    Var Name
  | Value Any
  | Lambda Name Code
  | Apply Code Code
\end{verbatim}
That's not going to be enough (a bare \cc{Any} is essentially useless, and we've left out
both conditionals and macros), but we'll add further features as necessary.

An environment is a (finite) map from names to values and optionally definitions.  That is
\begin{verbatim}
type Env = Map Name (Any,Maybe Code)
\end{verbatim}
Our knowledge is a set of names that we have proven are true:
\begin{verbatim}
type Known = Set Name
\end{verbatim}

Frequently, we'll have a function in \cc{Env} like \cc{refl = x => x == x}, together with a theorem
of the form \cc{reflAll = all refl Any} which will appear in \cc{Env} and \cc{Known}.  That is, the
theorem fills in all the missing universal quantification in the function.

\section{Definitions and proofs}

At a given point in the code, we have a number of definitions in \Env, some of which are \Known.
We would like to know how to define new things, and how to prove that some of these are true.

\end{document}