\chapter{Introduction}

\iffalse
why its called follow the leader.
Disposisjon.
	- There are different ways to approach the micro-macro limit
	- On the different philosophies
	- Different levels of mathematical complexity, distinct description for different phenomenon.

On the background in traffic modelling
Problemstilling:
\fi
The present paper establishes a connection between two modelling paradigms for traffic flows. The model in question is the  first order Follow-the-Leader model
\begin{equation} \label{intro:FtL}
	 \frac{dz_{i-1/2}}{dt} = k(z_{i-1/2})v\left(\frac{l}{z_{i+1/2} - z_{i-1/2}}\right) \text{ for } i \in \{1,...,N\} \,\, N \in \N
\end{equation}
Each vehicle is described by a particle, where the particles are related by a system of ordinary differential equations. $l$ models the car length of each vehicle. In the follow the leader model, any vehicle will adjust its speed in accordance with the distance to the vehicle it follows. The $k$ function allows the velocity of a vehicle to also depends on its position. This can model an accident or construction work, which will affect the speed-limit. The model is called first order, since it only involves the first derivative of each particle. The model \eqref{intro:FtL} is also an example of a microscopic model, in that it describes the path of alle vehicles exactly. In contrast,
a macroscopic model only describes averaged quantities, such as  traffic density. We will examine the relation between model \eqref{FtL} and a macroscopic model, a modified Lighthill-Whitham-Richards model.
\begin{equation} \label{intro:LWR}
	\rho_t + \left(k(x)\rho v\left(\rho\right))_x = 0.
\end{equation}

Model \eqref{intro:LWR} is a scalar conservation law with a space dependent flux. For $k = 1$, it has been established that there exist a connection between model \eqref{intro:FtL} and \eqref{intro:LWR} in the so-called many particle limit. As the number of particles increase and the length of each car decreases in such a way that preserves the total mass, the system \eqref{intro:FtL} converge to a equation \eqref{intro:LWR}. See for example \cite{di2015rigorous},  \cite{holden2017continuum} and \cite{1556-1801_2018_3_409}. The result has previously been generalised. For example, by considering infinetely many vehicles in \eqref{intro:FtL}, as in  \cite{MARCELLINI2021124664}. This paper bases itself largely on the works by Holden et al, in \cite{556-1801_2018_3_409} and \cite{holden2017continuum} and generalises the proofs for the system to hold for a general $k$. The motivation behind the project is that it strengthens the connection between two modelling paradigms, which are mathematically different. One can consider a PDE as a generalisation of an ODE, but the existence and uniqeness theory of \eqref{intro:LWR} is delicate and require the concept of weak solutions, while the corresponding theory only require Lipschitz continuity and calculus. If such a relation can be established, then the FtL can be seen as a numerical approximation to the scalar conservation law.
%base on Helge,

\iffalse

\textcite{argall2002rigorous}

The Lighthill and Whitham model takes the form of a scalar conservation law,
\begin{equation}
    \rho_t + f(\rho)_x = 0
\end{equation}
- Intelligent driver etc.

For the special system,

\begin{equation} \label{special inhom SCL}
    \rho_t + (k(x)f(\rho))_x = 0
