my forest

finished recursive domains

+176 -4
+3 -1
trees/dt/dt-004O.tree
··· 21 21 \transclude{dt-004W} 22 22 \transclude{dt-004X} 23 23 \transclude{dt-004Y} 24 - \transclude{dt-0050} 24 + \transclude{dt-005M} 25 + \transclude{dt-0050} 26 + \transclude{dt-005N}
+1 -3
trees/dt/dt-004Z.tree
··· 5 5 \transclude{dt-004J} 6 6 \transclude{dt-004O} 7 7 \transclude{dt-0052} 8 - \strong{TODO: Colimit construction} 9 - \strong{TODO: Producing Endofunctors} 10 - \strong{TODO: Untyped Lambda Calculus} 8 + \transclude{dt-005L}
+2
trees/dt/dt-0052.tree
··· 2 2 \author{liamoc} 3 3 \title{From #{\textbf{Cpo}} to #{\textbf{Cpo}^{\textbf{R}}}} 4 4 \transclude{dt-0053} 5 + \transclude{dt-005O} 5 6 \transclude{dt-0054} 6 7 \transclude{dt-0055} 7 8 \transclude{dt-0056} ··· 9 10 \transclude{dt-0058} 10 11 \transclude{dt-0059} 11 12 \transclude{dt-005A} 13 + \transclude{dt-005I} 12 14 \transclude{dt-005B} 13 15 \transclude{dt-005H}
+7
trees/dt/dt-005I.tree
··· 1 + \import{dt-macros} 2 + \title{Extending cpo Mappings to endofunctors on #{\textbf{Cpo}^\mathbf{R}}} 3 + \author{liamoc} 4 + \p{If #{\mathcal{F}} is a mapping on [cpos](dt-001D) built up from basic cpos using the constructions #{\times}, #{\otimes}, #{+}, #{\oplus}, #{(\cdot)_\bot}, \em{as well as} #{\contto} and #{\strictto}, then #{\mathcal{F}} extends to a (\em{covariant}!) [cocontinuous functor](dt-005E) on #{\textbf{Cpo}^\mathbf{R}}. 5 + We shall detail the construction for products and functions here, but the other constructions are all similar.} 6 + \transclude{dt-005J} 7 + \transclude{dt-005K}
+10
trees/dt/dt-005J.tree
··· 1 + \import{dt-macros} 2 + \taxon{Definition} 3 + \author{liamoc} 4 + \title{#{\times} operation for retraction pairs} 5 + \p{ 6 + Given two [retraction pairs](dt-0054) #{(f,g)} and #{(h,i)}, our [retraction pair](dt-0054) for their [product](dt-0021) is just the product of their \em{embedding} and \em{projection}, i.e. #{(f \times h, g \times i)}, using our [product operation on continuous functions](dt-0026): 7 + ##{ 8 + \inferrule{A \rpair{f}{g} B\quad C \rpair{h}{i} D}{A\times C \rpair{f \times h}{g \times i} B \times D} 9 + } 10 + }
+13
trees/dt/dt-005K.tree
··· 1 + \import{dt-macros} 2 + \taxon{Definition} 3 + \author{liamoc} 4 + \title{#{\contto} operation for retraction pairs} 5 + \p{ 6 + We are given two [retraction pairs](dt-0054) #{A \rpair{f}{g} B} and 7 + #{C \rpair{h}{i} D}. To define a suitable \em{covariant} [functor](dt-005E), we define our morphism mapping in terms of our #{\contto} [operation on continuous functions](dt-002X): ##{ (f,g) \contto (h,i) \; \triangleq \; (g\contto h, f \contto i)} 8 + Note that the positions of #{f} and #{g} are swapped in the above definition. 9 + ##{ 10 + \inferrule{A \rpair{f}{g} B \quad C \rpair{h}{i} D}{A \contto C \rpair{g \contto h}{f \contto i} B \contto D} 11 + } 12 + Unlike [with the category #{\textbf{Cpo}}](dt-0053), this functor is not [contravariant](dm-000S) but \em{covariant}: Note the positions of #{A} and #{B} are not swapped! 13 + }
+57
trees/dt/dt-005L.tree
··· 1 + \import{dt-macros} 2 + \title{Semantics of untyped #{\lambda}-calculus} 3 + \author{liamoc} 4 + \p{ 5 + Recall the untyped #{\lambda} calculus: 6 + \transclude{dt-004K} 7 + We mentioned before that the semantic domain of this language must be a cpo #{D} such that ##{D \simeq D\contto D} In other words, solutions to this equation are fixed points of #{\mathcal{F}(X) = X\contto X}. The least such fixed point can expressed, by \ref{dt-005B}, as the [colimit](dt-005H) of the [#{\omega}-chain](dt-005C): 8 + \figure{ 9 + \tex{\usepackage{tikz-cd}}{ 10 + \begin{tikzcd} 11 + \mathbf{1} \ar[r,"f_0",->,yshift=0.2em]\ar[r,"g_0"', <-,yshift=-0.2em] & 12 + \mathcal{F}(\mathbf{1}) \ar[r,"f_1",->,yshift=0.2em]\ar[r,"g_1"', <-,yshift=-0.2em] & 13 + \mathcal{F}(\mathcal{F}(\mathbf{1})) \ar[r,"f_2",->,yshift=0.2em]\ar[r,"g_2"', <-,yshift=-0.2em] & 14 + \mathcal{F}(\mathcal{F}(\mathcal{F}(\mathbf{1}))) \ar[r,-,dashed,yshift=0.2em]\ar[r,dashed,-,yshift=-0.2em] & 15 + \cdots 16 + \end{tikzcd} 17 + }} 18 + But, the least solution to this equation is \em{trivial}: #{D_\infty \simeq \mathbf{1}}, because #{\mathbf{1} \simeq \mathbf{1}\contto \mathbf{1}}. A non-trivial solution is obtained by starting the chain at #{\mathbf{2}}, the [cpo](dt-001D) containing just #{\Set{\top,\bot}}, rather than #{\mathbf{1}}. 19 + \figure{\tex{\usepackage{tikz-cd}}{ 20 + \begin{tikzcd} 21 + \mathbf{2} \ar[r,"f_0",->,yshift=0.2em]\ar[r,"g_0"', <-,yshift=-0.2em] & 22 + \mathcal{F}(\mathbf{2}) \ar[r,"f_1",->,yshift=0.2em]\ar[r,"g_1"', <-,yshift=-0.2em] & 23 + \mathcal{F}(\mathcal{F}(\mathbf{2})) \ar[r,"f_2",->,yshift=0.2em]\ar[r,"g_2"', <-,yshift=-0.2em] & 24 + \mathcal{F}(\mathcal{F}(\mathcal{F}(\mathbf{2}))) \ar[r,-,dashed,yshift=0.2em]\ar[r,dashed,-,yshift=-0.2em] & 25 + \cdots 26 + \end{tikzcd} 27 + }}} 28 + \p{ 29 + We will now sketch a proof of the [retraction pair](dt-0054) between #{D_\infty} and #{D_\infty \contto D_\infty}, by providing two functions, #{\textbf{\textsf{up}} : D_\infty \rightarrow (D_\infty\contto D_\infty)} and its inverse #{\textbf{\textsf{down}} : (D_\infty\contto D_\infty) \rightarrow D_\infty}. } 30 + \p{ 31 + Observe that each element of #{D_i} (for #{i > 0}) is a \em{function} #{D_{i-1} \contto D_{i-1}}. Therefore, an element of [the colimit #{D_\infty}](dt-005H) is an #{\omega}-tuple of such functions. To define #{\textbf{\textsf{up}}(d)(x)}, we must essentially "apply" each function in the element #{d \in D_\infty} (viewed as an #{\omega}-tuple of functions) to the element #{x \in D_\infty} (viewed as an #{\omega}-tuple of values). More specifically, we say that #{\textbf{\textsf{up}}(d)(x)} is an #{\omega}-tuple #{(y_m \mid y \in \mathbb{N})}, as follows: 32 + ##{ 33 + y_m = \bigsqcup_{k \in \mathbb{N}} \theta_{m+k,m}(d_{m+k+1}(x_{m+k})) 34 + } 35 + To define #{\textbf{\textsf{down}}(f)}, we are given a ([continuous](dt-001J)) function #{f : D_\infty\contto D_\infty} and must construct the #{\omega}-tuple of approximations at every #{D_n}. We do this by projecting the action of #{f} down to #{D_n}. We say that #{\textbf{\textsf{down}}(f)} is an #{\omega}-tuple #{(v_n \mid n \in \mathbb{N})} where: 36 + ##{ 37 + \begin{array}{lcl} 38 + v_0 & \triangleq & \theta_{\infty,0}(f(\theta_{0,\infty}(\bot_{D_0})))\\ 39 + v_{n+1} & \triangleq & \theta_{\infty,n} \circ f \circ \theta_{n,\infty} 40 + \end{array} 41 + }} 42 + \subtree{ 43 + \taxon{Definition} 44 + \title{Denotations for untyped #{\lambda}-calculus} 45 + \p{ 46 + Using the new functions #{\textbf{\textsf{up}}} and #{\textbf{\textsf{down}}}, it is now straightforward to define a semantics for untyped #{\lambda}-calculus, where #{\sigma} is an environment #{\mathsf{Var} \rightarrow D_\infty}: 47 + ##{\llbracket \cdot \rrbracket : (\mathsf{Var} \rightarrow D_\infty)\contto D_\infty} 48 + ##{ 49 + \begin{array}{lcl} 50 + \llbracket x \rrbracket \sigma & = & \sigma (x) \\ 51 + \llbracket e_0\ e_1 \rrbracket \sigma & = & \textbf{\textsf{up}}(\llbracket e_0 \rrbracket \sigma) (\llbracket e_1 \rrbracket \sigma)\\ 52 + \llbracket \lambda x.\ e \rrbracket \sigma & = & \textbf{\textsf{down}}(\boldsymbol{\lambda} v \in D_{\infty}.\ \llbracket e \rrbracket\ \sigma(x \mapsto v) ) 53 + \end{array} 54 + } 55 + This semantics does not distinguish non-terminating computations from terminating ones. To model call-by-value more faithfully, we could use the equation #{D \simeq D\contto D_\bot} instead, and for call-by-name we could use #{D \simeq D_\bot\contto D_\bot}. The constructions are very similar. 56 + } 57 + }
+26
trees/dt/dt-005M.tree
··· 1 + \import{dt-macros} 2 + \taxon{Exercise} 3 + \author{liamoc} 4 + \p{ 5 + Show that #{\mathcal{F}(X) \triangleq \mathbf{1} + X} and #{\mathcal{F}(f) \triangleq \mathsf{id}_\mathbf{1} + f} (using our [#{+} operator for functions](dt-0037)) define an [endofunctor](dt-004T) #{\mathbf{Cpo} \rightarrow \mathbf{Cpo}}, i.e. that they satisfy the functor laws.} 6 + \solnblock{ 7 + \ol{ 8 + \li{ 9 + We must show #{\mathcal{F}(\mathsf{id}_A : A \contto A) = \mathsf{id}_{\mathcal{F}(A)} : \mathcal{F}(A) \contto \mathcal{F}(A)}. 10 + ##{\begin{array}{lcl} 11 + \mathcal{F}(\mathsf{id}_A)& =& \mathsf{id}_\mathbf{1} + \mathsf{id}_A\\ 12 + &=& \mathsf{id}_{\mathbf{1} + A}\\ 13 + &=& \mathsf{id}_{\mathcal{F}(A)} 14 + \end{array}} 15 + 16 + } 17 + \li{ 18 + We must show #{\mathcal{F}(f \circ g) = \mathcal{F}(f) \circ \mathcal{F}(g)}. 19 + ##{\begin{array}{lcl} 20 + \mathcal{F}(f \circ g) &=& \mathsf{id}_\mathbf{1} + (f \circ g) \\ 21 + &=& (\mathsf{id}_\mathbf{1} + f) \circ (\mathsf{id}_\mathbf{1} + g) \\ 22 + & = & \mathcal{F}(f) \circ \mathcal{F}(g) 23 + \end{array}} 24 + } 25 + } 26 + }
+46
trees/dt/dt-005N.tree
··· 1 + \import{dt-macros} 2 + \taxon{Exercise} 3 + \author{liamoc} 4 + \p{ 5 + The lazy natural numbers, also called conats, are defined as the least solution to the equation #{X \simeq \mathbf{1} + X}. 6 + \ol{ 7 + \li{Sketch the first four approximations to the least fixed point. Call the two sum injections #{\mathsf{zero}} and #{\mathsf{succ}}. 8 + \solnblock{ 9 + ##{ 10 + \begin{array}{lcl} 11 + A_0 & = & \Set{\bot} \\ 12 + A_1 & = & \Set{\mathsf{zero}\ \bot, \mathsf{succ}\ \bot, \bot} \\ 13 + A_2 & = & \Set{\mathsf{zero}\ \bot, \mathsf{succ}\ \bot, \mathsf{succ}\ (\mathsf{zero}\ \bot), \mathsf{succ}\ (\mathsf{succ}\ \bot), \bot} \\ 14 + A_3 & = & \Set{\mathsf{zero}\ \bot, \mathsf{succ}\ \bot, \mathsf{succ}\ (\mathsf{zero}\ \bot), \mathsf{succ}\ (\mathsf{succ}\ \bot), \mathsf{succ}\ (\mathsf{succ}\ (\mathsf{zero}\ \bot)), \mathsf{succ}\ (\mathsf{succ}\ (\mathsf{succ}\ \bot)), \bot} \\ 15 + \end{array} 16 + } 17 + }} 18 + \li{Repeat this exercise assuming: 19 + \ol{ 20 + \li{ #{\mathsf{zero}} is strict (i.e. #{\mathsf{zero}\ \bot = \bot}) 21 + \solnblock{ 22 + ##{ 23 + \begin{array}{lcl} 24 + A_0 & = & \Set{\bot} \\ 25 + A_1 & = & \Set{\mathsf{succ}\ \bot, \bot} \\ 26 + A_2 & = & \Set{\mathsf{succ}\ \bot, \mathsf{succ}\ (\mathsf{succ}\ \bot), \bot} \\ 27 + A_3 & = & \Set{\mathsf{succ}\ \bot, \mathsf{succ}\ (\mathsf{succ}\ \bot), \mathsf{succ}\ (\mathsf{succ}\ (\mathsf{succ}\ \bot)), \bot} \\ 28 + \end{array} 29 + } 30 + } 31 + } 32 + \li{ #{\mathsf{succ}} is strict (i.e. #{\mathsf{succ}\ \bot = \bot}) 33 + \solnblock{ 34 + ##{ 35 + \begin{array}{lcl} 36 + A_0 & = & \Set{\bot} \\ 37 + A_1 & = & \Set{\mathsf{zero}\ \bot, \bot} \\ 38 + A_2 & = & \Set{\mathsf{zero}\ \bot, \mathsf{succ}\ (\mathsf{zero}\ \bot), \bot} \\ 39 + A_3 & = & \Set{\mathsf{zero}\ \bot, \mathsf{succ}\ (\mathsf{zero}\ \bot), \mathsf{succ}\ (\mathsf{succ}\ (\mathsf{zero}\ \bot)), \bot} \\ 40 + \end{array} 41 + } 42 + } 43 + } 44 + } 45 + } 46 + }}
+11
trees/dt/dt-005O.tree
··· 1 + \import{dt-macros} 2 + \taxon{Exercise} 3 + \author{liamoc} 4 + \p{ 5 + Show that, in contrast to #{\mathcal{F}(X) = X\contto \mathbb{Z}_\bot} from \ref{dt-0053}, the mapping #{\mathcal{G}(X) = \mathbb{Z}_\bot\contto X} \em{can} be extended to [continuous](dt-001J) functions giving a \em{covariant} [endofunctor](dt-004T) on #{\textbf{Cpo}}. 6 + \solnblock{ 7 + \p{Given a continuous function #{f : A \contto B}, we must produce a continuous function #{\mathcal{F}(f) : (\mathbb{Z}_\bot \contto A) \contto (\mathbb{Z}_\bot \contto B)}, defined as follows: 8 + ##{\mathcal{F}(f)(g)(x) = f \circ g(x)} 9 + Composition of continuous functions preserves continuity. The [functor laws](dt-004T) can be shown straightforwardly. 10 + } 11 + }}