%!TEX root = forallxyyc.tex
\part{Metateoria}
\label{ch.normalform}
\addtocontents{toc}{\protect\mbox{}\protect\hrulefill\par}

\chapter{Formas normais e expressividade}

\section{Disjunctive Normal Form}\label{s:DNFDefined}

Sometimes it is useful to consider sentences of a particularly simple form. For instance, we might consider sentences in which $\enot$ only attaches to atomic sentences, or those which are combinations of atomic sentences and negated atomic sentences using only $\eand$.  A relatively general but still simple form is that where a sentence is a disjunction of conjunctions of atomic or negated atomic sentences.  When such a sentence is constructed, we start with atomic sentences, then (perhaps) attach negations, then (perhaps) combine using $\eand$, and finally (perhaps) combine using~$\eor$.

Let's say that a sentence is in \define{disjunctive normal form} \emph{iff} it meets all of the following conditions:
	\begin{earg}
		\item[(\textsc{dnf1})] No connectives occur in the sentence other than negations, conjunctions and disjunctions;
		\item[(\textsc{dnf2})] Every occurrence of negation has minimal scope (i.e.\ any `$\enot$' is immediately followed by an atomic sentence);
		\item[(\textsc{dnf3})] No disjunction occurs within the scope of any conjunction.
	\end{earg}
\newglossaryentry{disjunctive normal form}{
  name = disjunctive normal form (DNF),
  text = disjunctive normal form,
  description = {a sentence which is a disjunction of conjunctions of atomic sentences or negated atomic sentences}
}
So, here are are some sentences in disjunctive normal form:
\begin{align*}
  & A \\
  & (A \eand \lnot B \eand C)\\
  & (A \eand B) \eor (A \eand \enot B)\\
  & (A \eand B) \eor (A \eand  B \eand C \eand \enot D \eand \enot E)\\
  & A \eor (C \eand \enot P_{234} \eand P_{233} \eand Q) \eor \enot B
\end{align*}
Note that we have here broken one of the maxims of this book and \emph{temporarily} allowed ourselves to employ the relaxed bracketing-conventions that allow conjunctions and disjunctions to be of arbitrary length. These conventions make it easier to see when a sentence is in disjunctive normal form. We will continue to help ourselves to these relaxed conventions, without further comment.

To further illustrate the idea of disjunctive normal form, we will introduce some more notation. We write `$\pm\meta{A}$' to indicate that $\meta{A}$ is an atomic sentence which may or may not be prefaced with an occurrence of negation. Then a sentence in disjunctive normal form has the following shape:
	$$(\pm \meta{A}_1 \land \ldots \land \pm \meta{A}_i) \lor (\pm \meta{A}_{i+1} \land \ldots \land \pm\meta{A}_j) \lor \ldots \lor (\pm\meta{A}_{m+1} \land \ldots \land \pm \meta{A}_n)$$
We now know what it is for a sentence to be in disjunctive normal form. The result that we are aiming at is:
	\factoidbox{\label{thm:dnf}\textbf{Disjunctive Normal Form Theorem.} For any sentence, there is a logically equivalent sentence in disjunctive normal form.
	}
Henceforth, we will abbreviate `Disjunctive Normal Form' by `DNF'.

\section{Proof of DNF Theorem via truth tables}
\label{s:DNFTruthTable}

Our first proof of the DNF Theorem employs truth tables. We will first illustrate the technique for finding an equivalent sentence in DNF, and then turn this illustration into a rigorous proof.

Let's suppose we have some sentence, $\meta{S}$, which contains three atomic sentences, `$A$', `$B$' and `$C$'. The very first thing to do is fill out a complete truth table for $\meta{S}$. Maybe we end up with this:
\begin{center}
\begin{tabular}{c c c | c}
$A$ & $B$ & $C$ & $\meta{S}$\\
\hline
 T & T & T & T \\
 T & T & F & F \\
 T & F & T & T \\
 T & F & F & F \\
 F & T & T & F \\
 F & T & F & F \\
 F & F & T & T \\
 F & F & F & T
\end{tabular}
\end{center}
%Now, consider a sentence, whose only connectives are negations and conjunctions, where no connective occurs within the scope of any negation, e.g.:
%	$$A \eand \enot B \eand C$$
%This sentence is true when, and only when, `$A$' is true, `$B$' is false and `$C$' is true. Similarly, the sentence:
%	$$\enot A \eand \enot B \eand C$$
%this is true when, and only when, `$A$' is false, `$B$' is false and `$C$' is true.
%
%A disjunction is true when, and only when, at least one of the disjuncts is true. So if we write down a disjunction of sentences of the above form, perhaps
%	$$(A \eand \enot B \eand C) \eor (\enot A \eand \enot B \eand C)$$
%then it will be true on exactly \emph{two} lines of the truth table which describes all possible valuations of `$A$', `$B$' and `$C$'.
%
As it happens, $\meta{S}$ is true on four lines of its truth table, namely lines 1, 3, 7 and 8. Corresponding to each of those lines, we will write down four sentences, whose only connectives are negations and conjunctions, where every negation has minimal scope:
	\begin{earg}
		\item  `$A \eand B \eand C$'\hfill which is true on line 1 (and only then)
		\item `$A \eand \enot B \eand C$' \hfill which is true on line 3 (and only then)
		\item `$\enot A \eand \enot B \eand C$' \hfill which is true on line 7 (and only then)
		\item `$\enot A \eand \enot B \eand \enot C$' \hfill which is true on line 8 (and only then)
	\end{earg}
We now combine all of these conjunctions using~$\eor$, like so:
$$(A \eand B \eand C) \eor (A \eand \enot B \eand C) \eor (\enot A \eand \enot B \eand C) \eor (\enot A \eand \enot B \eand \enot C)$$
This gives us a sentence in DNF which is true on exactly those lines where one of the disjuncts is true, i.e.\ it is true on (and only on) lines 1, 3, 7, and 8. So this sentence has exactly the same truth table as $\meta{S}$. So we have a sentence in DNF that is logically equivalent to $\meta{S}$, which is exactly what we wanted!

Now, the strategy that we just adopted did not depend on the specifics of $\meta{S}$; it is perfectly general. Consequently, we can use it to obtain a simple proof of the DNF Theorem.

Pick any arbitrary sentence, $\meta{S}$, and let $\meta{A}_1, \ldots, \meta{A}_n$ be the atomic sentences that occur in $\meta{S}$. To obtain a sentence in DNF that is logically equivalent $\meta{S}$, we consider $\meta{S}$'s truth table. There are two cases to consider:
	\begin{enumerate}
		\item \emph{$\meta{S}$ is false on every line of its truth table.} Then, $\meta{S}$ is a contradiction. In that case, the contradiction $(\meta{A}_1 \eand \enot \meta{A}_1)$ is in DNF and logically equivalent to~$\meta{S}$.

		\item \emph{$\meta{S}$ is true on at least one line of its truth table.}
		For each line $i$ of the truth table, let $\meta{B}_i$ be a conjunction of the form
		$$(\pm\meta{A}_1 \land \ldots \land \pm\meta{A}_n)$$
		where the following rules determine whether or not to include a negation in front of each atomic sentence:
			\begin{align*}
				\meta{A}_m\text{ is a conjunct of }\meta{B}_i&\emph{ iff }\meta{A}_m\text{ is true on line }i\\
				\enot\meta{A}_m\text{ is a conjunct of }\meta{B}_i&\emph{ iff }\meta{A}_m\text{ is false on line }i
			\end{align*}
		Given these rules, $\meta{B_i}$ is true on (and only on) line $i$ of the truth table which considers all possible valuations of $\meta{A}_1, \ldots, \meta{A}_n$ (i.e.\ $\meta{S}$'s truth table).

		Next, let $i_1$, $i_2$, \dots, $i_m$ be the numbers of the lines of the truth table where $\meta{S}$ is \emph{true}. Now let $\meta{D}$ be the sentence:
		$$\meta{B}_{i_1} \eor \meta{B}_{i_2} \eor \ldots \eor \meta{B}_{i_m}$$
		Since $\meta{S}$ is true on at least one line of its truth table, $\meta{D}$ is indeed well-defined; and in the limiting case where $\meta{S}$ is true on exactly one line of its truth table, $\meta{D}$ is just $\meta{B}_{i_1}$, for some $i_1$.

		By construction, $\meta{D}$ is in DNF. Moreover, by construction, for each line~$i$ of the truth table: $\meta{S}$ is true on line $i$ of the truth table \emph{iff} one of $\meta{D}$'s disjuncts (namely, $\meta{B_i}$) is true on, and only on, line $i$. Hence $\meta{S}$ and $\meta{D}$ have the same truth table, and so are logically equivalent.
	\end{enumerate}
	These two cases are exhaustive and, either way, we have a sentence in DNF that is logically equivalent to $\meta{S}$.

So we have proved the DNF Theorem. Before we say any more, though, we should immediately flag that we are hereby returning to the austere definition of a (TFL) sentence, according to which we can assume that any conjunction has exactly two conjuncts, and any disjunction has exactly two disjuncts.

\section{Conjunctive Normal Form}
\label{s:CNF}

So far in this chapter, we have discussed \emph{disjunctive} normal form. It may not come as a surprise to hear that there is also such a thing as \emph{conjunctive normal form} (CNF).

The definition of CNF is exactly analogous to the definition of DNF. So, a sentence is in CNF \emph{iff} it meets all of the following conditions:
	\begin{earg}
		\item[(\textsc{cnf1})] No connectives occur in the sentence other than negations, conjunctions and disjunctions;
		\item[(\textsc{cnf2})] Every occurrence of negation has minimal scope;
		\item[(\textsc{cnf3})] No conjunction occurs within the scope of any disjunction.
	\end{earg}
\newglossaryentry{conjunctive normal form}{
  name = conjunctive normal form (DNF),
  text = conjunctive normal form,
  description = {a sentence which is a conjunction of disjunctions of atomic sentences or negated atomic sentences}
}
Generally, then, a sentence in CNF looks like this
	$$(\pm \meta{A}_1 \lor \ldots \lor \pm \meta{A}_i) \land (\pm \meta{A}_{i+1} \lor \ldots \lor \pm\meta{A}_j) \land \ldots \land (\pm\meta{A}_{m+1} \lor\ldots \lor \pm \meta{A}_n)$$
where each $\meta{A}_k$ is an atomic sentence.

We can now prove another normal form theorem:
	\factoidbox{\label{thm:cnf}\textbf{Conjunctive Normal Form Theorem.} For any sentence, there is a logically equivalent sentence in conjunctive normal form.}

	Given a TFL sentence, $\meta{S}$, we begin by writing down the complete truth table for $\meta{S}$.

	If $\meta{S}$ is \emph{true} on every line of the truth table, then $\meta{S}$ and $(\meta{A}_1 \eor \enot \meta{A}_1)$ are logically equivalent.

	If $\meta{S}$ is \emph{false} on at least one line of the truth table then, for every line on the truth table where $\meta{S}$ is false, write down a disjunction $(\pm\meta{A}_1 \eor \ldots \eor \pm\meta{A}_n)$ which is \emph{false} on (and only on) that line. Let $\meta{C}$ be the conjunction of all of these disjuncts; by construction, $\meta{C}$ is in CNF and $\meta{S}$ and $\meta{C}$ are logically equivalent.

\practiceproblems
\problempart
\label{pr.DNF}
Consider the following sentences:
	\begin{earg}
		\item $(A \eif \enot B)$
		\item $\enot (A \eiff B)$
		\item $(\enot A \eor \enot (A \eand B))$
		\item $(\enot (A \eif B ) \eand (A \eif C))$
		\item $(\enot (A \eor B) \eiff ((\enot C \eand \enot A) \eif \enot B))$
		\item $((\enot (A \eand \enot B) \eif C) \eand \enot (A \eand D))$
	\end{earg}
        For each sentence, find a logically equivalent sentence in DNF and one in CNF.

\section{The expressive adequacy of TFL}

Of our connectives, $\enot$ attaches to a single sentences, and the others all combine exactly two sentences. We may also introduce the idea of an $n$-place connective. For example, we could consider a three-place connective, `$\heartsuit$', and stipulate that it is to have the following characteristic truth table:
\begin{center}
\begin{tabular}{c c c | c}
$A$ & $B$ & $C$ & $\heartsuit(A,B,C)$\\
\hline
 T & T & T & F \\
 T & T & F & T \\
 T & F & T & T \\
 T & F & F & F \\
 F & T & T & F \\
 F & T & F & T \\
 F & F & T & F \\
 F & F & F & F
\end{tabular}
\end{center}
Probably this new connective would not correspond with any natural English expression (at least not in the way that `$\eand$' corresponds with `and'). But a question arises: if we wanted to employ a connective with this characteristic truth table, must we add a \emph{new} connective to TFL? Or can we get by with the connectives we \emph{already have}?

Let us make this question more precise. Say that some connectives are \define{jointly expressively adequate} \emph{iff}, for any possible truth table, there is a sentence containing only those connectives with that truth table.

\newglossaryentry{expressively adequate}{
  name = {expressive adequacy},
  text = {expressively adequate},
  description = {property of a collection of connectives which holds iff every possible truth table is the truth table of a sentence involving only those connectives}}

The general point is, when we are armed with some jointly expressively adequate connectives, no characteristic truth table lies beyond our grasp. And in fact, we are in luck.
	\factoidbox{\label{thm:ExpressiveAdequacy}\textbf{Expressive Adequacy Theorem.}
The connectives of TFL are jointly expressively adequate. Indeed, the following pairs of connectives are jointly expressively adequate:
\begin{earg}
\item\label{expressive:eor} `$\enot$' and `$\eor$'
\item\label{expressive:eand} `$\enot$' and `$\eand$'
\item\label{expressive:eif} `$\enot$' and `$\eif$'
\end{earg}}

Given any truth table, we can use the method of proving the DNF Theorem (or the CNF Theorem) via truth tables, to write down a scheme which has the same truth table. For example, employing the truth table method for proving the DNF Theorem, we find that the following scheme has the same characteristic truth table as $\heartsuit(A,B,C)$, above:
		$$(A \eand B \eand \enot C) \eor (A \eand \enot B \eand C) \eor (\enot A \eand B \eand \enot C)$$
It follows that the connectives of TFL are jointly expressively adequate. We now prove each of the subsidiary results.

\emph{Subsidiary Result \ref{expressive:eor}: expressive adequacy of `$\enot$' and `$\eor$'.} Observe that the scheme that we generate, using the truth table method of proving the DNF Theorem, will only contain the connectives `$\enot$', `$\eand$' and `$\eor$'. So it suffices to show that there is an equivalent scheme which contains only `$\enot$' and `$\eor$'. To show do this, we simply consider that
		\begin{align*}
		(\meta{A} \eand \meta{B}) & \text{\quad and \quad} \enot(\enot \meta{A} \eor\enot \meta{B})
		\end{align*}
		are logically equivalent.

\emph{Subsidiary Result \ref{expressive:eand}: expressive adequacy of `$\enot$' and `$\eand$'.} Exactly as in Subsidiary Result~\ref{expressive:eor}, making use of the fact that
		\begin{align*}
		(\meta{A} \eor \meta{B}) & \text{\quad and \quad}\enot(\enot \meta{A} \eand\enot \meta{B})
		\end{align*}
are logically equivalent.

\emph{Subsidiary Result \ref{expressive:eif}: expressive adequacy of `$\enot$' and `$\eif$'.} Exactly as in Subsidiary Result~\ref{expressive:eor}, making use of these equivalences instead:
		\begin{align*}
		(\meta{A} \eor \meta{B}) &\text{\quad and \quad} (\enot \meta{A} \eif \meta{B})\\
		(\meta{A} \eand \meta{B}) &\text{\quad and \quad} \enot(\meta{A} \eif \enot\meta{B})
		\end{align*}
Alternatively, we could simply rely upon one of the other two subsidiary results, and (repeatedly) invoke only one of these two equivalences.

In short, there is never any \emph{need} to add new connectives to TFL. Indeed, there is already some redundancy among the connectives we have: we could have made do with just two connectives, if we had been feeling really austere.

\section{Individually expressively adequate connectives}

In fact, some two-place connectives are \emph{individually} expressively adequate. These connectives are not standardly included in TFL, since they are rather cumbersome to use. But their existence shows that, if we had wanted to, we could have defined a truth-functional language that was expressively adequate, which contained only a single primitive connective.

The first such connective we will consider is `$\uparrow$', which has the following characteristic truth table.
\begin{center}
\begin{tabular}{c c | c}
$\meta{A}$ & $\meta{B}$ & $\meta{A} \mathrel{\uparrow} \meta{B}$\\
\hline
 T & T & F \\
 T & F & T \\
 F & T & T  \\
 F & F & T
\end{tabular}
\end{center}
 This is often called `the Sheffer stroke', after Henry Sheffer, who used it to show how to reduce the number of logical connectives in Russell and Whitehead's \emph{Principia Mathematica}.\footnote{Sheffer, `A Set of Five Independent Postulates for Boolean Algebras, with application to logical constants,' (1913, \emph{Transactions of the American Mathematical Society} 14.4)} (In fact, Charles Sanders Peirce had anticipated Sheffer by about 30 years, but never published his results.)\footnote{See Peirce, `A Boolian Algebra with One Constant', which dates to c.1880; and Peirce's \emph{Collected Papers}, 4.264--5.} It is quite common, as well, to call it `nand', since its characteristic truth table is the negation of the truth table for `$\eand$'.
\factoidbox{\label{prop:upexpressive}`$\uparrow$' is expressively adequate all by itself.}

The Expressive Adequacy Theorem tells us that `$\enot$' and `$\eor$' are jointly expressively adequate. So it suffices to show that, given any scheme which contains only those two connectives, we can rewrite it as a logically equivalent scheme which contains only `$\uparrow$'. As in the proof of the subsidiary cases of the Expressive Adequacy Theorem, then, we simply apply the following equivalences:
		\begin{align*}
			\enot \meta{A} &\text{\quad and \quad} (\meta{A} \uparrow \meta{A})\\
			(\meta{A} \eor \meta{B}) & \text{\quad and \quad} ((\meta{A} \uparrow \meta{A}) \uparrow (\meta{B} \uparrow \meta{B}))
		\end{align*}
to the Subsidiary Result~\ref{expressive:eor}.

Similarly, we can consider the connective `$\downarrow$':
\begin{center}
\begin{tabular}{c c | c}
$\meta{A}$ & $\meta{B}$ & $\meta{A} \mathrel{\downarrow} \meta{B}$\\
\hline
 T & T & F \\
 T & F & F  \\
 F & T & F  \\
 F & F & T
\end{tabular}
\end{center}
This is sometimes called the `Peirce arrow' (Peirce himself called it `ampheck'). More often, though, it is called `nor', since its characteristic truth table is the negation of `$\eor$', that is, of `neither \dots{} nor \dots'.
	\factoidbox{
	`$\downarrow$' is expressively adequate all by itself. }

As in the previous result for $\uparrow$, although invoking the equivalences:
		\begin{align*}
			\enot \meta{A} &\text{\quad and \quad} (\meta{A} \downarrow \meta{A})\\
			(\meta{A} \eand \meta{B}) & \text{\quad and \quad} ((\meta{A} \downarrow \meta{A}) \downarrow (\meta{B} \downarrow \meta{B}))
		\end{align*}
and Subsidiary Result~\ref{expressive:eand}.

\section{Failures of expressive adequacy}

In fact, the \emph{only} two-place connectives which are individually expressively adequate are `$\uparrow$' and `$\downarrow$'. But how would we show this? More generally, how can we show that some connectives are \emph{not} jointly expressively adequate?

The obvious thing to do is to try to find some truth table which we \emph{cannot} express, using just the given connectives. But there is a bit of an art to this.

To make this concrete, let's consider the question of whether `$\eor$' is expressively adequate all by itself. After a little reflection, it should be clear that it is not. In particular, it should be clear that any scheme which only contains disjunctions cannot have the same truth table as negation, i.e.:
				\begin{center}
				\begin{tabular}{c | c}
				$\meta{A}$ & $\enot \meta{A}$\\
				\hline
				 T & F \\
				 F & T
				\end{tabular}
				\end{center}
The intuitive reason, why this should be so, is simple: the top line of the desired truth table needs to have the value False; but the top line of any truth table for a scheme which \emph{only} contains $\eor$ will always be True. The same is true for $\eand$, $\eif$, and $\eiff$.
 	\factoidbox{
		`$\eor$', `$\eand$', `$\eif$', and `$\eiff$' are not expressively adequate by themselves.}

In fact, the following is true:

\factoidbox{The \emph{only} two-place connectives that are expressively adequate by themselves are `$\uparrow$' and `$\downarrow$'. }

This is of course harder to prove than for the primitive connectives. For instance, the ``exclusive or'' connective does not have a T in the first line of its characteristic truth table, and so the method used above no longer suffices to show that it cannot express all truth tables.  It is also harder to show that, e.g., `$\eiff$' and `$\enot$' \emph{together} are not expressively adequate.

\chapter{Correção}\label{ch:Soundness}

In this chapter we relate TFL's semantics to its natural deduction \emph{proof system} (as defined in Part~\ref{ch.NDTFL}). We will prove that the formal proof system is safe: you can only prove sentences from premises from which they actually follow.
Intuitively, a formal proof system is sound iff it does not allow you to prove any invalid arguments. This is obviously a highly desirable property. It tells us that our proof system will never lead us astray. Indeed, if our proof system were not sound, then we would not be able to trust our proofs. The aim of this chapter is to prove that our proof system is sound.

Let's make the idea more precise. We'll abbreviate a list of sentences using the greek letter $\Gamma$ (`gamma'). A formal proof system is \define{sound} (relative to a given semantics) \emph{iff}, whenever there is a formal proof of $\meta{C}$ from assumptions among $\Gamma$, then $\Gamma$ genuinely entails $\meta{C}$ (given that semantics). Otherwise put, to prove that TFL's proof system is sound, we need to prove the following

\begin{factoidboxe}\textbf{Soundness Theorem.} For any sentences $\Gamma$ and $\meta{C}$: if $\Gamma\proves\meta{C}$, then $\Gamma \entails\meta{C}$
\end{factoidboxe}

To prove this, we will check each of the rules of TFL's proof system individually. We want to show that no application of those rules ever leads us astray. Since a proof just involves repeated application of those rules, this will show that no proof ever leads us astray. Or at least, that is the general idea.

To begin with, we must make the idea of `leading us astray' more precise. Say that a line of a proof is \define{shiny} iff the assumptions on which that line depends tautologically entail the sentence on that line.\footnote{The word `shiny' is not standard among logicians.} To illustrate the idea, consider the following:
	\begin{proof}
		\hypo{fgh}{F\eif(G\eand H)}
		\open
			\hypo{f}{F}
			\have{gh}{G \eand H}\ce{fgh,f}
			\have{g}{G}\ae{gh}
		\close
		\have{fg}{F \eif G}\ci{f-g}
	\end{proof}\noindent\noindent
Line $1$ is shiny iff $F \eif (G \eand H) \entails F \eif (G \eand H)$. You should be easily convinced that line $1$ is, indeed, shiny! Similarly, line $4$ is shiny iff $F \eif (G \eand H), F \entails G$. Again, it is easy to check that line $4$ is shiny. As is every line in this TFL-proof. We want to show that this is no coincidence. That is, we want to prove:
	\begin{factoidboxe}\textbf{Shininess Lemma.}
		Every line of every TFL-proof is shiny.
	\end{factoidboxe}\noindent
Then we will know that we have never gone astray, on any line of a proof. Indeed, given the Shininess Lemma, it will be easy to prove the Soundness Theorem:

\emph{Proof.} Suppose $\Gamma \proves \meta{C}$. Then there is a TFL-proof, with $\meta{C}$ appearing on its last line, whose only undischarged assumptions are among $\Gamma$. The Shininess Lemma tells us that every line on every TFL-proof is shiny. So this last line is shiny, i.e.\ $\Gamma \entails \meta{C}$. QED

It remains to prove the Shininess Lemma.

To do this, we observe that every line of any TFL-proof is obtained by applying some rule. So what we want to show is that no application of a rule of TFL's proof system will lead us astray. More precisely, say that a rule of inference is \define{rule-sound} \emph{iff} for all TFL-proofs, if we obtain a line on a TFL-proof by applying that rule, and every earlier line in the TFL-proof is shiny, then our new line is also shiny. What we need to show is that \emph{every} rule in TFL's proof system is rule-sound.

We will do this in the next section. But having demonstrated the rule-soundness of every rule, the Shininess Lemma will follow immediately:

\emph{Proof.} Fix any line, line $n$, on any TFL-proof. The sentence written on line $n$ must be obtained using a formal inference rule which is rule-sound. This is to say that, if every earlier line is shiny, then line $n$ itself is shiny. Hence, by strong induction on the length of TFL-proofs, every line of every TFL-proof is shiny. QED

Note that this proof appeals to a principle of strong induction on the length of TFL-proofs. This is the first time we have seen that principle, and you should pause to confirm that it is, indeed, justified.

It remains to show that every rule is rule-sound. This is not difficult, but it is time-consuming, since we need to check each rule individually, and TFL's proof system has plenty of rules! To speed up the process marginally, we will introduce a convenient abbreviation: `$\Delta_i$' (`delta') will abbreviate the assumptions (if any) on which line $i$ depends in our TFL-proof (context will indicate which TFL-proof we have in mind).

\begin{factoidboxe}Introducing an assumption is rule-sound.
\end{factoidboxe}

If $\meta{A}$ is introduced as an assumption on line $n$, then $\meta{A}$ is among $\Delta_n$, and so $\Delta_n \entails \meta{A}$.

\begin{factoidboxe}$\eand$I is rule-sound.
\end{factoidboxe}

\emph{Proof.} Consider any application of $\eand$I in any TFL-proof, i.e., something like:
\begin{proof}
	\have[i]{a}{\meta{A}}
	\have[j]{b}{\meta{B}}
	\have[n]{c}{\meta{A}\eand\meta{B}} \ai{a, b}
\end{proof}\noindent
To show that $\eand$I is rule-sound, we assume that every line before line $n$ is shiny; and we aim to show that line $n$ is shiny, i.e.\ that $\Delta_n \entails \meta{A} \eand \meta{B}$.

So, let $v$ be any valuation that makes all of $\Delta_{n}$ true.

We first show that $v$ makes $\meta{A}$ true. To prove this, note that all of $\Delta_i$ are among $\Delta_{n}$. By hypothesis, line $i$ is shiny. So any valuation that makes all of $\Delta_i$ true makes $\meta{A}$ true. Since $v$ makes all of $\Delta_i$ true, it makes $\meta{A}$ true too.

We can similarly see that $v$ makes $\meta{B}$ true.

So $v$ makes $\meta{A}$ true and $v$ makes $\meta{B}$ true. Consequently, $v$ makes $\meta{A}\eand\meta{B}$ true. So any valuation that makes all of the sentences among $\Delta_{n}$ true also makes $\meta{A} \eand \meta{B}$ true. That is: line $n$ is shiny. QED

All of the remaining lemmas establishing rule-soundness will have, essentially, the same structure as this one did.

\begin{factoidboxe}$\eand$E is rule-sound.
\end{factoidboxe}

\emph{Proof.}
	Assume that every line before line $n$ on some TFL-proof is shiny, and that $\eand$E is used on line $n$. So the situation is:
		   \begin{proof}
			   \have[i]{ab}{\meta{A}\eand\meta{B}}
			   \have[n]{a}{\meta{A}} \ae{ab}
		   \end{proof}\noindent
(or perhaps with $\meta{B}$ on line $n$ instead; but similar reasoning will apply in that case). Let $v$ be any valuation that makes all of $\Delta_{n}$ true. Note that all of $\Delta_i$ are among $\Delta_{n}$. By hypothesis, line $i$ is shiny. So any valuation that makes all of $\Delta_i$ true makes $\meta{A}\eand\meta{B}$ true. So $v$ makes $\meta{A}\eand\meta{B}$ true, and hence makes $\meta{A}$ true. So $\Delta_{n} \entails \meta{A}$. QED

\begin{factoidboxe}$\eor$I is rule-sound.
\end{factoidboxe}

We leave this as an exercise.

\begin{factoidboxe}$\eor$E is rule-sound.
\end{factoidboxe}

\emph{Proof.}
	Assume that every line before line $n$ on some TFL-proof is shiny, and that $\eand$E is used on line $n$. So the situation is:
   \begin{proof}
	   \have[m]{aob}{\meta{A}\eor\meta{B}}
	   \open
		   \hypo[i]{a}{\meta{A}} %\by{want \meta{C}}{}
		   \have[j]{c1}{\meta{C}}
	   \close
	   \open
		   \hypo[k]{b}{\meta{B}} %\by{want \meta{C}}{}
		   \have[l]{c2}{\meta{C}}
	   \close
	   \have[n]{ab}{\meta{C}}\oe{aob, a-c1,b-c2}
   \end{proof}\noindent
Let $v$ be any valuation that makes all of $\Delta_{n}$ true. Note that all of $\Delta_m$ are among $\Delta_{n}$. By hypothesis, line $m$ is shiny. So any valuation that makes $\Delta_{n}$ true makes $\meta{A} \eor \meta{B}$ true. So in particular, $v$ makes $\meta{A} \eor \meta{B}$ true, and hence either $v$ makes $\meta{A}$ true, or $v$ makes $\meta{B}$ true. We now reason through these two cases:
   \begin{ebullet}
	   \item[\emph{Case 1: $v$ makes $\meta{A}$ true.}] All of $\Delta_i$ are among $\Delta_{n}$, with the possible exception of $\meta{A}$. Since $v$ makes all of $\Delta_{n}$ true, and also makes $\meta{A}$ true,  $v$ makes all of $\Delta_i$ true. Now, by assumption, line $j$ is shiny; so $\Delta_{j} \entails \meta{C}$. But the sentences $\Delta_i$ are just the sentences $\Delta_{j}$, so $\Delta_i \entails \meta{C}$. So, any valuation that makes all of $\Delta_i$ true makes $\meta{C}$ true. But $v$ is just such a valuation. So $v$ makes $\meta{C}$ true.
	   \item[\emph{Case 2: $v$ makes $\meta{B}$ true.}] Reasoning in exactly the same way, considering lines $k$ and $l$, $v$ makes $\meta{C}$ true.
	   \end{ebullet}
Either way, $v$ makes $\meta{C}$ true. So $\Delta_n \entails \meta{C}$.
QED

\begin{factoidboxe}
	$\enot$E is rule-sound.
\end{factoidboxe}

\emph{Proof.}
	Assume that every line before line $n$ on some TFL-proof is shiny, and that $\enot$E is used on line $n$. So the situation is:
\begin{proof}
   \have[i]{i}{\meta{A}}
   \have[j]{j}{\enot\meta{A}}
   \have[n]{nb}{\ered}\ri{i, j}
\end{proof}\noindent
Note that all of $\Delta_i$ and all of $\Delta_j$ are among $\Delta_{n}$. By hypothesis, lines $i$ and $j$ are shiny. So any valuation which makes all of $\Delta_{n}$ true would have to make both $\meta{A}$ and $\enot\meta{A}$ true. But no valuation can do that. So no valuation makes all of $\Delta_{n}$ true. So $\Delta_{n} \entails \ered$, vacuously.
QED

\begin{factoidboxe}
	X is rule-sound.
\end{factoidboxe}

We leave this as an exercise.

\begin{factoidboxe}
	$\enot$I is rule-sound.
\end{factoidboxe}

\emph{Proof.}
	Assume that every line before line $n$ on some TFL-proof is shiny, and that $\enot$I is used on line $n$. So the situation is:
\begin{proof}
   \open
	   \hypo[i]{a}{\meta{A}}
	   \have[j]{b}{\ered}
   \close
   \have[n]{na}{\enot\meta{A}}\ni{a-b}
\end{proof}\noindent
Let $v$ be any valuation that makes all of $\Delta_{n}$ true. Note that all of $\Delta_{n}$ are among $\Delta_i$, with the possible exception of $\meta{A}$ itself. By hypothesis, line $j$ is shiny. But no valuation can make `$\ered$' true, so no valuation can make all of $\Delta_{j}$ true. Since the sentences $\Delta_i$ are just the sentences $\Delta_{j}$, no valuation can make all of $\Delta_i$ true. Since $v$ makes all of $\Delta_{n}$ true, it must therefore make $\meta{A}$ false, and so make $\enot \meta{A}$ true. So $\Delta_n \entails \enot \meta{A}$.
QED

\begin{factoidboxe}\label{lem:LastRuleSound} IP, $\eif$I,  $\eif$E, $\eiff$I, and $\eiff$E are all rule-sound.
\end{factoidboxe}

We leave these as exercises.

This establishes that all the basic rules of our proof system are rule-sound. Finally, we show:

\begin{factoidboxe}All of the derived rules of our proof system are rule-sound.
\end{factoidboxe}

\emph{Proof.}
	Suppose that we used a derived rule to obtain some sentence, $\meta{A}$, on line $n$ of some TFL-proof, and that every earlier line is shiny. Every use of a derived rule can be replaced (at the cost of long-windedness) with multiple uses of basic rules. That is to say, we could have used basic rules to write $\meta{A}$ on some line $n + k$, without introducing any further assumptions. So, applying our individual results that all basic rules are rule-sound several times ($k + 1$ times, in fact), we can see that line $n+k$ is shiny. Hence the derived rule is rule-sound.
QED

And that's that! We have shown that every rule---basic or otherwise---is rule-sound, which is all that we required to establish the Shininess Lemma, and hence the Soundness Theorem.

But it might help to round off this chapter if we repeat my informal explanation of what we have done. A formal proof is just a sequence---of arbitrary length---of applications of rules. We have shown that any application of any rule will not lead you astray. It follows (by induction)that no formal proof will lead you astray. That is: our proof system is sound.

\practiceproblems

\problempart
\label{pr.Soundness}
Complete the Lemmas left as exercises in this chapter. That is, show that the following are rule-sound:
	\begin{earg}
		\item $\eor$I. (\emph{Hint}: this is  similar to the case of $\eand$E.)
		\item X. (\emph{Hint}: this is similar to the case of $\enot$E.)
		\item $\eif$I. (\emph{Hint}: this is similar to $\eor$E.)
		\item $\eif$E.
		\item IP. (\emph{Hint}: this is similar to the case of $\enot$I.)
	\end{earg}


\documentclass[11pt,oneside,a4paper]{article}

\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{layout}
\usepackage{fancyhdr}

\usepackage{hyperref}
%\hypersetup{pdfcolorlinks=true,allcolors=blue}

%\pagestyle{fancy}
%\headheight = 14.5 pt
%\markright{Notes on \textsl{volatilitytrade.pdf} \hfill Peter Zsohar}

\title{Computational Algorithm}
\author{Peter Zsohar}

\voffset = -10 pt
\textheight = 650 pt
\parindent = 0 pt

\begin{document}
\maketitle

\section{Equilibrium Algorithm}
%
\subsection{Equilibrium Equations}
Equations (\ref{eq1}) - (\ref{eq8}) describe the equilibrium of the model.
\begin{align}
% \nonumber to remove numbering (before each equation)
  P_{nt} &= \prod_{j = 1}^J {\alpha_t^j}^{- \alpha_t^j} {P_{nt}^j}^{\alpha_t^j} \label{eq1}\\
  %
  P_{nt}^j &= \xi {\Phi_{nt}^j}^{-\frac{1}{\theta}} \label{eq2}\\
  %
  \Phi_{nt}^j &= {B^j}^{-\theta} \sum_{i = 1}^N T_i^j {A_{it}^j}^{\theta} \left(\frac{{w_{it}^j}^{\beta^j} \prod_{k = 1}^{J}{P_{it}^k}^{\gamma^{kj}} }{\kappa_{nit}^j}\right)^{-\theta} \label{eq3}\\
  %
  d_{mnt}^j &= \frac{{B^j}^{-\theta} T_n^j {A_{nt}^j}^{\theta} \left(\frac{ {w_{nt}^j}^{\beta^j} \prod_{k = 1}^{J}{P_{nt}^k}^{\gamma^{kj}} }{\kappa_{mnt}^j}\right)^{-\theta}} {\Phi_{mt}^j} \label{eq4}\\
  %
  R^j_{nt} &= \sum_{m=1}^N d^j_{mnt} E^j_{mt} \label{eq5}\\
  %
  E^j_{mt} &= \alpha^j_t P_{mt}C_{mt} + \sum_{k=1}^J \gamma^{jk}R^k_{mt} \label{eq6}\\
  %
  P_{mt}C_{mt} &= \sum_{j=1}^J \beta^j R_{mt}^j - S_{mt} \label{eq7}\\
  %
  \frac{L_{nt}^{j}}{L_{nt}} &= E_{t - 1} \left( \frac{w_{nt}^j L_{nt}^j}{w_{nt} L_{nt}}\right) \label{eq8}
\end{align}

Where
\begin{align}
  \nonumber
  \xi &= \Gamma\left(\frac{\theta + 1 - \eta}{\theta}\right) \\
  \nonumber
  B^j &= {\beta^j}^{- \beta^j} (1 - \beta^j)^{-(1 - \beta^j)}
\end{align}

\newpage
\subsection{Algorithm}
Solves for $L_{nt}^j, w_{nt}^j, P_{nt}^j \in \mathbf{R}^{N \times J \times T}$ that satisfy equations (\ref{eq1}) - (\ref{eq8}) in three steps:
\begin{itemize}
  \item Inner loop: Solve for $P_{n}^j\!\left(L_{n}^j, w_{n}^j\right)$ that satisfies equations (\ref{eq1}) - (\ref{eq3}) as a function of $L_{n}^j$ and $w_{n}^j$ independently for all periods.
  \item Middle loop: Solve for $w_{n}^j\!\left(L_{n}^j\right)$ that satisfies equations (\ref{eq1}) - (\ref{eq7}) as a function of $L_{n}^j$ independently for all periods.
  \item Outer loop: Solve for $L_{nt}^j$ that satisfies equations (\ref{eq1}) - (\ref{eq7}) and a numerical approximation of equation (\ref{eq8}).
\end{itemize}
% subsection steps (end)

\newpage
\subsection{Inner Loop}
For a given pair of sectoral resource allocation $(L_{nt}^j)$ and sectoral wages $(w_{nt}^j)$ solve the system below for sectoral prices indexes $P_{nt}^j.$
\begin{align*}
P_{nt} &= \prod_{j = 1}^J {\alpha_t^j}^{- \alpha_t^j} {P_{nt}^j}^{\alpha_t^j} \\
%
P_{nt}^j &= \xi {\Phi_{nt}^j}^{-\frac{1}{\theta}}\\
%
\Phi_{nt}^j &= {B^j}^{-\theta} \sum_{i = 1}^N T_i^j {A_{it}^j}^{\theta} \left(\frac{{w_{it}^j}^{\beta^j} \prod_{k = 1}^{J}{P_{it}^k}^{\gamma^{kj}} }{\kappa_{nit}^j}\right)^{-\theta}
\end{align*}

Simplify $\Phi_{nt}^j:$
\begin{eqnarray*}
  \Phi_{nt}^j &=&  {B^j}^{-\theta} \sum_{i = 1}^N \underbrace{T_i^j {A_{it}^j}^{\theta}}_{\frac{Z_{it}^j}{{L_{it}}^{\beta^j\theta}}} \left(\frac{ {w_{it}^j}^{\beta^j} \prod_{k = 1}^{J}{P_{it}^k}^{\gamma^{kj}}}{\kappa_{nit}^j}\right)^{-\theta}\\
  %
  &=& {B^j}^{-\theta} \sum_{i = 1}^N Z_{it}^j {L_{it}}^{- \beta^j\theta} {w_{it}^j}^{-\beta^j\theta} {\kappa_{nit}^j}^{\theta} \prod_{k = 1}^{J}{P_{it}^k}^{-\theta\gamma^{kj}}\\
  %
  &=& {B^j}^{-\theta} \sum_{i = 1}^N \underbrace{Z_{it}^j {\left((L_{it}w_{it}^j)^{- \beta^j} \kappa_{nit}^j\right)}^{\theta}}_{D_{nit}^j} \prod_{k = 1}^{J}{P_{it}^k}^{-\theta\gamma^{kj}}\\
  %
  &=& {B^j}^{-\theta} \sum_{i = 1}^N D_{nit}^j \prod_{k = 1}^{J}{P_{it}^k}^{-\theta\gamma^{kj}}
\end{eqnarray*}
%
Note that we can compute the coefficients of the equation (the $D$ values) before starting the search for prices.
Now we can write the system of equations as
\begin{align*}
{P_{nt}^j}^{-\theta} &= \xi^{-\theta} {\Phi_{nt}^j}\\
%
{P_{nt}^j}^{-\theta} &= \xi^{-\theta} {{B^j}^{-\theta} \sum_{i = 1}^N D_{nit}^j \prod_{k = 1}^{J}{P_{it}^k}^{-\theta\gamma^{kj}}}
\end{align*}
or
$$
\mathcal{P}_{nt}^j = \left(\xi B^j\right)^{-\theta} \sum_{i = 1}^N D_{nit}^j \prod_{k = 1}^{J}{\mathcal{P}_{it}^k}^{\gamma^{kj}}
$$
where $\mathcal{P}_{nt}^j \equiv {P_{nt}^j}^{-\theta}$.

\newpage
\subsection{Middle loop}
For a given resource allocation, $L_{nt}^j$, this loop searches for sectoral wages $w_{nt}^j$ that solve the system of equations below.
For notational simplicity we solve the system in terms of sectoral revenue and then calculate corresponding wages from $w_{nt}^j L_{nt}^j = \beta^j R_{nt}^j$.
\begin{align*}
R^j_{nt} &= \sum_{m=1}^N E^j_{mt} d^j_{mnt}\!\left(w_{nt}^j\right)  \\
%
E^j_{mt} &= \alpha^j_t P_{mt}C_{mt} + \sum_{k=1}^J \gamma^{jk}R^k_{mt} \\
%
P_{mt}C_{mt} &= \sum_{j=1}^J \beta^j R_{mt}^j - S_{mt} \\
\end{align*}
Note that $d^j_{mnt}$ depends on $w_{nt}^j$ through
$$d_{mnt}^j = \frac{{B^j}^{-\theta} T_n^j {A_{nt}^j}^{\theta} \left(\frac{{w_{nt}^j}^{\beta^j} \prod_{k = 1}^{J}{P_{nt}^k}^{\gamma^{kj}} }{\kappa_{mnt}^j}\right)^{-\theta}}{{B^j}^{-\theta} \sum_{i = 1}^N T_i^j {A_{it}^j}^{\theta} \left(\frac{{w_{it}^j}^{\beta^j} \prod_{k = 1}^{J}{P_{it}^k}^{\gamma^{kj}} }{\kappa_{mit}^j}\right)^{-\theta}},$$
where prices were solved for in the inner loop.

To facilitate computation we introduce $D$, the coefficients from the inner loop.
We can rewrite the definition of $d$ as
\begin{align*}
  d_{mnt}^j &= \frac{\overbrace{T_n^j {A_{nt}^j}^{\theta}}^{\frac{Z_{nt}^j}{{L_{nt}}^{\beta^j\theta}}} \left(\frac{{P_{nt}}^{1 - \beta^j} {w_{nt}^j}^{\beta^j}}{\kappa_{mnt}^j}\right)^{-\theta}}{\sum_{i = 1}^N \underbrace{T_i^j {A_{it}^j}^{\theta}}_{\frac{Z_{it}^j}{{L_{it}}^{\beta^j\theta}}} \left(\frac{{P_{it}}^{1 - \beta^j} {w_{it}^j}^{\beta^j}}{\kappa_{mit}^j}\right)^{-\theta}}\\
%
  &= \frac{Z_{nt}^j {L_{nt}}^{- \beta^j\theta} {w_{nt}^j}^{-\beta^j\theta} {\kappa_{mnt}^j}^{\theta}{P_{nt}}^{\theta(\beta^j - 1)}}{\sum_{i = 1}^N Z_{it}^j {L_{it}}^{- \beta^j\theta} {w_{it}^j}^{-\beta^j\theta} {\kappa_{mit}^j}^{\theta}{P_{it}}^{\theta(\beta^j - 1)}}\\
%
  &= \frac{\overbrace{Z_{nt}^j {L_{nt}}^{- \beta^j\theta} {w_{nt}^j}^{-\beta^j\theta} {\kappa_{mnt}^j}^{\theta}}^{D_{mnt}^j}{P_{nt}}^{\theta(\beta^j - 1)}}{\sum_{i = 1}^N \underbrace{Z_{it}^j {L_{it}}^{- \beta^j\theta} {w_{it}^j}^{-\beta^j\theta} {\kappa_{mit}^j}^{\theta}}_{D_{mit}^j}{P_{it}}^{\theta(\beta^j - 1)}}\\
%
  &= \frac{D_{mnt}^j {P_{nt}}^{\theta(\beta^j - 1)}}{\sum_{i = 1}^N D_{mit}^j{P_{it}}^{\theta(\beta^j - 1)}}
\end{align*}
Note that $d$ does not depend on the resource allocation.

\newpage
\subsection{Outer loop}
The goal of this loop is to find the sectoral resource allocations $L_{nt}^j$ that satisfy
$$\frac{L_{nt}^{j}}{L_{nt}} = E_{t - 1} \left( \frac{w_{nt}^j L_{nt}^j}{w_{nt} L_{nt}}\right).$$
This loop runs over iterations of $L_{nt}^j$ until it converges up to a predefined threshold.

To approximate the expectation we use a band pass filtered trend that allows for breaks in growth rates.

\begin{enumerate}
  \item We start from the initial value $(L_{nt}^j)^0 = \alpha^j L_{nt}$.
  \item In iteration $i$ for the actual $(L_{nt}^j)^i$ we get sectoral and aggregate wages, $(w_{nt}^j)^i$ and $(w_{nt})^i$, from the middle loop.
  \item We calculate the implied total value added and the sectoral value added shares as
    $$\left(\frac{w_{nt}^j L_{nt}^j}{w_{nt} L_{nt}}\right)^i = \frac{(w_{nt}^j)^i (L_{nt}^j)^i}{(w_{nt})^i L_{nt}}.$$
  \item
    \begin{enumerate}
      \item Decompose all $N \cdot J$ value added share series to trend and cycle components using a band pass filter with the same specification as in the shock decomposition.
        $$\log\left(\frac{w_{nt}^j L_{nt}^j}{w_{nt} L_{nt}}\right)^i = trend^j_{nt} + cycle_{nt}^j.$$
      \item Normalize the trend values so that in each period in each country the trend values add up 1:
        $$\widehat{\left(\frac{w_{nt}^j L_{nt}^j}{w_{nt} L_{nt}}\right)^i} = \frac{\exp(trend^j_{nt} + cycle_{nt}^j)}{\sum_k \exp(trend^k_{nt} + cycle_{nt}^k)}$$
      \item Replace the expectation with the adjusted trend value.
      $$E_{t - 1} \left( \frac{w_{nt}^j L_{nt}^j}{w_{nt} L_{nt}}\right) = \widehat{\left(\frac{w_{nt}^j L_{nt}^j}{w_{nt} L_{nt}}\right)^i}$$
    \end{enumerate}
  \item Update the resource allocations
    $$(L_{nt}^j)^{i + 1} = L_{nt} \widehat{\left(\frac{w_{nt}^j L_{nt}^j}{w_{nt} L_{nt}}\right)^i}$$
\end{enumerate}

\end{document}


\section{A Linear Encoding}
The encoding we have proposed is quadratic in the number of agents. In this section we show how to make it linear by introducing new atoms to the encoding. Specifically, we introduce the following atoms:
\begin{itemize}
    \item $rt(x,y,t)$ (resp.\ $lt(x,y,t)$) which specifies that the edge between $(x,y)$ and $(x,y+1)$ was traversed by \emph{some} agent at time $t$ from left to right (resp.\ from right to left).
    \item $ut(x,y,t)$ (resp.\ $dt(x,y,t)$) which specifies that the edge between $(x,y)$ and $(x,y+1)$ was traversed upwards (resp.\ downwards) by some agent at time $t$.
    \item $st(x,y,t)$, indicates that some agent stayed at $(x,y)$, that is, it  performed a wait action at time $t$.
\end{itemize}

The dynamics of these atoms are defined using one rule with variables. The rule for $rt$ is:
\begin{equation}\small\label{encoding:rt}
  rt(X,Y,T) \leftarrow exec(A,right,T), at(A,X,Y,T),
\end{equation}
while the rule for $st$ is:
{\small\begin{equation*}
  st(X,Y,T) \leftarrow at(A,X,Y,T), exec(A,wait,T).
\end{equation*}}
We omit the rules for $dt$, $lt$, and $ut$ since they are analogous to \eqref{encoding:rt}.

Using these predicates we now express the fact that a single cell cannot be entered at the same time instant by two different agents. This requires six rules each of which corresponds to a pairs of actions in $\{\Right,\Left,\Up,\Down\}$. For example, the following rule expresses that $(X,Y)$ cannot be entered by an agent performing a \Down action at the same time that is entered by another agent performing  \Up:
{\small\begin{equation*}
  \leftarrow lt(X,Y,T), dt(X,Y,T)
\end{equation*}}
It is easy to verify that these rules do not mention pairs of different agents, unlike \eqref{encoding:vertexone} and \eqref{encoding:swapone}, and as such after grounding we end with $\Theta(|\mathcal{A}|\cdot|V|\cdot\mathtt{T})$ rules, and therefore the resulting encoding is linear in $|\mathcal{A}|$.

\section{Using Search to Reduce the Atoms}
We can exploit our run of Dijkstra's algorithm during preprocessing time to generate an even smaller encoding by replacing rule~\eqref{encoding:effectsone} by the following rule.
\begin{equation}\small
  \begin{split}
    at(A,X,Y,T) \leftarrow &at(A,X',Y',T-1), exec(A,M,T),\\
    &delta(M,X',Y',X,Y), \\
    &cost\_to\_go(A,X,Y,C), T + C <= \mathtt{T},
  \end{split}
\end{equation}
where $cost\_to\_go(A,X,Y,C)$ specifies that $C$ is the minimum number of actions needed to go from $(X,Y)$ to the goal of agent $A$. This way we can ignore the generation of rules to positions that will not reach the goal, generating a much more compact encoding. This idea is related to the use of MDDs graphs in MDD-SAT \cite{SurynekFSB16}, but does not require the generation of the MDD, so it is conceptually simpler.


\section{Performance Modeling}
\label{sec:modeling}

In this section we describe the performance model used to analyze the target system, following the widely adopted modeling approach suggested in \cite{leemis2006discrete}.

% %
% SYSTEM DESCRIPTION
% %
We consider the environment sketched in Figure~\ref{fig:modeling-system-sketch}, which is characterized by:

\begin{itemize}
	\item  \textbf{workload:} mobile devices send to the system tasks that can be partitioned in two classes $C_{1}$ and $C_{2}$.
	\item \textbf{system:} a two-layers system, made of:
	\begin{itemize}
		\item a Cloudlet with $N$ servants, having the ability to off-load tasks to the Cloud server, accordingly to an \textit{off-loading policy} parametrized by a given \textit{threshold}.
		\item a remote Cloud server with virtually unlimited servants.

	\end{itemize}
\end{itemize}

\begin{figure}
	\includegraphics[width=\columnwidth]{fig/modeling-system-sketch}
	\caption{The system sketch.}
	\label{fig:modeling-system-sketch}
\end{figure}

We assume that
(i) the Cloudlet provides tasks with higher service rate than the Cloud,
(ii) when a task is interrupted in the Cloudlet and it is sent to the Cloud, the restart process comes with a \textit{setup time overhead}.

% %
% GOALS AND OBJECTIVES
% %
\subsection{Goals and Objectives}
The main goals of simulation are about system tuning.
In particular, we propose to determine with a $95\%$ level of confidence
\begin{itemize}
	\item the response time as a function of the threshold $S$,
	\item the throughput as a function of the threshold $S$,
	\item the distribution of the response time when $S=N$ and
	\item the threshold of the off-loading policy that minimizes the response time.
\end{itemize}

% %
% CONCEPTUAL MODEL
% %
\subsection{Conceptual Model}
The conceptual model is depicted in Figure~\ref{fig:modeling-conceptual-model}.

\begin{figure}
	\includegraphics[width=\columnwidth]{fig/modeling-conceptual-model}
	\caption{The conceptual model.}
	\label{fig:modeling-conceptual-model}
\end{figure}

% %
% SPECIFICATION MODEL
% %
\subsection{Specification Model}
The state of a system is a comprehensive characterization of the system at a particular time.
The state of the system is represented by the pair $(n_{clt,1},n_{clt,2},n_{cld,1},n_{cld,2})$, where $n_{cld,i}$ is the number of tasks belonging to the $i$-th class within the Cloudlet and $n_{cld,i}$ is the number of tasks belonging to the $i$-th class within the Cloud.
An event is an occurrence that could change the state of the system at the event time, according to the event type.
Our events are ...

Tasks belonging to the first class, i.e. $t\in C_{1}$ arrive to the system with an exponential arrival process with rate $ \lambda_{1}$; whilst tasks belonging to the seconds class, i.e. $t\in C_{2}$ arrive to the system with an exponential arrival process with rate $ \lambda_{2}$.
The Cloudlet serves tasks belonging to the first class with exponentially distributed service time with rate $\mu_{cld,1}$; whilst the Cloudlet serves tasks belonging to the second class with exponentially distributed service time with rate $\mu_{cld,2}$.
The Cloud serves tasks belonging to the first class with exponentially distributed service time with rate $\mu_{clt,1}$; whilst the Cloudlet serves tasks belonging to the second class with exponentially distributed service time with rate $\mu_{clt,2}$.
We assume that
(i) $\mu_{clt,i}>\mu_{cld,i}\ \forall i=1,2$ and
(ii) the setup time $T_{setup}$ is exponentially distributed with expected value $E[T_{setup}]$.

\begin{algorithm}
	\SetAlgoLined
	\If{task of class 1}{
		\If{$n_{clt}=N$}{
			send to Cloud
		}
		\If{$n_{clt}+n_{cld}<S$}{
			accept
		}
		\eIf{$n_{cld} > 0$}{
			accept on Cloudlet and send a class 2 task to Cloud
		}{
		accept on Cloudlet
		}
	}
	\If{arrival of class 2}{
		\eIf{$n_{clt}+n_{cld}>=S$}{
			send to Cloud
		}{
		accept on Cloudlet
	}
	}
	\caption{The offloading policy.}
	\label{alg:modeling-offloading-policy}
\end{algorithm}

% %
% COMPUTATIONAL MODEL
% %
\subsection{Computational Model}
The proposed performance model has been implemented as a Python application.
The simulation parameters can be configured with a YAML file loaded by the simulator when it starts up.
The full open source code is available in a public repository \cite{gmarciani-pydes} and representative examples of configuration and outputs are presented in Section~\ref{sec:usage}.

We adopted the next-event simulation paradigm, using
(i) a custom multi-stream Lehmer generator to generate random events, whose parameters have been described in Section~\ref{sec:random-number-generation} and whose evaluation is presented in Section~\ref{sec:evaluation}; and
(ii) a priority-queue based calendar with the ability both to schedule and un-schedule events.

Even if both the initial and terminal state can have any possible value, we adopted the convention of initializing and terminating the system in the idle state $(0,0,0,0)$. In particular, the terminal state is reached via the well-known closed door technique driven by a stop time condition.

The calendar is initialized by scheduling the first arrival in the initialization phase. The submission of an arrival $a$ to the system could induce
(i) the scheduling of the corresponding completion event,
(ii) the scheduling of a new arrival, or
(iii) the unscheduling of a previously scheduled completion, i.e. interruption in Cloudlet.

The next-event calendar is implemented as priority queue, appropriately extended to manage scheduling/unscheduling of events and exclusion of impossible events, i.e. arrivals with occurrence time greater than the stop time.
The impossibility of events is managed by letting the calendar contain possible events only, which is the best approach when the event list is assumed to be very long.

% %
% VERIFICATION
% %
\subsection{Verification}
The main goal of verification is to assess the consistency of the computational model with the specification model.
The verification has been carried out by evaluating the following consistency checks based on simulator logs and outputs:

\begin{itemize}
	\item \textbf{state consistency:} verifies the correctness of the system state evolution, i.e. state transitions;

	\item \textbf{arrival consistency:} verifies the correctness of arrivals ordering, i.e. tasks arrived before are served before;

	\item \textbf{service consistency:} verifies the correctness of service ordering, i.e. tasks with less service time leave the system before;

	\item \textbf{flow consistency:} verifies the correctness of flow trends, such as:

	\begin{equation}
	n_{clt,i}=a_{clt,i}-s_{clt,i}-c_{clt,i}
	\end{equation}
	\begin{equation}
	n_{cld,i}=a_{cld,i}+s_{cld,i}-c_{cld,i}
	\end{equation}
	\begin{equation}
	s_{clt,i}=s_{cld,i}
	\end{equation}

	where
	$n_{j,i}$ is the population in the $j$-th subsystem belonging to $i$-th class of tasks,
	$a_{j,i}$ is the number of arrivals to the $j$-th subsystem belonging to $i$-th class of tasks,
	$c_{j,i}$ is the number of completions in the $j$-th subsystem belonging to $i$-th class of tasks
	$s_{j,i}$ is the number of switches from/to the $j$-th subsystem belonging to $i$-th class of tasks\footnote{notice that $s_{j,1}=0\forall j=1,2$, as tasks belonging to class $C1$ cannot be switched from Cloudlet to Cloud.}.

	\item \textbf{workload change consistency:} verifies the correctness of performance metrics variations in response to arrival/service rates variations. For example, we verified that the following hold true:

	\begin{equation}
		\mu_{cld,2}^{new} > \mu_{cld,2}^{old} \Rightarrow E[T_{sys,2}]^{new} > E[T_{sys,2}]^{old}
	\end{equation}
	\\
	and

	\begin{equation}
	S^{new} > S^{old} \Rightarrow E[N_{cld,2}]^{new} < E[N_{cld,2}]^{old}
	\end{equation}
\end{itemize}

% %
% VALIDATION
% %
\subsection{Validation}
It is well-known that model development should include a final validation step in order to assess the consistency of the model with the real system.
%
As the simulation main purpose is insight, a widely adopted Turing-like technique is to place the computational model alongside with the real system and assess the consistency of performance indices.
%
Clearly, we cannot adopt this technique as we cannot compare the model with its real counterpart.
%
For this reason, we totally rely on the validation with respect to the analytical model.
In Figure \ref{tbl:validation} we show the comparison between theoretical performance results, taken from the analytical model, and their experimental counterpart, taken from the simulator.
The obtained results demonstrate that our simulator is a reliable tool to conduct the performance analysis of the target system.

\begin{figure}
	\begin{center}
		\begin{tabular}{|c||c|c|}
			\hline
			Index & Theoretical & Experimental\\
			\hline
			$E[N_{clt}]$  & $123456789$ & $123456789$ \\
			$E[N_{1,clt}]$  & $123456789$ & $123456789$ \\
			$E[N_{2,clt}]$  & $123456789$ & $123456789$ \\
			$E[T_{clt}]$  & $123456789$ & $123456789$ \\
			$E[T_{1,clt}]$  & $123456789$ & $123456789$ \\
			$E[T_{2,clt}]$  & $123456789$ & $123456789$ \\
			$X_{clt}$  & $123456789$ & $123456789$ \\
			$X_{1,clt}$  & $123456789$ & $123456789$ \\
			$X_{2,clt}$  & $123456789$ & $123456789$ \\
			\hline
			$E[N_{cld}]$  & $123456789$ & $123456789$ \\
			$E[N_{1,cld}]$  & $123456789$ & $123456789$ \\
			$E[N_{2,cld}]$  & $123456789$ & $123456789$ \\
			$E[T_{cld}]$  & $123456789$ & $123456789$ \\
			$E[T_{1,cld}]$  & $123456789$ & $123456789$ \\
			$E[T_{2,cld}]$  & $123456789$ & $123456789$ \\
			$X_{cld}$  & $123456789$ & $123456789$ \\
			$X_{1,cld}$  & $123456789$ & $123456789$ \\
			$X_{2,cld}$  & $123456789$ & $123456789$ \\
			\hline
			$E[N_{sys}]$  & $123456789$ & $123456789$ \\
			$E[N_{1,sys}]$  & $123456789$ & $123456789$ \\
			$E[N_{2,sys}]$  & $123456789$ & $123456789$ \\
			$E[T_{sys}]$  & $123456789$ & $123456789$ \\
			$E[T_{1,sys}]$  & $123456789$ & $123456789$ \\
			$E[T_{2,sys}]$  & $123456789$ & $123456789$ \\
			$X_{sys}$  & $123456789$ & $123456789$ \\
			$X_{1,sys}$  & $123456789$ & $123456789$ \\
			$X_{2,sys}$  & $123456789$ & $123456789$ \\
			\hline
		\end{tabular}
	\end{center}
	\caption{Validation: comparison between analytical results and experimental results.}
	\label{tbl:validation}
\end{figure}


\section{Model Specification}\label{sec:model1}

This paper presents a discrete time, finite horizon, discrete choice model of female labour supply. More specifically I model a household consisting of wife, husband and zero or more children. The model attempts to address what the effect of children is on the labour supply of women. The model consists of 3 components: 1) An income and human capital component, 2) A fertility process, 3) A leisure and utility component. I model the households from age $Q_{min}=18$ to the terminal age $Q_{max} = 60$. Here it should be noted, that I make the simplifying assumption that the husband and wife has the same age and that the couple is married from age $Q=18$. The age evolves deterministically, i.e., the household grows one year older for each step in the model:

\begin{equation}
    Q_{t+1} = Q_t + 1
\end{equation}

For each time step in the model, the agent has to  choose how many hours the woman of the household should supply on a weekly basis. The choice is discreet, and consists of four action values: $H_t \in \{0, 25, 37, 45 \}$. The labour supply of the man in the households is not a choice variable and is therefore considered an exogenous variable.

The households have two income streams, the husband's earning, which is perfectly deterministic, and the wife's earnings. The income process of the wife consists of an idiosyncratic component $Z_t$, which follows a random walk:

\begin{equation}
    Z_{t+1} = Z_t + \epsilon_t, \qquad \epsilon_t \sim \ndist (0, \sigma_\epsilon)
\end{equation}

This allows for agents to do display heterogeneity owing to the fact that some unobserved carrier choices will lead to higher wages, even though two otherwise identical agents have been part of the labour force equally long. Since these job characteristics is unobserved, it is assumed to be a random walk. The second component of the income process is a human capital component based on the Mincer equation, as described by \textcite{lemieux_mincer_2006}. That is the log-transformed wage rate/wage level can be described by the human capital accumulated:

\begin{equation}
    \log \tilde{W}_t = \alpha + \eta_G G_t + \eta_{G^2} G_t^2
\end{equation}

A couple of things to note. In the original formulation by \textcite{lemieux_mincer_2006}, the education level is also included. However, due to the lack of availability of such data I am not able to condition on this. It should also be noted, that the state $G_t$ represents the human capital accumulated of the woman in the household. Finally, this equation governs only the wage rate of the women (not of the husband), for whom the wage rate and the supplied number of hours is considered exogenous. The exogenous wage rate of the husband is found using the data set \textbf{LONS50} from Statistics Denmark. And the number of supplied hours for the husband is found using the data set \textbf{LIGEF15}, again supplied by Statistics Denmark. The wage rate of the women will be capped at the minimum wage if the sum of the two components $\tilde{W}_t + Z_t$ is not above the minimum wage $W_{min} = 120$:

\begin{equation}
    W_t = \max ( W_{min}, \tilde{W} + Z_t)
\end{equation}

The human capital accumulation process, follows a formulation allowing for depreciation (or skill atrophy):

\begin{equation}
    G_{t+1} = G_t (1-\delta)  + \frac{1}{37} H_t
\end{equation}

37 being the standard number of hours worked in Denmark. The total income $Y_t$ of the household can now be formulated as:

\begin{equation}
    Y_t = 46 \cdot W_t \cdot H_t + f^M(Q_t)
\end{equation}

Where $f^M$ represents the income from the husband as a function of age. And $46 \cdot W_t \cdot H_t$ is the number of supplied hours per week, $H_t$, times the number of weeks, 46, in a year for the average person on the labour market\footnote{This number comes from an assumption of 6 weeks of holiday.} times the wage rate, $W_t$. The income process is a function of the number of supplied working hours, $H_t$, and the states $(Q_t, Z_t, G_t)$. The parameters $\delta, \sigma_\epsilon, \eta_G, \eta_{G^{2}}$ will be calibrated in section \ref{sec:parameter_calibration}.

The second component of the model is the fertility process. The fertility is assumed to be exogenous depending on the age of the woman. This is summed up in the equation below:

\begin{equation}
    K_{t+1} = K_t+ \psi_t, \qquad \psi_t \mid Q_t \sim Bernoulli (p_\psi(Q_t))
\end{equation}

$K_t$ is the number of children in the household. The household is assumed to start with $K_t = 0$ at age $Q=18$. At each step with probability $p_\psi(Q_t)$ the wife gives birth to a child. This allows for the accumulation of children. The number of children is capped at a maximum of 5 in the model. The probability $p_\psi(Q_t)$ is modelled using data from Statistics Denmark using the data set \textbf{FOD33}. The number of children $K_t$ is part of the state space.

The third component of the model is the utility and leisure component. The agent is assumed to get utility from leisure, $L_t$, and consumption. Following \textcite{francesconi_joint_2002} the households are assumed to face a budget constraint such that all income of period $t$ must be consumed period $t$, which imply that consumption is equal to the household's total income, $Y_t$. The utility $U_t$ is given by:

\begin{equation}
    U_t = \beta_L \ln(L_t + 1) + \beta_Y \ln(Y_t + 1)
\end{equation}

Following the formulation of \textcite{adda_career_2011}, dividing the utility into sub-utility functions, where each sub-utility function allows for curvature by specifying a constant relative risk-averse (CRRA) function for each sub-utility assuming the special case of $\ln(\cdot)$. The parameters $\beta_L, \beta_Y$ is the individual weighing of the different sub-utilities. Note, that for identification I will restrict $\beta_Y= 1$. The total number of hours leisure the agent receives in a year follows:

\begin{equation}
    L_t = 46 \lp \lp 24 \cdot 7 \rp - \omega \cdot K_t - H_t \rp
\end{equation}

Following \textcite{firestone_estimation_1988}, \textcite{thrane_men_2000} and \textcite{ekert-jaffe_time_2015} I assume that some of the time spent with children can be considered work. The number of hours spent on children each week is captured by $-\omega \cdot K_t$. I let $\omega=3.5$ be the time spent of extra house work per child each week. This number is taken from \textcite{ekert-jaffe_time_2015}. The weekly number of hours supplied to the labour market $H_t$ is also subtracted from the total amount of leisure. The number of hours is aggregated to annual level subtracting 6 weeks for holiday. To conclude $\beta_L$ will be a parameter estimated to give the best fit of the model.

Summarizing the model; the model contains 4 states: $(G)$ human capital, $(Z)$ the idiosyncratic wage path, $(K)$ the number of children in the household and lastly $(Q)$ age. The action taken in each period $(H)$ represents the number of hours the woman supplies to the labour market on a weekly basis. Other important variables are: $(W)$ the wage rate, $(\tilde{W})$ the human capital dependent wage rate,  $(U)$ the utility and $(L)$ leisure. Formally this implies:

\begin{equation}
    \textbf{State space: }\statespace = \R^{2} \times \{0, 1, 2, 3, 4, 5\} \times \{ 18, 19, \cdots, 60\}
\end{equation}

\begin{equation}
    \textbf{Action space: }\actionspace  = \{0, 25, 37, 45\}
\end{equation}

\begin{equation}
    \textbf{States: }\{G, Z, K, Q\}, \qquad \textbf{Actions: } \{H\}
\end{equation}

The model furthermore contains the following parameters: $\alpha, \eta_G, \eta_{G^2}, \delta, \sigma_\epsilon, \beta_L, \beta_Y=1, W_{min}=120, \omega=3.5$. Where the parameters governing the income process $(\alpha, \eta_G, \eta_{G^2}, \delta, \sigma_\epsilon)$ will be calibrated using a simple agent based model, and $\beta_L$ will be estimated using the full model. The recursive formulation of the model is given below:

\begin{align}
    U_t(L_t, Y_t) &= \beta_L \ln(L_t + 1) + \beta_Y \ln(Y_t + 1) \label{eq:utility_v1}\\
    L_t(K_t, H_t) &= 46 \cdot ((24 \cdot 7) - \omega \cdot K_t  - H_t) \label{eq:leissure_v1}\\
    \log \tilde{W}_t (G_t) &= \alpha + \eta_G G_t + \eta_{G^2} G_t^2 \label{eq:salary_tilde_v1}\\
    W_t(\tilde{W}_t, Z_t) &= \max(W_{min} , \tilde{W}_t  + Z_t)  \label{eq:salary_v1}\\
    Y_t(Q_t,H_t, W_t) &= 46 \cdot H_t \cdot W_t + f^M(Q_t) \label{eq:total_salary_v1}\\
\end{align}

Law of motion:

\begin{align}
    Q_{t+1}(Q_t) &= Q_t \label{eq:age_v1}\\
    K_{t+1}(K_t, Q_t)  &= K_{t} + \psi_t, \qquad \psi_t \mid Q_t \sim Bernoulli(p_\psi(Q_t)) \label{eq:fertility_v1} \\
    Z_{t+1}(Z_t) &= Z_t + \epsilon_t, \qquad \epsilon_t \sim \ndist(0, \sigma_\epsilon) \label{eq:idiosyncratic_wage_path_v1}\\
    G_{t+1}(G_t) &= G_t(1 - \delta) + \frac{1}{37} H_t \\
\end{align}


\documentclass[notitlepage, 10pt]{article}
\title{Newton's Recurrence}
%\author{{\sc Carl, Sam, Hal} \\
%{\small University of Wisconsin--Madison}}
%%\date{March 11, 2004}
\usepackage{amssymb}

\usepackage{amscd}
\usepackage{hyperref}
\usepackage{graphicx}
\hypersetup{pdfstartview=FitH,pdfauthor={HC},
pdftitle={Newton's Recurrence}}

\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}

%% \setlength{\evensidemargin}{0in}
%% \setlength{\oddsidemargin}{0in}
%% \setlength{\topmargin}{0in}
%% \setlength{\textwidth}{450pt}
%% \setlength{\textheight}{635pt}

\setlength{\textheight}{8.5in}
\setlength{\topmargin}{0.5in}
\setlength{\headheight}{0in}
\setlength{\headsep}{0in}
\setlength{\footskip}{0.5in}

\newcommand{\R}{\mathbb{R}}
\newcommand{\Cstar}{\widetilde{\mathbb{C}}}
\newcommand{\onto}{\rightarrow}
\begin{document}

\maketitle

\begin{abstract}
If Newton's method is repeatedly applied, then something cool happens.
\end{abstract}

\section{Introduction}

Newton's method is an algorithm that allows one to approximate the
roots of a function, starting with a guess.

If $f:\R \onto \R$ is a differentiable function, then Newton's method
maps one approximation to a better approximation:

$$N : x \mapsto x - \frac{f(x)}{f'(x)}.$$

Definition a sequence $\{x\}$ using $N$:
$$x_n = N(x_{n-1})  = x_{n-1} - \frac{f(x_{n-1})}{f'(x_{n-1})}. $$

Instead of evaluating $N(x)$ at each iteration of the method, leave it
in terms of the original guess, $x_0$.  Let $f$ be the quadratic
polynomial $f(x)= a(x-r_1)(x-r_2)$.  Then the first two functions in
the sequence are:

$$x_1 = N(x_0) = \frac{ - x_0^2 + r_1 r_2}{ - 2 x_0 + r_2 + r_1}$$

$$x_2 = N^2(x_0) = \frac
{ - x_0^4 + 6 r_1 r_2 x_0^2 - 4 r_1 r_2^2 x_0 + r_1 r_2^3 - 4 r_1^2
  r_2 x_0 + r_1^3 r_2 + r_1^2 r_2^2 }
{(2 x_0^2 - 2 x_0 r_2 + r_2^2 - 2 x_0 r_1 + r_1^2)( - 2 x_0 + r_2 +
  r_1)}$$

%% $$ x_3 = N^3(x_0) = \frac
%% { - x_0^8 + 28 r_1 r_2 x_0^6 - 56 r_1 r_2^2 x_0^5 + 70 r_1 r_2^3 x_0^4
%% - 56 r_1 r_2^4 x_0^3 + 28 r_1 r_2^5 x_0^2 - 56 r_1^2 r_2 x_0^5 + 70
%% r_1^3 r_2 x_0^4 - 56 r_1^4 r_2 x_0^3
%% + 28 r_1^5 r_2 x_0^2 - 8 r_1 r_2^6 x_0 + 70 r_1^2 r_2^2 x_0^4 + r_1
%% r_2^7 + r_1^5 r_2^3 + r_1^3 r_2^5 + r_1^7 r_2 + r_1^2 r_2^6 + r_1^6
%% r_2^2 + r_1^4 r_2^4
%% - 56 r_1^3 r_2^2 x_0^3 + 28 r_1^4 r_2^2 x_0^2 - 8 r_1^5 r_2^2 x_0 - 56
%% r_1^2 r_2^3 x_0^3 + 28 r_1^3 r_2^3 x_0^2 - 8 r_1^4 r_2^3 x_0 + 28
%% r_1^2 r_2^4 x_0^2
%% - 8 r_1^2 r_2^5 x_0 - 8 r_1^6 r_2 x_0 - 8 r_1^3 r_2^4 x_0}
%% {(2 x_0^4 - 4 x_0^3 r_2 + 6 x_0^2 r_2^2 - 4 r_2^3 x_0 + r_2^4 - 4
%% x_0^3 r_1 + 6 x_0^2 r_1^2 - 4 x_0 r_1^3 + r_1^4)(2 x_0^2 - 2 x_0 r_2
%% + r_2^2 - 2 x_0 r_1 + r_1^2)( - 2 x_0 + r_2 + r_1)}$$

\begin{theorem}\label{rform}
The $n$th iteration of Newton's Recurrence is
$$
x_n = N^n(x_0) = \frac
{ \sum\limits_{k=1}^{2^n}(-1)^{2^n} {2^n \choose k}
\Big( r_1 r_2^{2^n-k} - r_2r_1^{2^n-k} \Big) x_0^k }
{\sum\limits_{k=1}^{2^n}(-1)^{2^n} {2^n \choose k}
\Big( r_2^{2^n-k} - r_1^{2^n-k} \Big) x_0^k}.
$$
\end{theorem}

\begin{theorem}\label{abcform}
If $f(x)= ax^2+bx+c$, then the $n$th iteration of Newton's Recurrence
is
$$
x_n = N^n(x_0) = \frac
{ \sum
\Big( ?? \Big) x_0^k }
{\sum
\Big( ?? \Big) x_0^k}.
$$
\end{theorem}

\section{M\"obius Transformation}

Here, we will prove Theorem \ref{rform}.
Define a M\"obius Transformation $M$ as

$$M : z \mapsto \frac{z-r_1}{z-r_2}$$

We claim that $N(x) = M^{-1}(M(x)^2)$, or that the diagram
\[
\begin{CD}\label{...}
\R @> N_f >> \R \\
@ V{M} VV @ VV {M} V \\
\Cstar @>> (\cdot)^2 > \Cstar \\
\end{CD}
\]
commutes.

%Look at $M^{-1}(M(z)^2)$.

%\section{Bleg}

%Here, we will prove Theorem \ref{abcform}.

%\begin{thebibliography}{9}
%\bibitem{}
%\end{thebibliography}

\end{document}


\section{Unitary Modular Tensor Categories}
This is sometimes called the algebraic theory of anyons.

Suppose you ave a UMTC $\mathcal{C}$.
We have a quantity called the chiral central charge $C_-$.
For a Chern insulator the central large is 1,

$\mathcal{C}$ determines $C_- \mod 8$.
Depending on people,
it could be mod 24,
but that's because they have a slightly different definition of $\mathcal{C}$.

It's conjectured, or believed to be the case,
basically everyone I know believes this,
that if you ignore symmetries:
\begin{conjecture}
$(2+1)d$ topological phases are classified by this pair $(\mathcal{C},C_-)$.
This is a condensed matter conjecture.
\end{conjecture}

There is also another conjecture.
$\mathcal{C}$ always comes from some quantum Chern-Simons theory.

For any UMTC,
there is some appropriate CS theory with some appropriate choice of gauge group
that defines it.

The important conjecture is the classification of $(2+1)D$ topological phases.

So far in this class we saw 3 examples.

\subsection{$U(1)_k$ CS theory}
When we were studying $U(1)_k$ CS theory,
we found there are $k$ distinct anyons.
You can label them by
$[0], [1], \ldots, [k - 1]$.
Remember these were described by some Wilson loop operators
\begin{align}
    W_{[l]}(C)
    &=
    e^{i l \oint_C a}
\end{align}
And we described how these anyons have exchange statistics
\begin{align}
    \theta_l
    &=
    e^{2\pi i l^2/k}
\end{align}
We talked about how in CS theory if you want to define the exchange statistics,
you need to think of the worldline as a ribbon,
which is also sometimes called giving a framing to a worldline.
If you twist the framing by $2\pi$,
then that's related to the untwisted version by a phase $\theta_l$.

Another way of thinking about this is that if you have two particles both of
type $l$,
then you get a phase of $\theta_l$.
This is the exchange statistics and this is thinking about it as a topological
spin,
like spinning around by $2\pi$ gives a phase of $\theta_l$.

Then we also had metal statistics $M_{l,l'}$.
This means that if you have a $l$ and $l'$ particle,
and you braided around,
you would get a phase
\begin{align}
    M_{l,l'}
    &=
    e^{2\pi i l l'/k}
\end{align}
Furthermore,
you could also fuse these particles together
\begin{align}
    [l] \times [l'] = [l + l']
\end{align}
That you could see from the Wilson loop perspective
\begin{align}
    W_{l} W_{l'} = W_{l + l'}
\end{align}
So that's a summary of $U(1)_k$ CS theory.

\subsection{$\ZZ_2$ toric code}
There are four kinds of particles
$1,e,m\epsilon=\e\times m$.
And they have properties
\begin{align}
    e\times e = 1 = m\times m = \epsilon\times \epsilon
\end{align}
And the exchange statistics are
\begin{align}
    \hteta_e = \theta_m = 1
\end{align}
And mutual statistics

\subsection{Non-abelian fusion rules}
MZMs in vortex comes in $p + ip$ superconductors.
$\sigma$ is a $\pi$ flux vertex.
If you had a pair of $\sigma$ MZMs,
they could have even or odd fermion parity.

When I have two,
they can fuse to either even or odd fermion parity.
\begin{align}
    \sigma\times \sigma = 1 + \psi
\end{align}
And fusing two $\sigma$ is trivial.
\begin{align}
    \psi\times\psi &= 1
\end{align}
The interesting thing is that when I fuse two $\sigma$ together,
I don't get a unique outcome,
but a distinct outcome.

\begin{question}
    Should it be $\frac{1+\psi}{\sqrt{2}}$ instead?
\end{question}
No. When I write $1+\psi$,
I means either two $\sigma$ fuse to odd or even fermion parity,
so the notion of a square root doesn't make sense.

The idea of UMTC is to generalise these phenomenon that provides a mathematical
framework to describe what's going on in the most general way.

UMTC gives a mathematical framework to generalize these examples.

Once we define a UMTC,
what we can do from that data I specify
is that it can be used to define a TQFT,
but it defines more than just a TQFT int the sense of a path integral associated
with closed manifolds,
remember how before you could also have defect TQFTs where you have defects and
worldlines of defects.

So UMTC is a way to define TQFT with worldlines of anyons,
which you can think of as zero-dimensional defects.
Its world line is one-dimensional that can form knots and links,
so we can define path integrals in the presence of these world lines.

TQFT defines the Hilbert space describes the topological sectors of topological
phases of matter.
An important direction a subject of current research is connecting the UMTC that
I'm going to define for you to microscopic properties of a many-body system.
This is an ongoing research topic.
It's slow-going because not many people are working on it,
so it's not fully developed.
There is a nice paper by Kawagoe and Levin where they do nice work of
connecting the abstract UMTC to a physical many-body system that they're using
to describe.

\begin{question}
    Is it Hamiltonian level or state level?
\end{question}
State level.

\subsection{Topological charges (anyons)}
If you're a mathematician you might call these objects of a category,
but mathematicians would think of it as isomorphism classes of simple objects.
If you look up category theory in Wikipedia,
it will tell you category theory is objects and morphisms.
In these categories,
there s a special class of objects called simple objects and isomorphisms of
those and we call those anyons.

We have a finite set of these topological charges, or anyons.
Let's label them
$\left\{ 0,a,b,\ldots \right\}$.
The 0 is the same thing I used to call 1,
but I'll explain.

These are the topologically inequivalent class of anyons,
but the important thing is that there are a finite number.

The first thing that comes up is the notion of a \emph{fusion space}
or \emph{splitting space}.

Define a vector space $V_c^{ab}$ as a ``splitting space'' graphically.

We have a Y shape, $c$ going into a vertex $\mu$ that branches out into $b$ and
$c$.
In going from the graphical notation to the bra-ket notation,
there is a normalization convention
\begin{align}
    \left( \frac{d_a d_b}{d_c} \right)^{1/4}
    \ket{a,b;c,\mu}
    \in V_c^{ab}
\end{align}
In addition,
there is the dual vector space $V^{c}_{ab}$
called the \emph{fusion space}.
Graphically,
we have an upside down $Y$ with two entering edges $a$ and $b$
into vertex $\mu$ and leaving edge $c$.
\begin{align}
    \left(
    \frac{d_a d_b}{d_c}
    \right)^{1/4}
    \bra{a,b;c,\mu}
\end{align}
Then I define fusion coefficients
\begin{align}
    N_{ab}^{c}
    &=
    \dim V_{ab}^{c}
    =
    \dim V_{c}^{ab}
\end{align}
And so formally,
we can define the fusion rules as
\begin{align}
    a\times b
    &=
    \sum_{c}
    N_{ab}^{c} c
\end{align}

So,
for each $a,b,c$,
we have a vector space $V^{ab}_{c}$
We can think of these diagrams as operators,
or equivalently,
as a spacetime process.
So in other words,
we have splitting operators as fusing operators.
When I draw this $Y$ diagram,
you can literally think of an operator that takes an anyon $c$
and splits out anyons $a$ and $b$.
You can think $c$ moves in time in fixed location and splits into $a$ and $b$.
There is an index $\mu$ because there are in principle different orthogonal
states that have $a,b$ at different locations,
because the process that causes splitting could be distinct.
So the index $\mu=0,\ldots,N_{ab}^{c} - 1$
labels distinct to split

\begin{question}
    Can $N_{ab}^c$ be greater than 1?
\end{question}
It turns out yes there are examples,
but they are not simple.
The simplest example is $SU(3)$ level 3 CS theory,
which you quantize and gives $N_{ab}^{c}>1$.
In general $N_{ab}^{c}>1$ is considered exotic.

OK, if $N_{ab}^c=0$,
it means there's no way to split or fuse $a,b$ into $c$.
Usually,
$N_{ab}^{c}=0$ or $1$.
Examples where $N_{ab}^{c}>1$ are kind of exotic.
Using these spaces,
I can build up vector spaces with more and more anyons.

For example,
one can define a vector space
\begin{align}
    V_{c}^{a_1 \cdots a_n}
\end{align}
which you would depict as this tree that starts from $c$,
and branches out at $\m_2$ to $a_n$
and $b_n$,
which splits out into $a_{n-1}$ and $b_{n-1}$, etc.
So you can see
\begin{align}
    V_{c}^{a_1 \cdots a_n}
    &=
    \bigotimes_{b_1,\ldots,b_{n-2}}
    V_{b_1}^{a_1 a_2}
    \otimes
    V_{b_2}^{b_1 a_3}
    \otimes \cdots \otimes
    V_{c}^{b_{n-2} a_n}
\end{align}
When I have a state with anyons far apart from each other,
in general there could be  some residual topological degeneracy.
If I tell you where some MZMs are,
you may not know the fermion parity between pairs of anyons.
In general,
in order to specify a state,
what you do is pick a sequence of larger and larger regions,
then pick a basis where $a_1,a_2$ will fuse to some particle $b_1$,
then in you can fuse $b_2$ and $a_3$ to give $b_2$, etc,
and finally they all fuse to $c$.
Just knowing where all the anyons are is not enough to specify which topological
sector we're in,
so you can decompose the state into a fusion tree that provides a basis which
allows one to write the state.
\begin{align}
    \ket{\Psi_{a_1\cdots a_n}}
    &=
    \sum \Psi_{\cdots}
    \ket{a-1,a_2;b_1,\mu_1}
    \otimes
    \ket{a_3,b_1,b_2,\mu_2}
    \otimes
    \cdots
\end{align}

\begin{question}
    Can I think of these as spin-$\frac{1}{2}$?
\end{question}
Yes that's a perfect example,
but wiht spin-$\frac{1}{2}$,
you could in general have arbitrarily large,
so you could just truncate up to $k$.
That just gives $SU(2)_k$ CS theory,
or something similar.

At this stage,
we can already make a distinction 2 kinds of theories.
Abeliean thoeries where
\begin{align}
    a\times b
\end{align}
has a unique outcome
That is,
\begin{align}
    N_{ab}^c &=
    \begin{cases}
        1 &\text{for unique }c\\
        0 &\text{otherwise}
    \end{cases}
\end{align}
This means that $\dim V_c^{a_1\cdots a_n}=1$ or $0$,
depending on $c$.
It's $1$ for a unique $c$ and zero otherwise.

On the other hand,
in a non-Abelian theory,
$a\times b$ would generally have more than one fusino outcome.
And so that implies
\begin{align}
    V_{c}^{a_1\cdots a_n}
\end{align}
can be multi-dimensional,
and because thise $V$ is just telling us about our topological sectors of our
topologicla phase of matter,
it turns out no local operators can distinh what tstates I'm in,
so the number of states I have is tooplogically protected degeneracy.
An example of that is MZMs.

Just a few consequences of the graphical calculus.
If I want to take an inner product between two states,
the inner projject is obtained just by stacking the diagrams.
That just menas taking the inner product
\begin{align}
    \braket{a,b;c,\mu}{a',b';c',\mu'}
    &=
    \delta_{cc'}
    \delta{\mu\ma'}
    \sqrt{\frac{d_a d_b}{d_c}}
    I
\end{align}
where the identity $I$ is jst an edge from $c$ to $c$.

We can also hvae the $\mathbf{1}_{ab}$
that is the trivial operator
\begin{align}
    \mathbf{1}_{ab}
    &=
    [\text{two parallel edges}|
    =
    \sum_{c,\m} \sqrt{\frac{d_c}{d_a d_b}} [Y\text{ shape}]
\end{align}
There exists soeme unique vacuum charge 0,
somtiems denoted $1$.

There is a dual of $a=\bar{a}$ defined by
\begin{align}
    N_{a\bar{a}}^{0} &= 1\\
    N_{ab}^{0} &= \delta_{a\bar{b}}
\end{align}
Assume each $a$ has a unique $\bar{a}$.
\begin{align}
    0 &= \bar{0}\\
    \bar{\bar{a}} &= \bar{a}
\end{align}
You can also reverse the arrows $a$ becomes $\bar{a}$.

The quantum dimension $a_ \ge 1$ is defined as a loop of $a$.
The total quantum dimension is
\begin{align}
    \mathcalD{D}
    &=
    \sqrt{\sum_a d_a^2}
\end{align}

You can think of vacuum $0$ branching into $a$ and $\bar{a}$ which fuse to
become $0$ again.

I chose a particular wya to define the vector space.
There should be a basis transformations that take from one decompositon to
another.
These basis transfomrations in the most baiscaly fom take up

\subsection{$F$-symbols}
Imagine a process that splits $d$ into $a,b,c$.
The $F$ symbol tells you how you should relate one set of splitting processes
to another set of splitting processes.
\begin{align}
    V_d^{abc}
    \simeq
    \bigoplus_e
    V_e^{ab}
    \otimes
    V_d^{ec}
    \simeq
    \bigoplus_f V_d^{af}\otimes V_f^{bc}
\end{align}

These $F$ are basis transformations we want to be unitary operators.
\begin{align}
    F_{d}^{abc}:
    \bigoplus_e V_e^{ab}
    \otimes
    V_d^{ec}
    \to
    \bigoplus_{f}
    V_d^{af}
    \otimes V_f^{bc}
\end{align}
is a unitary operator,
but if you're a mathematician,
you won't require that $V$ has a positive semi-definite inner product and $F$ be
unitary,
but we do.

\subsection{Pentagon equation}
If you have a vector space of may anyons,
you could choose some way of decomposing $V$ into some basis,
and you want all the ways to consistent with one another.
This consistency equation is called the \emph{pentagon equation}.

The pentagon equation which says that when I go from here via 2 moves,
it's the same as going the other way by 3 rules.
\begin{align}
    FF &= \sum FFF
\end{align}
summing over a bunch of indices.
[picture of 5 branch diagrams connected by arrows]

If you look at this equation,
it should remind you of the 2-3 Pachner moves on the triangulation of the SPT
phase.
It requires us to consider the 2-3 Pachner move which gave us an equation that
looked very similar to this.
Note this is formally similar to the 2-3 Pachner move which gave us 3-cocycle
equations
$\omega \omega = \omega \omega \omega$
for $H^3\left( G, U(1) \right)$ in group cohomology.

\subsection{Maclane's coherence theorem}
The question is whether there are other kinds of consistency equations for the
$F$-moves to be fully consistent.
The answer is no.
\begin{theorem}
    Pentagon equation is sufficient for $F$-moves to be fully consistent.
\end{theorem}
Here are some interesting facts for you prove as an exercise.
\begin{enumerate}
    \item
    \begin{align}
        d_a d_b = N_{ab}^c d_c
    \end{align}
    \item Define fusion matrices $N_a$
    \begin{align}
        \left[ N_a \right]_{bc} &= N_{ab}^{c}
    \end{align}
    Then $d_a$ is the largest eigenvalue of $N_a$.
    \item Only the largest eigenvalue contributes.
        \begin{align}
            \sum_{c} \dim V_c^{\overbrace{a\cdots a}^{n}}
            &=
            \sum_{c} \left[ N_a^n \right]_{oc}
            \sim d_a^n
        \end{align}
\end{enumerate}
So the quantum number $d_a$ is the average number of quantum degrees of freedom,
because the dimension of the state space grows as the quantum dimension to the
$n$-th power.
If $d_a=1$,
then the dimension is just one of these anyons,
and that's an abelian anyon.
If $d_a>1$,
then you have a non-trivial degeneracy that grows exponentially with the number
of anyons and $a$ is a non-abelian anyon.

It turns out that the $F$-symbols determine $d_a$.
You can think of $d_a$ as a parameter.
You have some fusion rules,
$F$-symbols,
and so on.
Then there are some relationships between them,
because the Pentagon equation is a consistency equations that forces only some
choices of $F$, $d_a$ and $N_a$ being consistent.

The $F$-symbols themselves are basis-dependent,
so if I change the basis the $F$-symbols themselves are going to change.
They are not gauge invariant.

\subsection{Gauge transformations}
There is a basis transformation you can do of these $V_{c}^{ab}$
\begin{align}
    \Gamma_{c}^{ab}:
    V_{c}^{ab}
    \to
    V_{c}^{ab}
\end{align}
And you can relate
\begin{align}
    \ket{a,b; c,\mu}
    &=
    \sum_{\nu}
    \left[ \Gamma_c^{ab} \right]_{\mu\nu}
    \ket{a,b;c,\nu}
\end{align}
And then
\begin{align}
    \tilde{F}_d^{abc}
    &=
    \Gamma_e^{ab}
    \Gamma_d^{ec}
    F_d^{abc}
    \left( \Gamma_f^{bc} \right)^\dagger
    \left( \Gamma_d^{af} \right)^\dagger
\end{align}
If you have an inequivalent consistent choice of this data
$\left\{ N_{ab}^{c}, F_{d}^{abc} \right\}$,
then you have defined a unitary fusion category.

There are two Hilbert spaces.
There's the Hilbert space of the TQFT,
then there's the Hilbert space of the topological phase of matter,
which consists of microscopic constituents interacting.
This is the Hilbert space of the TQFT,
which models the topological sectors the ground states of the topological phase
of matter than are pinned to these locations.

So you can either think of them as the topological sectors of the real phase of
matter,
or just the Hilbert space of the TQFT.

\begin{question}
    Is this enough to define the ground state of a torus?
\end{question}
Suppose you want a vector space on a torus $V\left( T^2 \right)$.
I can start with a sphere here
with two punctures $a$, $\bar{a}$.
And another sphere with punctures $\bar{a}, a$,
which I glue together to give a torus.
And then
\begin{align}
    \bigoplus_{a} V_{0}^{a\bar{a}}
    \otimes
    V_0^{a\bar{a}}
    &=
    V\left( T^2 \right)
\end{align}
So then
\begin{align}
    \dim V\left( T^2 \right) &=
    \sum_a 1
    = \text{\# of anyons}
\end{align}
\begin{question}
    Can you extract all the data from the path integral of the TQFT?
\end{question}
I haven't described how to find a TQFT from this structure yet.
It's almost another lecture.

Let me give you a nice example to have in mind of a fusion category which
connects to this group cohomology.

Our unitary fusion category will be denoted by
\begin{align}
    C &=
    \Vec_{G}^{[\omega_3]}
\end{align}
where $[\omega_3]\in H^3\left( G, U(1) \right)$.
The anyons are
$\left\{ g \mid g \in G \right\}$
with
$g\times h = gh$
and $N_{g,h}^{k} = \delta_k,gh$.
Then
\begin{align}
    F_{g,h,k}^{g,h,k}
    &=
    \omega_3\left( g,h,k \right)
\end{align}
So the pentagon equation gives a 3-cocycle equation for $\omega_3$.
The gauge transformation corresponds to 3-coboundaries.

Any UTF $\mathcal{C}$ can be used to define a $(2+1)D$ TQFT in terms of a state
sum,
which generalized the Digraph-Witten theory.

The amplitude for the tetrahedra is the $F$-symbols.
The pentagon equation you can view as retriangulation invariance of the path
integral.

These TQFTs define ground state wave functions on their boundaries.
These are Tuaev-Viro-Barrett-Westbury TQFTs,
which leads to Levin-Wen string-net models.

\subsection{Braiding}
I want to take anyons around each other and exchange them and so on.
I take a particle $c$ up to vertex $\mu$ that then branches and braids into $b$,
$a$.
You should really compare this to a diagram where there is no braiding,
and that is via $R$-symbols.
\begin{align}
    \left[ \text{diagram} \right]
    &=
    \sum_c \left[ R_c^{ab} \right]_{\mu\nu}
    \left[ \text{diagram} \right]
\end{align}
If I had a state
\begin{align}
    \ket{\Psi_{a_1\cdots a_n}}
    &=
    \sum
    \Psi_{\cdots}
    \ket{a_1,a_2;b_1,\mu_1}
    \ket{a_3b_1; b_2, \mu_2}\cdots
\end{align}
The braid operator can act like full braiding
\begin{align}
    B_{12}
    \ket{\Psi_{a_1,\cdots a_n}}
    &=
    \sum
    \Psi_{\cdots}
    \left[
    R^{a_2 a_1} R^{a_1 a_2}
    \right]_{\mu-1,\mu_1'}
    \ket{a_1,a_2; b_1, \mu_1'}
    \cdots
\end{align}
I can also define the $R^{ab}$ operator,
which is a diagram of $a$ and $b$ crossing.
\begin{align}
    R^{ab}
    &=
    [\text{diagram of $a$ and $b$ crossing}]\\
    &=
    \sum_{c,\mu}
    \sqrt{\frac{d_c}{d_a d_b}}
    [\text{diagram}]\\
    &=
    \sum_{c,\mu}
    \sqrt{\frac{d_c}{d_a d_b}}
    \left[ R_c^{ab} \right]_{\mu\nu}
    [\text{diagram}]
\end{align}
Unitary here means that
\begin{align}
    \left[ R^{ab} \right]^{-1}
    &=
    \left[ R^{ab} \right]^\dagger
\end{align}
so $R^{ab}$ is unitary.
Braiding commutes with fusion.

[diagrams]

Using these diagrams,
you can prove this famous relationship called the Yang-Baxter relation.

[diagram]

Just like we had the pentagon equation,
we need a consistency equation,
which leads us to a set of equations called the
\emph{hexagon equations},
which is compatibility between braiding and fusion.

Let me draw one of the diagrams.

[6 diagrams with arrows]

There is also another equation where the braid goes under instead of over.

If you actually include all the Greek indices, you will have
\begin{align}
    \sum_{\text{greeks}} RFR
    &=
    \sum_{\text{greeks}} \sum FRF\\
    \sum_{\text{greeks}} R^{-1}FR^{-1}
    &=
    \sum_{\text{greeks}} \sum FR^{-1}F
\end{align}

\begin{question}
    Do people do this day-to-day?
\end{question}
It is a research topic in maths to find solutions to these equations
systematically,
although it's very difficult because they're extremely complicated equations,
but yes,
there are all sorts of tricks to solve them.

Once we have these $R$-matrices,
we can define some other things.
\begin{align}
    \theta_a
    &=
    \theta_{\bar{a}}
    =
    \sum_{c,\mu}
    \frac{d_c}{d_a}
    \left[ R_c^{aa} \right]_{\mu\mu}\\
    &=
    \frac{1}{d_a}
    \left[ \text{diagram of figure 8}\right]
\end{align}

\subsection{Topological $S$-matrix}
The other important diagram to define is the topological $S$-matrix.
This is a matrix we diagrammatically define like this
\begin{align}
    S_{ab} &=
    \frac{1}{\mathcal{D}}
    \left[ \text{diagram of two rings $a$ and $b$ interlocking }\right]
\end{align}
Using the $S$-matrix there are some important identities one can prove.
Consider a strand $b$ and you take an $a$ loop around it,
then that's equivalent to $S_{ab}/S_{0b}$ times $b$.

You can verify this diagram by closing it up,
or taking the trace of the operator.
Understanding this relationship is useful for describing this very important
identity.

Consider a line of $x$ with two loops $a$ and $b$ going around it.
They can go around individually like
$\frac{S_{ax}}{S_{0x}} \frac{S_{bx}}{S_{0x}}$
times $x$,
or I can fuse the $a$ and $b$ together to get
\begin{align}
    \sum_{c} N_{ab}^c [\text{diagram}]
    &=
    \sum_c N_{ab}^c \frac{S_{cx}}{S_{0x}}
\end{align}
so
\begin{align}
    \frac{S_{ax}}{S_{0x}}
    \frac{S_{bx}}{S_{0x}}
    &=
    \sum_{c}
    N_{ab}^{c}
    \frac{S_{cx}}{S_{0x}}
\end{align}
which basically means these obey the fusion rules.

\subsection{Summary}
So under gauge transformation
\begin{align}
    R_{c}^{ab}
    \to
    \tilde{R}_{c}^{ab}
    =
    \Gamma_{c}^{ba}
    R_{c}^{ab}\left( \Gamma_{c}^{ab} \right)^\dagger
\end{align}
If you give me an inequivalent consistent choice of $\left\{ N,F,R \right\}$,
it can define a unitary braided fusion category (UBFC).
So if you give me some very crazy links and knots,
I can give you a number using these rules.

There's one more: modularity.
Modularity basically just meas $S$ is unitary,
which means I can invert that relation on the right hand side to write
\begin{align}
    N_{ab}^{c}
    &=
    \sum_{x}
    \frac{S_{ax} S_{bx} S_{cx}^*}{S_{0x}}
\end{align}
which is the famous Verlinde formula.
There's a nice relationship the $S$ matrix and the twists satisfy.
There is also the charge-conjugation matrix
\begin{align}
    C_{ab} &=
    \delta_{a\bar{b}}
\end{align}
And let me define the twist
\begin{align}
    T_{ab}
    &=
    \theta_a \delta_{ab}
\end{align}
And it turns out there is a really beautiful relationship
\begin{align}
    \left( ST \right)^3 &=
    e^{2\pi i C_{-}/S} C\\
    S^2 &= C\\
    C^2 &= \mathbf{1}
\end{align}
Here $C_-$ is the chiral central charge.
And it turns out there is
\begin{align}
    e^{2\pi i C_{-}/8}
    &=
    \frac{1}{\mathcal{D}}
    \sum_{a}
    d_a^2
    \theta_a
\end{align}
The modular tensor category defines the central charge mod 8 because of this
formula.
You may recognize this is a projective representation of $SL(2,\ZZ)$.

One more important fact.
Modularity is actually equivalent to braiding non-degeneracy,
which just means that
for all $a\ne 0$,
there exists a $b$ such that
\begin{align}
    R^{ab}R^{ba} \ne \mathbf{1}
\end{align}
That means every anyon is detectable by braiding.
For any anyon $a$,
there is some $b$ such that if I braid it all around,
I don't get something trivial,
so there exist no invisible particles by braiding.
This is equivalent to modularity.

So a braided fusion category with a unitary $S$ matrix is a modular fusion
category.
Once you have this,
you have a topological order,
if you don't care about symmetry.
If you do care about symmetry,
then you need to soup up this theory with a symmetry group $G$.
That's another lecture.

It's also another lecture for how to get from a UMFC to  $(2+1)D$ TQFT.