\end{equation}
where $k \in C^1[\R]$, we derive the entropy condition. Introduce a viscosity solution that satisifies $\rho^{\epsilon}_t + (k(x)f(\rho^{\epsilon}))_x = \epsilon  \frac{\partial^2 \rho^\epsilon}{\partial^2x} $ and consider any convex function $\xi \in C^1$ differentiable a.e. (fact from analysens grunnlag any convex function is differentiable almost everywhere), and multiply by the equation by the $\xi^{'}(\rho^{\epsilon})$. This leads to the equation

\begin{equation}
    \xi(\rho^{\epsilon})_t + k(x) \xi^{'}(\rho^{\epsilon}) f^{'}(\rho^{\epsilon})\rho^{\epsilon}_x + k^{'}(\rho^{\epsilon})(x)\xi^{'}f(\rho^{\epsilon}) = \epsilon \xi^{\rho}(\rho^{\epsilon}) \frac{\partial^2 \rho^\epsilon}{\partial^2x}.
\end{equation}
Note that $\partial_x(\xi \partial_x \rho) = \xi^{''} \partial_x \rho^2 + \xi^{'}\partial^2_{xx}\rho$ implies that the right hand term is less than $\partial_x(\epsilon \xi(\rho^{\eps}) \partial_x \rho)$. Assume $\epsilon \to 0$, then

\begin{equation}
    \xi(u)_t + (k(x)q(u))_x + k^{'}(x)\big( \xi^{'}(\rho^{\epsilon}) f(\rho^{\epsilon})  q(\rho^{\epsilon})\big).
\end{equation}
Let $\xi^\delta (u) = \sqrt{(u-k)^2 + \delta^2}$, then $\partial_u \xi^\delta = \frac{u - k}{\sqrt{(u - k}^2 + \delta ^2} \to \sgn(u - k)$ pointwise. By the dominated convergence theorem,
where There is done research on the case where

On hyperbolic conservation laws:
On conservation laws in their most general form. - Dafermos.
On the L1-contractitivty of scalar conservation law.
What came before.

Kruz\check{z}ov entropy solution, weak solution.

History of microscopic and macroscopic models:
- Two different approaches to traffic modelling are microscopic and macroscopic modelling. Microscopic models are density based and can be derived as continuum equations. Kinetic gass formulation.  These have been studied extensively in recent years.

- How they differ, central recults.

The motivation for this notion of admissibility is
provided by the observation that all the systems of balance laws from Continuum
Physics encountered in Chapter II are indeed accompanied by some inequality
in the form (4.3.3) which expresses, explicitly or implicitly, the Second Law of
thermodynamics. - Dafermos
\fi

\section{Some mathematical definitions}
Here are some definitions that will be used throughout the thesis.
\begin{definition}[Function]
A function is a rule that assigns to each input value to a unique output value. For sets $X$ and $Y$, we write
\begin{equation}
    f : X \rightarrow Y,
\end{equation}
and say that $f$ denotes the function between $X$ and $Y$. A set is a collection of distinct object. Examples of sets include the set of real numbers, denoted by $\mathscr{R}$, and $\mathscr{R}^n$, the $n$-dimensional euclidean space. \\
\end{definition}

A class of function that is of interest are continuous functions. Continuity for functions between metric spaces, like $\R$, is most commonly first introduced in the $\epsilon - \delta$-fashion:
\begin{definition}[Continuity between metric spaces]
A function  $f : X \rightarrow Y$ between metric spaces $X$, $Y$ is continuous at $x \in X$ if
given $\epsilon > 0 \,\, \exists \,\, \delta > 0,$ such that $ \forall y \in X$ where
\begin{equation}
    d(x,y) < \delta \implies d(f(x),f(y)) < \epsilon.
\end{equation}
\end{definition}
}

Geometrically, for each $\epsilon$ ball around an image point, there exists a $\delta$-ball such that the image of the latter is contained in the former. A continuous function is continuous at every point $x \in X$. The set, or space of continuous functions betweeen $X$ and $Y$ is denoted by $\C(X,Y)$.

\iffalse
 Let $\Omega \subset \mathscr{R}^n$. One important class is

\begin{equation} \label{C(Rn)}
     \mathscr{C}(\Omega) := \{f : \Omega \rightarrow \mathscr{R} \,|\, \text{f is a continuous function\}.
\end{equation}
If $\Omega$ is compact, a result by SOMEONE, states that every element of $\C$ attains its supremal value, and can be endowed with the supremum norm. Often called the topology of uniform convergence.

\begin{equation}
    \norm{f}_\infty = sup_{x \in \Omega} |f(x)|.
\end{equation}
By (...), is a banach space, or a complete normed space.

There are several equivalent definitions and generalisations of continuity, the standard one being a local definition.
USE DEFINITIONS

Total variation is a measure of how much a function changes. For a function that takes pointwise values, we have the following definition

\fi

\subsection{Functions of bounded variation and Lipschitz continuous functions}
Some results and definition concerning functions of bounded variation and Lipschitz continuous functions. Functions of bounded variation permeate the theory of hyperbolic conservation laws, and is often a vital assumption to make for the solutions to obtain existence and uniqueness theory. See for example \cite{holden2015front}. As we will see in the main part of the thesis, they serve a vital role.

Lipschitz continuous funtions are an important subclass of functions of bounded variation. In many cases, as good as differentiable. Many important results in differentiable calculus extend to Lipschitz continuous functions. The following definitions are taken from \cite{tao2011introduction}.

\begin{definition}(Bounded variation in one dimension) \label{def:bounded_variation}
Let $f : \R \rightarrow \R$ be a function. The \emph{total variation} T.V.($f$) of $f$ is defined to be the supremum
\begin{equation} \label{TV_1d}
	\text{T.V.}(f) = \sup_{x_0 < ... < x_n} \sum_{i = 0}^{n-1} \left| f(x_{i+1}) - f(x_i)\right|
\end{equation}
where the supremm ranges over all finite increasing sequences $x_0, ..., x_n$ of real numbers with $n \geq 0$; this is a quantity in $[0, \infty]$. We say that $f$ has \emph{bounded variation} on $\R$ if T.V.($f$) is finite. If T.V.($f$) is finite when $x_0, ..., x_n$ are restricted to a compact set $K$, we say that $f$ is of \emph{locally bounded variation}. Other ways to write T.V.($f$) include $\left|f\right|_{\text{BV}}$, to emphasise the semi-norm property. %Book that proves that BV norm is a banach space
%BV functions are bounded
%

A result from the theory of bounded variations concerns the decomposition of B.V-functions.

\begin{proposition} \label{TV_monotone_decomp}
	A function $f : \R \mapsto \R$ is of bounded variation if and only if it is the difference of two bounded monotone functions. A monotone function is a function that is either increasing or decreasing.
\end{proposition}
For proof, \cite[see][p.166]{tao2011introduction}.
This allows the following corollary
\begin{corollary}
	Any function $f : \R \mapsto \R$ of bounded variation has a left- continuous version $\tilde{f}}$ such that
	\begin{equation}
		\text{T.V.}(f) = \text{T.V.}(\tilde{f})
	\end{equation}
\end{corollary}
\begin{proof}
	By \eqref{TV_monotone_decomp}, $f$ can be decomposed into a sum of two bounded monotone functions. For a monotone function $g$, the existence of left continuous limit is equivalent to the statement
	\begin{align}
		\lim_{y \rightarrow x^-} g(y) \text{ exists } \forall x \in \R.  \label{montone_left_right_lim1}
	\end{align}
	 To see \eqref{montone_left_right_lim1}, assume without loss of generality that $g$ is monotone and increasing. Let $\{x_n^+\}_{n \in \N}$ be a sequence approaching $x$ from below. $g(x_n^+)$ is is a bounded increasing sequence, by assumption, and  convergent to some left limit $g^+(x)$ which is independent of  $\{x_n^+\}_{n \in \N}$. If it was not independent, one could define two sequences $\{x_n\}_{n \in \N}, \{y_n\}_{n \in \N}$ such that $\lim_{n \in \N} x_n = \lim_{n \in \N} y_n = x$ from below,  such that $\lim_{n \in \N} g(x_n) < \lim_{n \in \N} g(y_n)$. Then, $\exists N$ such that $ g(x_n) < g(y_n) \forall n \geq \N$. Fix $N_1 \geq N$ and pick $N_2$ such that $x_{N_2} > y_{N_1}$. This violates the assumption that $g$ is increasing.

	 \begin{equation}
	 	\lim_{y \rightarrow x^-} g(y) \leq g(x) \leq \lim_{y \rightarrow x^+} g(y) \label{montone_left_right_lim2}
	 \end{equation}
 	Implies that the total variation of $\lim_{y \rightarrow x^-} g(y)$ is that of $g$. $\lim_{y \rightarrow x^+} g(y)$ exist by the same argument as given above. For both monotone functions that compose $f$, one can therefore pick left continuous versions for both.

\end{proof}
The notion of T.V.$(\cdot)$ can be extended to functions $f:\R^n \mapsto \R$ for $n \geq 2$. One way of doing this is by taking the one dimensional total variation with respect to each component, as follows

\begin{definition}(One dimensional bounded variation in two dimensions)
	Let $f : \R\times\R \rightarrow \R$ be a function where $x_1, x_2$ are the variables of $f$. Define the function

	\begin{align} \label{TV_slice}
		\text{T.V.}_{x_1}(f) : \R &\mapsto \R^+_0 \cup \infty \\
		x &\mapsto \text{T.V.}(f(\cdot, x)) \nonumber
	\end{align}
	 For each $x \in \R$, $\text{T.V.}_{x_1}(f)$ returns the one dimensional total variation of $f$ restricted to the line $\{x_2 = x\} \subset \R^2$.  $\text{T.V.}_{x_2}(f)$ can be define similarly.
\end{definition}

\begin{remark}
	From here, T.V.($f$) can be extended to $\R^2$ by
	\begin{equation} \label{TV_2d}
		\text{T.V.}(f) = \int_\R \text{T.V.}_{x_1}(f) + \text{T.V.}_{x_2}(f) dx
	\end{equation}
	   If $f$ is differentiable, \eqref{TV_2d} is proportional to $\norm{\nabla g}_{L_1}$. In this thesis, \eqref{TV_slice} will mainly be used.
\end{remark}
	%Hva med locally of bounded variation?

	The \emph{total variation} T.V.($f$) of $f$ is defined to be the supremum
	\begin{equation}
		\text{T.V.}(f) = \sup_{x_0 < ... < x_n} \sum_{i = 0}^{n-1} \left| f(x_{i+1}) - f(x_i)\right|
	\end{equation}
	where the supremum ranges over all finite increasing sequences $x_0, ..., x_n$ of real number with $n \geq 0$; this is a quantity in $[0, \infty]$. We say that $f$ has \emph{bounded variation} on $\R$ if T.V.($f$) is finite. Other ways to write T.V.($f$) include $\left|f\right|_{\text{BV}}$ to emphasise the semi-norm property.

In this thesis, we will denote

An important subclass of locally B.V. functions are the Lipschitz continuous functions.

\begin{definition}(Lipschitz continuous functions over $\R$)
	A function $f : \R \mapsto \R$ is Lipschitz continuous if $ \exists C \in \R^+_0$ such that $\forall x,y \in \R$

	\begin{equation} \label{def:Lipschitz_R}
		\left|f(x) - f(y)\right| \leq C\left|x - y\right|
	\end{equation}
	A function is said to be locally Lipschitz if given $K \subset \R$ closed and bounded, then $\exists C_K$ such that $\forall x,y \in K$
	\begin{equation} \label{def:Lipschitz_K}
		\left|f(x) - f(y)\right| \leq C_K\left|x - y\right|
	\end{equation}
	The smallest $C$ (resp. $C_K$)such the the above properties is known as the Lipschitz constant $L$ (resp. $L_K$) of $f$.
\end{definition}

To see that Lipschitz continuous functions are of locally bounded variation, observe that for any partition

\begin{equation}
	\sum_{i = 0}^{n-1} \left| f(x_{i+1}) - f(x_i)\right| \leq L\left| x_0 - x_n \right| \leq L \cdot \text{diam}(K)
\end{equation}
So if $K$ is bounded, then T.V.($f$) $< \infty$. In particular, if $f$ is defined on a compact set, then it is of bounded variation.

\begin{theorem}(Lipschitz differentiation theorem) \label{prop:Lip_diff_prop}
	A Lipschitz continuous function is differentiable almost everywhere, in the sense of Lebesgue measure. Where the derivative exists, it is bounded by the Lipschitz constant $L$.
\end{theorem}
\begin{remark}
	For a statement of the theorem, see \cite[p.167]{tao2011introduction}. The result follows from the fact that Lipschitz functions are locally of bounded variation.
\end{remark}

Theorem \eqref{prop:Lip_diff_prop} states that Lipschitz functions are almost differentiable.

Two properties of Lipschitz continuous functions that will be useful are
\begin{proposition}(Lipschitz properties) \label{prop: Lipschitz_props}
	Let f,g : $\R \mapsto \R$ be Lipschitz continuous. Then the composition
	\begin{equation}
		f \circ g : \R \mapsto \R
	\end{equation}
	is Lipschitz continuous.

	If f,g are also bounded, then the product
	\begin{equation}
		f g : \R \mapsto \R
	\end{equation}
	is Lipschitz continuous. Furthermore, let $f', g'$ be the almost everywhere derivatives of $f, g$. Then the product rule for differentiation
	\begin{equation}
		(fg)' = f'g + fg'
	\end{equation}
	holds almost everywhere.
\end{proposition}

Another useful property relating B.V. functions and functions of bounded variation is the following result

 \begin{proposition}(\text{B.V.} properties) \label{prop:BV_props}
 	Let f, g: $\R \mapsto \R$ be functions of bounded variation. Then the product
 	\begin{equation} \label{prop:BV_prop_prod}
 		f g :\R \mapsto \R
 	\end{equation}
 	is also of bounded variation.

 	Assume in addition that $f$ is Lipschitz, then
 	\begin{equation} \label{prop:BV_prop_comp}
 		f \circ g :\R \mapsto \R
 	\end{equation}
 	is of bounded variation.
 \end{proposition}

Even for continuous B.V. functions, it is not true that the difference in function values can found by integrating the almost everywhere derivative. If the variation of the function is concentrated on a set of lebegue measure zero, the second fundamental theorem of calculus can fail to hold \cite[see The Devil's staircase function][p. 186]{tao2011introduction}}. The following theorem shows that this does not occur for Lipschitz continuous functions.

\begin{theorem}(Second fundamental theorem of calculus for Lipschitz functions) \label{thm:fundamental_calc_Lipschitz}

	Let f : $\R \mapsto \R$ be Lipschitz continuous and $a,b \in \R$ and f$^{'}$ : $\R \mapsto \R$ be the almost everywhere derivative. Then,
	\begin{equation}
		\int_a^b f'(x) dx = f(b) - f(a).
	\end{equation}
\end{theorem}
\begin{proof}
Exercise 1.6.44 in ~\autocite[p.169]{tao2011introduction}
\end{proof}

We state the other half of the fundamental theorem of calculus, under slightly stronger assumptions on the derivative.

\begin{theorem}(First fundamental theorem of calculus) \label{thm:first_fundamental_calc}

	Let $[a,b]$ be a compact interval of positive length. Let f :$[a,b] \mapsto \R$ be a continuous function, and let F: $[a,b] \mapsto \R$ be the indefinite integral $F(x):= \int_a^x f(t) d$. Then F is differentiable on $[a,b]$, with derivtative $F^{'}(x) = f(x)$ for all $x \in [a,b]$. In particular, $F$ is continuously differentiable.
\end{theorem}

A proof of a slightly more general version of \eqref{thm:first_fundamental_calc} can be found in \cite[p.135]{tao2011introduction}, where the functions $f,F$ are allowed to take complex values.

\subsection{Compactness for partial differential equations}

Central in the theory of non-linear partial differential equations is the quest for compactness. One can often formulate an approximating sequence of functions with the property such that the partial differential equation is satisfied in the limit. The method of front-tracking is one such example, see \cite{holden2015front}. Compactness results are needed to establish that the approximating sequence converges to some candidate solution, which then must be verified to satisify the original equation. The compactness trick is in many ways the substance ofthe argument. Therefore, I will introduce three notions of compactness that will be used in this thesis implicitly and explicitly. The relevant setting is that of metric spaces.

\begin{definition}(Metric space)\eqref{def:metric_space}
	A \emph{metric space} is a pairing of a set $X$ and a function $d$,
	\begin{align}
		d : X \times X \mapsto \R^+_0,
	\end{align}
	$d$ satisifies the metric axioms. For $x,y,z \in X$,
	\begin{align}
		d(x,y) &= 0 \iff x = y \,\, &&\text{identity of indiscernibles} \label{def:metric_identity}\\
		d(x,y) &= d(y,x) \ \,\, &&\text{symmetry of distances}\label{def:metric_symmetry} \\
		d(x,y) &= d(x,z) + d(z,y)  \,\, &&\text{subadditivity}\label{def:metric_subadditivity}
	\end{align}
	An open ball $B_x(r) \subset X$ centered at $x \in C$ with radius $r > 0$ is
	the set of points with distance less than $r$ from $x$ according to the metric $d$.
\end{definition}

A definition of topology is also included

\begin{definition}(The metric topology)

	Let $(X,d)$ be a metric space. A subset U is open in X if for every $x \in U$, there exist $\epsilon > 0$ and an open ball $B_x(\epsilon)$ such that  $B_x(\epsilon) \subset U$.
\end{definition}

Examples of metric spaces include $\R^d$ endowed with the euclidean metric and $L^1(\R)$ endowed with the $L^1(\R)$.

A useful fact about the open sets in $\left(\R,\left|\cdot\right|\right)$, is

\begin{proposition}(Characterisation of open sets in $\R$) \label{prop:char_opens_R}

	Any open subset U of $\R$ can be written
	as the union of at most countably many disjoint non-empty open intervals, whose endpoints lie outside of U.
\end{proposition}

\begin{remark}
	Given as exercise 1.6.10 in \cite{tao2011introduction}.
\end{remark}

\begin{definition} (Completeness in metric spaces)
	A metric space $(X,d)$ is complete if every cauchy sequence has a limit in $X$.
\end{definition}

Sequential compactness for metric spaces is defined as follows

\begin{definition}(Sequential compactness for metric spaces)

	Let $(X,d)$ be a metric space and $K \subset X$ be a subset. $K$ is \emph{sequentially compact} if for any sequence $\{x_n\}_{n \in \N} \subset K$, there exist a subsequence $\{x_{n_i}\}_{i \in \N}$ converging to some $\hat{x} \in K$.
	If every sequence of $K$ has a convergent subsequence, but we cannot guarantee that the limit lies in $K$, then $K$ is \emph{sequentially pre-compact}.
\end{{definition}

A topological definition of compactness uses the the open cover concepts.

\begin{definition} (Open covers and topological compactness)
	Let (X,d) be a metric space. X is said to be \emph{topologically compact}, or simply \emph{compact} if any open cover admits a finite subcover.
\end{definition}

\begin{remark}
 	If $X = \R$ is endowed with the euclidean metric, a subset $K$ is compact if and only if it is closed and bounded, by the Heine-Borel theorem \cite{kumaresan2005topology}. Pre-compactness is thus equivalent with boundedness. %CITE
 	The notions introduced in this section can thus be seen as generalisations of closed and boundened sets in one dimension.
\end{remark}

The following theorem concept important for characterising compact metric spaces

\begin{definition} (Totally bounded sets)

	Let $(X,d)$ be a metric space. $X$ is \emph{totally bounded} if for every $\epsilon > 0$, $\exists x_1, ..., x_n \in X$ for $n \in \N$ such that

	\begin{equation}
		X \subset \cup_{i = 1}^n B_{x_i}(\epsilon).
	\end{equation}
	$B_{c}(\epsilon)$ is the open ball of radius $\epsilon$, centered at $c$. Such a covering is dubbed an $\epsilon$-net.
\end{definition}

This concept resembles the definition of topological compactness, in that it stipulates the existence of  finite open covers, the $\epsilon$-nets. The three concepts of this section are in fact identical for complete metric spaces.

\begin{theorem} (Characterisation of compact sets for metric spaces) \label{thm:metric_space_equivalence}
	For a metric space (X,d), the following are equivalent:

	1) X is compact: every open cover has a finite subcover.

	2) X is complete and totally bounded.

	3) X is sequentially compact: every sequence has a convergent subsequence.

\end{theorem}

The definitions and the theorem above are taken from \cite{kumaresan2005topology}.

The main compactness result we will use is Strong-Compactness criterium of Kolmogorov-Riesz-Sudakov, found in \citet{HANCHEOLSEN201984}.

\begin{theorem}(Kolmogorov-Riesz-Sudakov) \label{thm:Kolmogorov}
	The set $\mathcal{F} \subset L^p(\R^d, m^d)$ for $1 \leq p < \infty$ is totally bounded if and only if
	\begin{align}
		i) &\,\text{Localisation: for any $\epsilon > 0$, $\exists \,\, R > 0$ such that} \\
		& \quad \quad \forall f \in \mathcal{F} \,\, \int_{\left|x\right| \geq R} \left| f\right|^p dx \leq \epsilon^p \\
		ii) &\,\text{Translation: For any $\epsilon > 0$, $\exists\,\, \rho > 0$ such that for $y \in \R^d, \left|y\right| \leq \rho$}\\
			&\quad \quad \forall f \in \mathcal{F} \,\, \int \left| f(x+y) - f(x)\right|^p dx \leq \epsilon^p
	\end{align}
