···11\import{dt-macros}
22\author{liamoc}
33-\title{Commutative Diagrams}
33+\title{Commutative diagrams}
44\p{When working in a [category](dm-000G), we can state many theorems compactly using \em{commutative diagrams}, such as this diagram for products:
55\figure{
66\tex{\usepackage{tikz-cd}}{
+5-4
trees/dt/dt-0030.tree
···22\title{Sums}
33\author{liamoc}
44\transclude{dt-0031}
55-\subtree{
66-\title{Primitive functions for sums}
77-\author{liamoc}
88-\transclude{dt-0032}
55+\transclude{dt-003D}
66+\transclude{dt-0039}
77+\transclude{dt-0036}
88+\upshotblock{
99+ \p{Our [category #{\mathbf{Cpo}}](dt-002B) has only [local](dt-0039) sums.}
910}
+6
trees/dt/dt-0033.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\taxon{Theorem}
44+\title{Continuity of sum constructors}
55+\p{The [constructor functions](dt-0032) #{\mathit{inl}} and #{\mathit{inr}} are [continuous](dt-001J).}
66+
+13
trees/dt/dt-0034.tree
···11+\import{dt-macros}
22+\taxon{Definition}
33+\author{liamoc}
44+\title{The case function}
55+\p{Elimination of [sums](dt-0031) is captured by the \em{case} function #{\scase{f}{g} : (A + B) \contto C}, made from functions #{f : A \contto C} and #{g : B \contto C}. This function is defined by:
66+##{
77+\begin{array}{l}
88+ \scase{f}{g} : (A + B) \contto C\\
99+ \scase{f}{g}(x) = \begin{cases} f(a) & \text{if}\ x = (0,a) \\
1010+ g(b) & \text{if}\ x = (1,b) \\
1111+ \bot_C & \text{if}\ x = \bot_{A+B}\end{cases}
1212+\end{array}
1313+}}
+31
trees/dt/dt-0035.tree
···11+\import{dt-macros}
22+\taxon{Exercise}
33+\author{liamoc}
44+\p{
55+ Prove that the [case function](dt-0034) #{\scase{f}{g}(x)} is, given [continuous](dt-001J) functions #{f : A \contto C} and #{g : B \contto C}, [continuous](dt-001J) on its argument #{x}.
66+\solnblock{
77+\p{
88+ As mentioned in \ref{dt-0031}, the only [directed](dt-0010) subsets of #{A + B} are those that contain entirely values of the format #{(0,\_)} and optionally #{\bot_{A+B}}, \em{or} those that contain entirely values of the format #{(1,\_)} and optionally #{\bot_{A+B}}. Call this [directed](dt-0010) subset #{X}.
99+}
1010+ \ul{
1111+ \li{\em{When #{\bigsqcup X = \bot_{A+B}}}: This means that #{X = \Set{\bot_{A+B}}} as #{\bot} is always the least element. From \ref{dt-0034}, we have: ##{\begin{array}{lcl} \scase{f}{g}(\bigsqcup X) &=& \scase{f}{g}(\bot_{A+B}) \\ &=& \bot_C \\ &=& \bigsqcup \Set{\bot_C} \\ &=& \bigsqcup\Set{\scase{f}{g}(\bot_{A+B})} \\ &=& \bigsqcup \Set{\scase{f}{g}(x) \mid x \in X}\end{array} } This discharges both requirements in \ref{dt-001J} for this case.}
1212+ \li{\em{When #{\bigsqcup X = (0,\_)}}: This means that #{X} consists of at least one #{(0,\_)} value plus possibly #{\bot_{A+B}}, that is #{X \setminus \Set{\bot_{A+B}} = \Set{ (0,a) \mid a \in Y} } for some nonempty #{Y \subseteq A}. We have the following, using the [continuity](dt-001J) of #{f}:
1313+ ##{\begin{array}{lcl}
1414+ \scase{f}{g}(\bigsqcup X) &=& \scase{f}{g}(\bigsqcup (X \setminus \Set{\bot_{A+B}})) \\
1515+ &=& \scase{f}{g}(\bigsqcup \Set{ (0,a) \mid a \in Y} )\\
1616+ &=& \scase{f}{g}(0,\bigsqcup Y) \\
1717+ &=& f(\bigsqcup Y) \\
1818+ &=& \bigsqcup \Set{ f(a) \mid a \in Y } \\
1919+ &=& \bigsqcup \Set{ \scase{f}{g}(0,a) \mid a \in Y} \\
2020+ &=& \bigsqcup \Set{ \scase{f}{g}(x) \mid x \in X \setminus \Set{\bot_{A+B}} } \\
2121+ &=& \bigsqcup (\Set{ \scase{f}{g}(x) \mid x \in X \setminus \Set{\bot_{A+B}} } \cup \Set{\bot_C}) \\
2222+ &=& \bigsqcup \Set{ \scase{f}{g}(x) \mid x \in X } \\
2323+ \end{array}}
2424+ }
2525+ \li{
2626+ \em{When #{\bigsqcup X = (1,\_)}}: Similar to the #{(0,\_)} case but using #{g} rather than #{f}.
2727+ }
2828+2929+}
3030+}
3131+}
+6
trees/dt/dt-0036.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\title{Sums form a bifunctor}
44+\p{With these, we can define the morphism mapping for the [sum](dt-0031) [bifunctor](dm-000M) #{(+) : \textbf{Cpo} \times \textbf{Cpo} \rightarrow \textbf{Cpo}}. Just as with [products](dt-0026) and [functions](dt-002W), we will overload the #{+} notation for \em{morphisms} as well as objects in [the category #{\mathbf{Cpo}}](dt-002B).}
55+\transclude{dt-0037}
66+\transclude{dt-0038}
+5
trees/dt/dt-0037.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\taxon{Definition}
44+\title{Sum of functions}
55+\p{ Given functions #{f : A \contto C} and #{g : B \contto D}, we have: ##{\begin{array}{l} f+g : (A + B)\contto (C + D) \\ f+g = [\mathit{inl} \circ f, \mathit{inr} \circ g] \end{array} }}
+8
trees/dt/dt-0038.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\taxon{Exercise}
44+\p{Prove that the #{+ : \mathbf{Cpo} \times \mathbf{Cpo} \rightarrow \mathbf{Cpo}} is a lawful [bifunctor](dm-000M), as a consequence of the [weak universal property](dt-003B).
55+\solnblock{
66+\p{TODO}
77+}
88+}
+17
trees/dt/dt-0039.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\title{Locality of sums}
44+\p{We can see by the definitions of [case](dt-0034) and our [constructors](dt-0032) that #{\scase{f}{g} \circ \mathit{inl} = f} and #{\scase{f}{g} \circ \mathit{inr} = g}, or, in a [commutative diagram](dm-000L):}
55+\figure{
66+\tex{\usepackage{tikz-cd}}{
77+\begin{tikzcd}[row sep=large]
88+ & C \arrow[dl, "f",<-,labels=above left]\arrow[dr,<-,"g"]\arrow[d,"{[ f, g ]}", <-, labels=description] & \\
99+A & A + B \ar[l, "{\mathit{inl}}",<-,labels=below] \ar[r, "{\mathit{inr}}",<-,labels=below]& B
1010+\end{tikzcd}
1111+}
1212+}
1313+\p{Note that this diagram is like the [dual](dm-000Q) of the diagram seen in the [universal property for products](dt-0029) — the arrows are reversed. That is because, generally speaking, sums are dual to products. However, because of our additional #{\bot} value, our [cpo sums](dt-0031) are only \em{weakly} universal — the #{h} arrow is \em{not} unique.
1414+}
1515+\transclude{dt-003A}
1616+\transclude{dt-003B}
1717+\transclude{dt-003C}
+16
trees/dt/dt-003A.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\taxon{Example}
44+\title{Weak universality of cpo sums}
55+\p{
66+Consider this scenario with the [cpos](dt-001D) #{\textbf{2} = \Set{ \top, \bot }} and #{\textbf{1} = \Set{\bot }}:
77+\figure{
88+\tex{\usepackage{tikz-cd}}{
99+\begin{tikzcd}[row sep=large]
1010+ & \mathbf{2} \arrow[dl, "\lambda x.\ \top",<-,labels=above left]\arrow[dr,<-,"\lambda x.\ \top"]\arrow[d,"{h}", <-, labels=description] & \\
1111+\mathbf{1} & \mathbf{1} + \mathbf{1} \ar[l, "{\mathit{inl}}",<-,labels=below] \ar[r, "{\mathit{inr}}",<-,labels=below]& \mathbf{1}
1212+\end{tikzcd}
1313+}
1414+}
1515+In this case, setting the function #{h = \lambda x.\ \top} makes the diagram commute, but #{(\lambda x.\ \top) \neq \scase{\lambda x.\ \top}{ \lambda x.\ \top}} due to the different handling of #{\bot_{\textbf{1}+\textbf{1}}}.
1616+}
+8
trees/dt/dt-003B.tree
···11+\import{dt-macros}
22+\taxon{Definition}
33+\author{liamoc}
44+\title{Weak universal property for [cpo sums](dt-0031)}
55+##{
66+(h \circ \mathit{inl} = f \land h \circ \mathit{inr} = g)\;\; \text{iff}\;\; \scase{f}{g} \sqsubseteq h
77+}
88+\p{This property is called \em{weak} because it uses only the [information ordering](dt-000B) rather than equality on the right hand side.}
+11
trees/dt/dt-003C.tree
···11+\import{dt-macros}
22+\author{liamoc}
33+\title{Failure of sum isomorphisms}
44+\taxon{Warning}
55+\p{
66+The weakness of the [universal property for sums](dt-0038) means that many common [isomorphisms](dt-002E) for sums in other contexts do not hold:
77+\ul{
88+\li{ #{A + (B + C) \not\simeq (A + B) + C}}
99+\li{ #{(A \contto C) \times (B \contto C) \not\simeq (A+B) \contto C}}
1010+}
1111+}
+6
trees/dt/dt-003D.tree
···11+\title{Primitive functions for sums}
22+\author{liamoc}
33+\transclude{dt-0032}
44+\transclude{dt-0033}
55+\transclude{dt-0034}
66+\transclude{dt-0035}