Skip to content

Commit dc5212e

Browse files
authored
Typing Rules (#6)
1 parent bcd5a4e commit dc5212e

45 files changed

Lines changed: 12994 additions & 47 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

spec/latex/dim.svg

Lines changed: 1192 additions & 0 deletions
Loading

spec/latex/dim.tex

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
\documentclass[preview]{standalone}
2+
\usepackage{amsmath}
3+
\usepackage{semantic}
4+
\begin{document}
5+
6+
\[
7+
\inference[dim-nrows]{
8+
F, D, L \vdash e : \langle d_1, d_2, R \rangle \\
9+
}{
10+
F, D, L \vdash_D e \texttt{.nrows} : d_1
11+
}
12+
\]
13+
14+
\[
15+
\inference[dim-ncols]{
16+
F, D, L \vdash e : \langle d_1, d_2, R \rangle \\
17+
}{
18+
F, D, L \vdash_D e \texttt{.ncols} : d_2
19+
}
20+
\]
21+
22+
\[
23+
\inference[dim-var]{
24+
d := D[M] \\
25+
}{
26+
F, D, L \vdash_D M : d
27+
}
28+
\]
29+
30+
\[
31+
\inference[assign-nrows]{
32+
\text{if } M_b \in L \text{: } L[M_b] = \langle 1, 1, \texttt{int} \rangle \\
33+
F, D, L \vdash e : \langle d_1, d_2, \texttt{int} \rangle \\
34+
L_r := L[M_b := \langle 1, 1, \texttt{int} \rangle] \\
35+
D_r := D[M_b := d_1] \\
36+
}{
37+
F, D, L \vdash M_b \texttt{ = } e \texttt{.nrows;} : L_r, D_r
38+
}
39+
\]
40+
41+
\[
42+
\inference[assign-ncols]{
43+
\text{if } M_b \in L \text{: } L[M_b] = \langle 1, 1, \texttt{int} \rangle \\
44+
F, D, L \vdash e : \langle d_1, d_2, \texttt{int} \rangle \\
45+
L_r := L[M_b := \langle 1, 1, \texttt{int} \rangle] \\
46+
D_r := D[M_b := d_2] \\
47+
}{
48+
F, D, L \vdash M_b \texttt{ = } e \texttt{.ncols;} : L_r, D_r
49+
}
50+
\]
51+
52+
\[
53+
\inference[assign-dim]{
54+
\text{if } M_b \in L \text{: } L[M_b] = \langle 1, 1, \texttt{int} \rangle \\
55+
L_r := L[M_b := \langle 1, 1, \texttt{int} \rangle] \\
56+
D_r := D[M_b := M_e] \\
57+
}{
58+
F, D, L \vdash M_b \texttt{ = } M_e \texttt{;} : L_r, D_r
59+
}
60+
\]
61+
62+
\end{document}

spec/latex/expr-apply.svg

Lines changed: 776 additions & 0 deletions
Loading

spec/latex/expr-apply.tex

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
\documentclass[preview]{standalone}
2+
\usepackage{semantic}
3+
\begin{document}
4+
\[
5+
\inference[apply-unary]{
6+
F, D, L \vdash e : \langle d_1, d_2, R_1 \rangle \\
7+
((\tau_p) \rightarrow \tau_r) := F[f] \\
8+
\langle 1, 1, R_1 \rangle := \tau_p & \langle 1, 1, R_2 \rangle := \tau_r \\
9+
}{
10+
F, D, L \vdash \texttt{apply(} f \texttt{, } e \texttt{)} : \langle d_1, d_2, R_2 \rangle
11+
}
12+
\]
13+
14+
\[
15+
\inference[apply-binary]{
16+
F, D, L \vdash e_1 : \langle d_1, d_2, R_1 \rangle \\
17+
F, D, L \vdash e_2 : \langle 1, 1, R_2 \rangle \\
18+
((\tau_{p_1} \times \tau_{p_2}) \rightarrow \tau_r) := F[f] \\
19+
\langle 1, 1, R_1 \rangle := \tau_{p_1}
20+
& \langle 1, 1, R_2 \rangle := \tau_{p_2}
21+
& \langle 1, 1, R_3 \rangle := \tau_r \\
22+
}{
23+
F, D, L \vdash \texttt{apply(} f \texttt{, } e_1 \texttt{, } e_2 \texttt{)} : \langle d_1, d_2, R_3 \rangle
24+
}
25+
\]
26+
27+
\end{document}

spec/latex/expr-arith.svg

Lines changed: 1053 additions & 0 deletions
Loading

spec/latex/expr-arith.tex

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
\documentclass[preview]{standalone}
2+
\usepackage{semantic}
3+
\begin{document}
4+
\[
5+
\inference[add]{
6+
F, D, L \vdash e_1 : \langle 1, 1, R \rangle \\
7+
F, D, L \vdash e_2 : \langle 1, 1, R \rangle \\
8+
}{
9+
F, D, L \vdash e_1 \texttt{ + } e_2 : \langle 1, 1, R \rangle
10+
}
11+
\]
12+
13+
\[
14+
\inference[mul]{
15+
F, D, L \vdash e_1 : \langle 1, 1, R \rangle \\
16+
F, D, L \vdash e_2 : \langle 1, 1, R \rangle \\
17+
}{
18+
F, D, L \vdash e_1 \texttt{ * } e_2 : \langle 1, 1, R \rangle
19+
}
20+
\]
21+
22+
\[
23+
\inference[sub]{
24+
F, D, L \vdash e_1 : \langle 1, 1, R \rangle \\
25+
F, D, L \vdash e_2 : \langle 1, 1, R \rangle \\
26+
R \in \{ \texttt{int}, \texttt{real}\} \\
27+
}{
28+
F, D, L \vdash e_1 \texttt{ - } e_2 : \langle 1, 1, R \rangle
29+
}
30+
\]
31+
32+
\[
33+
\inference[div]{
34+
F, D, L \vdash e_1 : \langle 1, 1, \texttt{real} \rangle \\
35+
F, D, L \vdash e_2 : \langle 1, 1, \texttt{real} \rangle \\
36+
}{
37+
F, D, L \vdash e_1 \texttt{ / } e_2 : \langle 1, 1, \texttt{real} \rangle
38+
}
39+
\]
40+
41+
\[
42+
\inference[neg]{
43+
F, D, L \vdash e : \langle 1, 1, R \rangle \\
44+
R \in \{ \texttt{int}, \texttt{real} \}
45+
}{
46+
F, D, L \vdash \texttt{-}\ e : \langle 1, 1, R \rangle
47+
}
48+
\]
49+
50+
\[
51+
\inference[not]{
52+
F, D, L \vdash e : \langle 1, 1, \texttt{bool} \rangle \\
53+
}{
54+
F, D, L \vdash \texttt{!}\ e : \langle 1, 1, \texttt{bool} \rangle
55+
}
56+
\]
57+
\end{document}

spec/latex/expr-cast.svg

Lines changed: 228 additions & 0 deletions
Loading

spec/latex/expr-cast.tex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
\documentclass[preview]{standalone}
2+
\usepackage{semantic}
3+
\begin{document}
4+
5+
\[
6+
\inference[cast]{
7+
F, D, L \vdash e : \langle d_1, d_2, R_2 \rangle \\
8+
}{
9+
F, D, L \vdash \texttt{cast<} R_1 \texttt{>(} e \texttt{)}: \langle d_1, d_2, R_1 \rangle
10+
}
11+
\]
12+
13+
\end{document}

spec/latex/expr-compare.svg

Lines changed: 538 additions & 0 deletions
Loading

spec/latex/expr-compare.tex

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
\documentclass[preview]{standalone}
2+
\usepackage{semantic}
3+
\begin{document}
4+
\[
5+
\inference[eq]{
6+
F, D, L \vdash e_1 : \langle 1, 1, R \rangle \\
7+
F, D, L \vdash e_2 : \langle 1, 1, R \rangle \\
8+
\diamond \in \{ \texttt{==}, \texttt{!=} \}
9+
}{
10+
F, D, L \vdash e_1 \diamond e_2 : \langle 1, 1, R \rangle
11+
}
12+
\]
13+
14+
\[
15+
\inference[ord]{
16+
F, D, L \vdash e_1 : \langle 1, 1, R \rangle \\
17+
F, D, L \vdash e_2 : \langle 1, 1, R \rangle \\
18+
R \in \{ \texttt{int}, \texttt{real} \} \\
19+
\diamond \in \{ \texttt{<}, \texttt{>}, \texttt{<=}, \texttt{>=} \} \\
20+
}{
21+
F, D, L \vdash e_1 \diamond e_2 : \langle 1, 1, R \rangle
22+
}
23+
\]
24+
25+
\end{document}

0 commit comments

Comments
 (0)