\end{theorem}

The next theorem is the Arzela-Ascoli theorem. First, the setting is introduced
\begin{definition}(Arzela-Ascoli setting) \label{Arzela_setting}
	Let $\mathcal{F} \subset \mathscr{C}(X,Y)$, where $X$ is a separable topological space and $Y$ is a complete metric space.

	$\mathcal{F}$ is called equicontinuous at $x \in X$ if given $\epsilon > 0$ there exists a neighbourhood $A \subset X$ so that $\forall f \in \mathcal{F}$ and $y \in A$:
	\begin{equation}
		d(f(x), f(y)) \leq \epsilon.
	\end{equation}
	$\mathcal{F}$ is equicontinuous if it is equicontinuous at every point $x \in X$.

	$\mathcal{F}$ is called pointwise totally bounded if the trajectory of $\mathcal{F}$ at $x \in X$ is pointwise totally bounded. The trajectory is defined by
	\begin{equation} \label{Arz_set:traj}
		\mathcal{F}(x) = \{f(x)  \, | \, f \in \mathcal{F}\}.
	\end{equation}
\end{definition}
Then, the theorem is stated

\begin{theorem} (Arzela-Ascoli theorem)
	If $\mathcal{F}$ is equicontinuous pointwise totally bounded, then any sequence in $\mathcal{F}$ has a pointwise convergent subsequence with a limit in $\C(X,Y)$. The convergence is uniform on topologically compact subsets of $X$.
\end{theorem}

\begin{theorem} (Arzelà-Ascoli theorem for Banach space valued functions) \label{thm:Arzela_banach}

	Let $(K,d)$ be a compact metric space, let $(Y, \norm{\cdot})$ be a Banach space, and let the space $\mathscr{C}(X,Y)$ be equipped with the sup-norm
	\begin{equation}
		\norm{f}_{{C}(X,Y)} = \sup_{x \in X} \norm{f(x)}_{Y},
	\end{equation}
	for $f \in \mathscr{C}(X,Y)$. Then, the closure $\mathcal{F}$ of a subset $\mathcal{F} \subset \mathscr{C}(X,Y)$ is compact if and only if the following two properties are satisfied:

	\indent a) For each $x \in X$, the closure of the set $\{f(x); x \in X\}$ is a compact subset of $Y$.
	\indent b) Given any $\epsilon > 0$, there exists $\delta(\epsilon) > 0$  such that $\norm{f(x) - f(y)} < \epsilon$ for all $x,y \in K$ such that $d(x,y) < \delta(\epsilon)$ and for all $f \in \mathcal{F}$.
\end{theorem}

Theorem \ref{thm:Arzela_banach} was given as an exercise in \cite{p. 166, problem 3.10-1, }

The Kolmogorov-Riesz-Sudakov theorem uses the concept of total boundedness to establish conditions for strong $L^p$-compactness. The concept of sequential compactness is useful to apply the theory, when compactness has already been established. In this thesis, we will use sequential compactness directly and the other concepts implicitly, e.g. by invoking of Arzela-Ascoli and the strong compactness criteria of Kolmogorov-Riesz-Sudakov.

\subsection{Some theory of $L^p$ spaces}

We define, as in ~\autocite{brezis2010functional}
\begin{definition} (Measure space) \label{def:measure_space}

	A measure space is a triple $(\Omega, \mathcal{M}, \mu)$.
	\begin{align}
		1) \,&\Omega \text{ is a set.} \\
		2) \,&\mathcal{M} \text{ is a collection of subsets of $\Omega$ such that:} \\
		&\quad \quad i)\, \varnothing \in \mathcal{M},   \\
		&\quad \quad ii) \,A \in \mathcal{M} \implies A^c \in \mathcal{M}  \\
		&\quad \quad iii) \,\cup_{i = 1}^\infty A_n \in \mathcal{M} \text{ whenever } A_n \in \mathcal{M}\\
		&\, \mathcal{M} \text{ is called a \emph{$\sigma$-algebra}. The sets of $\mathcal{M}$ are measurable sets}\\
		3) \,& \mu \text{ is a \emph{measure}, meaning a function } \mu : \mathcal{M} \mapsto \R^0_+, \text{ such that:} \\
		&\quad \quad i)\, \mu(\varnothing) = 0, \\
		&\quad \quad ii)\, \mu\left(\cup_{i = 1}^\infty A_n\right) = \sum_{i = 1}^\infty \mu\left( A_n \right) \text{ for a disjoint countable collection $\left(A_n\right)$ of measurable sets.} \\
		4) \,&\Omega \text{ is $\sigma$-finite. There exists a countable collection $\Omega_n \in \mathcal{M}$} \\
		&\text{such that $\Omega = \cup_{i = 1}^\infty \Omega_n$ and $\mu\left(\Omega_n\right) < \infty$.}
	\end{align}
\end{definition}

The measure space that will be used in this text is the lebesgue triple $(\Omega, \mathcal{L}^d, m^d)$.  $\Omega$ will be an open subset of $\R^d$ where $d \in \N^+$, and $\mathcal{L}^d, m^d$ are the $d$-dimensional lebesgue $\sigma$-algebra and lebesgue measure restricted to $\Omega$, respectively.

As in \cite[Definition 1.2.2][p. 20]{tao2011introduction}, we define
\begin{definition} (Lebesgue outer measure)
	For any set $E \subset \R^d$, define the $d$-dimensional lebesgue outer measure of $E$
	\begin{equation}
		m^d_{outer} := \inf_{\cup_{i = 1}^\infty B_n \superset E; B_1,B_2,..., \text{boxes}} \sum_{i = 1}^{\infty} \left| B_i \right|.
	\end{equation}
	A box is a cartesian product of $d$ intervals. $\left|\cdot \left|$ denotes the volume of a box, being the product of the length of its sides.
\end{definition}

\begin{definition} (Lebesgue measurability and lebesgue measure)
	A set $E \subset \R^d$ is said to be \emph{Lebesgue measurable} if, for every $\epsilon > 0$, there exists an open set $U \subset \R^d$ containing $E$ such that \[m^d_{outer}(U\backslash E) \leq \epsilon.\] If $E$ is Lebesgue measurable, we refer to \[m^d(E) := m^d_{outer}\] as the lebesgue measure of $E$. The quantity may possibly be infinite.

	The measure space $\left(\R^d, \mathcal{L}^d, m^d\right)$ is called the Lebesgue-triple.
\end{definition}

\begin{remark}
	Up to normalisation, lebesgue measure is the only measure over the lebesgue measurable sets, in the sense of \eqref{def:measure_space} which is also translation invariant.
\end{remark}

Measure theory introduces a generalisation of the function definition using  following equivalence class.

\begin{definition}(The almost everywhere equivalence class)
	Let $f,g : \Omega \mapsto \R$ be two functions defined on a measure space $(\Omega, \Sigma, \mu)$.  Let $N = \{x \in \Omega \, | \, f(x) \neq g(x)) \}$. $f,g$ are equal \emph{almost everywhere}, or a.e. if they differ on a \emph{null set}, i.e., a set of measure zero.
	We write
	\begin{equation}
		[f] = [g].
	\end{equation}
	A representative of an equivalence class is called a \emph{version}.
\end{definition}

The proceeding definitions and theorems require the formal notion of an integral and measurable functions. These are not of direct interest for this thesis, and we refer to \cite{tao2011introduction} for the construction and property of these objects.

An important space of functions in the context of integration theory are the $L^p$ spaces of integrable functions. First, recall the definition of a normed vector space

\begin{definition}(Normed vector space)
	A normed real vector space is a pairing $(X, \norm{\cdot })$ of a vector space $X$ over $\R$ endowed with a non-negative function $\norm{\cdot}$
	\begin{equation}
		\norm{\cdot} : X \mapsto \R_0^+,
	\end{equation}
	$\norm{\cdot}$ satisfies the norm axioms. For $x,y,z \in X$, $s \in \R$,
	\begin{align}
		\norm{x+y} &\leq \norm{x} + \norm{y} \,\, &&\text{subadditivity} \\
		\norm{s x} &= \left| s \right| \norm{x} \ \,\, &&\text{absolute homogeneity} \\
		\norm{x} &= 0 \implies x = 0  \,\, &&\text{Positive definiteness}
	\end{align}
