\documentclass{article}
\usepackage{enumerate}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[margin=1in]{geometry}
\usepackage[parfill]{parskip}
\DeclareMathOperator*{\argmax}{arg\,max}

\title{Econ C103 Problem Set 7}
\author{Sahil Chinoy}
\date{March 21, 2017}

\begin{document}
\maketitle{}

\subsection*{Exercise 1}

\begin{enumerate}[(a)]
	\item

	Since every bidder pays his own bid with probability one, the expected revenue is just the sum of all bids

	$$\sum \limits_{i=1}^N \mathbb{E}[t_i(\theta_i) | \theta_i] = \sum \limits_{i=1}^{N} b_i(\theta_i).$$

	\item

	By the revenue equivalence theorem, the revenue raised by the all-pay auction must be the same as the revenue raised by the second-price auction, given that they both implement the same allocation. So, if we assume a symmetric equilibrium, the expected transfer for an agent in each of the two auction formats must be the same. Since the expected transfer in the all-pay auction is just the bid, $b_{AP}(\theta_i)$, this implies

	$$b_{AP}(\theta_i) = \mathbb{E}[t_i(\theta_i)]_{SP} = \int \limits_{\underline{\theta}}^{\theta_i} z \; dF^{n-1}(z).$$

	To verify that this is an equilibrium, we first check that $b_{AP}(\theta_i)$ is increasing in $\theta_i$, which is clearly true, since we are integrating a positive function. We also need to check

	\begin{gather*}
	\theta_i \in \argmax_{z \in \Theta_i} \left\{ -(1 - F^{n-1}(z))\int \limits_{\underline{\theta}}^z s dF^{n-1}(s) + F^{n-1}(z) \left(\theta_i - \int \limits_{\underline{\theta}}^z s dF^{n-1}(s) \right) \right\} \\
	\theta_i \in \argmax_{z \in \Theta_i} \left\{ -\int \limits_{\underline{\theta}}^z s dF^{n-1}(s) + F^{n-1}(z) \theta_i  \right\}
	\end{gather*}

	Taking the derivative to check the first-order condition,

	\begin{equation*}
	\theta_i (dF^{n-1}(z)) = z (dF^{n-1}(z))
	\end{equation*}

	which is true when $z = \theta_i$.

	\item

	Recall the equilibrium bid in a second-price auction is the agent's true valuation, $b_{SP}(\theta_i) = \theta_i$, and the equilibrium bid in a first-price auction is given by

	$$b_{FP}(\theta_i) = \theta_i - \frac{1}{F^{n-1}(\theta_i)} \int \limits_{\underline{\theta}}^{\theta_i} F^{n-1}(z) \; dz .$$

	For ease of comparison, let us assume a uniform distribution on $[0,1]$, so $F(\theta_i) = \theta_i$. Then $b_{FP}(\theta_i) = \frac{n-1}{n} \theta_i$ and $b_{AP}(\theta_i) = \frac{n-1}{n} (\theta_i)^n$. So $b_{SP} > b_{FP} > b_{AP}$.

	We know that the equilibrium strategy for a first-price auction involves ``bid shading'' because the agent knows if they win, they will have to actually pay their bid, and if they bid their value they will extract zero utility. Similarly, when the agent knows they will have to pay their bid regardless of whether they win, they will bid even less -- since they know there is a low probability that they will win (and this chance decreases with the number of bidders $n$), they want to minimize their expected losses in the cases where they lose the auction.

	\item

	Take

	$$b'_{AP}(\theta_i) = c^{-1} \left( \int \limits_{\underline{\theta}}^{\theta_i} z \; dF^{n-1}(z) \right).$$

	If $c(\cdot)$ is increasing, then $c^{-1}(\cdot)$ is increasing, so the bid function is still increasing in $\theta_i$. We need to check that this bid maximizes expected utility

	\begin{align*}
	\theta_i &\in \argmax_{z \in \Theta_i} \left\{ -(1 - F^{n-1}(z)) \, c(b_{AP}'(\theta_i)) + F^{n-1}(z) (\theta_i - c(b_{AP}'(\theta_i)) \right\}.
	\end{align*}

	But this just reduces to the same expression as part (b), so we already know it is true.

\end{enumerate}

\subsection*{Exercise 2}

\begin{enumerate}[(a)]

	\item

	Given uniformly distributed values, the expected value for agent 1 is $\mathbb{E}[\theta_1] = \overline{\theta_1}/2$, and the expected value for agent 2 is $\mathbb{E}[\theta_2] = \overline{\theta_2}/2$. Since, $\overline{\theta_2} > \overline{\theta_1}$, agent 2 values the object more on average.

	\item

	The CDF of the maximum value is given by

	\[
	 F(\theta_{max}) =
	  \begin{cases}
	   \frac{(\theta_{max})^2}{\overline{\theta_1} \, \overline{\theta_2}} & \text{if } \theta_{max} \in [0,\overline{\theta_1}]  \\
	   \frac{\theta_{max}}{\overline{\theta_2}} & \text{if } \theta_{max} \in (\overline{\theta_1}, \overline{\theta_2}]
	  \end{cases}.
	\]

	So the expected maximum value is

	$$\int \limits_0^{\overline{\theta_2}} \theta_{max} f(\theta_{max}) d\theta_{max} = \int \limits_0^{\overline{\theta_1}}  \frac{2(\theta_{max})^2}{\overline{\theta_1} \, \overline{\theta_2}} d\theta_{max} + \int \limits_{\overline{\theta_1}}^{\overline{\theta_2}} \frac{\theta_{max}}{\overline{\theta_2}} d\theta_{max} = \frac{1}{2} \overline{\theta_2} + \frac{1}{6} \frac{\overline{\theta_1}^2}{\overline{\theta_2}}.$$

	\item

	The virtual value is given by

	$$J(\theta_i) = \theta_i - \frac{1 - F(\theta_i)}{f(\theta_i)}.$$

	For agent 1, $F(\theta_1) = \theta_1 / \overline{\theta_1}$ and $f(\theta_1) = 1 / \overline{\theta_1}$, so $J(\theta_1) = 2\theta_1 - \overline{\theta_1}.$ Symmetrically, $J(\theta_2) = 2\theta_2 - \overline{\theta_2}.$

	\item

	The revenue maximizing mechanism allocates the object to the agent with the highest virtual value whenever the virtual value is greater than 0. So, here, the revenue maximizing mechanism is a second-price auction with a reserve price of $\overline{\theta_1}/2$.

	Intuitively, the reserve price is set by the type distribution of the agent with the \textit{lowest} type, because in order to maximize profits, we care only about making sure the bidder who values the object the least meets a minimum bid -- at that reserve price, we expect all other agents who value the object more will be willing to bid above the minimum.

	\item

	First, we calculate the expected transfer for agent 1. Agent 1 pays $\overline{\theta_1}/2$ when they value the object more than the reserve price and when agent 2 values the object less than the reserve price. Agent 1 pays $\theta_2$ when agent 2 values the object more than the reserve price and agent 1 values the object more than agent 2. So

	$$\mathbb{E}[t_1] = \frac{\overline{\theta_1}}{2} \frac{1}{2} \frac{\overline{\theta_1}/2}{\overline{\theta_2}} + \int \limits_{\overline{\theta_1}/2}^{\overline{\theta_1}} \theta_2 \left( \int \limits_{\theta_2}^{\overline{\theta_1}} \frac{d\theta_1}{\theta_1} \right) \frac{d\theta_2}{\overline{\theta_2}} = \frac{5}{24} \frac{\overline{\theta_1}^2}{\overline{\theta_2}}.$$

	Now, we calculate the expected transfer for agent 2. Agent 2 pays $\overline{\theta_1}/2$ when they value the object more than the reserve price and when agent 1 values the object less than the reserve price. Agent 2 pays $\theta_1$ when agent 1 values the object more than the reserve price and agent 2 values the object more than agent 1. So

	$$\mathbb{E}[t_2] = \frac{\overline{\theta_1}}{2} \frac{1}{2} \left( 1 - \frac{\overline{\theta_1}/2}{\overline{\theta_2}} \right) + \int \limits_{\overline{\theta_1}/2}^{\overline{\theta_1}} \theta_1 \left( \int \limits_{\theta_1}^{\overline{\theta_2}} \frac{d\theta_2}{\theta_2} \right) \frac{d \theta_1}{\overline{\theta_1}} = \frac{5}{8} \overline{\theta_1} - \frac{5}{12} \frac{\overline{\theta_1}^2}{\overline{\theta_2}}.$$

	Then the expected revenue is

	$$\mathbb{E}[t_1] + \mathbb{E}[t_2] =  \frac{5}{8} \overline{\theta_1} - \frac{5}{24} \frac{\overline{\theta_1}^2}{\overline{\theta_2}}.$$

	\item

	In general, we can pick any two $\overline{\theta_1}, \overline{\theta_2}$ such that the expected maximum value is the same, and the expected revenue will be different.

	We see that if $\overline{\theta_1} = 1, \; \overline{\theta_2} = 2$, then the expected maximum value is $\frac{13}{12}$ and the expected revenue is $\frac{25}{48}$. But if, say $\overline{\theta_1} = \frac{3}{5} \sqrt{\frac{11}{2}}, \; \overline{\theta_2} = \frac{9}{5}$, then the expected maximum value is still $\frac{13}{12}$ but the expected revenue is $\frac{3}{8}\sqrt{\frac{11}{2}} - \frac{11}{48}$.

\end{enumerate}

\end{document}


\documentclass[12pt]{article}         % the type of document and font size (default 10pt)
\usepackage[margin=1.0in]{geometry}   % sets all margins to 1in, can be changed
\usepackage{moreverb}                 % for verbatimtabinput -- LaTeX environment
\usepackage{amssymb}                  % for many mathematical symbols
\usepackage[pdftex]{lscape}           % for landscaped tables
\usepackage{longtable}                % for tables that break over multiple pages
\usepackage{blkarray}
\usepackage{amsmath}

\title{The Buyer-Seller Problem}
\author{Takemyprocs}
\usepackage{Sweave}
\begin{document}
\input{framework-concordance}

\maketitle

\abstract{At first, we deal with a simplified case of the buyer-seller problem which we refer as The Seller Problem. We provide a simple model along with an illustrative application. Then, we depart from this basic framework to deal with more realistic scenarios where the decision maker jointly determines buying and selling choices. Finally, we discuss some issues on the buying and selling process that are not related to the choice problem.}

\section{The Seller Problem: a basic framework}
Suppose a seller is endowed with a fixed amount of $m$ inputs, namely: $s_1, s_2,...,s_m$. With them the seller can craft $n$ products, namely: $x_1,x_2,...,x_n$. Not all inputs may be required for crafting a particular product, so we define $A$ as the technical matrix that captures the input requirements for each output:

\[
A =
\begin{blockarray}{ccccc}
& x_1 & x_2 & ... & x_n \\
\begin{block}{c(cccc)}
  s_1 & a_{11} & a_{12} & ...    & a_{1n} \\
  s_2 & a_{21} & a_{22} & ...    & a_{2n} \\
  \vdots & \vdots & \vdots & \ddots & \vdots \\
  s_m & a_{m1} & a_{m2} & ...    & a_{mn} \\
\end{block}
\end{blockarray}
 \]

For instance, in order to craft $1$ unit of product $x_1$ we need to use $a_{11}$ units of input $s_1$, $a_{21}$ units of input $s_2$, and so on. We assume technical coefficients $a_{ij}$ are fixed. Recall that since not all inputs are required for crafting a particular product some of the elements in this matrix may be $0$. Finally, we assume that only outputs can be sold freely at fixed prices: $p_1, p_2,...,p_n$.\\
\\
Given those conditions, we can write the seller problem as follows:
\begin{equation}
\begin{aligned}
\max_{x_1,x_2,...,x_n} \quad & p_1x_1 + p_2x_2 + ... + p_nx_n \\
\textrm{s.t.} \quad & a_{11}x_1 + a_{12}x_2 + ... + a_{1n}x_n \leq s_1\\
  &a_{21}x_1 + a_{22}x_2 + ... + a_{2n}x_n \leq s_2\\
  &\vdots \\
  &a_{m1}x_1 + a_{m2}x_2 + ... + a_{mn}x_n \leq s_m\\
  &x_1,x_2,...,x_n\geq0    \\
\end{aligned}
\end{equation}

