-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrules.sty
189 lines (148 loc) · 4.6 KB
/
rules.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
178
179
180
181
182
183
184
185
186
187
188
189
\usepackage{mdframed}
\usepackage{mathpartir}
\usepackage{framed}
\usepackage{mathrsfs}
%% define \mathcolor
%%https://tex.stackexchange.com/questions/21598/how-to-color-math-symbols
\makeatletter
\def\mathcolor#1#{\@mathcolor{#1}}
\def\@mathcolor#1#2#3{%
\protect\leavevmode
\begingroup
\color#1{#2}#3%
\endgroup
}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Environment for typing systems
% #1 : Caption name
% #2 : Label name
\newenvironment{trules}[2]
{
\def\mycaption{#1}
\def\mylabel{#2}
\begin{figure}
\begin{mdframed}
\begin{center}
\begin{mathpar}
}
{
\end{mathpar}
\end{center}
\renewcommand{\figurename}{Figure}
\caption{\mycaption}
\label{\mylabel}
\end{mdframed}
\end{figure}
}
%% The \rrule[p*] macros allows to define new derivation rules. This aims to be used in and outstide the environment \trules
%% New derivation rule with 0 premise
% #1 : name of the rule
% #2 : conclusion
\newcommand{\rrule}[2]{
\inferrule*[vcenter, right=\ensuremath{#1}]{ }
{#2}
}
%% New derivation rule with 1 premise
% #1 : name of the rule
% #2 : 1st premise
% #3 : conclusion
\newcommand{\rrulep}[3]{
\inferrule*[vcenter, right=\ensuremath{#1}]{#2}
{#3}
}
%% New derivation rule with 2 premise
% #1 : name of the rule
% #2 : 1st premise
% #3 : 2nd premise
% #4 : conclusion
\newcommand{\rrulepp}[4]{
\inferrule*[vcenter, right=\ensuremath{#1}]{#2 \\ #3}
{#4}
}
%% New derivation rule with 3 premise
% #1 : name of the rule
% #2 : 1st premise
% #3 : 2nd premise
% #4 : 3nd premise
% #5 : conclusion
\newcommand{\rruleppp}[5]{
\inferrule*[vcenter, right=\ensuremath{#1}]{#2 \\ #3 \\ #4}
{#5}
}
%%%%%%%%%%% Lambda Terms
%% Abstraction
\newcommand{\tabs}[3]{\ensuremath{\lambda{#1}\,{:}\,{#2}.\,{#3}}}
%% Untyped Abstraction
\newcommand{\tabsU}[2]{\ensuremath{\lambda{#1}.\,{#2}}}
%% Application
\newcommand{\tapp}[2]{\ensuremath{{#1}~{#2}}}
%% Simple product
\newcommand{\tarr}[2]{\ensuremath{{#1}\rightarrow\, #2}}
%% Dependent product
\newcommand{\tpi}[3]{\ensuremath{\Pi {#1}\,{:}\,{#2}. \,#3}}
%%%%%%%%%%% Common symbols
\newcommand{\seq}{\ensuremath{\equiv}}
\newcommand{\srw}{\ensuremath{\hookrightarrow}}
\newcommand{\ssrw}{\ensuremath{\hookleftarrow}}
\newcommand{\sfv}{\ensuremath{\mathrm{FV}}}
\newcommand{\swf}[0]{\ensuremath{\mathbf{wf}}}
\newcommand{\sws}[0]{\ensuremath{\mathbf{ws}}}
\newcommand{\swt}[0]{\ensuremath{\mathbf{wt}}}
%%%%%%%%%%% Fonts
\newcommand{\BN}{\ensuremath{\mathbb{N}}}
\newcommand{\BO}{\ensuremath{\mathbb{O}}}
\newcommand{\SC}{\ensuremath{\mathscr{C}}}
\newcommand{\CC}{\ensuremath{\mathcal{C}}}
%%%%%%%%%%% meta
%% Substitution macro
\newcommand{\msubst}[3]{\ensuremath{#1\left\{#2 \leftarrow #3\right\}}}
%% Meta conversion
% #1 : specify the generating relation
\newcommand{\meq}[1]{\ensuremath{{\seq_{#1}}}}
%% Meta rewriting
\newcommand{\mrw}[1]{\ensuremath{\srw_{#1}}}
%% Free variable
\newcommand{\mfv}[1]{\ensuremath{\sfv(#1)}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%% Generic judgments definitions
%% generic judgment for n-ary relations
\newcommand{\jp}[5]{\ensuremath{#4 \mathcolor{#1}{\vdash_{#2}^{#3}} #5}}
%% generic judgment for has-type relations
% #1 is color
% #2 is vdash subscript
% #3 is vdash supperscript
% #4 is type symbol (usually ":")
% #5 is context
% #6 is term
% #7 is type
\newcommand{\jht}[7]{\jp{#1}{#2}{#3}{#5}{#6 \mathcolor{#1}{#4} #7}}
%% generic judgment for well-formed contexts
% #1 is color
% #2 is vdash subscript
% #3 is vdash supperscript
% #4 is context
\newcommand{\jwt}[4]{\ensuremath{#4 \mathcolor{#1}{\vdash_{#2}^{#3}~\swf}}}
%% generic judgment for well-formed types
% #1 is color
% #2 is vdash subscript
% #3 is vdash supperscript
% #4 is context
\newcommand{\jws}[6]{\ensuremath{#4 \mathcolor{#1}{\vdash_{#2}^{#3}} #5\mathcolor{#1}{\overset{?}{:}}#6~\mathcolor{#1}{\sws}}}
\newcommand{\jwf}[5]{\ensuremath{#4 \mathcolor{#1}{\vdash_{#2}^{#3}}#5~\mathcolor{#1}{\swf}}}
\newcommand{\jwwt}[5]{\ensuremath{#4 \mathcolor{#1}{\vdash_{#2}^{#3}}#5~\mathcolor{#1}{\swt}}}
%%%%% Classical CTS
\newcommand{\jccw}[2]{\jwt{\clwtstyle}{#1}{}{#2}}
\newcommand{\jccws}[4]{\jws{\clwststyle}{#1}{}{#2}{#3}{#4}}
\newcommand{\jcw}[1]{\jccw{}{#1}}
\newcommand{\jcws}[2]{\jccws{\SC}{#1}{#2}}
\newcommand{\jcct}[4]{\jht{\clwtstyle}{#1}{}{:}{#2}{#3}{#4}}
\newcommand{\jct}[3]{\jcct{}{#1}{#2}{#3}}
\newcommand{\jce}{\mathcolor{\eqstyle}{\meqb}}
%%%%%% Layered CTS
\newcommand{\clwtstyle}{blue}
\newcommand{\clhtstyle}{blue}
\newcommand{\jwpat}[2]{\jwf{\clwtstyle}{}{p}{#1}{#2}}
\newcommand{\jwr}[2]{\jwf{\clwtstyle}{}{r}{#1}{#2}}
\newcommand{\jwtr}[2]{\jwwt{\clwtstyle}{}{r}{#1}{#2}}
\newcommand{\jwpatpho}[2]{\jwf{\clwtstyle}{ho}{p}{#1}{#2}}