\end{definition}

\begin{remark}
	Any norm on $X$ induces a metric on $X$, defined by $d_{\norm{\cdot}}(x,y) = \norm{x - y}$.
\end{remark}

\begin{definition}(Banach space)
	A Banach space is a complete normed vector space. The metric space induced by the normed space is complete.
\end{definition}

We can now sensibly define the $L^p$ spaces associated with a measure space.
\begin{definition}($L^p$-spaces) \label{def:Lp_space}

	Let $\left(\Omega, \mathcal{M}, \mu\right)$ be a measure space. We set
	\begin{equation}
		L^p(\Omega, \mu) = \{ f : \Omega \mapsto \R | f \text{ is measurable and } \norm{f}_{L^p} < \infty \},
	\end{equation}
	where we define the norm-in-name
	\begin{numcases} {\norm{f}_{L^p}}
		 \left(\int_X \left|f(x)\right|^p d\mu\right)^{\frac{1}{p}} &\text{ for } p\in [1,\infty) \label{Lp-norm1} \\
		 \text{essup}_{x \in X} \left|f(x)\right|&\text{ if } p = \infty \label{Lp-norm2}
	\end{numcases}
	If the measure space is implied, we write $L^p$. The special case of $p = 1$ is called the space of \emph{integrable functions}.
\end{definition}

A fundamental property of $L^p$ are given in the following two theorems, namely that $L^p$ is a Banach space.

\begin{theorem}
	$L^p$ is a vector space over $\R$ and $\norm{\cdot}_{L^p}$ is a norm for any $p, 1 \leq p \leq \infty$.
\end{theorem}

\begin{remark}
	The theorem states that the norm-in-name of \eqref{def:Lp_space} is in fact a norm.
\end{remark}

\begin{theorem}(Fischer-Riesz)
	$L^p$ is a Banach space for any $p, 1 \leq p \leq \infty$.
\end{theorem}
There are several ways to compute $L^p$-norms. In general, norms of Banach spaces can be computed using the dual space. The Hahn-Banach theorem ensures the existence of a normalising dual vector \footnote{see Corollary 1.3 and 1.4 in \citet[p.3]{brezis2010functional}}. If $E$ is a banach space and $E^*$ is its dual space, then for $x \in E$
\begin{equation} \label{norm_dual_formulation}
	\norm{x} = \max_{f \in E^*, \norm{f} \leq 1} \left|\langle f, x \rangle\right|
\end{equation}
The problem of computing the norm can be formulated as an infinite dimensional linear program, which has a solution due to Hahn-Banach. More specifically for $L^p$-spaces, it can be shown that for $1 < p, q < \infty$, if $\frac{1}{p} + \frac{1}{q} = 1$, then $(L^p)^* = L^q$ and $(L^q)^* = L^p$ under the pairing
% in the setting where the domain is separable
\begin{equation} \label{LpLq_dual_pairing}
	\langle f, g \rangle\right| = \int_\Omega f g d\mu \quad \quad \text{ for } f \in L^p,g\in L^q
\end{equation}
Any dual vector has a concrete representation as a function residing in some other function space. For the special cases of $L^1$, $L^\infty$, we have that $(L^1)^* = L^\infty$ under \eqref{LpLq_dual_pairing} but $(L^\infty)^* \neq L^1$. A result in the same vein as \eqref{norm_dual_formulation} as given below

\begin{proposition}(Computing $L^1$-norms using test functions)
	Consider the Lebesgue triple. Let $f \in L^1(\R, m)$, then we have
	\begin{equation}
		\norm{f}_{L^1} = \sup_{\phi \in \C^\infty_c(\R), \left|\phi\right| \leq 1} \int_\R f(z)\phi(z) dm(z)
	\end{equation}
\end{proposition}
The result is taken from Exercise A.1 in \cite{holden2015front}.

%Skriv kortere og mer relevant til oppgaven.

A couple of essential theorems of integration theory that will be used throughout this text are the dominated convergence theorem and Fubini's theorem. The first of which is an essential convergence result.

\begin{theorem}(Lebesgue dominated convergence theorem) \label{DCT}
	Let $(\Omega, \mathcal{M}, \mu)$ be a measure space and let $\{f_n\}_{n \in \N}$ be a sequence of measurable functions that converge pointwise $\mu$-almost everywhere to a meaasurable limit $f : \Omega \mapsto \R$. Suppose that there is an unsigned absolutely interable function $G : \Omega \mapsto [0,\infty]$ such that $\left|f_n\right|$ are pointwise $\mu$-almost everywhere bounded by $G$ for each $n$. Then we have
	\begin{equation}
		\lim_{n \rightarrow \infty} \int_\Omega f_n d\mu = \int_\Omega f d\mu
	\end{equation}
\end{theorem}

Theorem \eqref{DCT} is theorem 1.4.49, p. 111 in \cite{tao2011introduction}.
Some special cases of theorem \eqref{DCT} is included,
\begin{corollary}(Finite measure space) \label{cor:DCT:finite}}
	For finite measure spaces, (meaning $\mu(\Omega) < \infty$), $L^\infty(\Omega, \mu) \subset L^1(\Omega, \mu)$. So if $\sup_{n \in \N} \norm{f_n}_\infty \leq C <\infty$, we can choose the constant $C$ as the dominating function $G$.
\end{corollary}

\begin{corollary}(Monotone convergence theorem) \label{cor:MCT}
	Let $(\Omega, \mathcal{M}, \mu)$ be a measure space and let  $0 \leq f_1 \leq f_2 \leq ...$ be a non-decreasing sequence of unsigned measurable functions on $\Omega$. Then we have
	\begin{equation}
		\lim_{n \rightarrow \infty} \int_\Omega f_n d\mu = \int_\Omega \lim_{n \rightarrow \infty} f_n d\mu
	\end{equation}
	p. 107, theorem 1.4.44. Tao.
\end{corollary}

Fubini's theorem allows us to exhange the order of integration and compute a $d$-fold integral by $d$ iterations of one dimensional integrals.

\begin{theorem}(Fubini)
	Assume that $f \in L^1(\Omega_1 \times \Omega_2)$. Then for a.e. $x \in \Omega_1, F(x,y) \in L^1_y(\Omega_2)$ and $\int_{\Omega_2} F(x,y)d\mu_2 \in L^1_x\left(\Omega_1\right)$. Similarly, for a.e. $y \in \Omega_1, F(x,y) \in L^1_x(\Omega_1)$ and $\int_{\Omega_1} F(x,y)d\mu_1 \in L^1_y\left(\Omega_2\right)$. Moreover, one has
	\begin{equation}
		\int_{\Omega_1} d\mu_1 \int_{\Omega_2} F(x,y)d\mu_2 = \int_{\Omega_2} d\mu_2 \int_{\Omega_1} F(x,y)d\mu_1 = \int_{\Omega_1 \times \Omega_2} F(x,y)d\mu_1\times d\mu_2
	\end{equation}
\end{theorem}
A proof can be found in \eqref{Tao}.

Another useful theorem concerns two modes of convergence of $L^p$-functions.

\begin{theorem}(Connection between normed and pointwise a.e. convergence) \label{thm:lp_implies_a.e.}
	Let $\{f_n\}_{n \in \N}$ be a sequence in $L^p$ and let $f \in L^p$ be such that $\norm{f_n - f}_{L^p} \rightarrow 0$.
	Then there exists a subsequence $\{f_{n_k}\}_{k \in \N}$ and $h \in L^p$ such that
	\begin{align}
		i) & \, f_{n_k}(x) \rightarrow f(x) \text{ a.e. on }\Omega \\
		ii) & \, \left| f_{n_k}(x)\right| \leq h(x) \,\, \forall k\in \N, \text{ a.e. on } \Omega
	\end{align}
\end{theorem}

Egorov's theorem concerns the equivalence between pointwise almost everywhere convergence and almost uniform convergence, for finite measure spaces. It is one of Littlewood's three principles.

\begin{theorem}(Egorov's theorem) \label{thm:egorov}
	Let $(\Omega, \mathbb{M}, \mu)$ be a finite measure space. That is
	\begin{equation}
		\mu(\Omega) < \infty,
	\end{equation}
	and let $f_n : \Omega \mapsto \R$ be a sequence of measurable functions that converge pointwise almost everywhere to a limit $f: \Omega \mapsto \R$, and let $\epsilon > 0$. There exist a set $E$ of measure at most $\epsilon$, such that $f_n$ converge uniformly to $f$ outside of $E$.
\end{theorem}
The complex version of \eqref{thm:egorov} was given as an exercise in TAO.

 If we have norm convergence of a sequence of functions in $L^p$, we can always extract a subsequence that convergences pointwise almost everywhere. Proofs of all the above theorems can be found in \textcite{brezis2010functional}. The following lemma is taken from \textcite[p.410]{holden2015front} and considers the the lebesgue triple in particular.

The following lemma was taken from p.420 \cite{holden2015front}

 \begin{lemma}(Pointwise convergence of sign) \label{lem:sign_lemma}
 	Let $\Omega \subset \R^d$ be an bounded open set, let $g \in L^1(\Omega, m^d)$ and suppose that $g_n(x) \rightarrow g(x)$ almost everywhere. Then there exists a set $\Theta \subset \R^d$, which is at most countable, such that for every $c \in \R \backslash \Theta$,
 	\begin{equation}
 		\textnormal{sign}\left( g_n(x) - c\right) \rightarrow \textnormal{sign}\left( g(x) - c\right) \text{a.e. in } \Omega.
 	\end{equation}
 	Furthermore, let $c \in \Theta$ and define
 	\begin{equation}
 		\mathcal{F} = \{x \in \Omega | g(x) = c\}
 	\end{equation}
 	then it is possible to define sequences $\{\underline{c}_n\}_{n \in \N} \subset \R \backslash \Theta$ and $\{\overline{c}_n\}_{n \in \N} \subset \R \backslash \Theta$ such that
 	\begin{align}
 		\underline{c}_n \uparrow c \text{ and } \textnormal{sign}\left(g(x) - \underline{c}_n \right) \rightarrow \textnormal{sign}\left(g(x) - c \right) \text{a.e. in } \Omega \backslash \Theta\\
 		\overline{c}_n \downarrow c \text{ and } \textnormal{sign}\left(g(x) - \overline{c}_n \right) \rightarrow \textnormal{sign}\left(g(x) - c \right) \text{a.e. in } \Omega \backslash \Theta\\
 	\end{align}
 	as $n \rightarrow \infty$.
 \end{lemma}

 \begin{lemma}(Convergence result) \label{lemma:convergence_result}
 	Let $\{x_n\}_{n \)in \N}$ be a sequence. If every subsequence of $\{x_n\}_{n \in \N}$ has a convergent subsequence to a common limit $x$, then the entire sequence converge to $x$.
 \end{lemma}

\begin{proof}
	Assume the sequence does not converge to $x$, then there must exist some subsequence of $\{x_n\}_{n \in \N}$ bounded away by $x$ by some $\epsilon > 0$. This subsequence cannot have a convergent subsequence to x, which is a contradiction.