Intuitively, the seller problem is to choose production quantities $x_1,x_2,...,x_n$ in order to maximize earnings subject to input availability constraints. This resembles the linear programming canonical form. Therefore, we can use almost any mathematical software (e.g. Matlab, R or Python) to solve this problem. In order to apply this model we need information on technical coefficients, input endowments and prices. We provide an example in the next section.

\section{An example}
Suppose a seller is endowed with $98$ units of input 1, $147$ units of input 2, $182$ units of input 3, $157$ units of input 4 and $114$ units of input 5. By using those inputs the seller can craft up to 6 different products, say $x_1,...,x_6$. The input requirements for crafting each product are summarized in the technical matrix shown below:

\[
A =
\begin{blockarray}{ccccccc}
& x_1 & x_2 & x_3 & x_4 & x_5 & x_6 \\
\begin{block}{c(cccccc)}
  s_1 & 5 & 0 & 0 & 0 & 0 & 4  \\
  s_2 & 0 & 5 & 0 & 0 & 0 & 4  \\
  s_3 & 0 & 0 & 5 & 0 & 3 & 4  \\
  s_4 & 0 & 0 & 0 & 5 & 3 & 4  \\
  s_5 & 0 & 0 & 0 & 0 & 1 & 3  \\
\end{block}
\end{blockarray}
 \]

Finally, market prices for products 1 to 6 are $100.2$, $80$, $110.96$, $120.11$, $115.90$ and $314$ respectively. According to the basic framework described in the previous section we formulate the seller problem for this particular application as follows:

\begin{equation}
\begin{aligned}
\max_{x_1,x_2,...,x_n} \quad & 100.2x_1 + 80x_2 + 110.96x_3 + 120.11x_4 + 115.90x_5 + 314x_6 \\
\textrm{s.t.} \quad & 5x_1 + 4x_6 \leq 98\\
  & 5x_2 + 4x_6 \leq 147\\
  & 5x_3 + 3x_5 + 4x_6 \leq 182\\
  & 5x_4 + 3x_5 + 4x_6 \leq 157\\
  & x_5 + 3x_6 \leq 114\\
  & x_1,x_2,x_3,x_4,x_5,x_6 \geq 0
\end{aligned}
\end{equation}

We use the package \texttt{lpSolve} (linear programming) in the R environment to solve this problem. As shown below, our code\footnote{See the seller.R script in GitHub.} provides us with optimal quantities for every product.

\begin{Schunk}
\begin{Soutput}
     product quantity
[1,] "x1"    "17"
[2,] "x2"    "27"
[3,] "x3"    "34"
[4,] "x4"    "29"
[5,] "x5"    "0"
[6,] "x6"    "3"
\end{Soutput}
\end{Schunk}

\newpage

Notice that quantity for product $x_5$ is null, this is an example of \textit{corner solution} which is very common in the linear programming framework. This solution implies that, at faced prices, endowments and current technical requirements, is not profitable to craft product $x_5$ at all. It is worth noting that although we use a linear programming approach what we use indeed is an \textit{integer programming} approach without loss of generality. The difference lies in the solution's domain, while linear programming admits solutions in the real domain, integer programming offers solutions within the integer domain which is a more realistic approach (Who would sugest you to produce $\pi$ units of any product?).

\section{Some extentions}
Insofar we have described a basic framework of the seller problem. Under this model we assumed that inputs cannot be sold in the market as we do with products. Also we have not considered the possibility of purchasing inputs in the market and then crafting products with them. In this section we make some departures from the basic framework to land into a more realistic trading scenario.

\subsection{What if we sell inputs as well?}
We extend the previous model by including the possibility to sell inputs directly through the market and not only use them for crafting purposes. This is easily done by attaching an identity matrix to our technical matrix, which is equivalent to add $m$ extra products that uses $1$ unit of each input. Put in simple, to "craft" and sell $1$ unit of input $s_i$ we require $1$ unit of input $i$ and $0$ units of the remain inputs. The new technical matrix looks as follows:

\[
A =
\begin{blockarray}{ccccccccc}
& x_1 & x_2 & ... & x_n & \bar{s}_1 & \bar{s}_2 & ... & \bar{s}_m \\
\begin{block}{c(cccccccc)}
  s_1 & a_{11} & a_{12} & ...    & a_{1n} & 1 & 0 & ... & 0 \\
  s_2 & a_{21} & a_{22} & ...    & a_{2n} & 0 & 1 & ... & 0 \\
  \vdots & \vdots & \vdots & \ddots & \vdots & \vdots & \vdots & \ddots & \vdots \\
  s_m & a_{m1} & a_{m2} & ...    & a_{mn} & 0 & 0 & ... & 1 \\
\end{block}
\end{blockarray}
 \]

At this point we must distinguish between the quantity of input $i$ that we choose to sell in the market, which we denote as $\bar{s}_i$, and the available stock of input $i$, which we still refer to as $s_i$. Finally, assume that along with product prices $p_1, p_2, ..., p_n$ we are facing the following prices for inputs: $r_1, r_2, ..., r_m$. Given those conditions, we reformulate our problem as follows:

\begin{equation}
\begin{aligned}
\max_{x_1,x_2,...,x_n,\bar{s}_1,\bar{s}_2,...,\bar{s}_m} \quad & p_1x_1 + p_2x_2 + ... + p_nx_n + r_1\bar{s}_1 + r_2\bar{s}_2 + ... + r_m\bar{s}_m \\
\textrm{s.t.} \quad & a_{11}x_1 + a_{12}x_2 + ... + a_{1n}x_n + \bar{s}_1 \leq s_1\\
  &a_{21}x_1 + a_{22}x_2 + ... + a_{2n}x_n + \bar{s}_2 \leq s_2\\
  &\vdots \\
  &a_{m1}x_1 + a_{m2}x_2 + ... + a_{mn}x_n + \bar{s}_m \leq s_m\\
  &x_1,x_2,...,x_n,\bar{s}_1,\bar{s}_2,...,\bar{s}_m\geq0    \\
\end{aligned}
\end{equation}

Notice that the objective function (or revenue function if you prefer) is now composed by earnings coming from both product and input sales. Also, inputs are now allocated in either product crafting or direct sale. This last condition is captured along the $m$ declared constraints \footnote{Take a look at our script sell\_inputs.R in GitHub for an application of this model}.

\subsection{What if we buy inputs?}
Now suppose we came back to the situation where we cannot sell inputs but we are able to buy them in order to craft and sell products. Of course, we cannot buy inputs indefinitively as we may have a budget constraint so we introduce capital $K$ as a new parameter in the model. For the sake of simplicity, we understand capital as available cash to buy items (like inputs in our model). Technology stays the same so we adopt the technical matrix described in section 1:

\[
A =
\begin{blockarray}{ccccc}
& x_1 & x_2 & ... & x_n \\
\begin{block}{c(cccc)}
  \bar{s}_1 & a_{11} & a_{12} & ...    & a_{1n} \\
  \bar{s}_2 & a_{21} & a_{22} & ...    & a_{2n} \\
  \vdots & \vdots & \vdots & \ddots & \vdots \\
  \bar{s}_m & a_{m1} & a_{m2} & ...    & a_{mn} \\
\end{block}
\end{blockarray}
 \]

However, it is worth noting that instead of having exogenous input quantities $s_i$ we simultaneously determine product and input quantities. Therefore, we use the $\hat{s}_i$ notation to indicate that input availability is endogenous and determined within the model. Finally, we assume that along with product prices $p_1, p_2, ..., p_n$ we are facing the following prices for inputs: $r_1, r_2, ..., r_m$. Given those conditions, we reformulate our problem as follows:

\begin{equation}
\begin{aligned}
\max_{x_1,x_2,...,x_n,\bar{s}_1,\bar{s}_2,...,\bar{s}_m} \quad & p_1x_1 + p_2x_2 + ... + p_nx_n - r_1\bar{s}_1 - r_2\bar{s}_2 - ... - r_m\bar{s}_m \\
\textrm{s.t.} \quad & a_{11}x_1 + a_{12}x_2 + ... + a_{1n}x_n - \bar{s}_1 \leq 0\\
  &a_{21}x_1 + a_{22}x_2 + ... + a_{2n}x_n - \bar{s}_2 \leq 0\\
  &\vdots \\
  &a_{m1}x_1 + a_{m2}x_2 + ... + a_{mn}x_n - \bar{s}_m \leq 0\\
  &r_1\bar{s}_1 + r_2\bar{s}_2 + ... + r_m\bar{s}_m \leq K \\
  &x_1,x_2,...,x_n,\bar{s}_1,\bar{s}_2,...,\bar{s}_m\geq0    \\
\end{aligned}
\end{equation}

In this case the objective function is composed by overall earnings due to product sales and the overall spending due to input purchases. Regarding constraints, we see that input availability depends on the input purchase decision while this in turn is limited by the capital budget \footnote{See the script seller\_buyer.R in GitHub for an application of this model}.

\end{document}


% !TEX root = /Users/hzd88688126com/Desktop/USFD_Academic-_Report_LaTeX-Template/main.tex
\section{Periodogram-based Methods Applied to Real-World Data}
\subsection{The sunspot time series}
As shown in Fig.\ref{fig:1_2_a}, the periodograms of raw sunspots data and its processed data are compared, including \texttt{detrend} in red line, \texttt {mean} in orange and \texttt {logarithm} in purple. In addition, the effects of applying rectangular window and Hanning window on spectral are illustrated as well.
\begin{figure}[htbp]
     \centering
      \hspace{-0.4cm}
     \begin{subfigure}[b]{0.33\textwidth}
         \centering
         \includegraphics[width=\textwidth]{fig/12/12a1.eps}
         \caption{Time series}
         \label{fig:raw}
     \end{subfigure}
      \hspace{-0.4cm}
     \begin{subfigure}[b]{0.33\textwidth}
         \centering
         \includegraphics[width=\textwidth]{fig/12/12a2.eps}
         \caption{Rectangular window}
         \label{fig:rect}
     \end{subfigure}
      \hspace{-0.4cm}
     \begin{subfigure}[b]{0.33\textwidth}
         \centering
         \includegraphics[width=\textwidth]{fig/12/12a3.eps}
         \caption{Hanning window}
         \label{fig:hann}
     \end{subfigure}
        \caption{Periodogram of processing sunspots data with rectangular and Hanning window}
        \label{fig:1_2_a}
\end{figure}\\
The results of using \texttt{detrend} and \texttt{mean} are similar. However, subtracting its mean leads to removing the DC component in zero frequency, while \texttt{detrend} results in eliminating the linear trend of a vector under low frequency region. Afterwards, the PSD curves of processing and raw data are same. As to centring after \texttt{log}, the curve is smoothly and the variance is reduced, as consequence of that the peaks are difficult to be detected.\\
Applying different windows will cause the changing of periodogram, due to the resolution of mainlobe width and sidelobe attenuation. Compared with Fig.\ref{fig:rect} and \ref{fig:hann}, the curve is smoothly with less ripples when using the Hanning window. The reason is that the Hanning window has larger mainlobe width than rectangular window. Moreover, interest peaks can be effectively detected by applying \texttt{log}, since most of ripples are eliminated.
\subsection{The basis for brain computer interface (BCI)}
Fig.\ref{fig:1_2_b1} illustrates periodagrams of the standard and Bartlett method. By applying Bartlett averaging method, the peaks of frequency are easily detected which are the range of $8-10$, $13$, $26$, $39$ and $50$ $Hz$. As stated in instruction, the strong response within $8-10 \ Hz$ and $50 \ Hz$ are not the SSVEP\cite{mandic}. Therefore, the fundamental frequency peak of the SSVEP is at $f=13 \ Hz$ with harmonics frequencies at $f=26 \ Hz$ and $f=39 \ Hz$.
\begin{figure}[htp]
     \centering
     \begin{subfigure}{0.4\textwidth}
         \centering
         \includegraphics[width=\textwidth]{fig/12/12b1.eps}
     \end{subfigure}
     ~
     \begin{subfigure}{0.4\textwidth}
         \centering
         \includegraphics[width=\textwidth]{fig/12/12b2.eps}
     \end{subfigure}
        \caption{Standard and Bartlett Method of EEG Periodograms}
        \label{fig:1_2_b1}
