abcd.tex 8.86 KB
\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,0)
  %%   \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,.7)
    \begin{center}
      \Huge\textbf{ABCD cheatsheet}
    \end{center}
  \end{textblock}

  \begin{textblock}{1.5}(1,27.5)
    \begin{tikzpicture}
      \node[inner sep=0pt] (snk) {\includegraphics[width=15mm]{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}};
    \end{tikzpicture}
  \end{textblock}

  %%
  %% command line interface
  %%

  \begin{textblock}{12}(1,2.7)
    \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.7)
    \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,11)
    \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.9)
    \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.7)
    \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:}

    \NT{name}\\
    \* a value is expected

    \NT{name}\abcdK{: buffer}\\
    \* a buffer name is expected

  \end{textblock}

  %%
  %% guide lines
  %%

  \begin{textblock}{21}(0,-.3)
    \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}