{"id":3531,"date":"2018-01-17T11:00:49","date_gmt":"2018-01-17T16:00:49","guid":{"rendered":"http:\/\/www.goodmath.org\/blog\/?p=3531"},"modified":"2018-01-17T11:00:49","modified_gmt":"2018-01-17T16:00:49","slug":"inference-with-sets-in-type-theory","status":"publish","type":"post","link":"http:\/\/www.goodmath.org\/blog\/2018\/01\/17\/inference-with-sets-in-type-theory\/","title":{"rendered":"Inference with Sets in Type Theory"},"content":{"rendered":"<p> It&#8217;s been quite a while since I did any meaningful writing on type theory. I spent a lot of time introducing the basic concepts, and trying to explain the intuition behind them. I also spent some time describing what I think of as the platform: stuff like arity theory, which we need for talking about type construction. But once we move beyond the basic concepts, I ran into a bit of a barrier &#8211; no so much in understanding type theory, but in finding ways of presenting it that will be approacha ble.<\/p>\n<p>  I&#8217;ve been struggling to figure out how to move forward in my exploration of type theory. The logical next step is working through the basics of intuitionistic logic with type theory semantics. The problem is, that&#8217;s pretty dry material. I&#8217;ve tried to put together a couple of approaches that skip over this, but it&#8217;s really necessary.<\/p>\n<p> For someone like me, coming from a programming language background, type theory really hits its stride when we look at type systems and particularly type inference. But you can&#8217;t understand type inference without  understanding the basic logic. In fact, you can&#8217;t describe the algorithm for type inference without referencing the basic inference rules of the underlying logic. Type inference is nothing but building type theoretic proofs based on a program.<\/p>\n<p> So here we are: we need to spend some time looking at the basic  logic of type theory. We&#8217;ve looked at the basic concepts that underlie the syntax and semantics, so what we need to do next is learn the basic rules that we use to build logical statements in the   realm of type theory. (If you&#8217;re interested in more detail, this is   material from chapter 5   of <a href=\"http:\/\/www.cse.chalmers.se\/research\/group\/logic\/book\/book.pdf\">&#8220;Programming in Martin-L&ouml;of&#8217;s Type Theory&#8221;<\/a>, which is the text I&#8217;m using to learn this material.)<\/p>\n<p> Martin L&ouml;off&#8217;s type theory is a standard intuitionistic predicate logic, so we&#8217;ll go through the rules using standard sequent notation. Each rule is a sequence which looks sort-of like a long fraction. The &#8220;numerator&#8221; section is a collection of things which we already know are true; the &#8220;denominator&#8221; is something that we can infer given those truths. Each statement has the form <img src='http:\/\/l.wordpress.com\/latex.php?latex=A%5B%5CGamma%5D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A[\\Gamma]' style='vertical-align:1%' class='tex' alt='A[\\Gamma]' \/>, where A is a statement, and B is a set of assumptions. For example, <img src='http:\/\/l.wordpress.com\/latex.php?latex=F%28a%29%20%5Ba%20%5Cin%20A%2C%20%5CDelta%5D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='F(a) [a \\in A, \\Delta]' style='vertical-align:1%' class='tex' alt='F(a) [a \\in A, \\Delta]' \/> means that <img src='http:\/\/l.wordpress.com\/latex.php?latex=F%28a%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='F(a)' style='vertical-align:1%' class='tex' alt='F(a)' \/> is true, provided we&#8217;re in a context that includes <img src='http:\/\/l.wordpress.com\/latex.php?latex=a%20%5Cin%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='a \\in A' style='vertical-align:1%' class='tex' alt='a \\in A' \/>.<\/p>\n<p> Personally, I find that this stuff feels very abstract until you take  the logical statements, and interpret them in terms of programming. So throughout this post, I&#8217;ll do that for each of the rules.<\/p>\n<p> With that introduction out of the way, let&#8217;s dive in to the first set of rules.<\/p>\n<h3> Simple Introductions <\/h3>\n<p> We&#8217;ll start off with a couple of really easy rules, which allow us to introduce a variable given a type, or a type given a variable.<\/p>\n<h4>Introducing Elements<\/h4>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Cfrac%7BA%20%5C%2C%5Ctext%7Btype%7D%7D%7Ba%20%5Cin%20A%20%5C%2C%5Ba%20%5Cin%20A%5D%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\frac{A \\,\\text{type}}{a \\in A \\,[a \\in A]}' style='vertical-align:1%' class='tex' alt='\\frac{A \\,\\text{type}}{a \\in A \\,[a \\in A]}' \/><\/center><\/p>\n<p> This is an easy one. It says that if we know that A is a type, then we can introduce the statement that <img src='http:\/\/l.wordpress.com\/latex.php?latex=a%20%5Cin%20A&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='a \\in A' style='vertical-align:1%' class='tex' alt='a \\in A' \/>, and add that as an assumption in our context. What this means is also simple: since our definition of type says that it&#8217;s only a type if it has an element, then if we know that A is a type, we know that there must be an element of A, and so we can write statements using it.<\/p>\n<p> If you think of this in programming terms, the statement <img src='http:\/\/l.wordpress.com\/latex.php?latex=A%20%5Ctext%7Btype%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='A \\text{type}' style='vertical-align:1%' class='tex' alt='A \\text{type}' \/> is saying that <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' \/> is a type. To be a valid type, there must be at least one value that belongs to the type. So you&#8217;re allowed to introduce a variable that can be assigned a value of the type.<\/p>\n<h4>Introducing Propositions as Types<\/h4>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%20%5Cfrac%7Ba%20%5Cin%20A%20%5C%2C%20%5B%5D%7D%7BA%20%5C%2C%20%5Ctext%7Btrue%7D%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title=' \\frac{a \\in A \\, []}{A \\, \\text{true}}' style='vertical-align:1%' class='tex' alt=' \\frac{a \\in A \\, []}{A \\, \\text{true}}' \/><\/center><\/p>\n<p> This is almost the mirror image of the previous. A type and a true proposition are the same thing in our type theory: a proposition is just a type, which is a set with at least one member. So if we know that there&#8217;s a member of the set A, then A is both a type and a true proposition. <\/p>\n<h3>Equality Rules<\/h3>\n<p> We start with the three basic rules of equality: equality is reflexive,  symmetric, and transitive.<\/p>\n<h4>Reflexivity<\/h4>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%20%5Cfrac%7Ba%20%5Cin%20A%7D%7Ba%20%3D%20a%20%5Cin%20A%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title=' \\frac{a \\in A}{a = a \\in A}' style='vertical-align:1%' class='tex' alt=' \\frac{a \\in A}{a = a \\in A}' \/><\/center><\/p>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%20%5Cfrac%7BA%20%5C%2C%20%5Ctext%7Btype%7D%7D%7BA%20%3D%20A%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title=' \\frac{A \\, \\text{type}}{A = A}' style='vertical-align:1%' class='tex' alt=' \\frac{A \\, \\text{type}}{A = A}' \/><\/center><\/p>\n<p> If <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' \/> is an element of a 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' \/>, then <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' \/> is equal to itself in 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' \/>; and if <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' \/> is a type, then <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' \/> is equal to itself. <\/p>\n<p> The only confusing thing about this is just that when we talk about an object in a type, we make reference to the type that it&#8217;s a part of. This makes sense if you think in terms of programming: you need to declare the type of your variables. &#8220;3: Int&#8221; doesn&#8217;t necessarily mean the same object as &#8220;3: Real&#8221;; you need the type to disambiguate the statement. So within type theory, we always talk about values with reference to the type that they&#8217;re a part of. <\/p>\n<h4>Symmetry<\/h4>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Cfrac%7Ba%20%3D%20b%20%5Cin%20A%7D%7Bb%20%3D%20a%20%5Cin%20A%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\frac{a = b \\in A}{b = a \\in A}' style='vertical-align:1%' class='tex' alt='\\frac{a = b \\in A}{b = a \\in A}' \/><\/center><\/p>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Cfrac%7BA%20%3D%20B%7D%7BB%20%3D%20A%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\frac{A = B}{B = A}' style='vertical-align:1%' class='tex' alt='\\frac{A = B}{B = A}' \/><\/center><\/p>\n<p> No surprises here &#8211; standard symmetry.<\/p>\n<h4>Transitivity<\/h4>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Cfrac%7Ba%20%3D%20b%20%5Cin%20A%20%5Cquad%20b%20%3D%20c%20%5Cin%20A%7D%7Ba%20%3D%20c%20%5Cin%20A%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\frac{a = b \\in A \\quad b = c \\in A}{a = c \\in A}' style='vertical-align:1%' class='tex' alt='\\frac{a = b \\in A \\quad b = c \\in A}{a = c \\in A}' \/><\/center><\/p>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Cfrac%7BA%20%3D%20B%20%5Cquad%20B%20%3D%20C%7D%7BA%20%3D%20C%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\frac{A = B \\quad B = C}{A = C}' style='vertical-align:1%' class='tex' alt='\\frac{A = B \\quad B = C}{A = C}' \/><\/center><\/p>\n<h4>Type Equality<\/h4>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Cfrac%7Ba%20%5Cin%20A%20%5Cquad%20A%20%3D%20B%7D%7Ba%20%5Cin%20B%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\frac{a \\in A \\quad A = B}{a \\in B}' style='vertical-align:1%' class='tex' alt='\\frac{a \\in A \\quad A = B}{a \\in B}' \/><\/center><\/p>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Cfrac%7Ba%20%3D%20b%20%5Cin%20A%20%5Cquad%20A%20%3D%20B%7D%7Ba%20%3D%20b%20%5Cin%20B%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\frac{a = b \\in A \\quad A = B}{a = b \\in B}' style='vertical-align:1%' class='tex' alt='\\frac{a = b \\in A \\quad A = B}{a = b \\in B}' \/><\/center><\/p>\n<p> These are pretty simple, and follow from the basic equality rules. If we know that <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' \/> is a member of the 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' \/>, and we know that the 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' \/> equals the 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' \/>, then obviously <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' \/> is also a member 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' \/>. Along the same lines, if we know that <img src='http:\/\/l.wordpress.com\/latex.php?latex=a%3Db&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='a=b' style='vertical-align:1%' class='tex' alt='a=b' \/> in 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' \/>, and <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' \/> equals <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' \/>, then <img src='http:\/\/l.wordpress.com\/latex.php?latex=a%3Db&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='a=b' style='vertical-align:1%' class='tex' alt='a=b' \/> in the 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' \/>. <\/p>\n<h3> Substitution Rules<\/h3>\n<p> We&#8217;ve got some basic rules about how to formulate some simple meaningful statements in the logic of our type theory. We still can&#8217;t do any interesting reasoning; we haven&#8217;t built up enough inference rules. In particular, we&#8217;ve only been looking at simple, atomic statements using parameterless predicates.<\/p>\n<p> We can use those basic rules to start building upwards, to get to parametric statements, by using substitution rules that allow us to take a parametric statement and reason with it using the non-parametric rules we talked about above.<\/p>\n<p> For example, a parametric statement can be something like <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28x%29%20%5C%2C%20%5Ctext%7Btype%7D%20%5Bx%20%5Cin%20A%5D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(x) \\, \\text{type} [x \\in A]' style='vertical-align:1%' class='tex' alt='C(x) \\, \\text{type} [x \\in A]' \/>, which says that applying <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' \/> to a value <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' \/> which is a member 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' \/> produces a value which is a type.  We can use that to produce new inference rules like the ones below.<\/p>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%20%5Cfrac%7BC%28x%29%20%5C%2C%20%5Ctext%7Btype%7D%20%5Bx%20%5Cin%20A%5D%20%5Cquad%20a%20%5Cin%20A%7D%7BC%28a%29%20%5C%2C%20%5Ctext%7Btype%7D%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title=' \\frac{C(x) \\, \\text{type} [x \\in A] \\quad a \\in A}{C(a) \\, \\text{type}}' style='vertical-align:1%' class='tex' alt=' \\frac{C(x) \\, \\text{type} [x \\in A] \\quad a \\in A}{C(a) \\, \\text{type}}' \/><\/center><\/p>\n<p> This says that if we know that given a 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' \/>, <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' \/> will produce a type; and we know that the value <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' \/> is 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' \/>, then <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28a%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(a)' style='vertical-align:1%' class='tex' alt='C(a)' \/> will be a type. In logical terms, it&#8217;s pretty straightforward; in programming terms it&#8217;s even clearer: if <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' \/> is a function on 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' \/>, and we pass it 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' \/>, it will produce a result. In other words, <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28a%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(a)' style='vertical-align:1%' class='tex' alt='C(a)' \/> is defined for all values 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' \/>.<\/p>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%20%5Cfrac%7BC%28x%29%20%5C%2C%20%5Ctext%7Btype%7D%5Bx%20%5Cin%20A%5D%20%5Cquad%20a%20%3D%20b%20%5Cin%20A%7D%7BC%28a%29%20%3D%20C%28b%29%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title=' \\frac{C(x) \\, \\text{type}[x \\in A] \\quad a = b \\in A}{C(a) = C(b)}' style='vertical-align:1%' class='tex' alt=' \\frac{C(x) \\, \\text{type}[x \\in A] \\quad a = b \\in A}{C(a) = C(b)}' \/><\/center><\/p>\n<p> This is even simpler: if <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' \/> is a function on 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' \/>, then given two values that are equal in 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' \/>, <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' \/> will produce the same result for those values.<\/p>\n<p> Of course, I&#8217;m lying a bit. In this stuff, <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' \/> isn&#8217;t really a function. It&#8217;s a logical statement; <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28x%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(x)' style='vertical-align:1%' class='tex' alt='C(x)' \/> isn&#8217;t quite a function. It&#8217;s a logical stamement which includes the symbol <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' \/>; when we say <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28a%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(a)' style='vertical-align:1%' class='tex' alt='C(a)' \/>, what we mean is the logical statement <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' \/>, with the object <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' \/> substituted for the symbol <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 I think the programming metaphors help clarify what it means.<\/p>\n<p> Using those two, we can generate more:<\/p>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%20%5Cfrac%7Bc%28x%29%20%5Cin%20C%28x%29%20%5Bx%20%5Cin%20A%5D%20%5Cquad%20a%20%5Cin%20A%7D%7Bc%28a%29%20%5Cin%20C%28A%29%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title=' \\frac{c(x) \\in C(x) [x \\in A] \\quad a \\in A}{c(a) \\in C(A)}' style='vertical-align:1%' class='tex' alt=' \\frac{c(x) \\in C(x) [x \\in A] \\quad a \\in A}{c(a) \\in C(A)}' \/><\/center><\/p>\n<p> This one becomes interesting. <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28x%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(x)' style='vertical-align:1%' class='tex' alt='C(x)' \/> is a proposition which is parametric in <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 <img src='http:\/\/l.wordpress.com\/latex.php?latex=c%28x%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='c(x)' style='vertical-align:1%' class='tex' alt='c(x)' \/> is a <em>proof-element<\/em>: it&#8217;s an instance of <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28x%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(x)' style='vertical-align:1%' class='tex' alt='C(x)' \/> which proves that <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28X%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(X)' style='vertical-align:1%' class='tex' alt='C(X)' \/> is a type, and we can see <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' \/> as a computation which, given 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' \/> produces a instance of <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' \/>. Then what this judgement says is that given an instance <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' \/> 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' \/>, we know that <img src='http:\/\/l.wordpress.com\/latex.php?latex=c%28a%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='c(a)' style='vertical-align:1%' class='tex' alt='c(a)' \/> is an instance of type <img src='http:\/\/l.wordpress.com\/latex.php?latex=C%28a%29&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='C(a)' style='vertical-align:1%' class='tex' alt='C(a)' \/>.  This will become very important later on, when we really get in to type inference and quantification and parametric types.<\/p>\n<p><center><img src='http:\/\/l.wordpress.com\/latex.php?latex=%5Cfrac%7Bc%28x%29%20%5Cin%20C%28x%29%20%5Bx%20%5Cin%20A%5D%20%5Cquad%20a%20%3D%20b%7D%7Bc%28a%29%3Dc%28b%29%5Cin%20C%28a%29%7D&#038;bg=FFFFFF&#038;fg=000000&#038;s=0' title='\\frac{c(x) \\in C(x) [x \\in A] \\quad a = b}{c(a)=c(b)\\in C(a)}' style='vertical-align:1%' class='tex' alt='\\frac{c(x) \\in C(x) [x \\in A] \\quad a = b}{c(a)=c(b)\\in C(a)}' \/><\/center><\/p>\n<p> This is just a straightforward application of equality to proof objects.<\/p>\n<p> There&#8217;s more of these kinds of rules, but I&#8217;m going to stop here. My goal isn&#8217;t to get you to know every single judgement in the intuitionistic logic of type theory, but to give you a sense of what they mean. <\/p>\n<p> That brings us to the end of the basic inference rules. The next things we&#8217;ll need to cover are ways of constructing new types or types from existing ones. The two main tools for that are enumeration types (basically, types consisting of a group of ordered values), and cartesian products of multiple types. With those, we&#8217;ll be able to find ways of constructing most of the types we&#8217;ll want to use in programming languages.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s been quite a while since I did any meaningful writing on type theory. I spent a lot of time introducing the basic concepts, and trying to explain the intuition behind them. I also spent some time describing what I think of as the platform: stuff like arity theory, which we need for talking about [&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":[292],"tags":[],"class_list":["post-3531","post","type-post","status-publish","format-standard","hentry","category-type-theory"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4lzZS-UX","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/3531","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=3531"}],"version-history":[{"count":18,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/3531\/revisions"}],"predecessor-version":[{"id":3549,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/posts\/3531\/revisions\/3549"}],"wp:attachment":[{"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/media?parent=3531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/categories?post=3531"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.goodmath.org\/blog\/wp-json\/wp\/v2\/tags?post=3531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}