\end{proof}

\begin{definition} (Embedding)

	For two normed spaces $X$,$Y$, an embedding
	\begin{equation}
		X \hookrightarrow Y
	\end{equation}
	is an injective bounded linear map. The map is thought of as an inclusion map from a subspace to a superspace, possibly under a different norm.
\end{definition}

%example
\begin{remark} (The space $\mathscr{C}\left([0,T],L^1\left(\R\right)\right)$) \label{rmk:arzela_C_space}
	We can define the Banach space
	\begin{equation}
		\mathscr{C}\left([0,T],L^1\left(\R\right)\right) = \{ \left f : [0,T] \mapsto L^1(\R) \right| f \text{ continuous } \}
	\end{equation}
	where the continuity is interpreted as continuity between metric
	spaces. In the topology of uniform convergence,
	\begin{equation}
		\norm{\cdot}_{\text{u}} = \max_{t \in [0,T]} \norm{\cdot}_{L^1(\R)},
	\end{equation}
	defines a norm. In fact, $\left(\mathscr{C}\left([0,T],L^1\left(\R\right)\right), \norm{\cdot}_{\text{u}}\right)$ is a Banach space.
	If we let $T > 0$ and $\Omega \subset [0,T] \times \R$ open, then

	\begin{equation}
		\left(\mathscr{C}\left([0,T],L^1\left(\R\right)\right), \norm{\cdot}_{\text{u}}\right) \hookrightarrow \left(L^1(\Omega), \norm{\cdot}_{L^1} \right)
	\end{equation}
	is an embedding. Let $f \in \mathscr{C}\left([0,T],L^1\left(\R\right)\right)$, then
	\begin{equation}
		\norm{f}_{L^1(\Omega)} = \iint_{\Omega} \left|\left(f(t)\right)(x) \right| dx dt \leq \int_0^T \norm{f}_{L^1\left(\R\right)}(t) dt \leq T \norm{f}_{u}.
	\end{equation}
	Therefore, $\hookrightarrow$ is a bounded. A bounded linear operator is continuous.
	%problem definedness,
\end{remark}

\subsection{Results from differentiable calculus and discrete difference rules}
We will however need some results for continously differentiable functions. A fundamental result in differentiable calculus is the mean value theorem

\begin{theorem}(The mean value theorem for $\C^{(1)}(\R)$-functions) \label{theorem:MVT}
	For any $f \in \mathscr{C}([a,b]) \cap \mathscr{C}^{(1)}((a,b))$ we have that

	\begin{equation} \label{MVT}
		\frac{f(b) - f(a)}{b-a} = \frac{df}{dx}(c)
	\end{equation}
	for some $c \in (a,b)$. As a function of the endpoints, $c$ is continuous.
\end{theorem}
\begin{proof}
	Found in \cite[p.142]{finney2000calculus}, using Rolle's theorem.
\end{proof}

The following result concern functions  differentiation under the integral sign.

\begin{theorem}(Leibniz rule for differentiation under the integral)

	\label{thm:leib_rule_int}
	Let  $f:\mathscr{R} x \mathscr{R} \rightarrow \mathscr{R}$ be a differentiable function such that $\frac{\partial f}{\partial t}(x,t)$
	is continuous on $\R\times\R$. Suppose that $a, b \in \C^{(1)}(\R)$. Then
	\begin{equation} \label{LeibRule}
		\frac{d}{dt}\int_{a(t)}^{b(t)} f(x,t) dx = - f(a(t),t) \frac{da}{dt}(t) + f(b(t),t) \frac{db}{dt}(t) + \int_{a(t)}^{b(t)}\frac{\partial f}{\partial t}(x,t) dx.
	\end{equation}
\end{theorem}

Formula is taken from
\begin{proof}
	See \cite[p.255]{kaplan1912advanced}.
\end{proof}

\begin{lemma}(The inverse function lemma in one dimension) \label{lem:IVT}

	Let $f : \R \mapsto \R$ be a continuously differentiable function with a non-zero derivative at $x \in \R$, then $f$ is differentiable in some neighbourhood $I \subset \R$ of $x$ and the inverse is continuously differentiable. In addition,
	\begin{equation} \label{lem:IVT_formula}
		(f^{-1})^{'}(f(x))= \frac{1}{f'(x)} \text{ for all } x \in I.
	\end{equation}
\end{lemma}

A proof can be found in \eqref{rudin1976principles}, p.221.

