One More Type in the Tiny Type Theory
jcreed blog > One More Type in the Tiny Type Theory
One More Type in the Tiny Type Theory
Continuing with the previous post, I can<br>define one more type constructor that I suspect to be important for constructing the backward direction of<br>\[\surd \rtype \cong (A : \T \to \rtype) \x (t : \T) (B : A\ t) \to \rtype \]<br>For that we would need to construct a genuine $\rtype$ in a context that looks like<br>\[ A \div \rtype, B \div A \to \rtype \]<br>Type Former
So my guess is we want a somewhat $\Sigma$-like type former, call it $\gg$ for "glue":<br>\[<br>\Gamma, \star \prov A : \rtype \qquad \Gamma^\oplus, \star, x : A \prov B : \rtype<br>\over<br>\Gamma \prov \gg(x : A). B : \rtype<br>\]<br>It glues together two types, one of which carries "downstairs" information, namely $A$, and the other lives "upstairs", namely "B". The interpretation of this back into<br>ordinary type theory is:
$(\gg(x : A). B)^* = A^*$
$\sem {\gg(x : A). B}(M^*) = [M^*/x^*]B^*$
Why are these well-typed? By induction hypothesis applying the translation<br>$\dash^*$ to the premises, we'd have<br>\[\Gamma^* \prov A^* : \rtype \tag{*}\]<br>\[(\Gamma^\oplus)^*, x^* : A^* \prov B^* : \rtype\]<br>We can reason that $(\Gamma^\oplus)^*$ is the same thing as $\sem \Gamma$, so we have<br>\[\sem \Gamma, x^* : A^* \prov B^* : \rtype\tag{**}\]<br>Showing<br>\[ \Gamma^* \prov (\gg(x : A). B)^* : \rtype\]<br>is just $(*)$, and then the obligation<br>\[ \sem \Gamma, y^* : (\gg(x : A). B)^* \prov \sem{\gg(x : A). B}(y^*) : \rtype\]<br>reduces to<br>\[ \sem \Gamma, y^* : A^* \prov [y^*/x^*] B^* : \rtype\]<br>and this is $(**)$ up to $\alpha$-equivalence.<br>Term Formers
Here's how I think we introduce $\gg$:<br>\[<br>\Gamma, \star \prov M : A \qquad \Gamma^\oplus, \star \prov N : [M/x]B<br>\over<br>\Gamma \prov \pair M N : \gg(x : A). B<br>\]
Here's how I think we eliminate $\gg$:<br>\[<br>{\Gamma \prov M : \gg(x : A). B<br>\over<br>\Gamma, \star \prov M\tri 1 : A}<br>\qquad<br>{\Gamma \prov M : \gg(x : A). B<br>\over<br>\Gamma^\oplus, \star \prov M\tri 2 : [M\tri 1/x]B}<br>\]
We say that these interpret as follows:
$(\pair M N)^* = M^*$
$\sem {\pair M N}^* = N^*$
$( M\tri 1)^* = M^*$
$\sem{M\tri 1} = \babort(☠)$
$( M\tri 2)^* = \sem M$
$\sem{M\tri 2} = \babort(☠)$
Let's check that these interpretations are well-typed.
Introduction
Applying $\dash^*$ to the premises we get<br>\[\Gamma^* \prov M^* : A^*\]<br>\[\sem \Gamma \prov N^* : [M^*/x^*]B^*\]<br>Applying $\sem\dash$ gives us nothing useful because $\star$ is present.<br>Downstairs we need<br>\[\Gamma^* \prov (\pair M N)^* : (\gg(x : A). B)^*\]<br>which computes to<br>\[\Gamma^* \prov M^* : A^*\]<br>which we have. Upstairs we need<br>\[\sem\Gamma \prov \sem{\pair M N} : \sem{\gg(x : A). B}((\pair M N)^*)\]<br>which computes to<br>\[\sem\Gamma \prov N^* : [M^*/x^*]B^*\]<br>which we also have.<br>First Projection
I.h. for $\dash^*$ on the premise gives<br>\[\Gamma^* \prov M^* : A^*\]<br>We need<br>\[(\Gamma^* \prov (M\tri 1)^* : A^* ) = (\Gamma^* \prov M^* : A^*)\]<br>and<br>\[(\sem{\Gamma, \star} \prov \sem{M\tri 1} : \sem A((M\tri 1)^*)) =<br>(\sem \Gamma,☠ : 0 \prov \babort(☠) : \sem A(M^*))\]<br>so we're good.<br>Second Projection
I.h. for $\sem\dash$ on the premise gives<br>\[\sem \Gamma \prov \sem M : \sem{\gg(x : A). B}(M^*) \]<br>in other words<br>\[\sem \Gamma \prov \sem M : [M^*/x^*]B^* \]<br>We need<br>\[((\Gamma^\oplus, \star)^* \prov (M\tri 2)^* : ([M\tri 1/x]B)^* ) =<br>(\sem \Gamma \prov \sem M : [M^*/x^*]B^* ) \]<br>and<br>\[(\sem{\Gamma^\oplus, \star} \prov \sem{M\tri 2} : \sem{[M\tri 1/x]B}((M\tri 2)^*) ) =<br>(\sem{\Gamma}, ☠ : 0 \prov \babort (☠) : \sem{[M\tri 1/x]B}((M\tri 2)^*) ) \]<br>so we're good.
$\blat$ is a special case of $\gg$
I claim that $\blat A$ is equivalent to the type<br>\[ \gg (x : 1) . \surd A\]<br>It is correct semantically:<br>\[ (\blat A)^* = 1 = ( \gg (x : 1) . \surd A)^*\]<br>\[ \sem{\blat A}(\_) = (a^* : A^*) \x \sem A(a^*) = (\surd A)^* = \sem{ \gg (x : 1).\surd A}(\_)\]<br>Or perhaps I should say 'subsumed by' since I'm suspicious that $\blat$ perhaps "doesn't have enough<br>inference rules", but I think I can implement the $\blat A$ inference rules using those of $\gg$.<br>So I might as well throw away $\blat$. Specifically, I can implement as derived rules:<br>\[<br>\Gamma^\oplus \prov M : A<br>\over<br>\Gamma \prov \pair {\langle\rangle} {\mathbf{in}_\surd\ M} : \gg (x:1).\surd A<br>\]<br>to replace $\mathbf{in}_\blat$, and<br>\[<br>\Gamma^\ominus \prov M : \gg (x:1).\surd A<br>\over<br>\Gamma \prov \mathbf{el}_\surd( M\tri 2) : A<br>\]<br>In the second rule, I'm using weakening to get from $\Gamma^\ominus$ to $\Gamma$. Actually<br>I could have actually asserted the stronger<br>\[<br>\Gamma^\ominus \prov M : \gg (x:1).\surd A<br>\over<br>\Gamma^\ominus \prov \mathbf{el}_\surd( M\tri 2) : A<br>\]<br>This is still kosher semantically. We have from applying the $\sem \dash$ i.h. to the premise<br>the fact that<br>\[ \Gamma^* \prov \sem M : (a^* : A^*) \x \sem A(a^*) \tag{*}\]<br>and we must show in the goal<br>\[ \Gamma^* \prov (\mathbf{el}_\surd( M\tri 2))^* : A^*\]<br>\[ \Gamma^* \prov \sem{\mathbf{el}_\surd( M\tri 2)} : \sem A((\mathbf{el}_\surd( M\tri 2))^*) \]<br>But we compute<br>\[...