{"id":211,"date":"2021-01-11T19:40:04","date_gmt":"2021-01-11T18:40:04","guid":{"rendered":"http:\/\/pinkieduck.net\/?p=211"},"modified":"2021-01-11T19:40:04","modified_gmt":"2021-01-11T18:40:04","slug":"equality-in-type-theory","status":"publish","type":"post","link":"https:\/\/pinkieduck.net\/?p=211","title":{"rendered":"Equality in type theory"},"content":{"rendered":"\n<p>I&rsquo;m always amazed by how many subtle assumptions we often make when doing day-to-day maths, and how challenging these assumptions yield to some interesting construct.<\/p>\n\n\n\n<p>I&rsquo;m currently trying to read the Homotopy Type Theory (\u00ab\u00a0Hott\u00a0\u00bb) book. HoTT is an extension of type theory which is the underlying logic foundation of most proof assistant.<br>It uses the \u00ab\u00a0proposition as type\u00a0\u00bb idea which identifies some usual logical building block like conjunction, disjunctions, implications, quantifiers&#8230; with usual (and sometimes less usual) programming type constructs like algebraic types, functions&#8230;<\/p>\n\n\n\n<p>One of the most important logical building block covered by type theory is the equality. To be honest I never really thought what \u00ab\u00a0being equals to\u00a0\u00bb really mean before reading the book, besides the usual \u00ab\u00a0it&rsquo;s just another equivalence relation between things\u00a0\u00bb. But that&rsquo;s neither a definition nor a satisfying properly, as for instance you can name several other equivalence like isomorphism which wouldn&rsquo;t act as a good replacement for equality in most context.<\/p>\n\n\n\n<p>Type theory gives two answers to this question : the first one is the definitional equality, or equality by definition. This equality comes from the fact that some composite type can be \u00ab\u00a0reduced\u00a0\u00bb : breaking a tuple into its component, or applying an argument to a function yield simpler syntaxical construct ; for instance in this framework (\\x -&gt; x + x)(1) (applying \u00ab\u00a01\u00a0\u00bb to the lambda function which transforms \u00ab\u00a0x\u00a0\u00bb to \u00ab\u00a0x + x\u00a0\u00bb) is definitionally equals to 2, or fst (x, y) is definitionally equals to x. It&rsquo;s just a matter of \u00ab\u00a0following your nose\u00a0\u00bb and determining if 2 objects are definitionally equal should better be decidable.<br>Unfortunatly not every equality is decidable in the day to day maths world : equality for reals is not decidable, there is no magic method to determine if 2 sides of an equation are equals. This means we need another kind of equality and here lie the second answer provided by type theory.<br>Type theory introduce an identity type, sometimes called \u00ab\u00a0judgemental equality\u00a0\u00bb. It&rsquo;s a proposition and not merely a syntaxical rewriting. However the computation and uniqueness principle are designed to capture the defining property of equality which was hinted by the definitional equality : If two objects x and y are equals, then you can replace x by y in any proposition containing y (it&rsquo;s a bit more involving but it&rsquo;s the overall idea). Note that identity type is a generalisation of the definitional equality : an introduction rule for the identity type is equality by reflexivity, ie an object x is equals to itself. Since two definitionnaly equals objects are really just the same object in this framework, 2 definitionnally equals object are also judgmentally equals. But what are the others way to introduce equality then ?<\/p>\n\n\n\n<p>That&rsquo;s where Homotopy type theory comes into play. There are several answer to this question : one is that reflexivity is always the only way to introduce equality, and thus if 2 objects are equals one can consider that they are really the same. This is the logic under the Extensional Type Theory. There are several consequence to this design choice that I won&rsquo;t cover.<br>On the other hand, homotopy type theory allows other kinds of \u00ab\u00a0equalities\u00a0\u00bb with root in homotopy (a subfield of topology as far as I understand which studies continuous path, path between path, and so on). It gives rise to a whole new interpretation of equality that is at the hearth of the book : objects are not merely \u00ab\u00a0element in a set\u00a0\u00bb but become \u00ab\u00a0points in a space\u00a0\u00bb whose path between point are equality relation.<\/p>\n\n\n\n<p>I will write more on it later.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&rsquo;m always amazed by how many subtle assumptions we often make when doing day-to-day maths, and how challenging these assumptions yield to some interesting construct. I&rsquo;m currently trying to read the Homotopy Type Theory (\u00ab\u00a0Hott\u00a0\u00bb) book. HoTT is an extension of type theory which is the underlying logic foundation of most proof assistant.It uses the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/pinkieduck.net\/index.php?rest_route=\/wp\/v2\/posts\/211"}],"collection":[{"href":"https:\/\/pinkieduck.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pinkieduck.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pinkieduck.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pinkieduck.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=211"}],"version-history":[{"count":1,"href":"https:\/\/pinkieduck.net\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":212,"href":"https:\/\/pinkieduck.net\/index.php?rest_route=\/wp\/v2\/posts\/211\/revisions\/212"}],"wp:attachment":[{"href":"https:\/\/pinkieduck.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pinkieduck.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pinkieduck.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}