\begin{remark} \label{rmk:IVT_order}
	Furthermore, if $f \in \mathscr{C}^{(k)}(I)$ for some natural number $k \geq 1$, then $f^{-1} \in \mathscr{C}^{(k)}(f(I))$. $f(I)$ denotes the image of $I$ under $f$.  This can be proven by induction. By lemma \eqref{lem:IVT}, it holds for the base case $k = 1$. Assume it holds for some $\tilde{k} \in \N$ and consider \eqref{lem:IVT_formula}, rewritten as

	\begin{equation} \label{lem:IVT_formula2}
		(f^{-1})^{'}(f) f'(f^{-1}(f)})= 1 \text{ for all } f \in f(I).
	\end{equation}

	As $f \in \mathscr{C}^{(\tilde{k}+1)}$, then $f^{-1} \in \mathscr{C}^{(\tilde{k})}$, by the induction hypotesis. We can differentiate the left- and right-hand side if \eqref{lem:IVT_formula2} $\tilde{k}$ times using the chain rule and composition rule for differentiation. After differentiating $\tilde{k}$ times, we have an equation of the form

	\begin{equation}\label{rmk:IVT_formula3}
		(f^{-1})^{(\tilde{k})}(f) f^{'}(f^{-1}(f)) + H_{\tilde{k}}(f^{(1)},...,f^{(\tilde{k})}, g^1, ..., g^{(\tilde{k}-1)}) = 0 \text{ for all } f \in f(I).
	\end{equation}
	The $H_\tilde{k}$-term corresponds to some additive and multiplicative combination of continuously differentiable functions, and is therefore continuously differentiable. $H_\tilde{k}$ depends on order of differentiation $\tilde{k}$. By assumption, $f^{'}(x)$ is bounded away from zero on $I$ and is continuously differentiable, so we get an explicit expression for $(f^{-1})^{(\tilde{k})}(f)$,

	\begin{equation}\label{rmk:IVT_formula4}
		(f^{-1})^{(\tilde{k})}(f) = - \frac{H_{\tilde{k}}(f^{(1)},...,f^{(\tilde{k})}, g^1, ..., g^{(\tilde{k}-1)})}{f^{'}(f^{-1}(f))} \in \mathscr{C}^{(1)}({f(I)}),
	\end{equation}
	and $f^{-1} \in \mathscr{C}^{(\tilde{k}+1)}(f(I))$.
\end{remark}

\iffalse
A generalisation of the mean-value formula for a closed interval $[a,b]$ reads:
\begin{equation}\label{genMVT}
	\int_a^bf(x)g(x)dx = f(c) \int_a^b g(x) dx, c \in (a,b),
\end{equation}
where $f \in \mathscr{C}([a,b])$ and $g \in L_1([a,b])$, in the sense of lebesgue measure.

A Grönwall type estimate.
\newtheorem{theorem}[T
heorem]

\begin{lemma}{A simple Grönwall type estimate}
	\begin{equation}
		\frac{df}{dt} \leq A + B f \Rightarrow f(t) \leq \left( f(0) + \frac{A}{B}\right)e^{B t} - \frac{A}{B}.
	\end{equation}
\end{Lemma}
This can be proved using integrating factors and integrating on both sides.
\begin{align}
	\frac{df}{dt} &\leq A + B f  \nonumber \\
	\Rightarrow \frac{d \left(f e^{-Bt}\right)}{dt} &\leq A e^{-Bt}\nonumber \\
	\Rightarrow e^{-Bt}f(t) - f(0) &\leq \frac{A}{B}\left(1 - e^{-Bt}\right)\nonumber \\
	\Rightarrow f(t) &\leq \left( f(0) + \frac{A}{B}\right)e^{B t} - \frac{A}{B}. \qed
\end{align}
The preceding theorem holds for any absolutely continuous function, in particular it will hold for a Lipshchitz continuous functions.

\fi

The following formula is very simple, but will be used often.

\begin{formula}(Difference by parts)

	For $x_0, x_1,y_0, y_1 \in \R$,
	\begin{equation} \label{disc_diff_part1}
		x_1y_1 - x_0 y_0 = x_1 \left(y_1 - y_0\right) + y_0 \left(x_1 - x_0\right).
	\end{equation}
	This can be generalised to hold over finite sums over $\R$. Let $x_i, y_i \in \R$  for $i \in \{1,...,N\}$, and let $\Delta_+(x_i) = x_{i+1} - x_i$. Then

	\begin{equation} \label{disc_diff_part2}
		x_{N}y_{N} - x_{1}y_{1} = \sum_{i = 1}^{N-1} x_i \Delta_+(y_i) + \sum_{i = 1}^{N-1} y_{i+1}\Delta_+(x_i).
	\end{equation}
	The last formula can be seen from expanding the terms on the right, which yields a telescoping sum.
\end{formula}

\iffalse
$\mathscr{P} = \{\{x_0, ..., x_N\} \subset \R$ for $N \in \mathscr{N}$ | $x_0 < x_1 < ... < x_N \}$ is the set of ordered partition of $\R$. For $p \in \mathscr{P}$, define
\begin{equation}
    p(f) = \sum_{i=0}^{\vert p\vert -1} |f(x_{i+1}) - f(x_i)|,
\end{equation}
where $\vert p \vert$ denotes the cardinality of $p$.
\begin{equation}
    TV(f) := \sup_{p \in \mathscr{P}} p(f),
\end{equation}
\end{definition}
is the total variation of $f$. If supremum does not exist, we say that $TV(f) = \infty$. The space of functions with bounded total variation is denoted $BV(\R)$. This notion of BV can has several extensions to several dimensions.

\begin{equation}
TV(f)
\end{equation}
\fi

\section{Solution concepts for hyperbolic conservation laws in one dimension}

Consider the one-dimensional scalar conservation law

\begin{equation} \label{def:inhom_cons_law}
	\rho_t + (k(z)f(\rho))_z = 0,\quad \rho(z,0) = \rho_0(z)
\end{equation}
where $k \in \mathscr{C}^1(\R)$ and $f$ is Lipschitz continuous.
The solution concepts that will be used in the present paper are weak solutions and the Kružkov entropy solution. One of the prime motiviations for the weak solution concept is that classical solutions of \eqref{def:inhom_cons_law} develop discontinuities in finite time. One example of which is the Burgers's equation \cite[exampel 1.3][p.5]{holden2015front}. A classical solution concept does not allow for discontinuities. However, some discontinous solutions can be found to be physically permissible, such as shock waves see \cite[example1.4, p]{holden2015front}. The weak solution concept allows for discontinutites, and imposes the well-known jump condition on such discontinuities. p.9 \cite{holden2015front}.

A weak solution is a function $\rho \in L^1_{\text{loc}}(\R^+_0 \times \R) \cap L^\infty\left(\R^+_0 \times \R\right)$ which satisfies \eqref{def:inhom_cons_law} distributionally, in the following sense

%endre på alle småtinga (\R_0^+ \times \R)
\begin{definition}(Weak solution of space-dependent scalar conservation law)\label{def:weak_solution}

	Let $\rho \in L_{\text{loc}}^1(\R^+_0 \times \R) \cap L^\infty(\R^+_0 \times \R)$ satisfy

	\begin{equation} \label{def}
		\int_{\R_0^+}\int_{\R} \rho \phi_t + k(z) f(\rho) \phi_z dz dt + \int_{\R} \phi(z,0) \rho(z,0) dz= 0 \quad \forall \phi \in \mathscr{C}^\infty_c(\R^+_0 \times \R),
	\end{equation}
	then we call $\rho$ a weak solution of \eqref{def:inhom_cons_law}.
\end{definition}

An issue with the concept of weak solution is the fact they are not unique. For example,
\begin{numcases}{\rho(z,t) = }
	1 &\text{ for } z \leq (1-\alpha)t/2,  \nonumber\\
	-\alpha &\text{ for } (1-\alpha)t/2 < z   \leq 0,  \nonumber\\
	\alpha &\text{ for } 0 < z \leq \left(\alpha -1 \right) t/2, \nonumber\\
	-1 &\text{ for } z \geq \left(\alpha - 1\right)t/2 \nonumber
\end{numcases}
is a weak solution of
\begin{equation}
	\rho_t + \left(\frac{1}{2}\rho^2\right)_z = 0, \text{ for } \rho(z,t) = \begin{cases}
		1 \text{ for } z \leq 0,\\
		-1\text{ for } z >0,
	\end{cases}
\end{equation}
for all $\alpha \geq 1$. Which solution should be picked? Taken from exercise 1.9, page 49 in \cite{holden2015front}. The concept of mathematical entropy can be used restrict the number of feasible solution. One such notion is that of the Kružkov entropy solution

\begin{definition}(Kružkov entropy solution for space-dependent flux)

	Assume $k$ to be continously differentiable. Let  $c \in \R$. We call  $\rho \in L^1\left(\R^+_0 \times \R\right) \cap L^\infty\left(\R^+_0 \times \R\right)$ a weak- or Kružkov entropy solution, if it satisfies
	\begin{align}
		\partial_t \left|\rho - c\right| + \partial_z \left(k(z) \sgn( \rho - c ) \left(f(\rho) - f(c)\right)\right) + \text{sign}(\rho - c) k'(z) f(c) \leq 0,
	\end{align}
	in the distributional sense.  This means that for $\phi \in \mathscr{C}^\infty_c(\R^+_0 \times \R), \, \, \phi \geq 0$, then
	\begin{align} \label{entropy_sol}
		\int_{\R_0^+}&\int_{\R} \left|\rho - c\right| \phi_t + k(z) \sgn( \rho - c ) \left(f(\rho) - f(c)\right) \phi_z dz dt \\&+\int_\R \left| \rho(z,0) - c \right| dz \geq \int_{\R_0^+}\int_{\R}\text{sign}(\rho - c) k'(z) f(c) \phi dx dt.
	\end{align}
\end{definition}

The entropy solution is unique.

\begin{theorem}(Uniqueness of Kružkov entropy solution) \label{thm:kruzkov_uniqueness}
	Assume that $f$ is Lipschitz, and let $u,v \in L^1\left(\R^+_0 \times \R\right) \cap L^\infty\left(\R^+_0 \times \R\right)$ be weak solutions of \eqref{def:inhom_cons_law} for initial values $u_0$ and $v_0$. If both are Kružkov entropy solution, then
	\begin{equation}
		\norm{u(\cdot, t) - v(\cdot, t)}_{L^1} \leq \norm{u_0 - v_0}_{L^1}
	\end{equation}
	In particular, if $u_0 = v_0$, then u = v.
\end{theorem}

Theorem \eqref{thm:kruzkov_uniqueness} was given as exercise 2.7,c), 91, , and adjusts proposition 2.10, p.79.

\begin{remark}
	Under the stated assumptions for  Kružkov entropy solution is also a weak solution. An existence proof can be found in \cite{holden2015front}, theorem 8.21, p.812.
\end{remark}

\subsection{Existence and uniqeness of systems of ordinary differential equation}

The following theorem is included to ensure existence of the solution of the FtL model. Taken from 3.2.1 \cite{david2018ordinary}, page 82.
\begin{theorem}(Existence and uniqueness)

	Consider the cauchy problem

	\begin{equation} \label{IVP}
		\frac{dx}{dt} = F(x), \,\,\, x(0)  \in \R^d
	\end{equation}

	Let $U \subset \R^d$ be open and contain the initial data $x(0)$, and let F : $U \mapsto \R^d$ be locally Lipschitz. Then there exists and interval $(-\eta, \eta)$ and a $\mathscr{C}^1$ function x : $(-\eta, \eta) \mapsto U$ such that x solves \eqref{IVP}.

	The solution $x$ is unique.
\end{theorem}

\iffalse

 One can therefore introduce a

\begin{equation}
	\xi(\rho^{\epsilon})_t + k(x) \xi^{'}(\rho^{\epsilon}) f^{'}(\rho^{\epsilon})\rho^{\epsilon}_x + k^{'}(\rho^{\epsilon})(x)\xi^{'}f(\rho^{\epsilon}) = \epsilon \xi^{\rho}(\rho^{\epsilon}) \frac{\partial^2 \rho^\epsilon}{\partial^2x}.
\end{equation}

A smooth approximation to the identity, or mollifier, is a useful tool for creating smooth approximations. A mollifier can be defined as a function which satisfies

\begin{align}
\phi \ \in \mathscr{C}^{\infty}(\mathscr{R}^n) \\
\phi \geq 0
\text{sup}(\phi) :=
\end{align}

forklar hvorfor antakelsene er rimelige. hva veivesenet gjør.
\fi

\iffalse
\section{Differentiation Identities and Calculus}
A useful result in the manipulation of differences is splitting of the sum. For any pair of indexed quantities, $x_0, x_1,y_0, y_1$,
\begin{equation} \label{disc_diff_part}
    x_1y_1 - x_0 y_0 = x_1 \left(y_1 - y_0\right) + y_0 \left(x_1 - x_0\right).
\end{equation}
This can be generalised to hold over arbitrary sums. Let $x_i, y_i$ for $i \in \{1,...,N\}$, and let $\Delta_+(x_i) = x_{i+1} - x_i$. Then

\begin{equation} \label{discreteDiffPart}
    x_{N}y_{N} - x_{1}y_{1} = \sum_{i = 1}^{N-1} x_i \Delta_+(y_i) + \sum_{i = 1}^{N-1} y_{i+1}\Delta_+(x_i).
\end{equation}
Expanding the terms on the right yields a telescoping sum.

 CITE RUDIN.  The integral can be understood in Lebesgue sense.

The Mean-Value formula is a fundamental result in Calculus, and goes as follows.

\begin{}

Definition of a metric

inverse function theorem

the fundamental theorem of calculus

Proof:

FUBINIS THEOREM

In the following I will add a technical result that will prove useful in the discussion of the weak entropy solution

FAST L1 convergers implies convergence almost everywhere and almost uniformly convergernce.

\begin{}

We can always pick a subsequence to obtain fast L1 convergence, and hence L1 convergence almost everywhere.
Note that it does not hold that L1 converegnce implies almost everywhere convergence. But we can always find a subsequence which converges.

List of assumptions:
- k is C2, constant outside of of some ball of finite radius. The total variation of k and k' are bounded. k in L^\infty
- V is bi-lipschitz, with the same things holding as in the article.
-

the mean value formula

for example
Differentiation under the integral sign is

The corresponding continuous variant is given a

% \begin{cases}
% \f^{(k)}(x)
% \end{cases}

$\mathscr{C}$
smooth with compact support,and therefore their convolution with any element function $f \in \$L_loc(\Omega)$A useful tool for function smoothing and approximation are the mollifier class of functions. The standard mollifier,

Hysteresis?

\section{On the microscopic and macroscopic models}

The microscopic model is a collection of models that base around the fact that
\begin{align}
    \overset{z_{i-1/2}}{\cdot}_{i-1/2} = V\left(\frac{l}{z_{i+1/2} - z_{i-1/2}}\right)
\end{align}
was first introduced by pipes [1953], a modification of which will be considered in this assignment. Other variants can be introduced as well. The second order models

Operate on different kinds of aggregation levels.

Microscopic models
From traffic and pedestrian follow-the-leader models with reaction time to first order convection-diffusion flow models:  - "Follow the leader models have many variants. One could consider accelration functions which".

Macroscopid models differ from the microscopic model in that the dynamical quantities of interest are locally aggregated. [Martin Trieberg] Instead of focusing on eavh vehicle, one instead consideres traffic density $\rho(x,t)$, the flow density $Q(x,t)$, the mean speed $V(x,t)$.

In physics, many quantities can be described aptly within the framework of conservation laws. A differential conservation law is an constitutive equation for a system which essentially states that for field quantities, such as density and density flux.  hyperoblic conservation law, or a Transport phenomena.
\begin{equation} \label{conservation_law}
    \frac{\partial \rho }{\partial t } + \text{div}(f) = 0
\end{equation}
The equation states that in some fixed region of space, the net change in mass in any fixed region of space must cancel the net flow of mass across the boundary.
The macroscopic traffic models are precisely those cast in the form of \eqref{conservation_law}. The model we will consider in are the celebrated LWR-model

begin{equation}

\label{conservation_law}
    \frac{\partial \rho }{\partial t } + \text{\rho v\left(\rho\right)}(f) = 0
\end{equation}

mass across the region, modeled respectively by the first and second term.

IverSON BRACKET!

The variables are surpressed
Thus, macroscopic models are able to describe.

My model:
- One of the simplest approach is a speed model solely based on the spacing,firstly proposed by Pipes

Macroscopic models:

The fundamental diagram is concave

Our case corresponds to congested traffic?

LWR refers to a whole
class of models.

Why macroscopic models are useful.
    - Can describe collective phenomenon
    - only interested in macroscopic quantities
    - Computation time of simulation is critical.
More can be found in Martin Treiber • Arne Kesting, Traffic Flow dynamics.
\fi

\section{Notation table}

\begin{tabular}{r c p{10cm} }
	\toprule
	$\rightarrow$ & $\triangleq$ & General convergence, should be specified.\\
	$\rightrightarrows$ & $\triangleq$ & everywhere uniform convergence $i$.\\
	$f_j$ & $\triangleq$ & $f(z_j)$ for any function that takes an indexed argument.\\
	$\Delta_+(x_i)$ & $\triangleq$ & $x_{i+1} - x_{i}$ The forward difference operator.\\
	$D_+(x_i)$ & $\triangleq$ & $\frac{x_{i+1} - x_{i}}{l}$ The forward difference divided by the car length.\\
	$D_+^z(x_i)$ & $\triangleq$ & $\frac{x_{i+1} - x_{i}}{z_{i+1/2}-z_{i-1/2}}$ The forward difference divided by bumper-to-bumper distance.\\
	$[\cdot]$ & $\triangleq$ & The Iverson bracket. Evaluates to 1 if true and 0 if false. Alternative notation for the indicator function.\\
	\multicolumn{3}{c}{}\\
	\multicolumn{3}{c}{\underline{Function spaces}}\\
	\multicolumn{3}{c}{}\\
	$\mathscr{C}(\Omega)$ & $\triangleq$ & The space of continuous functions on $\Omega$.\\
	$\mathscr{C}^{0,1}(\Omega)$ & $\triangleq$ & The space of Lipschitz continuous functions on $\Omega$.\\
	$\mathscr{C}}^{(k)}(\Omega)$ & $\triangleq$ & The space of continuously differentiable functions on $\Omega$.\\
$\mathscr{C}^\infty(\Omega) & \triangleq$ & $\bigcap_{i=0}^{\infty} \mathscr{C}^{(k)}(\Omega)$\\
$\mathscr{C}_c(\Omega)$ & $\triangleq$ & The space of continuous functions with compact support.\\
$\mathscr{C}_c^{(k)}(\Omega)$ & $\triangleq$ & $\mathscr{C}^{(k)}(\Omega) \cap \mathscr{C}_c(\Omega)$\\
$\mathscr{C}_c^\infty(\Omega)$ & $\triangleq$ & $\mathscr{C}^{\infty}(\Omega) \cap \mathscr{C}_c(\Omega)$\\
$\text{B.V.}(\Omega)$ & $\triangleq$ & The space of functions with bounded total variation.\\
$\text{T.V.}_x(f)$ & $\triangleq$ & Returns the total variation of $f$ in the $x-$ direction.\\
$L^1(\Omega)\right)$ & $\triangleq$ & The space of integrable functions on $\Omega$.\\
$\mathscr{C}\left([0,T], L^1(\R)\right)$ & $\triangleq$ & The space of continuous functions from $[0,T]$ to $L^1(\R)\right)$.