\end{figure}\\
With different length of windows, the total signal is divided into different length of segments. Fig.\ref{fig:1_2_b2} depicts the different periodograms with lengths of $\Delta t=10s$ and $\Delta t=1s$ windows. As to $\Delta t=1s$, the periodogram is smooth with reduced variance. Nevertheless, the peak frequencies of interest are unapparent resulting in difficultly detecting the SSVEP\cite{mandic}. Only alpha-rhythm peak at 8-10 $Hz$ and interference at 50 $Hz$ can be observed. When increasing the window length such as $\Delta t =10s$, the number of segments decreases and each segment is longer. Hence, the variance of periodogram is reduced to a slight extent, resulting in distinct peak. However, the variance is sufficiently elimanitade compared with standard periodogram. Therefore, the trade-off between variance and precision need to be considered.
\begin{figure}[htp]
     \centering
     \begin{subfigure}{0.4\textwidth}
         \centering
         \includegraphics[width=\textwidth]{fig/12/12b4.eps}
     \end{subfigure}
     ~
     \begin{subfigure}{0.4\textwidth}
         \centering
         \includegraphics[width=\textwidth]{fig/12/12b3.eps}
     \end{subfigure}
        \caption{Bartlett method with different windows of EEG Periodograms}
        \label{fig:1_2_b2}
\end{figure}


\documentclass{article}

\usepackage{graphicx}      % include this line if your document contains figures

\usepackage{bm}
\usepackage[utf8]{inputenc} % allow utf-8 input
\usepackage[T1]{fontenc}    % use 8-bit T1 fonts
\usepackage{url}            % simple URL typesetting
\usepackage{nicefrac}       % compact symbols for 1/2, etc.
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{amssymb}

\newcommand{\R}{\mathbb{R}} % Real number
\newcommand{\paramtf}{\theta} % transfer function parameter
\newcommand{\paramst}{\mathcal{W}} % static non-linearity parameter

% Transfer function symbols
\newcommand{\q}{q} % shift operator
\newcommand{\A}{A} % autoregressive polynomial
\newcommand{\ac}{a} % autoregressive polynomial coefficient
\newcommand{\B}{B} % exogenous polynomial
\newcommand{\bb}{b} % exogenous polynomial coefficient

