···11+\taxon{Definition}
22+\author{liamoc}
33+\title{Total order}
44+\p{A \em{total order} is a [partial order](dm-0000) that also satisfies [totality](dm-0008).
55+}
+5
trees/dm-0008.tree
···11+\taxon{Definition}
22+\author{liamoc}
33+\title{Totality}
44+\p{A binary relation #{\mathcal{R} \subseteq X \times X} is \em{total} iff, for all #{x, y \in X}, either #{x\ \mathcal{R}\ y} or #{y\ \mathcal{R}\ x}.
55+}
+6
trees/dm-0009.tree
···11+\taxon{Definition}
22+\title{Countable sets}
33+\author{liamoc}
44+\p{
55+ A set #{X} is \em{countable} if it can be put into a [one-to-one correspondence](dm-000A) with the natural numbers #{\mathbb{N}}.
66+}
+6
trees/dm-000A.tree
···11+\taxon{Definition}
22+\title{Set bijection}
33+\author{liamoc}
44+\p{
55+ A \em{bijection} between sets #{A} and #{B} is a one to one correspondence between their elements. That is, #{R \subseteq A \times B} is a \em{bijection} between #{A} and #{B} if, for each #{x \in A}, there is exactly one #{y \in B} such that #{x\ R\ y}, and vice versa.
66+}
+6
trees/dm-000B.tree
···11+\taxon{Definition}
22+\title{Set isomorphism}
33+\author{liamoc}
44+\p{
55+ Two sets #{A} and #{B} are \em{isomorphic}, written #{A \simeq B}, iff a [bijection](dm-000A) exists between them.
66+}
+2-2
trees/dt-0007.tree
···3030\transclude{dt-000P}
3131Unfolding the definition of #{\Sigma}, we end up with a recursive equation for the definition of #{\mathbf{C}}:
3232##{\mathbf{C} \; = \; (\mathcal{V} \rightarrow (\mathbb{Z} \uplus \mathbf{C})) \rightarrow (\mathcal{V} \rightarrow (\mathbb{Z} \uplus \mathbf{C}))}
3333-Such equations have \em{no} set-theoretic solution, even if we weaken equality to mere \em{set isomorphism} (here notated #{\simeq}).
3333+Such equations have \em{no} set-theoretic solution, even if we weaken equality to mere [set isomorphism](dm-000B) (here notated #{\simeq}).
3434}
3535\subtree{\taxon{Example}\title{A simpler equation with no solution}
3636-\p{Consider the recursive equation #{X = X \rightarrow \mathbb{B}}. Cantor's theorem says that there is no set #{X} such that #{X \simeq \pow{X}} (where #{\pow{X}} is the [[dm-0006]] of #{X}), and seeing as #{\pow{X} \simeq (X \rightarrow \mathbb{B})} it follows that #{X = X \rightarrow \mathbb{B}} has no solution.}
3636+\p{Consider the recursive equation #{X = X \rightarrow \mathbb{B}}. Cantor's theorem says that there is no set #{X} such that #{X \simeq \pow{X}} (where #{\pow{X}} is the [power set](dm-0006) of #{X}), and seeing as #{\pow{X} \simeq (X \rightarrow \mathbb{B})} it follows that #{X = X \rightarrow \mathbb{B}} has no solution.}
3737}
3838\p{Any kind of \em{higher-order} construct leads to such recursive domain equations.}
3939\scope{
-1
trees/dt-000T.tree
···88\p{Not all [monotonic](dt-000J) functions on [posets](dm-0004) have [fixed points](dt-000S), and some have \em{multiple} [fixed point](dt-000S)s!}
99}}
1010\p{So, requiring our functions to be monotonic is insufficient to guarantee that a single "best" solution exists. }
1111-\p{Intuitively, recursive programs are executed by "unfolding" as much as necessary to get a result. We would like to characterise our domains to ensure that solutions always exist, and to allow us to pick the solutions that are "minimal" in the sense that they rely on a minimal amount of unfolding.}
···11+\taxon{Definition}
22+\title{Chain}
33+\author{liamoc}
44+\p{
55+ A \em{chain} in a [poset](dm-0004) #{X} is a [totally ordered](dm-0007) subset of #{X}. That is, a subset #{Y \subseteq X} is a \em{chain} iff:
66+ ##{\forall x, y \in Y.\; x \sqsubseteq y \lor y \sqsubseteq x}
77+}
+7
trees/dt-000W.tree
···11+\taxon{Definition}
22+\title{#{\omega}-chain}
33+\author{liamoc}
44+\p{
55+ An \em{#{\omega}-chain} is a [chain](dt-000V) that is [countable](dm-0009). In other words, it is a sequence of elements #{x_{i \in \mathbb{N}}} such that:
66+ ##{x_0 \sqsubseteq x_1 \sqsubseteq x_2 \sqsubseteq x_3 \dots}
77+}
+7
trees/dt-000X.tree
···11+\title{Ascending Kleene chain}
22+\taxon{Example}
33+\p{
44+ Given a [pointed poset](dt-000G) #{(X,\subseteq)} and a [monotonic](dt-000J) function #{f : X \rightarrow X}, the \em{ascending Kleene chain} is the [#{\omega}-chain](dt-000W):
55+ ##{ \bot \sqsubseteq f(\bot) \sqsubseteq f(f(\bot)) \sqsubseteq f(f(f(\bot))) \sqsubseteq \cdots}
66+ Because #{\bot} is the [bottom element](dt-000A), we know that #{\bot \sqsubseteq f(\bot)}. Each subsequent step in the chain exists because of [monotonicity](dt-000J).
77+}
+7
trees/dt-000Y.tree
···11+\title{Chains and Unfolding}
22+\p{Intuitively, recursive programs are executed by "unfolding" as much as necessary to get a result. We would like to characterise our domains to ensure that solutions always exist, and to allow us to pick the solutions that are "minimal" in the sense that they rely on a minimal amount of unfolding.}
33+\p{After converting a recursive program into a non-recursive [monotonic](dt-000J) higher order function #{f}, the [fixed point](dt-000S) we desire would intuitively be the [limit](todo) of the [ascending Kleene chain](dt-000X) of #{f}: }
44+\transclude{dt-000X}
55+\p{Each element of [this chain](dt-000X) is another "unfolding" of the recursion.}
66+\transclude{dt-000V}
77+\transclude{dt-000W}
+6
trees/dt-000Z.tree
···11+\title{From chains to directed sets}
22+\p{While [#{\omega}-chains](dt-000W) are technically sufficient for [denotational semantics](dt-0001), for our purposes it is a little more convenient to think in terms of [directed sets](dt-0010) rather than [chains](dt-000V).}
33+\transclude{dt-0010}
44+\transclude{dt-0011}
55+\transclude{dt-0012}
66+\transclude{dt-0013}
+29
trees/dt-0010.tree
···11+\taxon{Definition}
22+\title{Directed set}
33+\author{liamoc}
44+\p{
55+Formally, A non-empty subset #{Y \subseteq X} of a [poset](dm-0004) #{(X,\sqsubseteq)} is \em{directed} iff: ##{\forall x, y \in Y.\ \exists z \in Y.\ x \sqsubseteq z \land y \sqsubseteq z}
66+\figure{\tex{\usepackage{tikz}}{
77+\begin{tikzpicture}
88+\draw[dotted, thick] (0,0) circle (1.5 cm);
99+\draw[dotted, thick] (5,0) circle (1.5 cm);
1010+\node at (2.5,0) {\Huge $\Rightarrow$ };
1111+\node at (2.5,0.6) {$\exists z$ };
1212+\node at (-0.7,-0.5) { \Large $\bullet$ };
1313+\node at (-0.7,-0.8) { $x$ };
1414+\node at (0.7,-0.5) { \Large $\bullet$ };
1515+\node at (0.7,-0.8) { $y$ };
1616+\node (x) at (4.3,-0.5) { \Large $\bullet$ };
1717+\node at (4.3,-0.8) { $x$ };
1818+\node (y) at (5.7,-0.5) { \Large $\bullet$ };
1919+\node at (5.7,-0.8) { $y$ };
2020+\node (z)at (5,0.5) { \Large $\bullet$ };
2121+\node at (5,0.8) { $z$ };
2222+\draw[thick] (x) -- (z)
2323+ (y) -- (z);
2424+\end{tikzpicture}
2525+}
2626+}
2727+The #{z} above is an [upper bound] of #{x} and #{y}. Hence, a non-empty set is \em{directed} iff every pair of values has an [upperbound] \em{in the set}.}
2828+\p{Intuitively, directed sets are "going somewhere" — given two elements we can always find a "greater" one in the set.}
2929+
+32
trees/dt-0011.tree
···11+\taxon{Example}
22+\p{The [power set](dm-0006) of any set #{X} is directed under #{\subseteq}.}
33+\p{ \strong{Below}: #{\cal{P}(\{1,2,3\})}: }
44+\figure{\tex{\usepackage{tikz}}{
55+\begin{tikzpicture}
66+\node (abc) at (1,3) {$\{1,2,3\}$};
77+\node (ab) at (0,2) {$\{1,2\}$};
88+\node (ac) at (1,2) {$\{1,3\}$};
99+\node (bc) at (2,2) {$\{2,3\}$};
1010+\node (a) at (0,1) {$\{1\}$};
1111+\node (b) at (1,1) {$\{2\}$};
1212+\node (c) at (2,1) {$\{3\}$};
1313+\node (em) at (1,0) {$\emptyset$};
1414+\draw[thick]
1515+ (em) -- (a)
1616+ (em) -- (b)
1717+ (em) -- (c);
1818+\draw[thick]
1919+ (ab) -- (abc)
2020+ (bc) -- (abc)
2121+ (ac) -- (abc);
2222+\draw[thick]
2323+ (a) -- (ab)
2424+ (a) -- (ac);
2525+\draw[thick]
2626+ (c) -- (bc)
2727+ (c) -- (ac);
2828+\draw[thick]
2929+ (b) -- (bc)
3030+ (b) -- (ab);
3131+\end{tikzpicture}
3232+}}
+7
trees/dt-0012.tree
···11+\taxon{Theorem}
22+\author{liamoc}
33+\p{All non-empty [chains](dt-000V) are [directed](dt-0010).}
44+\subtree{
55+\taxon{Proof}
66+\p{Let #{C} be a chain. Then, given two elements #{x,y \in C} we know from [totality](dm-0008) that either #{x \sqsubseteq y} or #{y \subseteq x}. If #{x \sqsubseteq y}, then #{y} is the [upperbound], otherwise #{x} is the [upperbound]. }
77+}
+30
trees/dt-0013.tree
···11+\taxon{Definition}
22+\title{Consistent subsets}
33+\p{
44+ A subset #{Y \subseteq X} of a [poset](dm-0004) #{X} is \em{consistent} iff
55+ ##{\exists x \in X.\ \forall y \in Y.\ y \sqsubseteq x}
66+ Such an #{x} is called an [upper bound] of #{Y}.
77+ \figure{\tex{\usepackage{tikz}}{
88+ \begin{tikzpicture}
99+ \node (a) at (-0.8,0) {$\bullet$};
1010+ \node (b) at (0.8,0) {$\bullet$};
1111+ \node (c) at (0,-1) {$\bullet$};
1212+ \draw[thick] (c) -- (a) (c) -- (b);
1313+ \draw[dashed, rounded corners=0.4cm] (-1.2,-0.4) rectangle (1.2,0.4);
1414+ \node (foo) at (2,-1.5) {a non-\emph{consistent} set};
1515+ \draw[->,thick] (foo) edge[bend right] (1.2,0);
1616+ \node (a) at (4.2,0) {$\bullet$};
1717+ \node (b) at (5.8,0) {$\bullet$};
1818+ \node (x) at (4.2,1) {$\bullet$};
1919+ \node (y) at (5.8,1) {$\bullet$};
2020+ \node (c) at (5,-1) {$\bullet$};
2121+ \draw[thick] (c) -- (a) (c) -- (b) (a) -- (x) (a) -- (y) (b) -- (x) (b) -- (y);
2222+ \draw[dashed, rounded corners=0.4cm] (3.8,-0.4) rectangle (6.2,0.4);
2323+ \node (foo) at (7,-1.2) {a \emph{consistent} set};
2424+ \draw[->,thick] (foo) edge[bend right] (6.2,0);
2525+ \node (foo) at (2,1) {upper bound};
2626+ \draw[->,thick] (foo) edge[bend left] (x);
2727+ \draw[->,thick] (foo) edge[bend left] (y);
2828+ \end{tikzpicture}
2929+ }}
3030+}