\multicolumn{3}{c}{}\\
\multicolumn{3}{c}{\underline{Miscellaneous}}\\
\multicolumn{3}{c}{}\\
$\interior{X}$ & $\triangleq$ & The interior of the set $X$.  \\
$\R$ & $\triangleq $ & The real line. \\
$\N$ & $\triangleq $ & The natural numbers. \\
$\mathscr{Z}$ & $\triangleq $ & The integers. \\
$\R^+_0$ & $\triangleq $ & The interval $[0, \infty).$ \\
$X \times Y$ & $\triangleq$ & The cartesian product of X and Y. \\
\bottomrule
\end{tabular}

\iffalse
Over the years, several thesis templates for \LaTeX{} have been developed by different groups at NTNU. Typically, there have been local templates for given study programmes, or different templates for the different study levels – bachelor, master, and \acrshort{phd}.\footnote{see, e.g., \url{https://github.com/COPCSE-NTNU/bachelor-thesis-NTNU} and \url{https://github.com/COPCSE-NTNU/master-theses-NTNU}}

Based on this experience, the \acrfull{CoPCSE}\footnote{\url{https://www.ntnu.no/wiki/display/copcse/Community+of+Practice+in+Computer+Science+Education+Home}} is hereby offering a template that should in principle be applicable for theses at all study levels. It is closely based on the standard \LaTeX{} \texttt{report} document class as well as previous thesis templates. Since the central regulations for thesis design have been relaxed – at least for some of the historical university colleges now part of NTNU – the template has been simlified and put closer to the default \LaTeX{} look and feel.

The purpose of the present document is threefold. It should serve (i) as a description of the document class, (ii) as an example of how to use it, and (iii) as a thesis template.

\fi


%\documentclass{sig-alternate}
\documentclass{llncs}
\usepackage{amsmath,amssymb,graphicx}
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{standalone}
\usepackage{algorithmic}
\usepackage{mdwlist}
\usepackage{color}
\usepackage{multirow}
\usepackage{rotating}
\usepackage{amsmath}
\usepackage[mathscr]{eucal} %% For \mathscr
\usepackage{amsbsy} %% For \boldsymbol
\newcommand{\T}[1]{\boldsymbol{\mathscr{#1}}}
\usepackage{booktabs}
\usepackage{tikz}
\usetikzlibrary{snakes}
\usepackage{multirow}
\usepackage{epstopdf}
\usepackage{enumitem}
\usepackage{url}
\usepackage{array}
\usepackage{pdfpages}
\setlist{nolistsep}
\newcommand{\hide}[1]{}
\usepackage{caption}
\usepackage[font={footnotesize}]{subcaption}
\captionsetup{compatibility=false}
\DeclareCaptionType{copyrightbox}
\DeclareMathOperator*{\argmin}{argmin}
\DeclareMathOperator*{\argmax}{argmax}
\newcommand{\reminder}[1]{ {\color{red} {\bf  #1} } }
\newcommand{\BigO}[1]{\ensuremath{\operatorname{O}\bigl(#1\bigr)}}

\title{Binomial and Fibonacci Heaps in Racket (rkt-heaps)}

\begin{document}

\author{
	Abhinav Jauhri\\
	\texttt{abhinavjauhri@gmail.com}\\
}

\maketitle

\begin{abstract}
	Library\footnote{A software package and will be referred as $rkt-heaps$ throughout the paper} providing data structures viz. Binomial heap \cite{vuillemin1978data} and Fibonacci heap\cite{fredman1987fibonacci} is described with primitive operations, performance and usage.
\end{abstract}

\section{Introduction}
%\vspace{-0.1in}
$rkt-heaps$\footnote{Source code - https://github.com/ajauhri/rkt-heaps} was made for demonstration in a contest, \textit{Lisp In Summer Projects}\footnote{http://lispinsummerprojects.org/}. Any participant was expected to develop one or many applications, or libraries, using any LISP-based technology. $rkt-heaps$ uses Racket, a dialect of the Lisp language and based on the Scheme branch of the Lisp family \cite{racket_dialect}.

\emph{Section 1 \& 2} describe Binomial and Fibonacci heaps respectively. \emph{Section 3} has performance results\footnote{Higher resolution images for all figures in this paper can be found at https://www.dropbox.com/sh/ms78nrkp0n8qh7p/G-SDznIfrc} to show $rkt-heaps$ correspond to run-time bounds, as shown in literature. Comparison with an existing library for Binary heaps\cite{racket_binary} in Racket is added to observe any runtime improvements in practice for operations which have similar run-time bounds in theory. \emph{Section 4} has conclusions and author's learnings. \emph{Appendix} includes syntactics of using this library in Racket.

\section{Binomial Heaps}
Binomial heaps are a collection of heap-ordered Binomial trees with a pointer $min$ to the root of a tree having the minimum value amongst all elements in the heap. Primitive operations described in \cite{kozen1992design} are as follows: \\

\begin{enumerate}
	\item \emph{makeheap(i)} Makes a new heap with one element $i$
	\item \emph{findmin(h)} Returns the minimum value in the heap $h$
	\item \emph{insert(h, i)} Adds element $i$ to heap $h$
	\item \emph{deletemin(h)} Deletes the element with minimum value from heap $h$
	\item \emph{meld(h, h')} Combines two heaps $h$ and $h'$ into one \\
\end{enumerate}

\begin{table}
	\centering
	\begin{tabular}{| >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} |}
		\hline
		\centering
		Operation & Amortized Cost \\
		\hline
		makeheap & \BigO{1} \\[1ex]
		findmin & \BigO{1} \\ [1ex]
		insert & \BigO{1}  \\ [1ex]
		deletemin & \BigO{\log n} \\ [1ex]
		meld (eager) & \BigO{\log n}\\ [1ex]
		meld (lazy) & \BigO{1} \\ [1ex] \hline
	\end{tabular}
	\vspace{2mm}
	\caption{Amortized costs for Binomial Heaps}
	\label{tab:binomialcost}
\end{table}

Before studying costs and implementation of the above mentioned operations, explanations for certain technical terms may be helpful for the reader.
\begin{enumerate}
	\item $Amortized\hspace{2mm} cost$ - Amortization analysis includes cost of a sequence of operations spread over the entire sequence\cite{kozen1992design}. Amortized costs may not always give the exact cost of an operation. An operation may be expensive or cheaper, but the average cost over a sequence of operations is small and defined as amortized cost.
	\item $rank$ - States the number of children of an element. For example, a Binomial tree, the tree size is $2^k$ with root at some element $e$ having rank $k$. \\
\end{enumerate}

Making a new heap with one element - $makeheap$, and using the $min$ pointer to get the minimum value - $findmin$, both require constant number of steps.

Insertion of a value is equivalent to making a heap, $h_1$, with a single element and then melding $h_1$ with an existing heap, $h_2$. At each step of a meld, two trees having the same rank are considered. It could be the case that either $h_1$ or $h_2$ have a tree of size $2^k$ (rank $k$), or neither have one. When two trees are combined, the resulting tree is of rank $(k+1)$. If a tree with rank $(k+1)$ already exists in either of the heaps - $h_1$ or $h_2$, then a tree of rank $(k+2)$ is made. This happens continuously till there is single tree of some rank $(>k)$ in the resulting heap, $h_{1,2}$. At the end of meld, $h_{1,2}$ has only one or no tree of size $2^i$, such that $0\le i \le \log_2 s$, where $size(h_{1,2})=s$ The heap property\footnote{Heap property ensures that all children of a tree rotted at $r$ have their values ordered with its parent's value and that the same ordering applies across the heap} is imposed each time roots of two trees are combined. For intuition on why $insert$ is \BigO{1} amortized cost consider a Binomial heap having only one tree with rank $2$. There will be no requirement to combine another tree of rank $2$ until $3$ elements have been inserted for trees with sizes $2^0$ and $2^1$.

The technique of meld can be extended for $deletemin$ operation also; take all children of the min element and meld them with the remaining trees in the heap, and update the min pointer, costing \BigO{\log n}. For a more detailed amortized analysis, refer \cite{kozen1992design}.

$meld$ eager version works in the manner as described above but for the lazy version, all roots of one heap are added to the set of roots of the other heap. This may result in more than one binomial tree of rank $k$ in the resulting heap. Any subsequent call to a $deletemin$ operation will correct the heap such that only one binomial tree of rank $k$ exists with cost in order of \BigO{\log n}.

Binomial heap in $rkt-heaps$ is an array-based purely functional implementation leveraging Racket's $vector$ library. Purely functional ensures there are no mutations of previously created data structures. Although, this leads to anomalies in runtime costs for certain operations like \emph{insert}. With reference to Table \ref{tab:binomialcost}, the total cost for $n$ inserts is linear - \BigO{n}; but in a purely functional implementation, the insert operation cost for $n$ inserts aggregates to \BigO{n^2}. The reason for such an anomaly is due to cloning of heap vector at every insert operation. This is validated in Fig:\ref{fig:bino_anomaly}. The curve \emph{binomial-insert (quadratic)} signifies the divisor(total expected cost) for the dividend(total time) is quadratic, and hence the slope of the curve does not linearly increase with $n$. Since, it is amortized cost the curve will have high and low peaks instead of slope being almost zero\footnote{The ratio of the actual cost to the value expected is constant. In other words, if the cost of doing $blah$ with $foo$ data structure is \BigO{n^2}, then the ratio is $Cost_{Actual} / n^2$ should be constant}. Alternatively, taking the divisor as linear, the total run-time cost depicts a curve with slope due to increase in cost of cloning the vector, which is to say that $nth$ insertion step clones the $(n-1)th$ heap vector\footnote{Racket's vector API provides \emph{(vector-append $v_1 v_2$ \dots)}, used for cloning, makes fresh copy of all elements of given vectors}. Modifying the structuring of the heap to a doubly linked list (DLL) wherein all roots of trees have pointers to its right and left root elements is imperative to ensure constant number of steps for each insert (used for analyzing run-time costs in \cite{kozen1992design}). The DLL implementation and cost shall be discussed in later sections of this paper.

\begin{figure}
	\begin{subfigure}{0.5\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{FIG/insert_binomial_linear.pdf}
		\caption{Total expected cost = \BigO{n}}
		\label{fig:bino_anomaly_linear}
	\end{subfigure}%
	\begin{subfigure}{0.5\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{FIG/insert_binomial_quad.pdf}
		\caption{Total expected cost = \BigO{n^2}}
		\label{fig:bino_anomaly_quad}
	\end{subfigure}
	\caption{Anomaly with pure functional impelementation of Binomial heaps}
	\label{fig:bino_anomaly}
\end{figure}

\section{Fibonacci Heaps}
Fibonacci heaps are a generalization of Binomial heaps. In addition to the operations provided by Binomial heaps, Fibonacci heaps provide a couple more operations. Specifically, they allow deletion of any element from the heap, and modification of value of any element provided the user has a pointer to the element. The prototypes for additional operations are as follows: \\

\begin{enumerate}
	\item \emph{decrement(h, i, $\delta$)} Decrements the value of element $i$ by $\delta$ in $h$
	\item \emph{delete(h, i)} Deletes element $i$ from the heap $h$
\end{enumerate}

\begin{table}
	\centering
	\begin{tabular}{| >{\centering\arraybackslash}m{1in} | >{\centering\arraybackslash}m{1in} |}
		\hline
		\centering
		Operation & Amortized Cost \\
		\hline
		\rule{0pt}{3ex}makeheap & \BigO{1}    \\ [1ex]
		findmin & \BigO{1} \\  [1ex]
		insert & \BigO{1}  \\  [1ex]
		deletemin & \BigO{\log n} \\ [1ex]
		meld (lazy) & \BigO{1} \\ [1ex]
		decrement & \BigO{1} \\ [1ex]
		delete & \BigO{\log n}\\ [1ex] \hline
	\end{tabular}
	\vspace{2mm}
	\caption{Amortized costs for Fibonacci Heaps}
	\label{tab:fibonaccicost}
\end{table}

Fibonacci heaps are implemented in $rkt-heaps$ using a DLL for its roots. Findings from array and functional based implementation of Binomial heaps, highlight the downsides of not having mutations which leads to much higher costs for performing primitive operations in contrast to what has been proved in literature. For this reason, Fibonacci heaps do not have a purely functional implementation in $rkt-heaps$.

A Fibonacci heap after creation, if operated with only $deletemin$ and $meld$ operations, becomes a Binomial heap. Thus the corollary that size of tree rooted at $r$ is exponential in $rank(r)$. The exponential size of a tree is also valid when the Fibonacci heap is operated upon with $decrement$ and $delete$ operations cutting sub-tress in a controlled fashion\cite{kozen1992design}. This fact is essential to analyze amortized costs to be \BigO{1} and \BigO{\log n} for $decrement$ and $delete$ operations respectively.

$decrement$ operation mutates the value of the element, $e$, followed by check with its parent, $p_e$, on whether the heap property is violated or not. If it is, then the sub-tree rooted at element $e$, is added to the DLL of the heap. Every parent, starting at $p_e$ is also added to DLL if a boolean flag is marked. This happens till either a root element or an element which does not have the flag marked is reached while traversing up the tree from $e$. This boolean flag is maintained for every element $e_i$, except root elements, and marked as true if one of its children have been removed or false otherwise. A sub-tree rooted at $e_i$ shall only be cut from its parent and added to DLL if a second child of $e_i$ is removed i.e. the parent element is marked and a decrement operation on a child violates the heap property or a child is deleted.

$delete$ makes the value of the element to be deleted less than the $min$ value of the heap by means of $decrement$ and then calls $deletemin$. This costs \BigO{\log n}.

\section{Evaluation}
In this section, comparisons are omitted between Binomial and Fibonacci heaps since one is purely functional and other is not. The functional technique was inefficient due to cloning of vectors as shown in Section $2$. It is trivial to build on the Fibonacci heap implementation by excluding the $decrement$ and $deletemin$ operations to get a Binomial heap with lazy melds\cite{kozen1992design} at the same cost as shown for Fibonacci heaps in this section.

Fibonacci heap performance for operatios viz. $insert$ and $meld$ are shown in Figure \ref{fig:fi_insert_meld}. The $insert$ curve has mountainous terrain as it is the amortized total expected cost. For $meld$ the curve does not validate the fact that total expected cost should be \BigO{n}. This could be probably be due to garbage collection in Racket or some underlying implementation for creating $structures$. More work needs to be done to validate the exact cause.

\begin{figure}
	\begin{subfigure}{0.5\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{FIG/fi_insert.pdf}
		\caption{Total expected cost = \BigO{n}}
		\label{fig:fi_insert}
	\end{subfigure}%
	\begin{subfigure}{0.5\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{FIG/fi_meld.pdf}
		\caption{Total expected cost = \BigO{n}}
		\label{fig:fi_meld}
	\end{subfigure}
	\caption{Fibonacci Heaps -  (a) $insert$ and (b) $meld$ operations}
	\label{fig:fi_insert_meld}
\end{figure}

As stated before, $delete$ involves a call to $decrement$ to mutate the value of the node less than the $min$ value in the heap, and subsequently to $deletemin$. In Figure \ref{fig:fi_delete}, there is a very gradual increase in the slope of the curve. This is probably due to the increase in the constant, \BigO{1}, number of steps by $decrement$ operation exceeding the \BigO{\log n} number of steps by $deletemin$. It should be noted that for benchmarking a heap $h$ of size $n$, the $delete$ operation is called $n$ times, and state of $h$ is maintained in-between all $delete$ operations. To find an element to be deleted, a simple random walk is performed on $h$. Algorithm \ref{alg:rand_walk} states the random walk procedure. Therefore, for decrement operation which recursively removes parents while traversing up the graph, there is a high chance that the length of path traversed is positively correlated to number of calls to $delete$ operation $h$. As a consequence, constant cost of $decrement$ increases and thereby making the ratio of total time over total expected cost to increase with $n$ for $delete$ operation.

\begin{algorithm}[!ht]
	\caption{Random Walk for Fibonacci heap $H_f$}
	\label{alg:rand_walk}
	\begin{algorithmic}[1]
%\scriptsize
		\REQUIRE A valid fibonacci heap $H_f$ of size $S_{H_f}$
		\STATE Using the fact that the rank of $H_f \le \log_{\phi}S_{H_f}$, where $\phi$ is Golden Ratio\cite{dunlap1997golden}, uniformly select a root element, $e_{current}$
		\STATE $r:=rank(e_{current})$
		\STATE $d:=F_{r+2}$ where $F_i$ is the ith Fibonacci number
		\WHILE {$not\_leaf\_node(e_{current})$ and $depth(e_{current})\le d$}
		\STATE Select uniformly a child $c$, from the set of children of $e_{current}$
		\STATE $e_{current}:=c$
		\ENDWHILE
		\RETURN $e_{current}$
	\end{algorithmic}
\end{algorithm}

\begin{figure}
	\begin{subfigure}{0.5\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{FIG/fi_delete.pdf}
		\caption{Total expected cost = \BigO{n \log n}}
		\label{fig:fi_delete}
	\end{subfigure}%
	\begin{subfigure}{0.5\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{FIG/fi_decrement.pdf}
		\caption{Total expected cost = \BigO{n}}
		\label{fig:fi_decrement}
	\end{subfigure}
	\caption{Fibonacci Heaps - (a) $delete$ and (b) $decrement$ operations.}
	\label{fig:fi_delete_decrement}
\end{figure}

Pre-packaged library for Binary heap in Racket is compared with Fibonacci implementation of $rkt-heaps$ on operations which have equal expected time bounds viz. $findmin$(Figure \ref{fig:findmin}) and $deletemin$(Figure \ref{fig:deletemin}). The reasons for the variability at $n\ge80,000$ in Figure \ref{fig:findmin} and for $n\le40,000$ in Figure \ref{fig:deletemin} are unknown. Fibonacci heaps outperforms Binary heaps in both operations. The equivalent operations in Binary heap library are called as $heap-min$ and $heap-remove-min$.

\begin{figure}
	\begin{subfigure}{0.5\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{FIG/findmin.pdf}
		\caption{Total expected cost = \BigO{n}}
		\label{fig:findmin}
	\end{subfigure}%
	\begin{subfigure}{0.5\textwidth}
		\centering
		\includegraphics[width=0.8\linewidth]{FIG/deletemin.pdf}
		\caption{Total expected cost = \BigO{n \log n}}
		\label{fig:deletemin}
	\end{subfigure}
	\caption{Binary Heaps vs Fibonacci Heaps - (a) $findmin$ and (b) $deletemin$ operations.}
	\label{fig:fi_bi_comp}
\end{figure}

\section{Conclusions}
In this paper:
\begin{itemize}
	\item Binomial heaps included in $rkt-heaps$ do not run in expected time since they have been implemented in a functional style
	\item $rkt-heaps$ provide an efficient implementation of Fibonacci heaps using doubly linked lists (DLL)
	\item Fibonacci heaps perform better than Binary heaps (with the existing Racket library implementation) for comparable operations
	\item Fibonacci heaps can be easily extended to work as Binomial heaps, although this approach may not be purely functional
\end{itemize}

\subsection{Author's learnings}
Initially, this work was started using mit-scheme but later it was migrated to Racket as there was better support for generation of graphs, testing and debugging. Over the course of this project, a few learnings were achieved:
\begin{itemize}
	\item Run-time graphs\footnote{Thanks to Dhruv Matani (http://dhruvbird.com) for his inputs in making graphs more meaningful} are essential to ascertain whether algorithms were performing correctly, as stated in literature
	\item Pure functional implementations can be slow
    \item A mutation can depend on other mutations, hence sequence of mutations is important for correctness of an operation
\end{itemize}

\bibliographystyle{plain}
\bibliography{BIB/refs.bib}

\newpage
\appendix
\includepdf[pages={-}]{binomial.pdf}
\includepdf[pages={-}]{fibonacci.pdf}
\newpage
\end{document}