-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathb2latex.sty
282 lines (239 loc) · 8.32 KB
/
b2latex.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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
%----------------------------------------------------------------------------
% This is b2latex.sty, generated by B2Latex plugin on Rodin
% Author: K. DAMCHOOM, [email protected]
% Copyright(c) 2008 - 2012 University of Southampton and others.
%----------------------------------------------------------------------------
% This style is required for all latex files generated by the
% B2Latex plugin 0.7.x. It can be modified for your own style.
% Internal commands, which are not contained in the generated
% latex document, are marked by the character '@' in the name.
%----------------------------------------------------------------------------
\usepackage[top=2.5cm, bottom=2.0cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[ddmmyyyy]{datetime}
\usepackage{fancyhdr,lastpage,color}
\definecolor{keycolor}{rgb}{0,0,0.8} % Keywords, blue
\definecolor{labelcolor}{rgb}{0,0.4,0.8} % Labels, cyan
\definecolor{codecolor}{rgb}{0,0,0} % Formulas, black
\definecolor{inhcolor}{rgb}{0.6,0.2,0} % Inherited formulas, maroon
\definecolor{cmtcolor}{rgb}{0,0.4,0} % Comments, green
%\renewcommand{\chaptername}{}
%\renewcommand{\thechapter}{}
\renewcommand{\dateseparator}{.}
% Reduce space between paras
\newcommand{\paraSpc@} {\hspace*{\fill} \setlength{\parskip}{-2pt}}
% Reduce space between para items
\newcommand{\itemSpc@} {\setlength{\itemsep}{-0pt}}
% Keywords
\newcommand{\key@}[1]{\textcolor{keycolor}{#1}}
% Labels
\newcommand{\lbl@}[1]{\textcolor{labelcolor}{\small{\texttt{#1}}}}
% Formulas
\newcommand{\code@}[1]{\textcolor{codecolor}{\small{#1}}}
% Inherited formulas
\newcommand{\inh@}[1]{\textcolor{inhcolor}{\small{#1}}}
% Comments
\newcommand{\cmt@}[1]{\textcolor{cmtcolor}{\small{#1}}}
% Modifiers (inline keywords)
\newcommand{\mod@}[1]{\key@{\small{$\langle$#1$\rangle$}}}
% Optional comment
\newcommand{\cmtOpt@}[1]{\ifthenelse{\equal{#1}{}}{}{\cmt@{#1}}}
% Alternate keyword
\newcommand{\keyAlt@}[3]{\ifthenelse{\boolean{#1}}{\key@{#2}}{\key@{#3}}}
% Optional modifier
\newcommand{\modOpt@}[2]{\ifthenelse{\boolean{#1}}{\mod@{#2}}{}}
% Code or inherited code
\newcommand{\codeInh@}[2]{\ifthenelse{\boolean{#1}}{\code@{#2}}{\inh@{\textit{#2}}}}
%----------------------------------------------------------------------------
% Common header definition
\newcommand{\Header@}{
\lfoot{\today~\currenttime}
\cfoot{}
\rfoot{\rm Page \thepage~of \pageref{LastPage}}
\pagestyle{fancy}
}
% Header used if a single context or machine is exported
% #1: Context / Machine name
\newcommand{\SingleHeader}[1]{
\Header@{}
\lhead{}
\chead{An Event-B Specification of #1}
\rhead{}
}
% Title page used if a whole project is exported
% #1: Project name
\newcommand{\MultiTitle}[1]{
\Header@{}
\lhead{An Event-B Specification of #1}
\chead{}
\rhead{}
\fancypagestyle{plain}{}
\tableofcontents
}
% Subheader for each component if a whole project is exported
% #1: Component type (CONTEXT / MACHINE); #2: Component name
\newcommand{\MultiHeader}[2]{
\newpage{}
\rhead{\texttt{#1} #2}
% \addcontentsline{toc}{chapter}{\texttt{#1} #2}
}
%----------------------------------------------------------------------------
% Special commands for CONTEXT
%----------------------------------------------------------------------------
% #1: Context name; #2: Extended contexts (optional); #3: Comment (optional)
\newcommand{\CONTEXT}[3]{
\begin{description}
\item[\key@{CONTEXT}] #1 \cmtOpt@{#3} \paraSpc@
\ifthenelse{\equal{#2}{}}{}{
\item[\key@{EXTENDS}] #2 \paraSpc@
}
}
% Alternative compact display:
%\newcommand{\CONTEXT}[3]{
% \begin{description}
% \item[\key@{CONTEXT}] #1
% \ifthenelse{\equal{#2}{}}{}{\key@{EXTENDS} #2}
% \cmtOpt@{#3}
% \paraSpc@
%}
% #1: Sets definitions
\newcommand{\SETS}[1]{
\item[\key@{SETS}] \paraSpc@
\begin{description} #1 \end{description}
}
% #1: Identifier; #2: Comment (optional)
\newcommand{\Set}[2]{
\item \code@{#1} \cmtOpt@{#2} \itemSpc@
}
% #1: Constants definitions
\newcommand{\CONSTANTS}[1]{
\item[\key@{CONSTANTS}] \paraSpc@
\begin{description} #1 \end{description}
}
% #1: Identifier; #2: Comment (optional)
\newcommand{\Constant}[2]{
\item \code@{#1} \cmtOpt@{#2} \itemSpc@
}
% #1: Axioms definitions
\newcommand{\AXIOMS}[1]{
\item[\key@{AXIOMS}] \paraSpc@
\begin{description} #1 \end{description}
}
% #1: Label; #2: true if theorem; #3: Predicate; #4: Comment (optional)
\newcommand{\Axiom}[4]{
\item \lbl@{#1}: \modOpt@{#2}{theorem} \code@{#3} \cmtOpt@{#4} \itemSpc@
}
%----------------------------------------------------------------------------
% Special commands for MACHINE
%----------------------------------------------------------------------------
% #1: Machine name; #2: Refined machines (optional);
% #3: Seen contexts (optional); #4: Comment (optional)
\newcommand{\MACHINE}[4]{
\begin{description}
\item[\key@{MACHINE}] #1 \cmtOpt@{#4} \paraSpc@
\ifthenelse{\equal{#2}{}}{}{
\item[\key@{REFINES}] #2 \paraSpc@
}
\ifthenelse{\equal{#3}{}}{}{
\item[\key@{SEES}] #3 \paraSpc@
}
}
% #1: variables definitions
\newcommand{\VARIABLES}[1]{
\item[\key@{VARIABLES}] \paraSpc@
\begin{description} #1 \end{description}
}
% #1: Identifier; #2: Comment (optional)
\newcommand{\Variable}[2]{
\item \code@{#1} \cmtOpt@{#2} \itemSpc@
}
% #1: Invariants definitions
\newcommand{\INVARIANTS}[1]{
\item[\key@{INVARIANTS}] \paraSpc@
\begin{description} #1 \end{description}
}
% #1: Label; #2: true if theorem; #3: Predicate; #4: Comment (optional)
\newcommand{\Invariant}[4]{
\item \lbl@{#1}: \modOpt@{#2}{theorem} \code@{#3} \cmtOpt@{#4} \itemSpc@
}
% #1: Variants definitions
\newcommand{\VARIANT}[1]{
\item[\key@{VARIANT}] \paraSpc@
\begin{description} #1 \end{description}
}
% #1: Expression; #2: Comment (optional)
\newcommand{\Variant}[2]{
\item \code@{#1} \cmtOpt@{#2} \itemSpc@
}
\newcommand{\EVENTS}{
\item[\key@{EVENTS}] \paraSpc@
}
% #1: true if extended; #2: Comment (optional); #3: Event content
\newcommand{\INITIALISATION}[3]{
\item[\key@{Initialisation}] \modOpt@{#1}{extended} \cmtOpt@{#2} \paraSpc@
\begin{description} #3 \end{description}
}
% #1: Event name; #2: true if extended; #3 convergence;
% #4: Refined events (optional); #5: Comment (optional); #6: Event content
\newcommand{\EVT}[6]{
\item[\key@{Event}] #1
% deactivate above line and activate line below to display only event name
% \item[\key@{#1}]
\mod@{#3} $\defi$ \cmtOpt@{#5} \paraSpc@
\ifthenelse{\equal{#4}{}}{}{
\item[\keyAlt@{#2}{extends}{refines}] #4 \paraSpc@
}
\begin{description} #6 \end{description}
}
% #1: Parameters definitions
\newcommand{\ANY}[1]{
\item[\key@{any}] \paraSpc@ \itemSpc@
\begin{description} #1 \end{description}
}
% #1: Identifier; #2: true if own, false if inherited; #3: Comment (optional)
\newcommand{\Param}[3]{
\item \codeInh@{#2}{#1} \cmtOpt@{#3} \itemSpc@
}
%1: true if the event has parameters; #2: Guards definitions
\newcommand{\GUARDS}[2]{
\item[\keyAlt@{#1}{where}{when}] \paraSpc@ \itemSpc@
\begin{description} #2 \end{description}
}
% #1: Label; #2: true if theorem; #3: Predicate;
% #4: true if own, false if inherited; #5: Comment (optional)
\newcommand{\Guard}[5]{
\item \lbl@{#1}: \modOpt@{#2}{theorem} \codeInh@{#4}{#3} \cmtOpt@{#5} \itemSpc@
}
% #1: Witnesses definitions
\newcommand{\WITNESSES}[1]{
\item[\key@{with}] \paraSpc@ \itemSpc@
\begin{description} #1 \end{description}
}
% #1: Label; #3: Predicate; #3: Comment (optional)
\newcommand{\Witness}[3]{
\item \lbl@{#1}: \code@{#2} \cmtOpt@{#3} \itemSpc@
}
%1: true if the event has guards; #2: Actions definitions
\newcommand{\ACTIONS}[2]{
\item[\keyAlt@{#1}{then}{begin}] \paraSpc@ \itemSpc@
\begin{description} #2 \end{description}
\item[\key@{end}] \paraSpc@
}
% #1: Label; #2: Predicate; #3: true if own, false if inherited; #4: Comment (optional)
\newcommand{\Action}[4]{
\item \lbl@{#1}: \codeInh@{#3}{#2} \cmtOpt@{#4} \itemSpc@
}
% Skip action
\newcommand{\Skip}{
\item \key@{\textit{skip}} \itemSpc@
}
%----------------------------------------------------------------------------
% General commands for both CONTEXT and MACHINE
%----------------------------------------------------------------------------
% End of MACHINE or CONTEXT
\newcommand{\END}{
\item[\key@{END}] \hspace*{\fill} \end{description}
}
% Missing in bsymb.sty version 1.9
\newcommand{\converse}{^{-1}}
%----------------------------------------------------------------------------