abcd.tex
9.13 KB
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
\documentclass{beamer}
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[orientation=portrait,size=a4,scale=2]{beamerposter}
\usepackage[absolute,overlay]{textpos}
\usepackage{url}
\usepackage{tikz}
\usetikzlibrary{shapes.callouts}
\parindent=0pt
\setbeamertemplate{navigation symbols}{}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
\def\${\texttt{{\color{gray}\string$}}}
\def\shell #1{{\setbox0\hbox{\texttt{#1\strut}}%
\dimen0=\dp0 \advance\dimen0 by 5pt
\leavevmode\raise -\dimen0 \hbox{$\smash{\tikz\node[shell]{\texttt{#1\strut}};}$}}}
\tikzstyle{shell}=[rounded corners,
inner sep=5pt,
align=flush left,
draw=black!10,
fill=black!5]
\tikzstyle{guide}=[line width=3pt,
rounded corners,
cap=round,
color=yellow!60!gray!50!white]
\def\minor #1{{\small\color{gray}#1}}
\def\remark #1{\minor{(#1)}}
\def\abcdC #1{{\color{blue!50!black!60!white}\texttt{\# #1}}}
\def\abcdK #1{{\texttt{\color{red!50!black}#1}}}
\def\abcdR #1{{\texttt{\color{purple!50!black}#1}}}
\def\abcdN #1{{\texttt{\color{green!50!black}#1}}}
\def\abcdA #1{\texttt{{\color{red!50!black}[}#1{\color{red!50!black}]}}}
\def\abcd #1{\texttt{#1}}
\def\NT #1{\texttt{\textit{\color{blue!50!black!60!white}#1}}}
\def\>{\texttt{~~~~}}
\def\*{$\color{gray}\triangleright$ \ignorespaces}
\def\+{$\phantom{\triangleright}$ \ignorespaces}
\def\({\leavevmode{\setbox0\hbox{(}\hbox to \wd0{\hfil}}\ignorespaces}
\begin{document}
\begin{frame}[t]{}
%%
%% drawing grid
%%
%% \begin{textblock}{21}(0,-.2)
%% \begin{tikzpicture}[yellow!70,yscale=-1]
%% \draw[densely dotted] (0,0) grid (21,30);
%% \foreach \x in {1,...,20} {
%% \node at (\x,.5) {\x};
%% }
%% \foreach \y in {1,...,29} {
%% \node at (.5,\y) {\y};
%% }
%% \end{tikzpicture}
%% \end{textblock}
%%
%% title & logos
%%
\begin{textblock}{19}(1,.5)
\begin{center}
\Huge\textbf{ABCD cheatsheet}
\end{center}
\end{textblock}
\begin{textblock}{1.5}(1,27.3)
\begin{tikzpicture}
\node[inner sep=0pt] (snk) {\includegraphics[width=15mm]{../pix/logo-snakes}};
\node[anchor=west,text width=6cm] at (snk.east)
{\tiny\color{gray}%
\copyright~2018 Franck Pommereau\\[4pt]
\href{mailto:franck.pommerau@univ-evry.fr}%
{franck.pommerau@univ-evry.fr}\\[4pt]
\href{https://snakes.ibisc.univ-evry.fr}%
{snakes.ibisc.univ-evry.fr}\\[-4pt]
\href{https://creativecommons.org/licenses/by-sa/4.0/}%
{CC BY-SA
\raisebox{-.5ex}{%
\includegraphics[height=\baselineskip]{../pix/by-sa}}}};
\end{tikzpicture}
\end{textblock}
%%
%% command line interface
%%
\begin{textblock}{12}(1,2.5)
\advance\baselineskip by 14pt
\advance\parskip by 7pt
\noindent
\tikz\node[shell,text width=\textwidth-10pt] {\texttt{\$ abcd
{\color{red!50!black}[option]\dots}
{\color{green!50!black}spec.abcd}\strut}};
\shell{--pnml=FILE} save net as PNML \remark{SNAKES' variant}
\shell{--dot=FILE}
\shell{--neato=FILE}
\shell{--towpi=FILE}
\shell{--circo=FILE}
\shell{--fdp=FILE} draw net using a GraphViz engine
\shell{--load=PLUGIN} load a plugin before to build net
\remark{may be repeated}
\shell{--simul} start interactive simulator
\end{textblock}
%%
%% source structure
%%
\begin{textblock}{5}(15,2.5)
\begin{tikzpicture}[xscale=.8,yscale=-1]
\node[anchor=base west] at (.2,.8) {\abcdC{a comment}};
\node[anchor=base west] at (.2,1.3) {\abcdC{another comment}};
\path[fill=red,opacity=.1] (0,1.5) rectangle (6,4);
\node at (3,2.7) {\color{red!50!black}declarations};
\path[fill=green,opacity=.1] (0,4) rectangle (6,6);
\node at (3,5) {\color{green!50!black}process};
\draw[color=gray!70,line width=2pt,rounded corners] (0,0) -- (5,0) -- (6,1) -- (6,6) -- (0,6) -- cycle;
\draw[color=gray!70,line width=2pt,rounded corners,cap=round,shorten <=2pt,shorten >=2pt] (5,0) |- (6,1);
\end{tikzpicture}
\end{textblock}
%%
%% declarations
%%
\begin{textblock}{6}(1,10.8)
\textbf{buffer declarations:}
\abcdK{buffer} \NT{name}\abcdK{:} \NT{type} \abcdK{= ()}\\
\* empty buffer
\abcdK{buffer} \NT{name}\abcdK{:} \NT{type} \abcdK{=} \NT{val}\abcdK{,} \NT{\dots}\\
\* buffer with initial content
\vspace*{5pt}
\textbf{type expressions:}
any Python type or class\\
\* eg, \abcdR{int}, \abcdR{str}, \abcdR{object}, \dots,\\
\+ or user-defined classes
\abcdK{enum(}\NT{val}\abcdK{,} \NT{val}\abcdK{,} \NT{\dots}\abcdK{)}\\
\* enumerated type
\NT{type} \abcdK{*} \NT{type}\\
\* cross-product of types
\NT{type} \abcdK{|} \NT{type}\\
\* union of types
\NT{type} \abcdK{\&} \NT{type}\\
\* intersection of types
\vspace*{5pt}
\textbf{types definition:}$^\star$
\abcdK{typedef} \NT{name}\abcdK{:} \NT{type}\\
\vspace*{5pt}
\textbf{constants:}$^\star$
\abcdK{const} \NT{name} \abcdK{=} \NT{expr}
\vspace*{5pt}
\textbf{symbols:}$^\star$
\abcdK{symbol} \NT{name}\abcdK{,} \NT{\dots}\\
\* define fresh unique values
\vspace*{5pt}
\textbf{Python imports:}$^\star$
\* just use regular Python imports
\vspace*{5pt}
\tikz[remember picture]\node[inner sep=0pt](call) {\textbf{sub-processes}};
\vspace*{5pt}
\minor{$\star$ global declarations only}
\end{textblock}
%%
%% atomic actions
%%
\begin{textblock}{6}(14,9.7)
\textbf{atomic actions:}
\abcdA{\abcdR{True}}\\
\* no-op non-blocking action
\abcdA{\abcdR{False}}\\
\* always-blocking action
\abcdA{\NT{accesses}}\\
\* unguarded action
\abcdA{\NT{accesses} \abcdK{if} \NT{expr}}\\
\* guarded action
\vspace*{5pt}
\textbf{accesses:}
\abcdN{buff}\abcdK{-(}\NT{val}\abcdK{)}\\
\* consume \NT{val} from \abcdN{buff}
\abcdN{buff}\abcdK{-(}\NT{var}\abcdK{)}\\
\* consume a value from \abcdN{buff}\\
\+ and binds it to \NT{var}
\abcdN{buff}\abcdK{+(}\NT{expr}\abcdK{)}\\
\* produce a value into \abcdN{buff}
\abcdN{buff}\abcdK{?(}\NT{val}\abcdK{)}\\
\* test for \NT{val} in \abcdN{buff}
\abcdN{buff}\abcdK{?(}\NT{var}\abcdK{)}\\
\* test for a value in \abcdN{buff}\\
\+ and binds it to \NT{var}
\abcdN{buff}\abcdK{>>(}\NT{var}\abcdK{)}\\
\* flush \abcdN{buff} into \NT{var}
\abcdN{buff}\abcdK{<<(}\NT{var}\abcdK{)}\\
\* add the values contained in\\
\+ \NT{var} to \abcdN{buff}
\abcdN{buff}\abcdK{<>(}\NT{val}\abcdK{=}\NT{expr}\abcdK{)}\\
\* replace \NT{val} in \abcdN{buff}\\
\+ with \NT{expr}
\abcdN{buff}\abcdK{<>(}\NT{var}\abcdK{=}\NT{expr}\abcdK{)}\\
\* replace \NT{var} in \abcdN{buff}\\
\+ with \NT{expr}
\vspace*{5pt}
\remark{a comma-separated list of accesses\\[-2pt]
\( is performed atomically}
\end{textblock}
%%
%% control flow
%%
\begin{textblock}{5}(8,11.5)
\textbf{control flow:}
\NT{process} \abcdK{;} \NT{process}\\
\* sequential composition
\NT{process} \abcdK{+} \NT{process}\\
\* non-deterministic choice\\
\+ \remark{use opposite guards to\\[-2pt]
\+\( make it deterministic}
\NT{process} \abcdK{*} \NT{process}\\
\* iterate left-hand-side and\\
\+ exit with right-hand-side
\NT{process} \abcdK{|} \NT{process}\\
\* parallel composition
\vspace*{5pt}
\remark{no priorities $\Rightarrow$ use parentheses}
\vspace*{5pt}
\textbf{sub-process instances:}
\NT{name}\abcdK{(}\NT{args}\abcdK{)}\\
\* substitute \NT{args} in net \NT{name}\\
\+ scope its local buffers\\
\+ insert the net
\tikz\draw[guide,dashed,dash pattern=on 12pt off 6pt](0,0) -- (5,0);
\vspace*{5pt}
\leavevmode\hbox to 0pt{\tikz[remember picture]\node[inner sep=3pt](suite){};\hss}%
\textbf{sub-process declarations:}
\abcdK{net} \NT{name} \abcdK{(}\NT{params}\abcdK{):}\\[-4pt]
\begin{tikzpicture}[yscale=-1]
\node[fill=red,opacity=.1,text opacity=1,minimum width=4cm,minimum height=1cm]
at (2.6,0) {\color{red!50!black}declarations};
\node[fill=green,opacity=.1,text opacity=1,minimum width=4cm,minimum height=1cm]
at (2.6,1) {\color{green!50!black}process};
\node[rotate=90,text width=2cm,text centered,opacity=.3] at (0,.5) {\small indented\\[-5pt] block};
\end{tikzpicture}
\vspace*{5pt}
\textbf{sub-process parameters:}
\minor{a comma-separated list of:}
\NT{name}\\
\* a value is expected
\NT{name}\abcdK{:} \abcdK{buffer}\\
\* a buffer name is expected
\end{textblock}
%%
%% guide lines
%%
\begin{textblock}{21}(0,-.5)
\begin{tikzpicture}[overlay,remember picture,yscale=-1]
\draw[guide,->] (3.6,3.8) -- +(0,.7);
\draw[guide,->] (6.7,3.8) |- +(8.35,.6);
\draw[guide,->] (16.2,5.8) -| (14,9) -- (10,10.5) -| (3,11.2);
\draw[guide,->] (17.5,8.3) |- (15.5,9.5) -- (15.5,10.2);
\draw[guide,->] (16,9.5) -- (14,9.5) -- (9.5,11.2) -- (9.5,11.9);
\draw[guide,->,shorten >=3pt,shorten <=3pt] (call) -| (7.5,25) |- (suite);
\end{tikzpicture}
\end{textblock}
\end{frame}
\end{document}