-
Notifications
You must be signed in to change notification settings - Fork 0
/
infer-style.sty
178 lines (164 loc) · 7.4 KB
/
infer-style.sty
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
% macros for Clojure grammars
\usepackage{mathpartir}
\usepackage{amsfonts}
\usepackage{bbm}
\usepackage{xcolor}
\usepackage{xspace}
\usepackage{mmm}
\newcommand\specialformfont[1]{\ma{\textbf{#1}}}
\newcommand\trackEOp[0]{\ma{\specialformfont{track}}}
\newcommand\trackE[2]{\ma{({\trackEOp{}}\ #1\ #2)}}
\newcommand\trackEAlignArray[2]{\ma{(& \trackEOp{} \ \\\\& #2)}}
\newcommand\trackpolyE[3]{(\trackEOp{}\ #1\ #2\ #3)}
\newcommand\genE[0]{({\specialformfont{genInt}})}
\newcommand\inferletliteral[0]{{\specialformfont{let}}}
\newcommand\PairOfT[1]{{\mathsf{PairOf}}}
\newcommand\NatT[1]{{\mathsf{N}}}
\newcommand\IntT[1]{\ma{\mathsf{N}}}
\newcommand\UnknownT[1]{\ma{\mathrm{?}}}
\newcommand\HMapOp[0]{\ma{\mathsf{HMap}}}
\newcommand\HMaptwo[2]{\ma{(\HMapOp{}_{#2}^{#1})}}
\newcommand\HMapsplice[1]{\ma{(\HMapOp{}\ #1)}}
\newmeta\HMapreq{\ma{m}}
\newmeta\HMapreqp{\ma{m'}}
\newmeta\HMapreqpp{\ma{m''}}
\newmeta\HMapopt{\ma{o}}
\newmeta\HMapoptp{\ma{o'}}
\newcommand\HMappretty[1]{\ma{\{#1\}}}
\newcommand\appendone[2]{#1 :: [#2]}
\newcommand\append[2]{#1 :: #2}
% proxy
\newcommand\proxyextdiffcolor{red}
\newcommand\proxyextdiff[1]{\colorlet{thecurrentcolour}{.}\ma{\color{\proxyextdiffcolor}{#1}}\color{thecurrentcolour}}
\newcommand\proxyextsame[1]{\colorlet{thecurrentcolour}{.}\ma{\color{black}{#1}}\color{thecurrentcolour}}
\newcommand\ovadiff[1]{\colorlet{thecurrentcolour}{.}\ma{\color{red}\ova{\color{thecurrentcolour}#1}}\color{thecurrentcolour}}
% #1 = original fn
% #2 = wrapped fn
% #3 = rho
\newcommand\ProxyV[3]{\ma{{#2}^{#1}_{#3}}}
\newcommand\ProxyVdiff[3]{\ma{\proxyextdiff{\ProxyV{#1}{\proxyextsame{#2}}{#3}}}}
\newcommand\MProxyV[2]{\ma{{#1}^{#2}}}
\newcommand\MProxyVdiff[2]{\ma{\proxyextdiff{\MProxyV{\proxyextsame{#1}}{#2}}}}
% types
\newcommand\arrow[2]{\ma{[#1 \rightarrow #2]}}
\newmeta\ty{\tau}
% semantics
\newcommand\opsemtrack[4]{\ma{#1 \vdash #2 \Downarrow #3\ ;\ #4}}
\newcommand\bigstepgen[6]{\ma{#1 ; #2 \vdash #3 \Downarrow #4\ ;\ #5\ ;\ #6}}
\newcommand\inferconstantopsem[4]{\ma{{\constantopsemliteral{}}(#1, #2) = #3\ ;\ #4}}
\newcommand\inferconstantopsemalign[4]{\ma{{\constantopsemliteral{}}(#1, #2) &=& #3\ ;\ #4}}
\newcommand\inferconstantopsemalignnospace[4]{\ma{{\constantopsemliteral{}}(#1, #2) &=& #3 ; #4}}
\newcommand\inferconstantopsemalignsplice[3]{\ma{{\constantopsemliteral{}}(#1, #2) &=& #3}}
% environments
\newmeta\aenv{\ma{A}}
\newmeta\aenvp{\ma{A'}}
\newmeta\tenv{\ma{\Gamma}}
\newmeta\atenv{\ma{\Delta}}
\newmeta\atenvp{\ma{\Delta'}}
\newmeta\atenvpp{\ma{\Delta''}}
\newcommand\emptytenv[0]{\ma{\{\}}}
\newcommand\emptyaenv[0]{\ma{\{\}}}
\newcommand\makeatenv[2]{\ma{(#1, #2)}}
\newcommand\emptyatenv[0]{\ma{\makeatenv{\emptyaenv{}}{\emptytenv{}}}}
%arrows
\newcommand\ova[1]{\ma{\overline{#1}}}
%env update
\newcommand\updatemap[3]{\ma{#1 [#2 \mapsto #3]}}
\newcommand\updatemapmulti[3]{\ma{#1 [\ova{#2 \mapsto #3}]}}
% algorithm
\newcommand\infermetafnfont[1]{\ma{\mathsf{#1}}}
\newcommand\squashlocal[0]{\ma{\infermetafnfont{squashLocal}}}
\newcommand\steptwohelper[0]{\ma{\infermetafnfont{h}}}
\newcommand\squashglobal[0]{\infermetafnfont{squashGlobal}}
\newcommand\aliashmap[0]{\infermetafnfont{aliasHMap}}
\newcommand\inferrecOp[0]{\infermetafnfont{inferRec}}
\newcommand\squashall[0]{\infermetafnfont{squashAll}}
\newcommand\squash[0]{\infermetafnfont{squash}}
\newcommand\trymergealias[0]{\infermetafnfont{tryMerge}}
\newcommand\mergealiases[0]{\infermetafnfont{mergeAliases}}
\newcommand\deepkeysets[0]{\infermetafnfont{keysets}}
\newcommand\aliasesin[0]{\infermetafnfont{aliases}}
\newcommand\shouldmergeOp[0]{\infermetafnfont{merge?}}
\newcommand\register[0]{\infermetafnfont{reg}}
\newcommand\fullyresolve[0]{\infermetafnfont{resolve}}
\newcommand\squashhorizonally[0]{\infermetafnfont{squashHorizontally}}
\newcommand\aliassinglehmap[0]{\infermetafnfont{aliasSingleHMap}}
\newcommand\singlehmap[0]{\infermetafnfont{singleHMap}}
\newcommand\inferanns[0]{\ma{\infermetafnfont{infer}}}
\newcommand\inferannsnoalign[2]{\ma{\inferanns{}(#1) = #2}}
\newcommand\generatetenv[0]{\ma{\infermetafnfont{toEnv}}}
\newcommand\genupdate[0]{\ma{\infermetafnfont{genUpdate}}}
\newcommand\trackmetaOp[0]{\ma{\infermetafnfont{track}}}
\newcommand\trackmetalhs[2]{\ma{\trackmetaOp{}(#1, #2)}}
\newcommand\trackmetarhs[2]{\ma{#1\ ; #2}}
\newcommand\trackmeta[4]{\ma{\trackmetalhs{#1}{#2} = \trackmetarhs{#3}{#4}}}
\newcommand\trackmetaalignsplice[3]{\ma{\trackmetalhs{#1}{#2} &=& #3}}
\newcommand\trackmetaalign[4]{\ma{\trackmetaalignsplice{#1}{#2}{\trackmetarhs{#3}{#4}}}}
\newcommand\trackpolymeta[0]{\ma{\trackmetaOp{}}}
\newcommand\inferupdateOp[0]{\ma{\infermetafnfont{update}}}
\newcommand\inferupdatetwo[2]{\ma{\inferupdateOp{}(#1, #2)}}
\newcommand\inferupdate[3]{\ma{\inferupdatetwo{#1}{\resentry{#2}{#3}}}}
\newcommand\inferupdatecommon[5]{\inferupdate{#1}{#2}{#3} #4 #5} % takes the = sign to allow extra alignment
\newcommand\inferupdatenoalign[4]{\ma{\inferupdatecommon{#1}{#2}{#3}{=}{#4}}}
\newcommand\inferupdatealign[4]{\inferupdatecommon{#1}{#2}{#3}{&=&}{#4}}
\newcommand\joinOp[0]{\ma{\sqcup}}
\newcommand\joinlhs[2]{\ma{#1 \joinOp{} #2}}
\newcommand\joinalign[3]{\joinlhs{#1}{#2} &=& #3}
\newcommand\joinnoalign[3]{\ma{\joinlhs{#1}{#2} = #3}}
\newcommand\joinexpression[2]{\joinlhs{#1}{#2}}
\newcommand\joinHMapOp[0]{\ma{\sqcup^{\infermetafnfont{H}}}}
\newcommand\joinHMaplhs[2]{\ma{#1 \joinHMapOp{} #2}}
\newcommand\joinHMapnoalign[3]{\ma{\joinHMaplhs{#1}{#2} = #3}}
\newcommand\joinHMapexpression[2]{\ma{\joinHMaplhs{#1}{#2}}}
\newcommand\joinstarOp[0]{\ma{\bigsqcup}}
\newcommand\joinstaralign[2]{\ma{\joinstarOp{} #1 &=& #2}}
\newcommand\joinstarnoalign[2]{\ma{\joinstarOp{} #1 = #2}}
\newcommand\joinstarexpression[1]{\ma{\joinstarOp{} #1 }}
\newcommand\instrumentOp[0]{\ma{\infermetafnfont{instrument}}}
\newcommand\instrumentnoalign[3]{\ma{\instrumentOp{}(#1, #2) = #3}}
\newcommand\instrument[2]{\ma{\instrumentOp{}(#1, #2)}}
\newcommand\collectOp[0]{\ma{\infermetafnfont{collect}}}
\newcommand\collectnoalign[3]{\ma{\collectOp{}(#1, #2) = #3}}
\newcommand\annotateOp[0]{\ma{\infermetafnfont{annotate}}}
\newcommand\annotatenoalign[3]{\ma{\annotateOp{}(#1, #2) = #3}}
% aliases
\newmeta\alias{a}
\newmeta\aliasp{a'}
\newmeta\aliaspp{a''}
% expressions
\newmeta\val{v}
\newmeta\kw{k}
\newmeta\kwp{k'}
\newmeta\kwpp{k''}
\newmeta\xvar{x}
\newmeta\yvar{y}
\newmeta\num{n}
% abstract syntax for pathelem
\newmeta\inferpth{l}
\newcommand\inferpefont[1]{\textbf{#1}}
\newcommand\keypeOp[0]{\ma{\inferpefont{key}}}
\newcommand\inferkeype[2]{\ma{\keypeOp{}_{#1}(#2)}}
\newcommand\inferkeypenokeyset[2]{\ma{\keypeOp{}(#2)}}
\newcommand\dompe[0]{\ma{\inferpefont{dom}}}
\newcommand\rngpe[0]{\ma{\inferpefont{rng}}}
% abstract syntax for paths
\newmeta\inferpath{\ma{\pi}}
\newmeta\inferpathp{\ma{\pi'}}
\newmeta\inferpathpp{\ma{\pi''}}
% inference results
\newmeta\res{\ma{r}}
\newmeta\resp{\ma{r'}}
\newmeta\respp{\ma{r''}}
\newcommand\emptyres[0]{\ma{\{\}}}
\newcommand\resentry[2]{\ma{{#2}_{#1}}}
%\newcommand\resentry[2]{\ma{#1 : #2}}
\newcommand\singletonres[2]{\ma{\{\resentry{#1}{#2}\}}}
\newcommand\resflat[1]{\ma{\{#1\}}}
\newcommand\resflatcolor[1]{\ma{\textcolor{red}{\resflat{#1}}}}
\newcommand\restwoarrow[2]{\ma{\{\ova{\resentry{#1}{#2}}\}}}
\newcommand\rescombineOp[0]{\ma{\cup}}
\newcommand\bigrescombineOp[0]{\ma{\bigcup}}
\newcommand\unionres[2]{\ma{{#1 \rescombineOp{} #2}}}
\newcommand\bigunionres[1]{\ma{\bigrescombineOp{}\ #1}}
\newcommand\unionresthree[3]{\ma{{#1 \rescombineOp{} \unionres{#2}{#3}}}}
\newcommand\lambdatrack[0]{\ma{\lambda_{\trackmetaOp{}}}}