-
Notifications
You must be signed in to change notification settings - Fork 2
/
170124.tex
145 lines (113 loc) · 5.26 KB
/
170124.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
\newpage
\section{Introduction to the $F\omega$ type system}
% This came first, fundementally useless for us
%\subsection{Grammar of the $F$ type system (``System F'')}
%\begin{align*}
%\tau & \bnfdef \alpha \bnfalt \tau \arrow \tau \bnfalt \forall \alpha. \tau \\
%e &\bnfdef x \bnfalt \lambda x \of \tau. e \bnfalt e\ e \bnfalt \Lambda \alpha. e \bnfalt e [ \tau ]
%\end{align*}
%Type $\tau$ and Term $e$.
\begin{grouped}{\subsection{Grammar}}
\begin{align*}
k & \bnfdef \type \bnfalt k \arrow k \\
c & \bnfdef \alpha \bnfalt c \arrow c \bnfalt \forall \bind{\alpha \of k}{c} \bnfalt c\ c \\
e & \bnfdef x \bnfalt \lambda \bind{x \of c}{e} \bnfalt e\ e
\bnfalt \Lambda \bind{\alpha \of k}{e} \bnfalt e [ c ] \\
\end{align*}
Kind $k$, Type Constructor $c$, and Term $e$.\\
\note{$\type$ is often referred to with just ``T'' (by Crary), for simplicity.\\}
\end{grouped}
\begin{grouped}{\subsection{Context for Judgements}}
\begin{equation} \label{Context}
\Gamma \bnfdef \epsilon \bnfalt \Gamma, x \of \tau \bnfalt \Gamma, \alpha \of k
\end{equation}
\note{For simplicity, whenever a new $\alpha$ appears in the context, we
implicitly ensure that $\alpha$ is not already in $\Gamma$.\\}
\end{grouped}
\begin{grouped}{\subsection{$\Gamma \vd c \of k$}}
\begin{mathpar}
\inferr{\Gamma \vd \alpha \of k}
{\Gamma(\alpha) = k}
\inferr{\Gamma \vd \tau_1 \arrow \tau_2 \of T}
{\Gamma \vd \tau \of T \\ \Gamma \vd \tau_2 \of T}
\inferr{\Gamma \vd \forall\bind{\alpha \of k}{\tau}}
{\Gamma, \alpha \of k \vd \tau \of T}
\inferr{\Gamma \vd \lambda\bind{\alpha \of k}{c} \of k \arrow k'}
{\Gamma, \alpha \of k \vd c \of k'}
\inferr{\Gamma \vd c_1\ c_2 \of k'}
{\Gamma \vd c_1 \of k \arrow k' \\ \Gamma \vd c_2 : k}
\end{mathpar}
\end{grouped}
\begin{grouped}{\subsection{$\Gamma \vd e \of \tau$}}
\begin{mathpar}
\inferr{\Gamma \vd x \of \tau}{\Gamma(x) = \tau}
\inferr{\Gamma \vd \lambda\bind{x \of \tau}{e} \of \tau \arrow \tau'}
{\Gamma, x \of \tau \vd e \of \tau'}
\inferr{\Gamma \vd e_1\ e_2 \of \tau'}
{\Gamma \vd e_1 \of \tau \arrow \tau' \\ \Gamma \vd e_2 : \tau}
\inferr{\Gamma \vd \Lambda\bind{\alpha \of k}{e} \of \forall\bind{\alpha \of k}{\tau}}
{\Gamma, \alpha \of k \vd e \of \tau}
\inferr{\Gamma \vd e [c] \of \subst{c}{\alpha}{e}}
{\Gamma \vd e \of \forall\bind{\alpha \of k}{e} \\ \Gamma \vd c \of k}
\inferr{\Gamma \vd e \of \tau'}
{\Gamma \vd e \of \tau \\ \Gamma \vd \tau \equiv \tau' : T}
\end{mathpar}
\end{grouped}
\begin{grouped}{\subsection{$\Gamma \vd c \equiv c \of k$}}
Definitional Equivalence.\\
\begin{mathpar}
\inferr{\Gamma \vd c \equiv c \of k}{\Gamma \vd c \of k}
\inferr{\Gamma \vd c' \equiv c \of k}{\Gamma \vd c \equiv c' \of k}
\inferr{\Gamma \vd c_1 \equiv c_3 \of k}
{\Gamma \vd c_1 \equiv c_2 \of k \\ \Gamma \vd c_2 \equiv c_2 \of k}
\end{mathpar}
The above are identity, reflexivity, and transitivity respectively.\\
The following are ``compatibility'' rules.\\
\begin{mathpar}
\inferr{\Gamma \vd c_1c_2 \equiv c_1'c_2' \of k}
{\Gamma \vd c_1 \equiv c_1' \of k \\ \Gamma \vd c_2 \equiv c_2' \of k}
\inferr{\Gamma \vd \lambda\bind{\alpha \of k_1}{c} \equiv
\lambda\bind{\alpha \of k_1}{c'} \of k_1 \arrow k_2}
{\Gamma, \alpha \of k_1 \vd c \equiv c' \of k_2}
\inferr{\Gamma \vd \tau_1 \arrow \tau_2 \equiv \tau_1' \arrow \tau_2' \of T}
{\Gamma \vd \tau_1 \equiv \tau_1' \of k \\
\Gamma \vd \tau_2 \equiv \tau_2' \of k}
\inferr{\Gamma \vd \forall\bind{\alpha \of k}{\tau} \equiv
\forall\bind{\alpha \of k}{\tau'} \of T}
{\Gamma, \alpha \of k \vd \tau \equiv \tau' : T}
\end{mathpar}
congruence = compatible equivalence relation \\ %% TODO: WTF IS THIS
The following are the rules for beta equivalence and extensionality:\\
\begin{mathpar}
\inferr{\Gamma \vd (\lambda\bind{\alpha \of k}{c_1})\ c_2 \equiv
\subst{c_2}{\alpha}{c_1} \of k'}
{\Gamma \vd c_2 \of k \\ \Gamma, \alpha \of k \vd c_1 \of k'}
\inferr{\Gamma \vd c \equiv c' \of k_1 \arrow k_2}
{\Gamma, \alpha \of k_1 \vd c\ \alpha \equiv c'\ \alpha \of k_2 \\
\Gamma \vd c \of k_1 \arrow k_2 \\ \Gamma \vd c' : k_1 \arrow k_2}
\end{mathpar}
\end{grouped}
\begin{grouped}{\subsection{Extending $F\omega$}}
\note{This helps in the understanding of sml's module system\\}
Grammar:
\begin{align*}
k & \bnfdef \ldots \bnfalt k \times k \\
c & \bnfdef \ldots \bnfalt \langle c, c \rangle \bnfalt \pi_1 c \bnfalt \pi_2 c
\end{align*}
New Judgements:
\begin{mathpar}
\inferr{\Gamma \vd \langle c_1, c_2 \rangle \of k_1 \times k_2}
{\Gamma \vd c_1 \of k_2 \\ \Gamma \vd c_2 \of k_2}
\inferr{\Gamma \vd \pi_i\ c \of k_1}{\Gamma \vd c \of k_1 \times k_2}
\inferr{\Gamma \vd \langle c_1, c_2 \rangle \equiv
\langle c_1', c_2' \rangle \of k_1 \times k_2}
{\Gamma \vd c_1 \equiv c_1' \of k_1 \\ \Gamma \vd c_2 \equiv c_2' \of k_2}
\inferr{\Gamma \vd \pi_i\ c \equiv \pi_i\ c' \of k_i}
{\Gamma \vd c \equiv c' \of k_1 \times k_2}
\inferr{\Gamma \vd \pi_i\langle c_1, c_2 \rangle \equiv c_i \of k_i}
{\Gamma \vd c_1 \of k_1 \\ \Gamma \vd c_2 \of k_2}
\inferr{\Gamma \vd c \equiv c' \of k_1 \times k_2}
{\Gamma \vd \pi_1\ c \equiv \pi_1\ c' \of k_1 \\
\Gamma \vd \pi_2\ c \equiv \pi_2\ c' \of k_2}
\end{mathpar}
\end{grouped}