{"id":3641,"date":"2019-06-07T12:14:34","date_gmt":"2019-06-07T16:14:34","guid":{"rendered":"http:\/\/www.goodmath.org\/blog\/?p=3641"},"modified":"2019-06-07T12:15:15","modified_gmt":"2019-06-07T16:15:15","slug":"3641","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2019\/06\/07\/3641\/","title":{"rendered":"Category Theory Lesson 3: From Arrows to Lambda"},"content":{"rendered":"<p><em>Quick personal aside: I haven&#8217;t been posting a lot on here lately. I keep wanting to get back to it; but each time I post anything, I&#8217;m met by a flurry of crap: general threats, lawsuit threats, attempts to steal various of my accounts, spam to my contacts on linkedin, subscriptions to ashley madison or gay porn sites, etc. It&#8217;s pretty demotivating. I shouldn&#8217;t let the jerks drive me away from my hobby of writing for this blog!<\/em><\/p>\n<p>I started this series of posts by saying that Category Theory was an extremely abstract field of mathematics which was really useful in programming languages and in particular in programming language type systems. We\u2019re finally at one of the first places where you can really see how that\u2019s going to work.<\/p>\n<p>If you program in Scala, you might have encountered curried functions. A curried function is something that\u2019s in-between a one-parameter function and a two parameter function. For a trivial example, we could write a function that adds two integers in its usual form:<\/p>\n<pre>  def addInt(x: Int, y: Int): Int = x + y\n<\/pre>\n<p>That\u2019s just a normal two parameter function. Its curried form is slightly different. It\u2019s written:<\/p>\n<pre>  def curriedAddInt(x: Int)(y: Int): Int = x +y\n<\/pre>\n<p>The curried version isn\u2019t actually a two parameter function. It\u2019s a shorthand for:<\/p>\n<pre>  def realCurrentAddInt(x: Int): (Int =&gt; Int) = (y: Int) =&gt; x + y\n<\/pre>\n<p>That is: <code>currentAddInt<\/code> is a function which takes an integer, x, and returns a function which takes one parameter, and adds x to that parameter.<\/p>\n<p>Currying is the operation of taking a two parameter function, and turning it into a one-parameter function that returns another one-parameter function &#8211; that is, the general form of converting <code>addInt<\/code> to <code>realAddInt<\/code>. It might be easier to read its type: <code>realCurrentAddInt: Int =&gt; (Int =&gt; Int)<\/code>: It\u2019s a function that takes an int, and returns a new function from int to int.<\/p>\n<p>So what does that have to do with category theory?<\/p>\n<p>One of the ways that category theory applies to programming languages is that types and type theory turn out to be natural categories. Almost any programming language type system is a category. For example, the figure below shows a simple view of a programming language with the types <code>Int<\/code>, <code>Bool<\/code>, and <code>Unit<\/code>. <code>Unit<\/code> is the initial object, and so all of the primitive constants are defined with arrows from <code>Unit<\/code>.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.goodmath.org\/blog\/wp-content\/uploads\/2019\/06\/int-lang-cat.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3792 alignright\" src=\"https:\/\/i0.wp.com\/www.goodmath.org\/blog\/wp-content\/uploads\/2019\/06\/int-lang-cat.png?resize=204%2C232\" alt=\"\" width=\"204\" height=\"232\" \/><\/a><\/p>\n<p>For the most part, that seems pretty simple: a type <code>T <\/code>is an object in the programming language category; a function implemented in the language that takes a parameter of type <code>A<\/code> and returns a value of type <code>B\u00a0<\/code>is an arrow from <code>A<\/code> to <code>B<\/code>. A multi-parameter function just uses the cartesian product: a function that takes <code>(A, B)<\/code> and returns a <code>C<\/code> is an arrow from <img src='http:\/\/l.wordpress.com\/latex.php?latex=A%20%5Ctimes%20B%20%5Crightarrow%20C&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A \\times B \\rightarrow C' style='vertical-align:1%' class='tex' alt='A \\times B \\rightarrow C' \/>.<\/p>\n<p>But how could we write the type of a function like our curried adder? It\u2019s a function from a value to a function. The types in our language are objects in the category. So where\u2019s the object that represents functions from <code>A<\/code> to <code>B<\/code>?<\/p>\n<p>As we do often, we\u2019ll start by thinking about some basic concepts from set theory, and then generalize them into categories and arrows. In set theory, we can define the set of functions from <img src='http:\/\/l.wordpress.com\/latex.php?latex=A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A' style='vertical-align:1%' class='tex' alt='A' \/> to <img src='http:\/\/l.wordpress.com\/latex.php?latex=B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B' style='vertical-align:1%' class='tex' alt='B' \/> as: <img src='http:\/\/l.wordpress.com\/latex.php?latex=B%5EA%3D%7Bf%3A%20A%20%5Crightarrow%20B%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B^A={f: A \\rightarrow B}' style='vertical-align:1%' class='tex' alt='B^A={f: A \\rightarrow B}' \/> &#8211; that is, as exponentiation of the range of the produced functions.<\/p>\n<ul>\n<li>There\u2019s a product object <img src='http:\/\/l.wordpress.com\/latex.php?latex=B%5EA%20%5Ctimes%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B^A \\times A' style='vertical-align:1%' class='tex' alt='B^A \\times A' \/>.<\/li>\n<li>There\u2019s an arrow from <img src='http:\/\/l.wordpress.com\/latex.php?latex=B%5EA%20%5Ctimes%20A%20%5Crightarrow%20B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B^A \\times A \\rightarrow B' style='vertical-align:1%' class='tex' alt='B^A \\times A \\rightarrow B' \/>, which we\u2019ll call eval.<\/li>\n<\/ul>\n<p>In terms of the category of sets, what that means is:<\/p>\n<ul>\n<li>You can create a pair of a function from <img src='http:\/\/l.wordpress.com\/latex.php?latex=A%20%5Crightarrow%20B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A \\rightarrow B' style='vertical-align:1%' class='tex' alt='A \\rightarrow B' \/> and an element of <img src='http:\/\/l.wordpress.com\/latex.php?latex=A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A' style='vertical-align:1%' class='tex' alt='A' \/>.<\/li>\n<li>There is a function named eval which takes that pair, and returns an instance of <img src='http:\/\/l.wordpress.com\/latex.php?latex=B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B' style='vertical-align:1%' class='tex' alt='B' \/>.<\/li>\n<\/ul>\n<p>Like we saw with products, there\u2019s a lot of potential exponential objects <img src='http:\/\/l.wordpress.com\/latex.php?latex=C&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C' style='vertical-align:1%' class='tex' alt='C' \/> which have the necessary product with <img src='http:\/\/l.wordpress.com\/latex.php?latex=A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A' style='vertical-align:1%' class='tex' alt='A' \/>, and arrow from that product to <img src='http:\/\/l.wordpress.com\/latex.php?latex=B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B' style='vertical-align:1%' class='tex' alt='B' \/>. But which one is the ideal exponential? Again, we\u2019re trying to get to the object with thie universal property &#8211; the terminal object in the category of pseudo-exponentials. So we use the same pattern as before. For any potential exponential, there\u2019s an arrow from the potential exponential to the actual exponential, and the potential exponential with arrows from every other potential exponential is the exponential.<\/p>\n<p>Let\u2019s start putting that together. A potential exponential <img src='http:\/\/l.wordpress.com\/latex.php?latex=C&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C' style='vertical-align:1%' class='tex' alt='C' \/> for <img src='http:\/\/l.wordpress.com\/latex.php?latex=B%5EA&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B^A' style='vertical-align:1%' class='tex' alt='B^A' \/> is an object where the following product and arrow exist:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.goodmath.org\/blog\/wp-content\/uploads\/2019\/02\/potential-exponent.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3734\" src=\"https:\/\/i0.wp.com\/www.goodmath.org\/blog\/wp-content\/uploads\/2019\/02\/potential-exponent.png?resize=162%2C40\" alt=\"\" width=\"162\" height=\"40\" \/><\/a><\/p>\n<p>There\u2019s an instance of that pattern for the real exponential:<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/www.goodmath.org\/blog\/wp-content\/uploads\/2019\/02\/terminal-exponent.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3735\" src=\"https:\/\/i0.wp.com\/www.goodmath.org\/blog\/wp-content\/uploads\/2019\/02\/terminal-exponent.png?resize=172%2C45\" alt=\"\" width=\"172\" height=\"45\" \/><\/a><\/p>\n<p>We can create a category of these potential exponentials. In that category, there will be an arrow from every potential exponential to the real exponential. Each of the potential exponentials has the necessary property of an exponential &#8211; that product and eval arrow above &#8211; but they also have other properties.<\/p>\n<p>In that category of potential exponentials of <img src='http:\/\/l.wordpress.com\/latex.php?latex=B%5EA&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B^A' style='vertical-align:1%' class='tex' alt='B^A' \/>, there\u2019s an arrow from an object <img src='http:\/\/l.wordpress.com\/latex.php?latex=X&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='X' style='vertical-align:1%' class='tex' alt='X' \/> to an object <img src='http:\/\/l.wordpress.com\/latex.php?latex=Y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='Y' style='vertical-align:1%' class='tex' alt='Y' \/> if the following conditions hold in the base category:<\/p>\n<ul>\n<li>There is an arrow <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Bcurry%7D%28x%2Cy%29%3A%20X%20%5Crightarrow%20Y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{curry}(x,y): X \\rightarrow Y' style='vertical-align:1%' class='tex' alt='\\text{curry}(x,y): X \\rightarrow Y' \/> in the base category.<\/li>\n<li>There is an arrow <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Bcurry%7D%28x%2Cy%29%5Ctimes%20id_A%3A%20X%5Ctimes%20A%20%5Crightarrow%20Y%5Ctimes%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{curry}(x,y)\\times id_A: X\\times A \\rightarrow Y\\times A' style='vertical-align:1%' class='tex' alt='\\text{curry}(x,y)\\times id_A: X\\times A \\rightarrow Y\\times A' \/><\/li>\n<li><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Beval%7D_y%28%5Ctext%7Bcurry%7D%28x%2Cy%29%5Ctimes%20id_A%3D%5Ctext%7Beval%7D_y%20y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{eval}_y(\\text{curry}(x,y)\\times id_A=\\text{eval}_y y' style='vertical-align:1%' class='tex' alt='\\text{eval}_y(\\text{curry}(x,y)\\times id_A=\\text{eval}_y y' \/><\/li>\n<\/ul>\n<p>It\u2019s easiest to understand that by looking at what it means in <b>Set<\/b>:<\/p>\n<ul>\n<li>We\u2019ve got sets <img src='http:\/\/l.wordpress.com\/latex.php?latex=X&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='X' style='vertical-align:1%' class='tex' alt='X' \/> and <img src='http:\/\/l.wordpress.com\/latex.php?latex=Y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='Y' style='vertical-align:1%' class='tex' alt='Y' \/>, which we believe are potential exponents.<\/li>\n<li><img src='http:\/\/l.wordpress.com\/latex.php?latex=X&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='X' style='vertical-align:1%' class='tex' alt='X' \/> has a function <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Beval%7D_x%3A%20X%20%5Ctimes%20A%20%5Crightarrow%20B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{eval}_x: X \\times A \\rightarrow B' style='vertical-align:1%' class='tex' alt='\\text{eval}_x: X \\times A \\rightarrow B' \/>.<\/li>\n<li><img src='http:\/\/l.wordpress.com\/latex.php?latex=Y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='Y' style='vertical-align:1%' class='tex' alt='Y' \/> has a function <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Beval%7D_y%3A%20Y%20%5Ctimes%20A%20%5Crightarrow%20B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{eval}_y: Y \\times A \\rightarrow B' style='vertical-align:1%' class='tex' alt='\\text{eval}_y: Y \\times A \\rightarrow B' \/>.<\/li>\n<li>There\u2019s a function <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Bcurry%7D%3A%20X%20%5Crightarrow%20Y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{curry}: X \\rightarrow Y' style='vertical-align:1%' class='tex' alt='\\text{curry}: X \\rightarrow Y' \/> which converts a value of <img src='http:\/\/l.wordpress.com\/latex.php?latex=X&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='X' style='vertical-align:1%' class='tex' alt='X' \/> to a value of <img src='http:\/\/l.wordpress.com\/latex.php?latex=Y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='Y' style='vertical-align:1%' class='tex' alt='Y' \/>, and a corresponding function <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Bcurry%7D%28%5Ccdot%29%5Ctimes%5Ctext%7Bid%7D_A%3A%20X%5Ctimes%20A%20%5Crightarrow%20Y%5Ctimes%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{curry}(\\cdot)\\times\\text{id}_A: X\\times A \\rightarrow Y\\times A' style='vertical-align:1%' class='tex' alt='\\text{curry}(\\cdot)\\times\\text{id}_A: X\\times A \\rightarrow Y\\times A' \/>, which given a pair <img src='http:\/\/l.wordpress.com\/latex.php?latex=%28x%2C%20a%29%20%5Cin%20X%5Ctimes%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='(x, a) \\in X\\times A' style='vertical-align:1%' class='tex' alt='(x, a) \\in X\\times A' \/> transforms it into a pair <img src='http:\/\/l.wordpress.com\/latex.php?latex=%28y%2C%20a%29%20%5Cin%20Y%5Ctimes%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='(y, a) \\in Y\\times A' style='vertical-align:1%' class='tex' alt='(y, a) \\in Y\\times A' \/>, where evaluating <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Beval%7D_x%28x%2C%20a%29%3D%5Ctext%7Beval%7D_y%28%5Ctext%7Bcurry%7D%28x%2C%20a%29%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{eval}_x(x, a)=\\text{eval}_y(\\text{curry}(x, a))' style='vertical-align:1%' class='tex' alt='\\text{eval}_x(x, a)=\\text{eval}_y(\\text{curry}(x, a))' \/>. In other words, if we restrict the inputs to <img src='http:\/\/l.wordpress.com\/latex.php?latex=Y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='Y' style='vertical-align:1%' class='tex' alt='Y' \/> to be effectively the same as the inputs to <img src='http:\/\/l.wordpress.com\/latex.php?latex=X&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='X' style='vertical-align:1%' class='tex' alt='X' \/>, then the two eval functions do the same thing. (Why do I say restrict? Because <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Beval%7D_y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{eval}_y' style='vertical-align:1%' class='tex' alt='\\text{eval}_y' \/> might have a larger domain than the range of <img src='http:\/\/l.wordpress.com\/latex.php?latex=X&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='X' style='vertical-align:1%' class='tex' alt='X' \/>, but these rules won\u2019t capture that.)<\/li>\n<\/ul>\n<p>An arrow in the category of potential products is a pair of two arrows in the base category:\u00a0 one from <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%20%5Crightarrow%20B%5EA&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C \\rightarrow B^A' style='vertical-align:1%' class='tex' alt='C \\rightarrow B^A' \/>, and one from <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%5Ctimes%20A%20%5Crightarrow%20B%5EA%20%5Ctimes%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C\\times A \\rightarrow B^A \\times A' style='vertical-align:1%' class='tex' alt='C\\times A \\rightarrow B^A \\times A' \/> . Since the two arrows are deeply related (they\u2019re one arrow in the category of potential exponentials), we\u2019ll call them <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Bcurry%7D%28g%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{curry}(g)' style='vertical-align:1%' class='tex' alt='\\text{curry}(g)' \/> and <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Bcurry%7D%28g%29%5Ctimes%20id_A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{curry}(g)\\times id_A' style='vertical-align:1%' class='tex' alt='\\text{curry}(g)\\times id_A' \/>. (Note that we\u2019re not really taking the product of an arrow here: we haven\u2019t talked about anything like taking products of arrows! All we\u2019re doing is giving the arrow a name that helps us understand it. The name makes it clear that we\u2019re not touching the right-hand component of the product.)<\/p>\n<p>Since the exponential is the terminal, which means that that pair of curry arrows must exist for every potential exponential to the true exponential. So the exponential object is the unique (up to isomorphism) object for which the following is true:<\/p>\n<ul>\n<li>There\u2019s an arrow <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Beval%7D%3A%20B%5EA%20%5Ctimes%20A%20%5Crightarrow%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{eval}: B^A \\times A \\rightarrow A' style='vertical-align:1%' class='tex' alt='\\text{eval}: B^A \\times A \\rightarrow A' \/>. Since <img src='http:\/\/l.wordpress.com\/latex.php?latex=B%5EA&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B^A' style='vertical-align:1%' class='tex' alt='B^A' \/> is the type of functions from <img src='http:\/\/l.wordpress.com\/latex.php?latex=A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A' style='vertical-align:1%' class='tex' alt='A' \/> to <img src='http:\/\/l.wordpress.com\/latex.php?latex=B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B' style='vertical-align:1%' class='tex' alt='B' \/>, <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Beval%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{eval}' style='vertical-align:1%' class='tex' alt='\\text{eval}' \/> represents the application of one of those functions to a value of type <img src='http:\/\/l.wordpress.com\/latex.php?latex=A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A' style='vertical-align:1%' class='tex' alt='A' \/> to produce a result of type <img src='http:\/\/l.wordpress.com\/latex.php?latex=B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B' style='vertical-align:1%' class='tex' alt='B' \/>.<a href=\"https:\/\/i0.wp.com\/www.goodmath.org\/blog\/wp-content\/uploads\/2019\/06\/exponent-curry.png\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-3795 alignright\" src=\"https:\/\/i0.wp.com\/www.goodmath.org\/blog\/wp-content\/uploads\/2019\/06\/exponent-curry.png?resize=308%2C218\" alt=\"\" width=\"308\" height=\"218\" \/><\/a><\/li>\n<li>For each two-parameter function <img src='http:\/\/l.wordpress.com\/latex.php?latex=g%3AC%5Ctimes%20A%5Crightarrow%20B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='g:C\\times A\\rightarrow B' style='vertical-align:1%' class='tex' alt='g:C\\times A\\rightarrow B' \/>, there is a unique function (arrow) <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Ctext%7Bcurry%7D%28g%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\text{curry}(g)' style='vertical-align:1%' class='tex' alt='\\text{curry}(g)' \/> that makes the following diagram commute<\/li>\n<\/ul>\n<p>Now, how does all this relate to what we understand as currying?<\/p>\n<p>It shows us that in category theory we can have an object that is effectively represents a function type in the same category as the object that represents the type of values it operates on, and you can capture the notion of applying values of that function type onto values of their parameter type using an arrow.<\/p>\n<p>As I said before: not every category has a structure that can support exponentiation. The examples of this aren\u2019t particularly easy to follow. The easiest one I\u2019ve found is <strong>Top<\/strong> the category of topological spaces. In <strong>Top<\/strong>, the exponent doesn\u2019t exist for many objects. Objects in <strong>Top<\/strong> are topological spaces, and arrows are continuous functions between them. For any two objects in <strong>Top<\/strong>, you can create the necessary <em>objects<\/em> for the exponential. But for many topological spaces, the required <em>arrows<\/em> don\u2019t exist. The functions that they correspond to exist in <b>Set<\/b>, but they\u2019re not continuous &#8211; and so they aren\u2019t arrows in <strong>Top<\/strong>. (The strict requirement is that for an exponential <img src='http:\/\/l.wordpress.com\/latex.php?latex=X%5EY&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='X^Y' style='vertical-align:1%' class='tex' alt='X^Y' \/> to exist, <img src='http:\/\/l.wordpress.com\/latex.php?latex=Y&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='Y' style='vertical-align:1%' class='tex' alt='Y' \/> must be a locally compact Hausdorff space. What that means is well beyond the scope of this!)<\/p>\n<h3>Cartesian Closed Categories<\/h3>\n<p>If you have a category <img src='http:\/\/l.wordpress.com\/latex.php?latex=C&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C' style='vertical-align:1%' class='tex' alt='C' \/>, and for every pair of objects <img src='http:\/\/l.wordpress.com\/latex.php?latex=A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A' style='vertical-align:1%' class='tex' alt='A' \/> and <img src='http:\/\/l.wordpress.com\/latex.php?latex=B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B' style='vertical-align:1%' class='tex' alt='B' \/> in the category <img src='http:\/\/l.wordpress.com\/latex.php?latex=C&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C' style='vertical-align:1%' class='tex' alt='C' \/>, there exists an exponential object <img src='http:\/\/l.wordpress.com\/latex.php?latex=B%5EA%20%5Cin%20C&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='B^A \\in C' style='vertical-align:1%' class='tex' alt='B^A \\in C' \/>, then we\u2019ll say that <img src='http:\/\/l.wordpress.com\/latex.php?latex=C&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C' style='vertical-align:1%' class='tex' alt='C' \/> <em>has exponentiation<\/em>. Similarly, if for every pair of objects <img src='http:\/\/l.wordpress.com\/latex.php?latex=A%2C%20B%20%5Cin%20Ob%28C%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A, B \\in Ob(C)' style='vertical-align:1%' class='tex' alt='A, B \\in Ob(C)' \/>, there exists a product object <img src='http:\/\/l.wordpress.com\/latex.php?latex=A%5Ctimes%20B&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A\\times B' style='vertical-align:1%' class='tex' alt='A\\times B' \/>, we say that the category <em>has products<\/em>.<\/p>\n<p>There\u2019s a special kind of category, called a <span style=\"text-decoration: underline;\">cartesian closed category<\/span>, which is a category\u00a0 where:<\/p>\n<ol>\n<li>Every pair of objects has both product and exponent objects; and<\/li>\n<li>Which has at least one terminal object. (Remember that terminals are something like singletons, and so they work as a way of capturing the notion of being a single element of an object; so this requirement basically says that the category has at least one value that \u201cfunctions\u201d can be applied to.)<\/li>\n<\/ol>\n<p>That may seem like a very arbitrary set of rules: what\u2019s so important about having all products, exponents, and a terminal object?<\/p>\n<p>It means that we have a category which can model types, functions, and function application. Lambda calculus proves that that\u2019s all you need to model computation. Closed cartesian categories are, basically, a formal model of a computing system! Any cartesian closed category is a model for a simply typed <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Clambda&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\lambda' style='vertical-align:1%' class='tex' alt='\\lambda' \/>-calculus; and <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Clambda&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\lambda' style='vertical-align:1%' class='tex' alt='\\lambda' \/>-calculus is something known as the internal language of a cartesian closed category.<\/p>\n<p>What \u201cinternal language\u201d means formally is complicated, but in simple terms: you can take any computation in lambda calculus, and perform the computation by chasing arrows in a category diagram of a closed cartesian category that includes the values of that calculus. Alternatively, every computation step that you perform evaluating a <img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Clambda&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\lambda' style='vertical-align:1%' class='tex' alt='\\lambda' \/>-calculus expression corresponds to an arrow in a CCC.<\/p>\n<h3>References<\/h3>\n<p>For this post, I\u2019ve made heavy use of:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.amazon.com\/Category-Computer-Scientists-Foundations-Computing\/dp\/0262660717\">Basic Category Theory for Computer Science<\/a>, by Benjamin Pierce.<\/li>\n<li><a href=\"https:\/\/bartoszmilewski.com\/2014\/10\/28\/category-theory-for-programmers-the-preface\/\">Category Theory for Programmers<\/a>, by Bartosz Milewski.<\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=I8LbkfSSR58\">The Category Theory lectures<\/a>, by Bartosz Milewski.<\/li>\n<li><a href=\"https:\/\/www.amazon.com\/Category-Theory-Applications-Textbook-Beginners\/dp\/9813231068\">Category Theory and Applications: A Textbook for Beginners<\/a>, by Marco Gandis.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Quick personal aside: I haven&#8217;t been posting a lot on here lately. I keep wanting to get back to it; but each time I post anything, I&#8217;m met by a flurry of crap: general threats, lawsuit threats, attempts to steal various of my accounts, spam to my contacts on linkedin, subscriptions to ashley madison or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[],"class_list":["post-3641","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/s4lzZS-3641","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/3641","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/comments?post=3641"}],"version-history":[{"count":28,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/3641\/revisions"}],"predecessor-version":[{"id":3806,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/3641\/revisions\/3806"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=3641"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=3641"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=3641"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}