% Others
\newcommand{\sens}[1]{\tilde{#1}}
\newcommand{\adjoint}[1]{\overline{#1}}

% Correlation and Convolution
\newcommand{\conv}{*}
\newcommand{\ccorr}{\star}

\newcommand{\tvec}[1]{\mathbf{#1}}
\newcommand{\nsamp}{T}
\newcommand{\pdiff}[2]{\frac{\partial #1}{\partial #2}}
\newcommand{\diff}[2]{\frac{d #1}{d #2}}
\newcommand{\loss}{\mathcal{L}}
\newcommand{\norm}[1]{\left\lVert#1\right\rVert}
\newcommand{\simul}{{\rm sim}}
\newcommand{\Name}{\emph{dynoNet}}
\newcommand{\vv}{z}

\title{Deep learning with transfer functions: new applications in system identification}
\author{%
  Dario~Piga, Marco~Forgione, Manas~Mejari \\%\thanks{} \\
  IDSIA Dalle Molle Institute for Artificial Intelligence\\
  USI-SUPSI, Lugano, Switzerland\\
  \texttt{\{dario.piga, marco.forgione, manas.mejari\}@supsi.ch} \\
}

\begin{document}

\maketitle

\begin{abstract}
This paper presents a linear dynamical operator described in terms of a rational transfer function, endowed with a well-defined and efficient back-propagation behavior for automatic derivatives computation.
The operator enables end-to-end training of structured networks containing linear transfer functions and other differentiable units {by} exploiting standard deep learning software.
 Two relevant applications of the operator in system identification are presented. The first one consists in the  integration of \emph{prediction error methods} in deep learning. The dynamical operator is included as {the} last layer of a neural network in order to obtain the optimal one-step-ahead prediction error.
 The second one considers identification of general block-oriented models from quantized data. These block-oriented models are constructed by combining linear dynamical operators with static nonlinearities described as standard feed-forward neural networks. A custom loss function corresponding to the log-likelihood of quantized output observations is defined. For gradient-based optimization, the derivatives of the log-likelihood are computed by applying the back-propagation algorithm through the whole network.  Two system identification benchmarks are used to show the effectiveness of the proposed methodologies.
\end{abstract}

\vskip 1em
%\begin{large}
\noindent\rule{\textwidth}{1pt}
 To cite this work, please use the following bibtex entry:
\begin{verbatim}
@inproceedings{piga2021a,
  title={Deep learning with transfer functions:
            new applications in system identification},
  author={Piga, D. and Forgione, M. and Mejari, M.},
  booktitle={Proc. of the 19th IFAC Symposium System Identification:
                learning models for decision and control},
  address={Padova, Italy},
  year={2021}
}
\end{verbatim}
\vskip 1em
Using the plain bibtex style, the bibliographic entry should look like:\\ \\
\textsf{D. Piga, M. Forgione and M. Mejari Deep learning with transfer functions: new applications in system identification.}
 In \textit{Proc. of the 19th IFAC Symposium System Identification: learning models for decision and control},
 Padova, Italy, 2021.

\noindent\rule{\textwidth}{1pt}

%\begin{keyword}
%System identification; neural networks; quantized data; prediction error methods; deep learning.
%\end{keyword}

%\end{frontmatter}
%===============================================================================

\section{Introduction}

%\cite{piga2021a}

Thanks to  the universal approximation capabilities of neural networks, deep learning algorithms are nowadays behind high-impact cutting-edge technologies such as language translation, speech recognition, and autonomous driving, just to cite a few \cite{schmidhuber2015deep}. Highly optimized and user-friendly deep learning frameworks are available \cite{paszke:2017automatic}, often distributed under permissive open-source licenses.
On one hand, using the high-level functionalities offered by a deep learning framework, standard learning tasks (once considered extremely hard) such as image classification can be accomplished with moderate efforts even by non-expert practitioners. On the other hand, experienced users can build customized models and objective functions,
exploiting the framework's built-in back-propagation engine \cite{rumelhart1988learning} for gradient computations.

\emph{System identification} definitely represents a challenging field where the flexibility of neural networks and  deep learning algorithms can be used to describe and estimate non-linear dynamical systems. This requires {one} to define specialized networks that take into account  temporal evolution of the input/output data, a fundamental feature setting identification of dynamical systems apart from typical (static) supervised problems in machine learning.

Neural networks have been widely used in system identification in the past (see, e.g.,
 \cite{werbos1989neural, chen1990non,chen1992neural}), and the \emph{back-propagation through time} algorithm \cite{williams1995gradient} has been applied to train \emph{Recurrent Neural Networks} (RNNs). Recently, the use of
 \emph{Long Short-Term Memory} (LSTM)  and 1-D  \emph{Convolutional Neural Networks} (CNNs) in system identification has been discussed in~\cite{gonzalez2018non, wang2017new} and~\cite{andersson:2019deep}, respectively.
 An architecture specialized for continuous-time system identification called \emph{Integrated Neural Network}, %and consisting in
 {which consists of} a feed-forward network followed by an integral block is proposed in~\cite{Mav2020}.  Loss functions based on the simulation error over small subsets of the training data are proposed in~\cite{forgione2019model,forgione2021continuous} and~\cite{ribeiro_smoothness_2020}, where a regularization  term and a multiple shooting approach are employed, respectively, to enforce
   that the initial conditions of all the subsets are compatible with the identified model dynamics.
   The list above is far from being exhaustive, as new contributions using neural networks and deep learning algorithms for system identification are regularly appearing   every year in dedicated conferences and journals.

  A novel network architecture called \Name \ {which is}  tailored for the identification of nonlinear dynamical systems has been recently proposed by the authors in~\cite{forgione2021dynonet}. The network consists in the interconnection of \emph{Linear Time-Invariant} (LTI) dynamical blocks and static nonlinearities.
   In this paper, we describe the LTI dynamical layer which constitutes the elementary block of \Name, along with the  forward and backward operations needed to make this layer compatible with the back-propagation algorithm. The LTI layer is described  in terms of rational transfer functions, and thus acts as an \emph{infinite impulse response} (IIR) filter applied to its input sequence.
%

    A differentiable LTI dynamical layer allows us to tackle several challenging problems in system identification. In particular,  in this paper:
  \begin{itemize}
  	\item   We consider the case of output signals affected by an additive colored noise. To this aim, we include  a trainable linear dynamical unit as {the} last layer of an end-to-end differentiable network representing a dynamical system (e.g., a convolutional, recurrent, or \Name\ network) in order to build the ``one-step-ahead prediction error'' minimized in the popular \emph{Prediction Error Method} (PEM).  Such an application of PEM in deep learning will be referred to as \emph{deepPEM};
  	\item We address the problem of identification from quantized output observations, and present a method
  	that is applicable to end-to-end differentiable model structures (including \Name), by properly changing the likelihood function maximized in training. As  \Name \ represents a
  	generalization of classic \emph{block-oriented} architectures~\cite{giri2010block}, the proposed approach can be applied for {the} identification of block-oriented models from quantized data.
  \end{itemize}

  The linear dynamical operator has been implemented in the  \emph{PyTorch} deep learning framework
   and the software is available for download at  \url{https://github.com/forgi86/sysid-transfer-functions-pytorch}.

The rest of this paper is organized as follows. The linear dynamical operator is described in Section \ref{sec:LTI} and the steps required to integrate it in a deep learning framework are described in Section \ref{sec:layer_DL}. The \emph{deepPEM} algorithm and the problem of identification from quantized data are discussed in Section \ref{sec:pem} and \ref{sec:quantized}, respectively. Finally, two benchmark  examples are presented in Section \ref{sec:examples}.

\section{Dynamical layer} \label{sec:LTI}
The input-output relation of the linear dynamical layer is described by a rational transfer function $G(q)$ as:
	\begin{equation} \label{eqn:filter} %label{eqn:filter}
	y(t) = G(\q) u(t) =  \frac{\B(\q)}{\A(\q)}u(t), %\overbrace{\frac{\B(\q)}{\A(\q)}}^{=G(q)} u(t),
	\end{equation}
	where 	  $u(t) \in \R$ and  $y(t) \in \R$ are the input and output signals of the filter $G(q)$ at time  $t$ {respectively}, 	and
	 $A(q)$ and $B(q)$ are polynomials in the \emph{time delay operator}  $\q^{-1}$ ($q^{-1}u(t)=u(t-1)$), i.e.,
\begin{subequations}
	\begin{align}
	\A(q) &= 1 + \ac_1 \q^{-1} + \dots + \ac_{n_\ac}q^{-n_\ac}, \\
	\B(q) &= \bb_0 + \bb_1 \q^{-1} + \dots + \bb_{n_{\bb}}q^{-n_{\bb}}.
	\end{align}
\end{subequations}

The coefficients   of the polynomials $\A(q)$ and $\B(q)$ are collected in vectors  $\ac = [\ac_1\; \ac_2\dots\;\ac_{n_\ac}] \in \R^{n_\ac}$ and $\bb = [\bb_0\; \bb_1\; \dots \;\bb_{n_\bb}] \in \R^{n_\bb + 1}$. They represent
 the tunable parameters of the filter $G(q)$.

The filtering operation  in \eqref{eqn:filter} has the following  input/output representation:
\begin{equation} \label{eqn:filterA}
\A(\q)y(t) =  \B(\q)u(t),
\end{equation}
which, according to the definitions of $\A(q)$ and $\B(q)$, is equivalent to the linear difference  equation:
\begin{align}
\label{eq:OE_predictor_b}
y(t) = & -\ac_1 y(t\!-\!1) \dots - \ac_{n_\ac} y(t\!-\!n_\ac) + \nonumber \\
& + \bb_0 u(t) + \bb_1 u(t-1) + \dots + \bb_{n_\bb}\!u(t-n_\bb).
\end{align}

 In the following, we assume that the filter $G(\q)$ is always initialized from rest, i.e., $u(t)=0$ and $y(t)=0$ for $t < 0$.

 Let us stack the input and output samples $u(t)$ and $y(t)$ from time $0$ to $\nsamp\!-\!1$ in vectors $\tvec{u} \in \mathbb{R}^{\nsamp}$  and $\tvec{y} \in \mathbb{R}^{\nsamp}$, respectively.\footnote{In the following, the bold-face notation is reserved to real-valued $\nsamp$-length vectors.  For instance, $\tvec{u} \in \R^{\nsamp}$ is a $T$-length vector with entries $\tvec{u}_0, \tvec{u}_1, \dots, \tvec{u}_{\nsamp -1}$.}
 With a slight abuse of notation, the filtering operation in \eqref{eqn:filter} applied to $\tvec{u}$ is denoted as %finite-length sequences is denoted as
 $
 \tvec{y} = G(\q)\tvec{u}$.
 This operation is also equivalent to the convolution
 \begin{equation}
 \label{eq:G_conv}
 \tvec{y}_i =  \sum_{j=\max{(0, i+1-T)}}^{\min(i, T-1)} \tvec{g}_j \tvec{u}_{i-j},\qquad
 i=0,1,\dots,\nsamp\!-\!1,
 \end{equation}
 where $\tvec{g} \in \R^{\nsamp}$ is a vector containing the first $\nsamp$ samples of the  \emph{impulse response} of $G(q)$.

The derivations are presented in the paper for a proper, single-input-single-output (SISO) transfer function to simplify the notation. Note that the software implementation available in the paper's on-line repository
allows setting an arbitraty number of input delays $n_k$, {\emph{i.e.} $\B(q) = \bb_0 \q^{-n_k} + \bb_1 \q^{-n_k-1} +  \dots + \bb_{n_{\bb}}q^{-(n_k-n_{\bb})}$ with $n_k \geq 0$}, and includes support for the multi-input-multi-output (MIMO) case.

\section{Dynamical Layer in Deep Learning}
\label{sec:layer_DL}

In this section, the forward and backward pass operations required to integrate the linear dynamical layer in a deep learning framework are derived. The operator $G(q)$ interpreted as a differentiable block for use in deep learning will be referred to as $G$-block in the rest of the paper.

\subsection{Forward pass}
The forward operations of a $G$-block are represented by solid arrows  in the computational graph sketched in Fig.~\ref{fig:backprop_tf}.
In the {forward pass}, the block filters an input sequence $\tvec{u} \in \mathbb{R}^{\nsamp}$ through a dynamical system $G(\q)$ with  parameters $\ac = [\ac_1\;\dots\;\ac_{n_\ac}]$ and $\bb = [\bb_0\; \bb_1\; \dots \;\bb_{n_\bb}]$. The block output   $\tvec{y} \in \mathbb{R}^{\nsamp}$ contains the filtered sequence:
\begin{equation}
\label{eq:forward_op}
\tvec{y} =  G(\q,b,a) \tvec{u}.
\end{equation}
The input $\tvec{u}$ of the $G$-block  may be either the training input sequence or the result of previous operations in the computational graph, while
the output $\tvec{y}$ is an intermediate step towards the computation of a scalar loss $\loss$. %The exact operations leading to $\loss$ are not relevant in this discussion, and thus they are not further specified.
%, but the exact sequence of computations leading to $\loss$ are not
\begin{figure}%`[b]
	\begin{center}
		\includegraphics[width=140pt]{fig/backprop_tf_ab_circle.pdf}
	\end{center}
	\caption{Forward and backward operations of a $G$-block within a computational graph.}
	\label{fig:backprop_tf}
\end{figure}

When the filtering operation \eqref{eq:forward_op} is implemented through the recurrent equation \eqref{eq:OE_predictor_b}, the computational cost of the forward pass for the  $G$-block corresponds to $\nsamp(n_\bb + n_\ac + 1)$ multiplications. These multiplications  need to be performed sequentially for the $\nsamp$ time samples, but can be parallelized for the $n_\bb$ + $n_\ac + 1$ different coefficients at each time index $t$.
%Note that in a typical implementation alternative expressions are used instead of \eqref{eq:OE_predictor_b} for better numerical stability properties.   For instance, \texttt{scipy.signal.lfilter} implements the \emph{Transposed Direct II form} \cite{oppenheim1999discrete} of the filter. Nevertheless, these same considerations on the computational cost apply for these alternative filter structure.

\subsection{Backward pass}
The backward operations are illustrated in Fig.  \ref{fig:backprop_tf} with dashed arrows.
In the {backward pass}, the $G$-block receives the vector $\adjoint{\tvec{y}} \in \mathbb{R}^{\nsamp}$ with the partial derivatives of the loss $\loss$ w.r.t. $\tvec{y}$, i.e.,
\begin{equation}
\adjoint{\tvec{y}}_t = \pdiff{\loss}{\tvec{y}_t},\quad  t=0,\dots,\nsamp-1,
\end{equation}
and  it has to compute the derivatives of the loss $\loss$ w.r.t. its differentiable inputs  $\bb$, $\ac$, and $\tvec{u}$, i.e.,

%\begin{equation}
%\adjoint{\bb}, \adjoint{\ac}, \adjoint{\tvec{u}} = G.{\rm backward}(\tvec{u}, \bb, \ac, \adjoint{\tvec{y}}),
%\end{equation}
%where
\begin{subequations}
	\begin{align}
	\adjoint{\bb}_j &= \pdiff{\loss}{\bb_j},\qquad j=0,\dots,n_\bb \\
	\adjoint{\ac}_j &= \pdiff{\loss}{\ac_j},\qquad j=1,\dots,n_\ac\\
	\adjoint{\tvec{u}}_\tau &= \pdiff{\loss}{\tvec{u}_\tau},\qquad \tau=0,1,\dots,\nsamp\!-\!1. \label{eq:adjsensu}
	\end{align}
\end{subequations}

%In the following,
\subsubsection{{Derivatives w.r.t} numerator coefficients $\bb$.}

Application of the chain rule leads to:
%For a certain coefficient $\bb_j$, by applying the chain rule we get% $ \adjoint{\bb}_j$ as
%\begin{subequations}
\begin{equation}
\label{eq:backprop_b_first}
\adjoint{\bb}_j = \sum_{t=0}^{\nsamp-1} \pdiff{\loss}{\tvec{y}_t} \pdiff{\tvec{y}_t}{\bb_j} = \sum_{t=0}^{\nsamp-1} \adjoint{\tvec{y}}_t \pdiff{\tvec{y}_t}{b_j}
%=  \sum_{t=0}^{\nsamp-1} \adjoint{\tvec{y}}_t J^{\bb}_{tj}
%= \sum_{t=0}^{\nsamp-1} \adjoint{\tvec{y}}_t \sens{\tvec{\bb}}_{t-j}.
\end{equation}
%\end{subequations}

The  sensitivities  $\sens{\bb}_j(t)  = \pdiff{\tvec{y}_t}{b_j}$, $j=0,1,\dots,n_\bb,$ can be computed through recursive filtering operations~\cite{ljung:1999system}. Specifically,  by differentiating
the left  hand side of Eq. \eqref{eqn:filterA} w.r.t $\bb_j$ we obtain:
\begin{align}  \label{eq:sens_b}
\A(\q) \sens{\bb}_j(t)  = u(t-j),
\end{align}
%\MM{Perhaps better to use $\tvec{u}_{t-j}$ for consistency}
%or equivalently:
%\begin{align}  \label{eq:sens_b2}
%\sens{\bb}_j(t)  = \frac{1}{\A(\q)}u(t-j).
%\end{align}

Thus, $\sens{\bb}_j(t)$ can be computed by filtering the input vector $u(t)$  through the linear filter $ \displaystyle \frac{1}{\A(\q)}$. Furthermore,
\begin{equation}
\label{eq:regime_b2}
\sens{\bb}_{j}(t) = \begin{cases}
\sens{\bb}_0(t-j), \;\;&t-j \geq 0\\
0,           \;\; & t-j < 0.
\end{cases}
\end{equation}
%MF: also a case with zero?
Then,  only $ \sens{\bb}_0(t)$ needs to be recursively simulated through Eq.~\eqref{eq:sens_b}. The  sensitivities $ \sens{\bb}_j(t)$, $j=1,\ldots,n_\bb$, are  computed  through simple shifting operations. % according to \eqref{eq:regime_b2}.

From~\eqref{eq:backprop_b_first} and~\eqref{eq:regime_b2}, the $j$-th component of $\adjoint{\bb}$ is given by:
\begin{equation}
\label{eq:backprop_b_last}
\adjoint{\bb}_j = \sum_{t=j}^{\nsamp-1} \adjoint{\tvec{y}}_t \sens{b}_0(t-j).
\end{equation}
%This operation corresponds to the dot product of $\adjoint{\tvec{y}}$ with shifted version of the sensitivity $b_0(t)$.%vector $\sens{\tvec{\bb}}$.

Overall, the  computation of  $\adjoint{\bb}$ requires to:
\begin{itemize}
	\item filter the input $\tvec{u}$ through $\frac{1}{A(\q)}$, which entails  $\nsamp n_\ac$ multiplications.  Because of the recursive form ~of \eqref{eq:sens_b}, these operations need  to be performed sequentially;
	\item compute
	the $n_{\bb}\!+\!1$ dot products  in \eqref{eq:backprop_b_last}, for a total of  $\nsamp(n_{\bb}\!+\!1)- n_\bb$ multiplications. These operations can be parallelized.
\end{itemize}

\subsubsection{{Derivatives w.r.t} denominator coefficients $\ac$.}
The   sensitivities $\sens{\ac}_j(t) = \pdiff{\tvec{y}_t}{\ac_j}$, $j=1,2,\dots,n_\ac$ are obtained based on the same rationale described above,
by differentiating the terms in  Eq. \eqref{eqn:filterA} with respect to $\ac_j$. This yields:
%\begin{equation*}
%y(t-j) + \A(\q) \pdiff{y(t)}{\ac_j} = 0,
%\end{equation*}
%or equivalently
\begin{equation}
\label{eq:sens_a}
\sens{\ac}_j(t) = -\frac{1}{\A(\q)}y(t-j).
\end{equation}
%\MM{for consistency $\sens{\ac}_j(t) = -\frac{1}{\A(\q)}\tvec{y}_{t-j}.$}
%Then, $\sens{\ac}_j(t)$ can be computed by filtering the output $\tvec{y}$ through the linear filter $-\frac{1}{\A(\q)}$.

The following condition holds:
\begin{equation}
\label{eq:regime_a2}
\sens{\ac}_{j}(t) = \begin{cases}
\sens{\ac}_1(t-j+1), \;\;&t-j+1 \geq 0\\
0,           \;\; & t-j+1 < 0
\end{cases}
\end{equation}
and the $j$-th component of $\adjoint{\ac}$ is given by: %$\adjoint$_j
\begin{equation} \label{eqn:abar}
\adjoint{\ac}_j = \sum_{t=j-1}^{\nsamp-1} \adjoint{\tvec{y}}_t \sens{a}_1(t-j+1).
\end{equation}

The back-propagation for the  coefficients $a$ thus requires: ($i$) the  filtering operation \eqref{eq:sens_a}, which involves  $\nsamp n_\ac$ multiplications; and ($ii$)
the $n_\ac$ dot products defined in \eqref{eqn:abar}, for a total of $\nsamp n_\ac - n_\ac + 1$ multiplications.
%Note that we do not consider here the cost of computing $\tvec{y}$ as this operation is already performed during the forward pass.
%In a practical implementation, the vector $\tvec{y}$ computed in the forward pass is indeed stored and then re-used during the backward operation.

\subsubsection{Derivatives w.r.t. input time series  $\tvec{u}$.}
In order to compute the partial derivatives $\pdiff{\loss}{\tvec{u}_\tau} $ the  chain rule is applied, which yields:
\begin{equation}
\label{eq:chainrule_u}
\adjoint{\tvec{u}}_\tau = \pdiff{\loss}{\tvec{u}_\tau}
= \sum_{t=0}^{\nsamp-1}{\pdiff{\loss}{\tvec{y}_t} \pdiff{\tvec{y}_t}{\tvec{u}_\tau}}
= \sum_{t=0}^{\nsamp-1}{\adjoint{\tvec{y}}_t \pdiff{\tvec{y}_t}{\tvec{u}_\tau}}
\end{equation}
From \eqref{eq:G_conv}, the term $\pdiff{\tvec{y}_t}{\tvec{u}_\tau}$ is given by:
\begin{equation} \label{eqn:dydu}
\pdiff{\tvec{y}_t}{\tvec{u}_\tau} = \begin{cases}
\tvec{g}_{t-\tau},\;\; &t-\tau \geq 0\\
0, \; & t-\tau < 0.
\end{cases}
\end{equation}
By substituting Eq.~\eqref{eqn:dydu} into \eqref{eq:chainrule_u}, we obtain
\begin{equation} \label{eq:backprop_u_corr2}
\adjoint{\tvec{u}}_\tau =
\sum_{t=\tau}^{\nsamp-1}\adjoint{\tvec{y}}_t
\tvec{g}_{t-\tau}
\end{equation}

%Note that the above   expression  corresponds to the   cross-correlation operation:
%\begin{equation}
%\label{eq:backprop_u_corr}
%\adjoint{\tvec{u}}_\tau = (\tvec{g}  \ccorr \tvec{\adjoint y})_\tau,\qquad \tau=0,1,\dots \nsamp-1.
%\end{equation}
Direct implementation of the cross-correlation~\eqref{eq:backprop_u_corr2} requires a number of operations which grows \emph{quadratically} with   $\nsamp$.
A more efficient solution is obtained by observing:
\begin{align*}
& \adjoint{\tvec{u}}_0 = \sum_{t=0}^{\nsamp-1} \adjoint{\tvec{y}}_t \tvec{g}_t, \ \  \ \
\adjoint{\tvec{u}}_1 = \sum_{t=1}^{\nsamp-1} \adjoint{\tvec{y}}_t \tvec{g}_{t-1}, \ \ \ \
\adjoint{\tvec{u}}_2 = \sum_{t=2}^{\nsamp-1} \adjoint{\tvec{y}}_t \tvec{g}_{t-2}, \\
&\dots, \ \ \ \  \adjoint{\tvec{u}}_{\nsamp-2} = \adjoint{\tvec{y}}_{\nsamp-2} \tvec{g}_0 + \adjoint{\tvec{y}}_{\nsamp-1}\tvec{g}_1, \ \ \ \ \
\adjoint{\tvec{u}}_{\nsamp-1} = \adjoint{\tvec{y}}_{\nsamp-1} \tvec{g}_{0}.
\end{align*}

Since $\tvec{g}$ represents the impulse response of  $G(q)$, the vector $\adjoint{\tvec{u}}$ can be obtained  by filtering the vector $\adjoint{\tvec{y}}$ in reverse time through $G(q)$, and then reversing the result, i.e.,
\begin{equation}
\label{eq:backprop_u_filt}
{\adjoint{\tvec{u}}} = \textrm{flip}\big(G(q)\textrm{flip}(\adjoint{\tvec{y}})\big),
\end{equation}
where $\textrm{flip}(\cdot)$ denotes the time reversal operator applied to a $\nsamp$-length vector, defined as
\begin{equation}
\left(\textrm{flip}(\tvec{x})\right)_t = \tvec{x}_{\nsamp-t-1},\qquad t=0,1,\dots,\nsamp-1.
\end{equation}

Eq.~\eqref{eq:backprop_u_filt} represents the filtering of a $\nsamp$-length vector through $G(\q)$, whose  complexity grows  linearly with  $\nsamp$.

\section{Applications in system identification}

\subsection{deepPEM}
\label{sec:pem}
%Bringing PEM into the deep-learning framework, for identification of dynamical systems
As a first application of the differentiable LTI layer discussed in the previous section, we  integrate PEM in a deep learning context. To this aim, let us consider the data-generating system   which provides the output $y$ at time $t$ according to the equation:
%\begin{
\begin{align}
\label{eq:truesys_PEM}
y(t) = \mathcal{S}(U_t) + \overbrace{H_{\rm o}(q) e(t)}^{=v(t)},
\end{align}
where $\mathcal{S}(\cdot)$ is the deterministic causal component processing the entire past input sequence $U_t$ up to time $t$, and $v(t)$ is an additive
colored noise source obtained by filtering a white noise $e(t)$ through a stable linear filter
$H_{\rm o}$. According to the PEM framework~\cite[Ch. 2.3]{ljung:1999system}, we assume that $H_{\rm o}$ is monic  and minimum phase.

%Specifically, we show  how the differentiable LTI dynamic layer can be used to compute the ``optimal predictor''   in PEM.

%we add the differentiable dynamical unit  as a last layer of an end-to-end differentiable block (e.g., standard feed-forward networks, recurrent networks or \Name s) in order to build the ``optimal predictor'' used by the popular \emph{Prediction Error Method} (PEM).  Such an application of PEM in the deep-learning framework will be referred to as \emph{deepPEM};

Let us now consider a model structure
\begin{align}
\label{eq:model_PEM}
y(t) = \mathcal{M}(U_t, \theta_\mathcal{M}) + H(q, \theta_H) e(t),
\end{align}
where $\mathcal{M}(U_t,\theta_{\mathcal{M}})$ is a deterministic causal component (described by the parameter vector $\theta_{\mathcal{M}}$) modeling the deterministic component  $\mathcal{S}(U_t)$ in~\eqref{eq:truesys_PEM}
and $H(q, \theta_H)$ is a transfer function with parameters $\theta_H = [a_H \ b_H]$. We denote with $\theta = [\theta_{\mathcal{M}} \ \theta_{H}]$ the vector containing all the unknown parameters in~\eqref{eq:model_PEM}.

As known (see ~\cite[Ch. 2.3]{ljung:1999system}), the optimal \emph{one-step-ahead predictor} for  \eqref{eq:model_PEM} at time $t$, given input and output data up to time $t-1$, is given by
\begin{equation} \label{eqn:y_pred}
\hat y(t|t-1) = H^{-1}(q, \theta_H) \mathcal{M}(U_t, \theta_\mathcal{M}) + [1\!-\!H^{-1}(q, \theta_H)]y(t).
\end{equation}
%where $Y_t$ is the past output sequence up to time $t$
{Note that the output predictor in~\eqref{eqn:y_pred}  only depends on outputs up to time $t-1$ since $\!H^{-1}(q, \theta_H)$ is monic.}
%and output up to time $t-1$ since $\mathcal{M}(U_t; \theta_\mathcal{M})$ is strictly casual and $\!H^{-1}(q; \theta_H)$ is monic.}.
The  \emph{prediction error}  $\varepsilon(t) = y(t) - \hat y(t|t-1)$ is then given by
\begin{equation}
\varepsilon(t, \theta) = H^{-1}(q, \theta_H)(y(t) - \mathcal{M}(U_t, \theta_\mathcal{M})).
\end{equation}
According to the Prediction Error Minimization (PEM) criterion, we consider the loss function:
\begin{equation}
\label{eq:loss_PEM}
\mathcal{L}(\theta) = \frac{1}{\nsamp} \sum_{t=0}^{\nsamp -1} \ell(\bm{\varepsilon}_t(\theta)),
\end{equation}
where $\bm{\varepsilon} \in \mathbb{R}^\nsamp$ is the  vector stacking the prediction error $\varepsilon$ from time $0$ up to  $\nsamp - 1$, and
 $\ell(\cdot)$ is a scalar-valued function (e.g., $\ell(\bm{\varepsilon}_t(\theta))=\bm{\varepsilon}^2_t(\theta)$).

The differentiable transfer function discussed in this paper enables easy implementation of the PEM
framework for models where the deterministic component $\mathcal{M}(\cdot,\theta_\mathcal{M})$ is   compatible with back-propagation. For instance, $\mathcal{M}(\cdot,\theta_\mathcal{M})$ could be a RNN, a 1-D CNN, or a \Name.

The corresponding computational graph for \emph{deepPEM} is outlined in Fig. \ref{fig:neural_PEM}. Note that the monic transfer function $H^{-1}(q, \theta)$ is constructed as $$H^{-1}(q, \theta_H) = 1 + \check{H}(q, \theta_H),$$
where $\check{H}(q, \theta_H)$ is a strictly proper transfer function implemented as
a $G$-block with one input delay ($n_k\!=\!1$).
This makes the estimated $H^{-1}(q, \theta_H)$ monic by construction.

\begin{figure}
	\centering
	\includegraphics[width=.45\textwidth]{fig/neural_PEM.pdf} \vspace{-0.1cm}
	% neural_PEM.pdf: 0x0 px, 300dpi, 0.00x0.00 cm, bb=
	\caption{\emph{deepPEM}: block diagram representing the computation of the one-step-ahead prediction error.}
	\label{fig:neural_PEM}
\end{figure}

\subsection{Learning from quantized observations}
\label{sec:quantized}
As a second application, we consider the problem of learning dynamical systems from \emph{quantized} output measurements. Specifically, we assume that at each time $t$ we observe a quantized output $\tvec{\vv}_t \in \{0,1,\ldots,K\!-\!1\}$. The integer $K$ represents the number of quantization intervals and $\tvec{\vv}_t$ is given by
\begin{subequations}
\begin{align}
\label{datagen_quant}
 \tvec{\vv}_t &= Q(\tvec{y}_t + \tvec{e}_t),
\end{align}
\end{subequations}
where $\tvec{y}_t$ is the latent non-quantized output of the underlying data generating system, $\tvec{e}_t$ is a zero-mean white Gaussian noise with (unknown) standard deviation $\sigma_e$, and
 $Q(\cdot)$ is the quantizing operator, defined as
\begin{equation}
 Q(x) = m \;\; \text{if}\;\; x \in (q_m, q_{m+1}],
\end{equation}
with  $(q_m, q_{m+1}]$ denoting  the $m$-th quantization interval.

Let us consider a simulation model $\mathcal{M}(\cdot, \theta_\mathcal{M})$ parametrized by a vector $\theta_\mathcal{M}$ which provides an output   $\tvec{y}^{\simul}_t$  when fed with an input sequence $U_t$, i.e.,  $\tvec{y}^{\simul}_t = \mathcal{M}(U_t, \theta_\mathcal{M})$.

Because of the conditional independence of the observed outputs $\tvec{\vv}_t$ given the non-quantized output
$\tvec{y}_t$, the log-likelihood function of the parameters $\theta = [\theta_\mathcal{M}\ \sigma_e]$ is: %given by
\begin{align}
\label{eq:likelihood_quant}
\mathcal{L}(\theta) =  &  \sum_{t=0}^{T-1} \log \left[  p( Q(\tvec{y}^{\simul}_t + \tvec{e}_t) = \tvec{\vv}_t  )  \right] \nonumber  \\
 =  &  \sum_{t=0}^{T-1} \log \left[ p( q_{\tvec{\vv}_t} <  \tvec{y}^{\simul}_t +  \tvec{e}_t \leq q_{\tvec{\vv}_{t+1}} )  \right] \nonumber \\
=  & \sum_{t=0}^{T-1} \underset{\mathcal{L}_t(\theta)} {\underbrace{\log \left[ \Phi\left(\frac{ q_{\tvec{\vv}_{t+1}}-\tvec{y}^{\simul}_t}{\sigma_e} \right)
\!-\! \Phi\left(\frac{ q_{\tvec{\vv}_t}\!-\!\tvec{y}^{\simul}_t}{\sigma_e} \right) \right]}},
\end{align}
where $\Phi$ is the cumulative density function of the Normal distribution, i.e.,
$\Phi(x) = \int_{w=-\infty}^x \mathcal{N}(w; 0, 1) dw$.

%Let us consider a simulation model $\mathcal{M}(\cdot;\; \theta)$ of the system dynamics $\mathcal{S}$. Overall, we assume the following model structure for the data-generating system:
%\begin{subequations}
%\label{eq:model_struct_quant}
%\begin{align}
%y_k &= \mathcal{M}(U_k;\;\theta_\mathcal{M})\\
% v_k &= Q(y_k + e_k),
%\end{align}
%\end{subequations}
%with parameters $\theta^\top = [\theta_\mathcal{M}^\top\; \sigma_e^\top]$.
%
%The log-likelihood $\mathcal{L}(\theta)$ of the quantized observations for the model structure \eqref{eq:model_struct_quant} is given by
%\begin{multline}
%\label{eq:likelihood_quant}
%\mathcal{L}(\theta) \!=\! \sum_{k=1}^N \log \left[ \Phi\left(\frac{ q_{v_{k+1}}-y^{\simul}_k}{\sigma_e} \right)
%\!-\! \Phi\left(\frac{ q_{v_k}\!-\!y^{\simul}_k}{\sigma_e} \right) \right],
%\end{multline}
%where $y^{\simul}_k = \mathcal{M}(U_k; \theta_\mathcal{M})$ is the model output at time $k$ and  $\Phi(\cdot)$ is the cumulative density function of the Normal distribution.

The log-likelihood \eqref{eq:likelihood_quant} may be readily implemented in
current deep learning software frameworks using standard differentiable blocks. The block diagram corresponding to the log-likelihood $\mathcal{L}_t(\theta)$ of a single quantized observation $\tvec{\vv}_t$ is sketched in  Fig.~\ref{fig:quantized}. The model   $\mathcal{M}(\cdot, \theta_{\mathcal{M}})$ can be a \Name\ network, which allows us to train   block-oriented models  (constituted by trainable $G$-blocks followed by static nonlinearities)
from quantized output  observations.

%
% Fig.~\ref{fig:quantized} is a graphical representation of the
%corresponding computational graph. %, any dynamical model $\mathcal{M}$ may be tra.
%In particular, $\mathcal{M}(\theta)$ can be a \Name\ network, we are able to train classic block-oriented models
%in presence of quantized observations.
%%, which in turn is able to describe classic block-oriented models...

 \begin{figure}
 \centering
 \includegraphics[width=.4\textwidth]{fig/dynonet_quant.pdf}\vspace{-0.0cm}
 % dynonet_quant.pdf: 0x0 px, 300dpi, 0.00x0.00 cm, bb=
 \caption{Learning from quantized data: block diagram representing the computation of the log-likelihood $\mathcal{L}_t(\theta)$~\eqref{eq:likelihood_quant}  of the quantized output sample $\tvec{\vv}_t$.}
 \label{fig:quantized}
\end{figure}

\section{Examples}
\label{sec:examples}
The effectiveness of the proposed methodologies is evaluated on benchmark datasets for system identification  available at the website \url{www.nonlinearbenchmark.org}. We present, in particular, results based on the Wiener-Hammerstein (WH) and the parallel Wiener-Hammerstein (PWH)   benchmarks described in  \cite{ljung2009wiener} and \cite{schoukens2015parametric}, respectively.
The original training datasets of the two benchmarks are modified to make the identification problem  more challenging and to highlight flexibility of the presented methodologies   in handling non-standard learning problems. For the WH benchmark, we perturb the output with an additive colored noise and adopt the \emph{deepPEM} method described in Section \ref{sec:pem} to   estimate the WH model parameters and the power spectrum of the noise.  For the PWH benchmark,  we consider the case of quantized output measurements and estimate the model parameter by maximizing the log-likelihood \eqref{eq:likelihood_quant}. %, as discussed in Section \ref{sec:quantized}.

We use \Name\ networks to describe the deterministic system component in the two benchmarks, with
an obvious choice of the network architectures reflecting the block-oriented structures of the  PWH and WH systems.

All computations are carried out on a PC equipped with an AMD Ryzen 5 1600x processor and 32 GB of RAM.
 The codes required to reproduce the results   are available in the GitHub repository \url{https://github.com/forgi86/sysid-transfer-functions-pytorch.git}.  The   reader is referred to~\cite{forgione2021dynonet} for further examples showing the effectiveness of \Name.

\subsection{Training settings and metrics}
The Adam algorithm \cite{kingma2014adam} is used for gradient-based optimization. The number $n$ of iterations  is chosen sufficiently large to reach a cost function plateau. The learning rate $\lambda$ is adjusted by a rough trial and error. All static non-linearities   are modeled as feed-forward Neural Networks with a single hidden layer containing 10 neurons and hyperbolic tangent activation function. %The numerator and denominator coefficients of the $G$-blocks are randomly initialized from a uniform distribution with zero mean and range $[-0.01\ \  0.01]$, while the feed-forward neural network parameters are initialized according to PyTorch's default strategy.

% Note that several settings are kept constant across the benchmarks to highlight that limited tuning is needed to obtain state-of-the art identification results using the proposed \Name\ architecture.

The $\mathrm{fit}$ index and the Root Mean Square Error (RMSE) are used to assess the quality of the identified models:
\begin{footnotesize}
	\begin{align*}
 \mathrm{fit} &= 100\cdot \left(1- \frac{\sqrt{\sum_{t=0}^{\nsamp-1} \left(\tvec{y}_t - \tvec{y}^{\simul}_t\right)^2} }
{\sqrt{\sum_{t=0}^{\nsamp-1} \left(\tvec{y}_t -  {\overline{{\tvec{y}}}}\right)^2}}\right) (\%),
\\
\mathrm{RMSE} &= \sqrt{\frac{1}{\nsamp} \sum_{t=0}^{\nsamp-1} \left(\tvec{y}_t - \tvec{y}^{\simul}_t\right)^2},
\end{align*}
\end{footnotesize}
where $\tvec{y}^{\simul}_t$ is the open-loop simulated output of the estimated  model
and $\overline{\tvec{y}}$ is the average   of the measured output sequence.  Both the $\mathrm{fit}$ and the RMSE indexes   are measured  on the benchmarks' original test data.
%(thus, $\tvec{y}^{\rm meas}$ corresponds here to the non-quantized measurements and without introducing additional noise on the test datset).

\subsection{WH with colored noise}

The experimental setup used in this benchmark is an electronic circuit described in \cite{ljung2009wiener} that behaves as a Wiener-Hammerstein system. Therefore, a simple \Name\ architecture corresponding to the WH model structure is adopted. Specifically, the \Name\ model used has a sequential structure defined by a SISO $G$-block with $n_a = n_b = 8, n_k=1$; a SISO feed-forward neural network; and a final SISO $G$-block with $n_a = n_b = 8, n_k=0$.

The original training dataset is modified by adding to the measured output
a colored noise $v$ with standard deviation $0.1$ obtained by filtering a white noise $e$ through the transfer function
$H_{\rm o}(\q) = \frac{1 - 1.568\q^{-1} + 0.902\q^{-2}}{1 - 1.901 \q^{-1} + 0.9409\q^{-2}}$.

In order to jointly estimate the system and the noise disturbance, the \emph{deepPEM} approach presented in Section
\ref{sec:pem} is applied.
 The model is trained over $n=40000$ iterations of the Adam algorithm with learning rate $\lambda=10^{-4}$ on the whole training dataset ($\nsamp=100000$ samples). The total training time is 267 seconds.

% by minimizing the one-step-ahead prediction loss \eqref{eq:loss_PEM} with  $\ell(\varepsilon(t,\theta)) = \varepsilon(t,\theta)^2$ on the whole training dataset ($\nsamp=100000$ samples). The total training time is 267 seconds.

On the test dataset ($\nsamp=87000$ samples), the performance of the identified \Name \ model    are $\rm fit\!=\!96.9\%$ and $\rm{RMSE}\!=\!7.5$~mV.
The measured output $\tvec{y}$ and simulated output $\tvec{y}^{\simul}$ on the test dataset are shown in Fig~\ref{fig:WH_timetrace}, together with the simulation error $\tvec{e} = \tvec{y}\! -\! \hat{\tvec{y}}$.\footnote{
For the sake of visualization,   a portion of the test data is shown.}
The magnitude Bode plot of the noise filter $H_{\rm o}(q)$ and of the identified $H(q,  \theta_H)$ are reported in Fig.~\ref{fig:WH_H}. The obtained results  show the capabilities of the \emph{deepPEM} in accurately reconstructing the system's output and the noise spectrum.
%While specialized training algorithms for WH systems may provide even superior results on this benchmark
%(the best published result \cite{schoukens2014identification} reports $\mathrm{RMSE}=0.28$~mV), the
%\Name\ model trained by plain back-propagation achieves remarkably good performance.

\begin{figure}
	\centering
	\includegraphics[width=.7\textwidth]{fig/WH_timetrace_zoom.pdf} \vspace{-0.55cm}
	% WH_timetrace.pdf: 0x0 px, 300dpi, 0.00x0.00 cm, bb=
	\caption{WH benchmark: measured output $\tvec{y}$ (black), simulated output $\tvec{y}^{\simul}$ (blue), and simulation error $\tvec{e}\! =\! \tvec{y}\! -\! \tvec{y}^{\simul}$ (red) on the  test dataset.
%\MM{Legend is  overlapping with the plot. Perhaps a smaller linewidth for plots will make the figure more clear.}
}
	\label{fig:WH_timetrace}
\end{figure}

\begin{figure}
	\centering
	\includegraphics[width=.8\textwidth]{fig/WH_H.pdf} \vspace{-0.4cm}
	% WH_H.pdf: 0x0 px, 300dpi, 0.00x0.00 cm, bb=
	\caption{WH benchmark: Magnitude Bode plot of the filter $H_{\rm o}(q)$ and of the estimated filter $H(q,\theta_H)$.}
	\label{fig:WH_H}
\end{figure}

\subsection{PWH with quantized observations}
The experimental setup used in the second benchmark is an electronic circuit with a two-branch parallel Wiener-Hammerstein
structure described in \cite{schoukens2015parametric}. %The non-linearities on the two branches are realized as two independent diode-resistor networks.
The original training dataset of the PWH benchmark  consists in 100 input/output training sequences, each one containing $N=16384$ samples.
The 100 training sequences
are obtained by exciting the system with random-phase multisine input signals at 5 different \emph{rms} levels: $\{100, 325, 550, 775, 1000\}$~mV, for 20 different realizations of the random phases.
In this paper, we modify the original training dataset by discretizing the measured output voltage in
$12$ equally spaced bins in the range $[-1 \ \  1]~V$. It is worth pointing out that in the benchmark datasets associated to \emph{rms} levels equal to $100$~mV and $325$~mV, the chosen quantization intervals lead to quantized outputs that only take $2$ different values.

As a simulation model $\mathcal{M}(\cdot,\theta_\mathcal{M})$ (see Fig.~\ref{fig:quantized}) we use a sequential \Name\ network corresponding to the PWH structure and  constructed as the cascade connection of: a one-input-two-output $G$-block; two independent one-input-one-output feed-forward neural networks; and a two-input-one-output $G$-blocks. The $G$-blocks are characterized by $n_a=12$, $n_b=12$, and $n_k=1$.

We train the \Name\ network by maximizing the log-likelihood $\mathcal{L}(\theta)$ (Eq. \eqref{eq:likelihood_quant}) on the whole training dataset over $n=4000$ iterations with learning rate $\lambda=10^{-3}$.
In the benchmark, 6 test datasets are provided. In the first 5 test datasets, the input signals are random-phase multisine at the same \emph{rms} levels considered in training (but with independent phase realizations), while in the latter the input signal is filtered Gaussian noise with an envelope that grows linearly over time.
On the 6 test datasets, the model achieves $\rm fit$ index $\{91.1,93.5,94.1,94.1,93.3,91.9\}\%$ and RMSE
$\{3.65,8.20,12.02,16.04,22.06,21.37\}$~mV.  Time traces of the measured and simulated \Name\ output on the growing envelope test dataset are shown in Fig.~\ref{fig:PWH_timetrace}.

\begin{figure}
 \centering
 \includegraphics[width=.8\textwidth]{fig/PWH_timetrace.pdf} \vspace{-0.5cm}
 \caption{PWH benchmark: measured output $\tvec{y}$ (black),  simulated output $\tvec{y}^{\simul}$ (blue), and simulation error $\tvec{e}\! =\! \tvec{y}\! -\! \tvec{y}^{\simul}$ (red) on the growing envelope test dataset.}
 \label{fig:PWH_timetrace}
\end{figure}

\section{Conclusions}
We have described  the operations required to make the linear time-invariant transfer functions fully compatible with the back-propagation algorithm.
This enables training of structured models combining transfer functions with other differentiable operators (such as deep neural networks) using standard deep learning software.
%Moreover,  \emph{dynoNet}   allows us to train dynamical models without using back-propagation through time.

Furthermore, we have illustrated two  applications of the back-propagation-compatible linear dynamical block in system identification, namely the extension of the prediction error method to non-linear neural models in the presence of additive colored noise and the estimation of block-oriented models from quantized output observations.

Current  research is devoted to the analysis of neural model structures containing transfer functions through  linear system theory, to applications of these networks in other domains such as state estimation and time series classification, and to the extension of the $G$-block to the case of linear dynamics with parameter-varying coefficients.

\section*{Acknowledgments}
This work was partially supported by the European H2020-CS2 project ADMITTED, Grant agreement no. GA832003.

\bibliographystyle{plain}
\bibliography{ms}             % bib file to produce the bibliography
\end{document}


% declare document class and geometry
\documentclass[12pt]{article} % use larger type; default would be 10pt
\usepackage[margin=1in]{geometry} % handle page geometry

\input{../header2.tex}

\title{Phys 220A -- Classical Mechanics -- Lec16}
\author{UCLA, Fall 2014}
\date{\formatdate{4}{12}{2014}} % Activate to display a given date or no date (if empty),
         % otherwise the current date is printed

\begin{document}
\setlength{\unitlength}{1mm}
\maketitle

\section{More relativity}

\subsection{More on Maxwell's equations}

Let's go through the stuff on Maxwell's equations from last time again, more carefully this time. Recall that we defined the 4-potential
\begin{eqn}
A^\mu = (\phi / c, \v A).
\end{eqn}
We define the electromagnetic tensor
\begin{eqn}
F_{\mu\nu} = \partial_\mu A_\nu - \partial_\nu A_\mu,
\end{eqn}
where we have lowered all the indices since the coordinate derivatives naturally have lower indices
\begin{eqn}
\partial_\mu = \pd{}{{x^\mu}}.
\end{eqn}
This in fact gives us a $4 \times 4$ matrix of components of the $\v E$ and $\v B$ fields,
\begin{eqn}
F_{\mu\nu} =
\begin{pmatrix}
0 & -E_1 / c & -E_2 / c & -E_3 / c \\
E_1 / c & 0 & B_3 & -B_2 \\
E_2 / c & -B_3 & 0 & B_1 \\
E_3 / c & B_2 & -B_1 & 0
\end{pmatrix}.
\end{eqn}

It turns out that using this tensor we can rewrite the sourced half of Maxwell's equations as
\begin{eqn}
\partial_\mu F^{\mu \nu} = - J^\nu
\end{eqn}
where $J^\mu = (\rho_e / c, \v J)$. Working it out explicitly, we find that this set of equations is equivalent to
\begin{eqn}
\v \nabla \cdot \v E = \rho_e
\end{eqn}
for $\nu = 0$ and
\begin{eqn}
\frac{1}{c^2} \partial_0 E_i - (\v \nabla \times \v B)_i = J_i
\end{eqn}
for $\nu = i = 1,2,3$. Furthermore, we can rewrite the other half of Maxwell's equations as
\begin{eqn}
\epsilon^{\mu\nu\rho\lambda} \partial_\nu F_{\rho\lambda} = 0
\end{eqn}
where $\epsilon^{\mu\nu\rho\lambda}$ is the 4-dimensional antisymmetric tensor with
\begin{eqn}
\epsilon^{0123} = -\epsilon_{0123} = +1
\end{eqn}
by convention. This tensor equation is equivalent to
\begin{eqn}
\v \nabla \cdot \v B = 0
\end{eqn}
for $\mu = 0$ and
\begin{eqn}
\partial_0 \v B + \v \nabla \times \v E = 0
\end{eqn}
for $\mu = i = 1,2,3$.

\subsection{Classical field theory}

Where before we thought of electromagnetism and electrodynamics in terms of the individual fields $\v E$ and $\v B$ and Maxwell's equations, we now have a set of \emph{field equations} in terms of the field $F_{\mu\nu}$ as determined by the potential $A^\mu$. This leads us to a nice segue into field theory.

In particulate classical mechanics we have dynamical variables $q_i(t)$; on the other hand, in field theory our dynamical variables will instead be \emph{fields} $\phi(x^\nu)$ which are functions over all of spacetime, for example the 4-potential $A_\mu (x^\nu)$. We would then use the Euler-Lagrange equations in terms of a \emph{Lagrangian density} depending on the fields at each point $x^\mu$,
\begin{eqn}
L(q, \dot q, t) \rightarrow \Lag(\phi(x), \partial_\mu \phi(x), t)
\end{eqn}
while the action becomes an integral over spacetime
\begin{eqn}
S = \int \dif{t} \, L(q, \dot q, t) \rightarrow
	\int \underbrace{\dif t \, \dif^3 x}_{\dif^4 x} \, \Lag(\phi, \partial_\mu \phi, t)
\end{eqn}

But why don't we have terms in the Lagrangian depending on multiple points? Suppose we have another term in the Lagrangian depending on two points
\begin{eqn}
\Lag' (\phi(x_1), \phi(x_2), \dots).
\end{eqn}
Then the action would involve a term
\begin{eqn}
\int \dif t \int \dif^3 x_1 \int \dif^3 x_2 \Lag' (\phi(x_1), \phi(x_2), \dots)
\end{eqn}
but we could then define
\begin{eqn}
\Lag''(x_1) = \int \dif^3 x_2 \Lag' (\phi(x_1), \phi(x_2), \dots)
\end{eqn}
which is now a nonlocal Lagrangian. Since physics should generally be determined locally at small scales, we just won't have nonlocal terms like this. The Lagrangian density is purely a \emph{local} function on spacetime.

So now we define the action by
\begin{eqn}
S[\phi] = \int \dif^4 x \, \Lag(\phi, \partial_\mu \phi, t).
\end{eqn}
From Hamilton's principle, we have
\begin{align}
0 = \delta S &= \int \dif^4{x} \cbr{ \pd{\Lag}{\phi} \delta \phi + \pd{\Lag}{(\partial_\mu \phi)} \partial_\mu \delta \phi } \\
	&= \int \dif^4{x} \cbr{ \pd{\Lag}{\phi} \delta \phi - \partial_\mu \pd{\Lag}{(\partial_\mu \phi)} } \delta \phi \\
		&\quad + \eval{ \int \dif^3 x \, \pd{\Lag}{(\partial_t \phi)} \delta \phi }_{t=ti}^{t=t_f}
		+ \eval{ \int \dif x^2 \, \dif x^3 \, \pd{\Lag}{(\partial_{x_1} \phi)} \delta \phi }_{x_1 = x_1^\mathrm{min}}^{x_1 = x_1^\mathrm{max}}
		+ \dots
\end{align}
where we include all the boundary terms. Assuming the boundary conditions are satisfied, this gives us the Euler-Lagrange equations for fields,
\begin{eqn}
0 = \pd{\Lag}{\phi} - \partial_\mu \pd{\Lag}{(\partial_\mu \phi)}.
\end{eqn}
The boundary conditions of course impose the requirement that the variations in the field must vanish on the spacetime boundaries $\partial t$ and $\partial \v x$,
\begin{eqn}
\eval{\delta \phi}_{\partial t} = \eval{\delta \phi}_{\partial \v x} = 0.
\end{eqn}
What about momentum? We define the momentum $\Pi$ conjugate to the field $\phi$ as
\begin{eqn}
\Pi_\mu = \pd{\Lag}{\dot \phi},
\end{eqn}
as usual.

\begin{example}[Klein-Gordon equation]
One primary example of a relativistically-invariant action is that defined by the Lagrangian
\begin{eqn}
\Lag = -\frac{1}{2} \partial_\mu \phi \partial^\mu \phi - \frac{1}{2} m^2 c^2 \phi^2.
\end{eqn}
In this example the Lagrangian density is now a Lorentz \emph{scalar}---it is invariant under boosts. This action gives us field equations (from the EL equations)
\begin{eqn}
0 = \partial_\mu \partial^\mu \phi - m^2 c^2 \phi.
\end{eqn}
\end{example}

\begin{example}[Maxwell's equations]
How could we apply this approach to the Maxwell field $F_{\mu\nu}$? Consider the action
\begin{eqn}
S = \int \dif^4 x \left( - \frac{1}{4} F_{\mu\nu} F^{\mu\nu} + A_\mu j^\mu \right),
\end{eqn}
for which we find that the variation becomes
\begin{align}
\delta S &= \int \dif^4 x \left( -\frac{1}{2} F^{\mu\nu} \delta F_{\mu\nu} + \delta A_\mu j^\mu \right) \\
	&= \int \dif^4 x \left( -F^{\mu\nu} \partial_\mu \delta A_\nu + \delta A_\nu J^\nu \right) \\
	&= \int \dif^4 x \left( \partial_\mu F^{\mu\nu} + J^\nu \right) \delta A_\nu + (\text{bdry. terms}).
\end{align}
So we have derived the sourced Maxwell's equations from this field action!

But this only gives us the two sourced equations. What about the other two equations? Actually if we write the other two equations in the form from before we find that
\begin{eqn}
0 = \epsilon^{\mu\nu\rho\lambda} \partial_\nu F_{\rho\lambda} = \epsilon^{\mu\nu\rho\lambda} \partial_\nu (\partial_\rho A_\lambda - \partial_\lambda A_\rho)
\end{eqn}
is automatically satisfied by antisymmetry of the terms $F_{\rho\lambda}$ being summed over the permutation tensor. This is of course completely trivial in flat space; in curved spaces it is slightly less obvious but it still holds naturally without adding terms to the Lagrangian.
\end{example}

\subsection{Lorentz-invariant quantities, momentum, and energy}

Suppose we have a particle traveling through spacetime with trajectory $\v x(t)$ in some inertial frame. We define the \emph{proper time} of the particle as the Lorentz-invariant quantity
\begin{eqn}
\dif \tau^2 = - \eta_{\mu\nu} \dif x^\mu \dif x^\nu = -\dif x^\mu \dif x_\mu.
\end{eqn}
It's called the proper time of course because it's Lorentz-invariant but also because if the particle is at rest we have $\dif \tau^2 = \dif t^2$.

This suggests a definition for a Lorentz-invariant \emph{4-velocity}
\begin{eqn}
u^\mu = \od{x^\mu}{\tau}, \qquad
u^\mu u_\mu = - \eta_{\mu\nu} \od{x^\mu}{\tau} \od{x^\nu}{\tau} = -c^2.
\end{eqn}
Furthermore, we find that
\begin{eqn}
\dif \tau^2 = \dif t^2 (1 - \v v^2 / c^2)
\end{eqn}
so that we have
\begin{eqn}
u^\mu = (\gamma c, \gamma \v v), \qquad
\gamma = (1 - \v v^2 / c^2)^{1/2}.
\end{eqn}
Furthermore, we can define the \emph{4-momentum} as
\begin{eqn}
p^\mu = m u^\mu
\end{eqn}
for which we find
\begin{align}
p^0 = \gamma m c &= mc \left( 1 + \frac{1}{2} v^2 / c^2 + \bigO((v^2 / c^2)^2) \right) \\
	&= mc + (1/c) T_\mathrm{Newton} + \bigO((v^2 / c^2)^2).
\end{align}
and similarly for $\v p$. Thus we identify the 0th component of the 4-momentum as the energy $E/c$ so that we have the famous equation
\begin{eqn}
E^2 = (mc^2)^2 + (c \v p)^2.
\end{eqn}
And of course we can generalize all this to quantum mechanics, which leads us to quantum field theory. But this generalization is highly nontrivial and we don't go into it here, because this is classical mechanics.

\subsection{Final remarks}

What is the action in special relativity? We have a readily available Lorentz scalar available, so we suppose
\begin{eqn}
S = -mc^2 \int \dif \tau = -mc^2 \dif t \sqrt{1 - \vd x^2 / c^2}
\end{eqn}
which gives us the Lagrangian
\begin{eqn}
L = -mc^2 \sqrt{1 - \vd x^2 / c^2}
\end{eqn}
and conjugate momentum $\v p = \gamma m \v v$ as expected.

What about Newton's equations? For a free particle we have
\begin{eqn}
\od{p^\mu}{t} = 0,
\end{eqn}
while in general we have
\begin{eqn}
\od{p^\mu}{t} = f^\mu
\end{eqn}
for some \emph{4-force} $f^\mu$. In Newtonian mechanics we have forces acting instantaneously at a distance. Of course, this cannot happen relativistically, so we don't have a direct analogy for Newtonian gravity in terms of forces (hence GR). On the other hand, Maxwell's equations are \emph{naturally} relativistic, so that the equations of motion indeed give us a 4-force equivalent to the Lorentz force.

Furthermore, momentum is still conserved so that for an isolated system of particle we have
\begin{eqn}
\sum_i \dot p_i^\mu = 0.
\end{eqn}

\end{document}


\problemname{Mr. Plow King}

In the kingdom of Winterfield, there are several cities and each pair of cities is connected by exactly one old dirt road. The king of Winterfield has decided that he will upgrade some of those roads. The set of roads that he upgrades must be such that it is possible to get from any city in the kingdom to any other city via some sequence of upgraded roads.

Because there is so much snow in Winterfield, the king has also decided to plow some of those upgraded roads. The local plow company, \textit{Mr. Plow}, and the king have agreed on the following: the king labels each of the upgraded roads $1, 2, \dots, m$ (the label of each road is the number of gold pieces it costs to plow that road) and each road must receive a distinct label. Mr. Plow will plow a set of upgraded roads so that it is possible to get from any city to any other city via some sequence of plowed roads. Mr. Plow will select the cheapest possible set of roads that satisfies the above condition.

For example, if the kingdom has six cities and the king decides to upgrade and label the 8 bolded dirt roads as follows, then Mr. Plow will then plow the roads with labels 1, 2, 3, 4 and 6 (costing a total of 16 gold pieces).

\begin{center}
\includegraphics[width=0.9\textwidth]{plow_img.png}
\end{center}
\vspace{10pt}

The king has decided on the number of roads to upgrade, but he is not sure how to label them, so he has turned to Barney (the kingdom's mathematician) to help decide. However, the king is unaware that Barney is actually invested in Mr. Plow, so Barney will choose the set of roads to upgrade and how to label them so that the total cost is as large as possible. What is the maximum cost of plowing the roads?

\section*{Input}

The input consists of a single line containing two integers $n$~($2 \leq n \leq 1\,000\,000$), which is the number of cities, and $m$~($n-1 \leq m \leq \frac{n(n-1)}{2}$), which is the number of roads to be upgraded.

\section*{Output}

Display the maximum possible cost of plowing the roads following the rules above.


\subsection{Plain objects}
\label{subsec:library_of_transformations:instance_level_transformations:plain_objects}

\begin{figure}[b]
    \centering
    \begin{subfigure}{0.45\textwidth}
        \centering
        \includegraphics{images/05_library_of_transformations/03_instance_level_transformations/01_plain_objects/class_instance.pdf}
        \caption{$Im_{Class}$ with one object identified as $x$}
        \label{fig:library_of_transformations:instance_level_transformations:plain_objects:visualisation:ecore}
    \end{subfigure}
    \begin{subfigure}{0.45\textwidth}
        \centering
        \input{images/05_library_of_transformations/03_instance_level_transformations/01_plain_objects/class_as_node_type_instance.tikz}
        \caption{$IG_{Class}$ with one node identified as $x$}
        \label{fig:library_of_transformations:instance_level_transformations:plain_objects:visualisation:groove}
    \end{subfigure}
    \caption{Visualisation of the transformation of plain objects typed by regular classes}
    \label{fig:library_of_transformations:instance_level_transformations:plain_objects:visualisation}
\end{figure}

The first transformation that will be defined is a transformation of plain objects of a regular class type. The corresponding type level transformation can be found in \cref{subsec:library_of_transformations:type_level_transformations:regular_classes}. This transformation introduces an arbitrary amount of instances of the class introduced on the type level. First, the definition of the corresponding instance model is given.

\begin{defin}[Instance model $Im_{Class}$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:imod_class}
Let $Im_{Class}$ be the instance model containing a set of objects $objects$ which are all typed by class $name$. Furthermore, an injective function $fid$ is defined which maps every object in the set to its corresponding identifier. $Im_{Class}$ is typed by $Tm_{Class}$ (\cref{defin:library_of_transformations:type_level_transformations:regular_classes:tmod_class}) and is defined as:
\begin{align*}
Object =\ &objects \\
\mathrm{ObjectClass} =\ & \begin{cases}
    (ob, name) & \mathrm{if }\ ob \in objects
\end{cases}\\
\mathrm{ObjectId} =\ & \begin{cases}
    (ob, fid(ob)) & \mathrm{if }\ ob \in objects
\end{cases}\\
\mathrm{FieldValue} =\ & \{\} \\
\mathrm{DefaultValue} =\ & \{\}
\end{align*}
\isabellelref{imod_class}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{defin}

\begin{thm}[Correctness of $Im_{Class}$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:imod_class_correct}
$Im_{Class}$ (\cref{defin:library_of_transformations:instance_level_transformations:plain_objects:imod_class}) is a valid instance model in the sense of \cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.
\isabellelref{imod_class_correct}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{thm}

A visual representation of $Im_{Class}$ with $objects = \{ob\}$ and $fid(ob) = x$ can be seen in \cref{fig:library_of_transformations:instance_level_transformations:plain_objects:visualisation:ecore}. Although this visualisation only shows one object, it is possible to have an arbitrary amount of objects in $Im_{Class}$, as long as they are all typed by the corresponding class introduced on the type level. In the visualisation, the identifier $.\type{Example}$ is used for the class, in correspondence with \cref{fig:library_of_transformations:type_level_transformations:regular_classes:visualisation:ecore} The correctness proof of $Im_{Class}$ is trivial, and therefore not included here. The proof can be found as part of the Isabelle validated proofs.

In order to make composing transformation functions possible, $Im_{Class}$ should be compatible with the instance model it is combined with.

\begin{thm}[Correctness of $\mathrm{combine}(Im, Im_{Class})$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:imod_class_combine_correct}
Assume an instance model $Im$ that is valid in the sense of \cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}. Then $Im$ is compatible with $Im_{Class}$ (in the sense of \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:compatibility}) if:
\begin{itemize}
    \item All requirements of \cref{defin:library_of_transformations:type_level_transformations:regular_classes:tmod_class_combine_correct} are met, to ensure the combination of the corresponding type models is valid;
    \item All the objects in $Im_{Class}$ have an (internal and explicit) identity that is not yet used in $Im$.
\end{itemize}
\isabellelref{imod_class_combine_correct}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{thm}

\begin{proof}
Use \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_models:imod_combine_merge_correct}. It is possible to show that all assumptions hold. Now we have shown that $\mathrm{combine}(Im, Im_{Class})$ is consistent in the sense of \cref{defin:formalisations:ecore_formalisation:instance_models:model_validity}.
\end{proof}

Please note that this combination is quite trivial, as the newly introduced objects cannot have fields. This is because they are all typed by the new class type introduced in $Tm_{Class}$. Since this new class type is new by assumption, the existing model cannot have fields defined for the class type.

The definitions and theorems for introducing plain objects of regular classes within Ecore are now complete.

\subsubsection{Encoding as nodes}

A possible encoding for plain objects in Ecore is using nodes in GROOVE. Each node is typed by the node type that was introduced in $TG_{Class}$, and copies the identifiers set of the objects to the corresponding nodes. The encoding corresponding to $Im_{Class}$ can then be represented as $IG_{Class}$, defined in the following definition:

\begin{defin}[Instance graph $IG_{Class}$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:ig_class_as_node_type}
Let $IG_{Class}$ be the instance graph with as nodes the converted $objects$ of $Im_{Class}$ (\cref{defin:library_of_transformations:instance_level_transformations:plain_objects:imod_class}). Furthermore, reuse the injective function $fid$ that maps every object to its identifier. Finally, use the node type introduced in $TG_{Class}$ (\cref{defin:library_of_transformations:type_level_transformations:regular_classes:tg_class_as_node_type}). $IG_{Class}$ is defined typed by $TG_{Class}$ and is defined as:
\begin{align*}
N =\ & objects \\
E =\ & \{\} \\
\mathrm{ident} =\ & \begin{cases}
    (fid(ob), ob) & \mathrm{if }\ ob \in objects
\end{cases}
\end{align*}
with
\begin{align*}
\mathrm{type}_n =\ & \begin{cases}
    (ob, \mathrm{ns\_\!to\_\!list}(name)) & \mathrm{if }\ ob \in objects
\end{cases}
\end{align*}
\isabellelref{ig_class_as_node_type}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{defin}

\begin{thm}[Correctness of $IG_{Class}$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:ig_class_as_node_type_correct}
$IG_{Class}$ (\cref{defin:library_of_transformations:instance_level_transformations:plain_objects:ig_class_as_node_type}) is a valid instance graph in the sense of \cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}.
\isabellelref{ig_class_as_node_type_correct}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{thm}

A visual representation of $IG_{Class}$ with $objects = \{ob\}$ and $fid(ob) = x$ can be seen in \cref{fig:library_of_transformations:instance_level_transformations:plain_objects:visualisation:groove}. Like the previous example for the Ecore instance model, only one node is shown here, but multiple nodes can be introduced at once if there are more objects in the $objects$ set. As shown in the definition, the node type identified by $\type{Example}$ is used to type all the nodes, in correspondence with \cref{fig:library_of_transformations:type_level_transformations:regular_classes:visualisation:groove}. The correctness proof of $IG_{Class}$ is trivial, and therefore not included here. The proof can be found as part of the Isabelle validated proofs.

In order to make composing transformation functions possible, $IG_{Class}$ should be compatible with the instance graph it is combined with.

\begin{thm}[Correctness of $\mathrm{combine}(IG, IG_{Class})$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:ig_class_as_node_type_combine_correct}
Assume an instance graph $IG$ that is valid in the sense of \cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}. Then $IG$ is compatible with $IG_{Class}$ (in the sense of \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:compatibility}) if:
\begin{itemize}
    \item All requirements of \cref{defin:library_of_transformations:type_level_transformations:regular_classes:tg_class_as_node_type_combine_correct} are met, to ensure the combination of the corresponding type graphs is valid;
    \item All the nodes in $IG_{Class}$ have an (internal and explicit) identity that is not yet used in $IG$.
\end{itemize}
\isabellelref{ig_class_as_node_type_combine_correct}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{thm}

\begin{proof}
Use \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_instance_graphs:ig_combine_merge_correct}. It is possible to show that all assumptions hold. Now we have shown that $\mathrm{combine}(IG, IG_{Class})$ is valid in the sense of \cref{defin:formalisations:groove_formalisation:instance_graphs:instance_graph_validity}.
\end{proof}

The next definitions define the transformation function from $Im_{Class}$ to $IG_{Class}$:

\begin{defin}[Transformation function $f_{Class}$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:imod_class_to_ig_class_as_node_type}
The transformation function $f_{Class}(Im)$ is defined as:
\begin{align*}
N =\ & Object_{Im} \\
E =\ & \{\} \\
\mathrm{ident} =\ & \begin{cases}
    (fid(ob), ob) & \mathrm{if }\ ob \in Object_{Im}
\end{cases}
\end{align*}
with
\begin{align*}
\mathrm{type}_n =\ & \begin{cases}
    (ob, \mathrm{ns\_\!to\_\!list}(name)) & \mathrm{if }\ ob \in Object_{Im}
\end{cases}
\end{align*}
\isabellelref{imod_class_to_ig_class_as_node_type}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{defin}

\begin{thm}[Correctness of $f_{Class}$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:imod_class_to_ig_class_as_node_type_func}
$f_{Class}(Im)$ (\cref{defin:library_of_transformations:instance_level_transformations:plain_objects:imod_class_to_ig_class_as_node_type}) is a valid transformation function in the sense of \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_model_instance_graph} transforming $Im_{Class}$ into $IG_{Class}$.
\isabellelref{imod_class_to_ig_class_as_node_type_func}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{thm}

The proof of the correctness of $f_{Class}$ will not be included here. Instead, it can be found in the validated Isabelle theories. The proof is quite trivial, as extending $Im$ can only add extra objects, but not remove the existing ones.

Finally, to complete the transformation, the transformation function that transforms $IG_{Class}$ into $Im_{Class}$ is defined:

\begin{defin}[Transformation function $f'_{Class}$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:ig_class_as_node_type_to_imod_class}
The transformation function $f'_{Class}(IG)$ is defined as:
\begin{align*}
Object =\ &N_{IG} \\
\mathrm{ObjectClass} =\ & \begin{cases}
    (ob, name) & \mathrm{if }\ ob \in N_{IG}
\end{cases}\\
\mathrm{ObjectId} =\ & \begin{cases}
    (ob, fid(ob)) & \mathrm{if }\ ob \in N_{IG}
\end{cases}\\
\mathrm{FieldValue} =\ & \{\} \\
\mathrm{DefaultValue} =\ & \{\}
\end{align*}
\isabellelref{ig_class_as_node_type_to_imod_class}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{defin}

\begin{thm}[Correctness of $f'_{Class}$]
\label{defin:library_of_transformations:instance_level_transformations:plain_objects:ig_class_as_node_type_to_tmod_class_func}
$f'_{Class}(IG)$ (\cref{defin:library_of_transformations:instance_level_transformations:plain_objects:ig_class_as_node_type_to_imod_class}) is a valid transformation function in the sense of \cref{defin:transformation_framework:instance_models_and_instance_graphs:combining_transformation_functions:transformation_function_instance_graph_instance_model} transforming $IG_{Class}$ into $Im_{Class}$.
\isabellelref{ig_class_as_node_type_to_imod_class_func}{Ecore-GROOVE-Mapping-Library.ClassInstance}
\end{thm}

Once more, the correctness proof is not included here but can be found in the validated Isabelle proofs of this thesis.