···11+\taxon{Definition}
22+\author{liamoc}
33+\title{Contravariant functor}
44+\p{A \em{contravariant} [functor](dm-000J) #{\mathcal{F}} is a [functor](dm-000J) that, instead of associating a morphism #{X \xrightarrow{m} Y} with a morphism #{\mathcal{F}(X) \xrightarrow{\mathcal{F}(m)} \mathcal{F}(Y)}, it instead gives a morphism #{\mathcal{F}(Y) \xrightarrow{\mathcal{F}(m)} \mathcal{F}(X)$}. Alternatively, it can be viewed as a functor from the [dual category](dm-000Q).}
+1-1
trees/dt/dt-004M.tree
···22\author{liamoc}
33\title{Untyped higher-order languages}
44\p{
55- If we take [PCF](dt-003T), \em{discard} the type system, #{\syn{fix}}, natural number primitives and any other superfluous features, and just boil our language down to a minimal, Turing-complete subset, we end up with the [untyped #{\lambda}-calculus](dt-004K) — a language consisting only of untyped functions.}
55+ If we take [PCF](dt-003T), \em{discard} the type system, [#{\textbf{fix}}](dt-001Q), natural number primitives and any other superfluous features, and just boil our language down to a minimal, Turing-complete subset, we end up with the [untyped #{\lambda}-calculus](dt-004K) — a language consisting only of untyped functions.}
66\transclude{dt-004K}
77\p{Trying to give a semantics to the [untyped #{\lambda} calculus](dt-004K) poses an issue: we can no longer rely on the type of an expression to select an appropriate semantic domain. Instead, we we must pick a \em{single} domain #{D} which, since functions can be applied to themselves, must apparently include the set of functions #{D \contto D}:
88##{
···44\p{This lecture is based on material from [[haskellhutt]], [[jlongley]],[[danascott]], [[jstoy]], [[cgunter]], and [[gwinskel]].}
55\transclude{dt-004J}
66\transclude{dt-004O}
77+\transclude{dt-0052}
78\p{\strong{TODO: Retraction pairs stuff}}
+5
trees/dt/dt-0050.tree
···11+\import{dt-macros}
22+\title{Constructing endofunctors}
33+\author{liamoc}
44+\p{If we have a mapping on [cpos](dt-001D) #{\mathcal{F} : \textbf{Cpo} \rightarrow \textbf{Cpo}} that is made up of the primitives #{\times}, #{+}, #{\otimes}, #{\oplus}, #{\mathbf{1}} and #{(\cdot)_\bot}, we can generate a corresponding \em{morphism mapping} on continuous functions #{\mathcal{F} : (A\contto B) \rightarrow (\mathcal{F}(A)\contto \mathcal{F}(B))} by using the corresponding morphism mappings of each of these operators. Thus any such mapping can be turned into an [endofunctor](dt-004T).}
55+\transclude{dt-0051}
···11+\import{dt-macros}
22+\taxon{Problem}
33+\author{liamoc}
44+\title{Contravariance in the function arrow}
55+\p{We cannot get morphism mappings in [the category #{\textbf{Cpo}}](dt-002B) as easily as \ref{dt-0050} when our object mapping makes use of the function operators #{\strictto} and #{\contto}, as they are [contravariant](dm-000S) in their first argument. This means the [functor](dm-000J) that they extend to is not #{\textbf{Cpo} \rightarrow \textbf{Cpo}} but #{\textbf{Cpo}^\textsf{op} \rightarrow \textbf{Cpo}}, where #{\textbf{Cpo}^\textsf{op} } is the [dual category](dm-000Q) of #{\textbf{Cpo}}. The morphisms end up the wrong way around. }
66+77+\p{As an example, consider #{\mathcal{F}(X) = X\contto\mathbb{Z}_\bot}. Then, recalling [the morphism mapping of the #{\contto} functor](dt-002X):
88+##{
99+\inferrule{f : A \contto B \quad g : C\contto D}{f\contto g : (B\contto C)\contto (A\contto D)}
1010+}
1111+We can generate a morphism mapping for #{\mathcal{F}}: ##{\mathcal{F}(f)\; =\; f\contto\mathsf{id}_{\mathbb{Z}_\bot}\; =\; (\lambda h.\ \mathsf{id}_{\mathbb{Z}_\bot}\circ h \circ f)\; = \;(\lambda h.\ h \circ f) }
1212+However, this mapping has the wrong type. For #{f : A\contto B}, then #{\mathcal{F}(f) : (B\contto \mathbb{Z}_\bot) \rightarrow (A\contto \mathbb{Z}_\bot)}, which is #{\mathcal{F}(B)\contto\mathcal{F}(A)}, not the required #{\mathcal{F}(A)\contto \mathcal{F}(B)}. This is because the generated functor is [contravariant](dm-000S), not [covariant](dm-000J).
1313+}
+14
trees/dt/dt-0054.tree
···11+\import{dt-macros}
22+\taxon{Definition}
33+\title{Retraction pair}
44+\author{liamoc}
55+\p{A \em{retraction pair} #{(f,g)} on [cpos](dt-001D) #{A} to #{B} consists of two [continuous](dt-001J) functions #{A \rpair{f}{g} B}
66+ such that:
77+\ol{
88+\li{#{g \circ f = \mathsf{id}_A\quad} (i.e. #{\forall x \in A.\ g(f(x)) = x })}
99+\li{ #{f \circ g \sqsubseteq \mathsf{id}_B\quad} (i.e. #{\forall y \in B.\ f(g(y)) \sqsubseteq y })}
1010+}
1111+In this retraction pair, #{f} is called a \em{embedding} and #{g} is called a \em{projection}.
1212+}
1313+\p{
1414+Retraction pairs are weakenings of [isomorphisms](dt-002E). Intuitively, going #{A \contto B\contto A}, all information is \em{preserved} due to requirement 1, but going #{B\contto A\contto B}, we \em{may lose} some information (hence the use of #{\sqsubseteq} in requirement 2). }
+46
trees/dt/dt-0055.tree
···11+\import{dt-macros}
22+\import{table-macros}
33+\taxon{Example}
44+\author{liamoc}
55+\title{Examples and counterexamples of retraction pairs}
66+\p{Here are two examples of [retraction pairs](dt-0054):
77+\figure{
88+\tex{\usepackage{tikz-cd}}{
99+\begin{tikzcd}
1010+ & z \ar[dl, thick,->] \\
1111+ b \ar[r,thick,<->] & y \ar[u,-] \\
1212+ a\ar[u,-]\ar[r,thick,<->] & x \ar[u,-]
1313+\end{tikzcd}
1414+$\quad\qquad\qquad$
1515+\begin{tikzcd}
1616+ & z \ar[dl, thick,<->] \\
1717+ b & y \ar[dl, thick,->] \ar[u,-] \\
1818+ a\ar[u,-]\ar[r,thick,<->] & x \ar[u,-]
1919+\end{tikzcd}}}
2020+(this demonstrates that there can be \em{many} [retraction pairs](dt-0054) #{A \rpair{f}{g} B})}
2121+\p{The following, however, are \em{not} [retraction pairs](dt-0054) #{A \rpair{f}{g} B}:
2222+\figure{
2323+\tableW{\tr{\td{
2424+\tex{\usepackage{tikz-cd}}{
2525+\begin{tikzcd}
2626+ & z \ar[dl, thick,<->] \\
2727+ b \ar[r,thick,<-] & y \ar[u,-] \\
2828+ a\ar[u,-]\ar[r,thick,<->] & x \ar[u,-]
2929+\end{tikzcd}
3030+}}\td{
3131+\tex{\usepackage{tikz-cd}}{
3232+\begin{tikzcd}
3333+ & z \ar[dl, thick,->] \\
3434+ b \ar[dr, thick,->] & y \ar[l, thick,->] \ar[u,-] \\
3535+ a\ar[u,-]\ar[r,thick,<->] & x \ar[u,-]
3636+\end{tikzcd}
3737+}}}
3838+\tr{
3939+ \td{
4040+ (#{y \mapsto b \mapsto z} but #{z \not\sqsubseteq y})
4141+ }
4242+ \td{
4343+ (#{b \mapsto x \mapsto a} but #{a \neq b})
4444+ }
4545+}
4646+}}}
+13
trees/dt/dt-0056.tree
···11+\import{dt-macros}
22+\title{Composition of retraction pairs}
33+\taxon{Definition}
44+\author{liamoc}
55+\p{We can compose [retraction pairs](dt-0054) by composing their \em{embedding} and \em{projection}:}
66+\figure{
77+ \tex{\usepackage{tikz-cd}\usepackage{amsmath}\usepackage{amssymb}}{
88+ \begin{tikzcd}
99+ A \ar[r,"f",yshift=0.2em] & B \ar[l,"g", ,yshift=-0.2em]
1010+ \ar[r,"h",yshift=0.2em] & C \ar[l,"i", ,yshift=-0.2em] &\leadsto &
1111+ A \ar[r,"h \circ f",yshift=0.2em] & C \ar[l,"g \circ i",yshift=-0.2em] &\quad
1212+ \end{tikzcd}
1313+}}
+10
trees/dt/dt-0057.tree
···11+\import{dt-macros}
22+\taxon{Corollary}
33+\title{Derived products of retraction pairs}
44+\p{It follows from the definition of [retraction pairs](dt-0054) that, for a pair #{\rpair{f}{g}}:
55+\ol{
66+\li{ #{f} and #{g} are [strict](dt-000K), i.e. #{f(\bot) = \bot} and #{g(\bot) = \bot}.}
77+\li{ #{g} is \em{uniquely determined} by #{f} and vice-versa, so if another [retraction pair](dt-0054) #{\rpair{f}{g'}} exists, then #{g = g'}. To see why, remember that #{f} and #{g} must be [continuous](dt-001J) and therefore [monotonic](dt-000J).}
88+\li{ #{A} is [isomorphic](dt-002E) to the range of #{f}, i.e. #{A \simeq \Set{ f(x) \mid x \in A} \subseteq B}.}
99+}
1010+}
+5
trees/dt/dt-0058.tree
···11+\import{dt-macros}
22+\taxon{Definition}
33+\title{The category #{\textbf{Cpo}^\textbf{R}}}
44+\author{liamoc}
55+\p{The category #{\textbf{Cpo}^\textbf{R}} is the [category](dm-000G) where the objects are [cpos](dt-001D), the morphisms are [retraction pairs](dt-0054), composition is as in \ref{dt-0056} and identity is just the [retraction pair](dt-0054) #{A \rpair{\lambda x. x}{\lambda x. x} A}. }
+8
trees/dt/dt-0059.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\taxon{Definition}
44+\title{Information ordering in #{\textbf{Cpo}^\textbf{R}}}
55+\p{
66+The third point in \ref{dt-0057} suggests a notion of approximation, or [information ordering](dt-000B), for [cpos](dt-001D). Rather than say, as we did in \ref{dt-004O}, that for [cpos](dt-001D) #{A} and #{B}, #{A \sqsubseteq B} iff there exists a [continuous function](dt-001J) #{A\contto B}, we now say:
77+\figure{#{A \sqsubseteq B} iff there exists a [retraction pair](dt-0054) #{A \rpair{f}{g} B}}
88+}
+4
trees/dt/dt-005A.tree
···11+\title{Generalising to #{\textbf{Cpo}^\textbf{R}}}
22+\author{liamoc}
33+\p{All of our other notions for #{\textbf{Cpo}} naturally generalise to a setting with [retraction pairs](dt-0054) #{\textbf{Cpo}^\textbf{R}}: least elements, [#{\omega}-chains](dt-004Q), [upper bounds](dt-004R), [colimits](dt-004S), [cocontinuous endofunctors](dt-004V) and so on.}
44+\transclude{dt-005C}
+18
trees/dt/dt-005B.tree
···11+\taxon{Theorem}
22+\title{Fixed point theorem for endofunctors on #{\textbf{Cpo}^\textbf{R}}}
33+\p{Every [cocontinuous endofunctor](TODO) #{\mathcal{F}} on #{\mathbf{Cpo}^\textbf{R}} has a least fixed point, given by the [colimit](TODO) of the ascending [#{\omega}-chain](dt-005C):
44+\figure{
55+\tex{\usepackage{tikz-cd}}{\begin{tikzcd}
66+ \mathbf{1} \ar[r,"f_0",->,yshift=0.2em]\ar[r,"g_0"', <-,yshift=-0.2em] &
77+ \mathcal{F}(\mathbf{1}) \ar[r,"f_1",->,yshift=0.2em]\ar[r,"g_1"', <-,yshift=-0.2em] &
88+ \mathcal{F}(\mathcal{F}(\mathbf{1})) \ar[r,"f_2",->,yshift=0.2em]\ar[r,"g_2"', <-,yshift=-0.2em] &
99+ \mathcal{F}(\mathcal{F}(\mathcal{F}(\mathbf{1}))) \ar[r,-,dashed,yshift=0.2em]\ar[r,dashed,-,yshift=-0.2em] &
1010+ \cdots
1111+\end{tikzcd}}}
1212+Where the [retraction pairs](dt-0054) #{(f_i, g_i)} are defined by:
1313+##{
1414+\begin{array}{lcl}
1515+(f_0,g_0) & \triangleq & (\lambda x. \bot, \lambda x. \bot)\\
1616+(f_{i+1},g_{i+1}) & \triangleq & \mathcal{F}(f_i,g_i) \\
1717+\end{array}
1818+}}
+15
trees/dt/dt-005C.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\taxon{Definition}
44+\title{#{\omega}-chains of cpos in the category #{\mathbf{Cpo}^\textbf{R}}}
55+\p{An [#{\omega}-chain](dt-000W) of [cpos](dt-001D) in the [category #{\mathbf{Cpo}^\textbf{R}}](dt-0058) consists of a family of [cpos](dt-001D) #{\Set{D_i \mid i \in \mathbb{N} }}, together with a family of [retraction pairs](dt-0054) #{ D_i \rpair{f_i}{g_i} D_{i+1}}, shown below:}
66+\figure{
77+\tex{\usepackage{tikz-cd}}{
88+\begin{tikzcd}
99+ D_0 \ar[r,"f_0",->,yshift=0.2em]\ar[r,"g_0"', <-,yshift=-0.2em] &
1010+ D_1 \ar[r,"f_1",->,yshift=0.2em]\ar[r,"g_1"', <-,yshift=-0.2em] &
1111+ D_2 \ar[r,"f_2",->,yshift=0.2em]\ar[r,"g_2"', <-,yshift=-0.2em] &
1212+ D_3 \ar[r,-,dashed,yshift=0.2em]\ar[r,dashed,-,yshift=-0.2em] &
1313+ \cdots
1414+\end{tikzcd}
1515+}}