<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Inside the Implementation on Massimo Nocentini</title><link>https://massimo-nocentini.github.io/book/dependent-types/part-3/</link><description>Recent content in Inside the Implementation on Massimo Nocentini</description><generator>Hugo</generator><language>en-US</language><atom:link href="https://massimo-nocentini.github.io/book/dependent-types/part-3/index.xml" rel="self" type="application/rss+xml"/><item><title>Inside Pie: syntax, values and contexts</title><link>https://massimo-nocentini.github.io/book/dependent-types/part-3/07-representation/</link><dc:creator>Massimo Nocentini</dc:creator><guid>https://massimo-nocentini.github.io/book/dependent-types/part-3/07-representation/</guid><description>&lt;p&gt;From here on we read the implementation. &lt;a class="xref" href="https://massimo-nocentini.github.io/book/dependent-types/part-3/08-nbe/"&gt;Chapter&amp;nbsp;8&lt;/a&gt; explains how Pie computes and decides equality, and &lt;a class="xref" href="https://massimo-nocentini.github.io/book/dependent-types/part-3/09-checking/"&gt;Chapter&amp;nbsp;9&lt;/a&gt; how it checks programs. Both manipulate the data structures that this section describes, most of them defined in &lt;code&gt;basics.rkt&lt;/code&gt;. The Racket idioms of the excerpts were explained in the paragraph “Reading the Racket” of &lt;a class="xref" href="https://massimo-nocentini.github.io/book/dependent-types/part-1/01-intro/#sub:intro-map"&gt;Section&amp;nbsp;1.3&lt;/a&gt;.&lt;/p&gt;&#10;&lt;p&gt;Besides Pie programs, we show the output of two Racket scripts, &lt;code&gt;repr.rkt&lt;/code&gt; and &lt;code&gt;elaborate.rkt&lt;/code&gt;, which call Pie’s modules directly.&lt;label for="mn-761ff9-1" class="margin-toggle"&gt;&amp;#8853;&lt;/label&gt;&lt;input type="checkbox" id="mn-761ff9-1" class="margin-toggle"/&gt;&lt;span class="marginnote"&gt;The scripts call the modules of an unmodified copy of Pie. Racket prints a struct as &lt;code&gt;#(struct:NAME field ...)&lt;/code&gt; and a box as &lt;code&gt;#&amp;amp;&lt;/code&gt;. For long values, &lt;code&gt;repr.rkt&lt;/code&gt; uses a compact printer of its own, which forces nothing: a struct prints as &lt;code&gt;(NAME field ...)&lt;/code&gt;, a delayed value not yet computed as &lt;code&gt;(later e)&lt;/code&gt;, one already computed as &lt;code&gt;(! v)&lt;/code&gt;.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Normalization by evaluation</title><link>https://massimo-nocentini.github.io/book/dependent-types/part-3/08-nbe/</link><dc:creator>Massimo Nocentini</dc:creator><guid>https://massimo-nocentini.github.io/book/dependent-types/part-3/08-nbe/</guid><description>&lt;p&gt;The checker keeps asking one question: are two expressions the same? The &lt;span class="sc"&gt;Same&lt;/span&gt; rule asks it about the endpoints of an equality type (&lt;a class="xref" href="https://massimo-nocentini.github.io/book/dependent-types/part-2/04-equality/#sub:equality-same"&gt;Section&amp;nbsp;4.1&lt;/a&gt;), the mode switch asks it about two types (&lt;a class="xref" href="https://massimo-nocentini.github.io/book/dependent-types/part-3/09-checking/#sub:checking-modes"&gt;Section&amp;nbsp;9.2&lt;/a&gt;), and &lt;code&gt;check-same&lt;/code&gt; asks it directly. It is the judgment &lt;span class="tufte-nobr"&gt;&lt;span class="katex tufte-math-euler"&gt;&lt;span class="katex-mathml"&gt;&lt;math xmlns="http://www.w3.org/1998/Math/MathML"&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant="normal"&gt;Γ&lt;/mi&gt;&lt;mo&gt;⊢&lt;/mo&gt;&lt;mi&gt;a&lt;/mi&gt;&lt;mo&gt;≡&lt;/mo&gt;&lt;mi&gt;b&lt;/mi&gt;&lt;mo&gt;:&lt;/mo&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;/mrow&gt;&lt;annotation encoding="application/x-tex"&gt;\Gamma \vdash a \equiv b : A&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt;,&lt;/span&gt; or &lt;span class="katex tufte-math-euler"&gt;&lt;span class="katex-mathml"&gt;&lt;math xmlns="http://www.w3.org/1998/Math/MathML"&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mi mathvariant="normal"&gt;Γ&lt;/mi&gt;&lt;mo&gt;⊢&lt;/mo&gt;&lt;mi&gt;A&lt;/mi&gt;&lt;mo&gt;≡&lt;/mo&gt;&lt;mi&gt;B&lt;/mi&gt;&lt;mtext&gt; &lt;/mtext&gt;&lt;mrow&gt;&lt;mi&gt;𝗍&lt;/mi&gt;&lt;mi&gt;𝗒&lt;/mi&gt;&lt;mi&gt;𝗉&lt;/mi&gt;&lt;mi&gt;𝖾&lt;/mi&gt;&lt;/mrow&gt;&lt;/mrow&gt;&lt;annotation encoding="application/x-tex"&gt;\Gamma \vdash A \equiv B\ \mathsf{type}&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; for types. Pie answers it with &lt;em&gt;normalization by evaluation&lt;/em&gt; (NbE): evaluate both expressions to values, read the values back into syntax guided by the type, and compare the results up to the names of bound variables. This section follows that procedure through &lt;code&gt;normalize.rkt&lt;/code&gt; and &lt;code&gt;alpha.rkt&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Bidirectional checking as elaboration</title><link>https://massimo-nocentini.github.io/book/dependent-types/part-3/09-checking/</link><dc:creator>Massimo Nocentini</dc:creator><guid>https://massimo-nocentini.github.io/book/dependent-types/part-3/09-checking/</guid><description>&lt;p&gt;The last two sections described the data the checker works on and the test it uses for equality. This section describes the checker itself, &lt;code&gt;typechecker.rkt:1–897&lt;/code&gt;. It does two jobs in one pass. It decides whether a Src term is well typed, and it translates the term into Core. A checker that produces a translated term as a side product of checking is called an &lt;em&gt;elaborator&lt;/em&gt;. Each form of judgment in the appendix of &lt;em&gt;The Little Typer&lt;/em&gt;&lt;label for="sn-0a6d45-1" class="margin-toggle sidenote-number"&gt;&lt;/label&gt;&lt;input type="checkbox" id="sn-0a6d45-1" class="margin-toggle"/&gt;&lt;span class="sidenote citation"&gt;&lt;span class="bib-entry" data-cite="littletyper"&gt;Daniel P. Friedman and David Thrane Christiansen. &lt;cite&gt;The Little Typer&lt;/cite&gt;. MIT Press, Cambridge, MA, 2018&lt;/span&gt;&lt;/span&gt; becomes one Racket function, and the output of each function is the term written after &lt;span class="katex tufte-math-euler"&gt;&lt;span class="katex-mathml"&gt;&lt;math xmlns="http://www.w3.org/1998/Math/MathML"&gt;&lt;semantics&gt;&lt;mrow&gt;&lt;mo&gt;⇝&lt;/mo&gt;&lt;/mrow&gt;&lt;annotation encoding="application/x-tex"&gt;\rightsquigarrow&lt;/annotation&gt;&lt;/semantics&gt;&lt;/math&gt;&lt;/span&gt;&lt;/span&gt; in the judgment.&lt;/p&gt;</description></item><item><title>Pie among type theories, and building your own</title><link>https://massimo-nocentini.github.io/book/dependent-types/part-3/10-context/</link><dc:creator>Massimo Nocentini</dc:creator><guid>https://massimo-nocentini.github.io/book/dependent-types/part-3/10-context/</guid><description>&lt;p&gt;Pie is small on purpose. This last section lists what it leaves out and what it takes for granted, compares it with four larger systems, and ends with a recipe for a checker of the same kind, exercises that change Pie itself, and further reading.&lt;/p&gt;&#10;&lt;p&gt;&lt;span class="run-in"&gt;User-defined datatypes.&lt;/span&gt; A Pie file contains only &lt;code&gt;claim&lt;/code&gt;, &lt;code&gt;define&lt;/code&gt;, &lt;code&gt;check-same&lt;/code&gt; and expressions: the declaration parser &lt;code&gt;parse-pie-decl&lt;/code&gt; has exactly these four cases (&lt;code&gt;parser.rkt:395–423&lt;/code&gt;), and the type formers are a fixed list of keywords (&lt;code&gt;basics.rkt:39–51&lt;/code&gt;). A would-be declaration is read as an expression, an application of an unknown variable:&lt;/p&gt;</description></item></channel></rss>