% use [nosolutions] flag to hide solutions.
% use [solutions] flag to show solutions.
\documentclass[
	solutions,
	singlenumbering
]{../../resources/ormc_handout}

\usepackage{mathtools} % for \coloneqq

\usepackage{alltt}


\newenvironment*{helpbox}[1][0.5]{
	\begin{center}
	\begin{tcolorbox}[
		colback=white!90!black,
		colframe=white!90!black,
		coltitle=black,
		center title,
		width = #1\textwidth,
		leftrule = 0mm,
		rightrule = 0mm,
		toprule = 0mm,
		bottomrule = 0mm,
		left = 1mm,
		right = 1mm,
		top = 1mm,
		bottom = 1mm,
		toptitle = 1mm,
		lefttitle = 1mm,
		titlerule = 1pt,
		title={\textbf{Things you will need:}}
	]
}{
	\end{tcolorbox}
	\end{center}
}

% Logic block comment
\newcommand{\cmnt}[1]{
	\textcolor{gray}{\# #1}
}


\newcommand{\thus}{\(\Rightarrow\)}
\newcommand{\qed}{\(\blacksquare\)}


\begin{document}

	\maketitle
		<Advanced 2>
		<Fall 2022>
		{To Mock a Mockingbird}
		{
			Prepared by Mark on \today \\
			Based on a book of the same name.
		}

	\section{Introduction}

	A certain enchanted forest is inhabited by talking birds. Each of these birds has a name, and will respond whenever it hears the name of another. Suppose you are exploring this forest and come across the bird $A$. You call the name of bird $B$. $A$ hears you and responds with the name of some other bird, which we will designate $AB$.

	Bird $AB$ is, by definition, $A$'s response to $B$.

	\vspace{2mm}

	As you wander around this forest, you quickly discover two interesting facts:
	\begin{enumerate}[itemsep = 1mm]
		\item $A$'s responds to $B$ mustn't be the same as $B$'s response to $A$.
		\item Given three birds $A$, $B$, and $C$, $(AB)C$ and $A(BC)$ are not necessarily the same bird. \\
		Bird $A(BC)$ is $A$'s response to bird $BC$, while $(AB)C$ is $AB$'s response to $C$. \\
		Thus, $ABC$ is ambiguous. Parenthesis are mandatory.
	\end{enumerate}

	\vspace{2mm}

	You also find that this forest has two laws:
	\begin{enumerate}[itemsep = 1mm]
		\item $L_1$, \textit{The Law of Composition}: \\
		For any two birds $A$ and $B$, there must be a bird $C$ so that $Cx = A(Bx)$
		\item $L_2$, \textit{The Law of the Mockingbird}: \\
		The forest must contain the Mockingbird $M$, which always satisfies $Mx = xx$. \\
		In other words, the Mockingbird's response to any bird $x$ is the same as $x$'s response to itself.
	\end{enumerate}

	\vfill

	\definition{}
	We say a bird $A$ is fond of a bird $B$ if $A$ responds to $B$ with $B$. \\
	In other words, $A$ is fond of $B$ if $AB = B$.

	\vfill

	\definition{}
	We say a bird $C$ \textit{composes} $A$ with $B$ if for any bird $x$,
	$$
		Cx = A(Bx)
	$$
	In other words, this means that $C$'s response to $x$ is the same as $A$'s response to $B$'s response to $x$.

	\vfill
	\pagebreak

	\section{To Mock a Mockingbird}

	\problem{}
	The bear, a lifelong resident of the forest, tells you that any bird $A$ is fond of at least one other bird. \\
	Complete his proof.
	\begin{alltt}
		let A           \cmnt{Let A be any any bird.}
		let Cx := A(Mx) \cmnt{Define C as the composition of A and M}

		\cmnt{The rest is up to you.}
		CC = ??
	\end{alltt}


	\begin{helpbox}
		\texttt{Law:} There exists a Mockingbird, $Mx := xx$ \\
		\texttt{Def:} $A$ is fond of $B$ if $AB = B$
	\end{helpbox}


	\begin{solution}
		\begin{alltt}
			let A           \cmnt{Let A be any any bird.}
			let Cx := A(Mx) \cmnt{Define C as the composition of A and M}
			CC = A(MC)
			   = A(CC)  \qed{}
		\end{alltt}
	\end{solution}

	\vfill
	\problem{}
	We say a bird $A$ is \textit{egocentric} if it is fond if itself.

	Show that the laws of the forest guarantee that at least one bird is egocentric.


	\begin{helpbox}
		\texttt{Law:} There exists a Mockingbird, $Mx := xx$ \\
		\texttt{Def:} $A$ is fond of $B$ if $AB = B$ \\
		\texttt{Lem:} Any bird is fond of at least one bird.
	\end{helpbox}

	\begin{solution}
		\begin{alltt}
			\cmnt{We know M is fond of at least one bird.}
			let E so that ME = E

			ME = E     \cmnt{By definition of fondness}
			ME = EE    \cmnt{By definition of M}
			\thus{} EE = E  \qed{}
		\end{alltt}
	\end{solution}

	\vfill
	\pagebreak


	\problem{}
	We say a bird $A$ is \textit{agreeable} if for all birds $B$, there is at least one bird $x$ on which $A$ and $B$ agree. \\
	This means that $Ax = Bx$.

	\begin{helpbox}
		\texttt{Def:} $Mx := xx$
	\end{helpbox}

	\begin{solution}
		We know that $Mx = xx$. \\

		From this definition, we see that $M$ agrees with any $x$ on $x$ itself.
	\end{solution}

	\vfill

	\problem{}
	Take two birds $A$ and $B$. Let $C$ be their composition. \\
	Show that $A$ must be agreeable if $C$ is agreeable. \\
	The bear has again given you a hint.
	\begin{alltt}
		\cmnt{Given information}
		let A, B
		let Cx := A(Bx)

		let D            \cmnt{Arbitrary bird}
		let Ex := D(Bx)  \cmnt{Define E as the composition of D and B}
		Cy = ??
	\end{alltt}

	\begin{helpbox}[0.65]
		\texttt{Def:} $A$ is agreeable if $Ax = Bx$ for all $B$ with some $x$. \\
		\texttt{Law:} For any $A, B$, there is C defined by Cx = A(Bx)
	\end{helpbox}


	\begin{solution}
		\begin{alltt}
			\cmnt{Given information}
			let A, B
			let Cx := A(Bx)

			let D           \cmnt{Arbitrary bird}
			let Ex := D(Bx) \cmnt{Define E as the composition of D and B}
			Cy = Ey         \cmnt{For some y, because C is agreeable}
			\thus{} A(By) = Ey
			\thus{} A(By) = D(By)  \qed{}
		\end{alltt}
	\end{solution}

	\vfill
	\pagebreak

	\problem{}
	Given three arbitrary birds $A$, $B$, and $C$, show that there exists a bird $D$ defined by $Dx = A(B(Cx))$

	\begin{solution}
		\begin{alltt}
			let A, B, C

			\cmnt{Invoke the Law of Composition:}
			let Q := BC
			let D := AQ

			D = AQ
			  = A(BC)  \qed{}
		\end{alltt}
	\end{solution}

	\vfill


	\problem{}
	We say two birds $A$ and $B$ are \textit{compatible} if there are birds $x$ and $y$ so that $Ax = y$ and $By = x$. \\
	Note that $x$ and $y$ may be the same bird. \\
	Show that any two birds in this forest are compatible. \\
	\begin{alltt}
		let A, B
		let Cx := A(Bx)
	\end{alltt}

	\begin{helpbox}
		\texttt{Law:} Law of composition \\
		\texttt{Lem:} Any bird is fond of at least one bird.
	\end{helpbox}

	\begin{solution}
		\begin{alltt}
			let A, B

			let Cx := A(Bx)  \cmnt{Composition}
			let y := Cy      \cmnt{Let C be fond of y}

			Cy = y
			\thus{} A(By) = y

			let x := By  \cmnt{Rename By to x}
			Ax = y  \qed{}
		\end{alltt}
	\end{solution}

	\vfill

	\problem{}
	Show that any bird that is fond of at least one bird is compatible with itself.

	\begin{solution}
		\begin{alltt}
			let A
			let x so that Ax := x
			Ax = x  \qed{}
		\end{alltt}
		That's it.
	\end{solution}


	\vfill
	\pagebreak

\end{document}