\documentclass[sans]{beamer}
\usetheme{metropolis}

\usepackage{lmodern}
\usepackage{tikz}
\usepackage{pdfpages}
\usepackage{listings}
\usepackage{multirow}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{ulem}
\usetikzlibrary{arrows, positioning, shapes.geometric}
\usetikzlibrary{shadows.blur}

% hide the footline navigation
\setbeamertemplate{footline}[frame number]{}
\setbeamertemplate{navigation symbols}{}
%\setbeamertemplate{footline}{}

\tikzset{
    %Define standard arrow tip
    >=stealth',
}

\tikzset{
    invisible/.style={opacity=0,text opacity=0},
    visible on/.style={alt=#1{}{invisible}},
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
    },
}

\tikzset{
  setstyle/.style={#1},
  %bcg/.default={white},
  setstyle on/.style={alt=#1{}{setstyle}},
}

\tikzset{
  background fill/.style={fill=#1},
  background fill/.default={white},
  fill on/.style={alt=#1{}{background fill}},
}

\tikzset{
  background draw/.style={draw=#1},
  background draw/.default={white},
  draw on/.style={alt=#1{}{background draw}},
}

\tikzset{
  background filldraw/.style 2 args={draw=#1, fill=#2},
  background filldraw/.default={white}{white},
  filldraw on/.style={alt=#1{}{background filldraw}},
}

\tikzset{
  background shade/.style={#1},
  background shade/.default={top color=white, bottom color=white},
  shade on/.style={alt=#1{}{background shade}},
}

\tikzset{
  background shadedraw/.style 2 args={draw=#1, #2},
  background shadedraw/.default={white}{top color=white, bottom color=white},
  shadedraw on/.style={alt=#1{}{background shadedraw}},
}

 \lstset{escapeinside={<@}{@>}, columns=fullflexible, basicstyle=\ttfamily}

 \title{Analýza programů}
 \date {FAKOS 2017}

\begin{document}
  %% -------------------------------------------------------------------
  \maketitle
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}
  \centering
  \begin{tikzpicture}
  \tikzset{
    cell/.style={draw,
                 %rounded corners,
                 fill=gray!15,
                 drop shadow,
                 align=center
                 },
    every node/.style={outer sep=8},
  }

  \node[cell] (honza) {
    \includegraphics[width=2cm]{strejda.jpg}\\
    Jan Strejček
  };

  \node[cell, below=of honza] (marta) {
    \includegraphics[width=2cm]{marta.jpg} \\
    Martina Vitovská
  };

  \node[cell, left= of marta] (jirka) {
    \includegraphics[width=2cm]{jirislaby.jpg}\\
    Jiří Slabý
  };

  \node[cell, right=of marta] (marek) {
    \includegraphics[width=2cm]{marek.jpg} \\
    Marek Chalupa
  };

 %\node[cell, right=of honza] (tomas) {
 %  \includegraphics[width=2cm]{tomas.jpg} \\
 %  Tomáš Jašek
 %};

  \draw (honza) edge (jirka);
  \draw (honza) edge (marta);
  \draw (honza) edge (marek);

  \end{tikzpicture}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}
  \frametitle{Co děláme?}
  Cíle:
  \begin{itemize}
    \item Automatické hledání chyb v počítačových programech
    \item Automatická verifikace počítačových programů
  \end{itemize}
  Metody:
  \begin{itemize}
    \item Statická analýza kódu (tj. bez jeho skutečného spuštění)
    \item Analýza ukazatelů, analýza cyklů, abstraktní interpretace,
          symbolická exekuce, ...
  \end{itemize}
  \end{frame}
  %% -------------------------------------------------------------------

\section{Symbiotic}
  %% -------------------------------------------------------------------
  \begin{frame}
  \frametitle{Přístup}
  \begin{itemize}
    %\setlength\itemsep{1em}
    \item Použít statickou analýzu kódu k nalezení potenciálních chyb
    \item Vložit kontroly chyb na tato místa
    \item Odstranit části kódu, které nemůžou mít vliv na tyto kontroly
    \item Prohledat každou možnou cestu v programu a ověřit, zda nějaká kontrola selže
  \end{itemize}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}[fragile]
  \frametitle{Instrumentace kódu}
	\begin{lstlisting}[language=C]
  int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int i, sum = 0, sum2 = 0;

  for (i = 0; i < 10; ++i) {

    sum += array[i];
  }


  sum2 = ((array[0] + array[9])*array[9])/2);
  assert(sum == sum2);
	\end{lstlisting}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}[fragile]
  \frametitle{Instrumentace kódu}
	\begin{lstlisting}[language=C]
  int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int i, sum = 0, sum2 = 0;

  for (i = 0; i < 10; ++i) {
    <@{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[i]);}@>
    sum += array[i];
  }
  <@{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[0]);}@>
  <@{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[9]);}@>
  sum2 = ((array[0] + array[9])*array[9])/2);
  assert(sum == sum2);
	\end{lstlisting}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}[fragile]
  \frametitle{Instrumentace kódu}
	\begin{lstlisting}[language=C]
  int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int i, sum = 0, sum2 = 0;

  for (i = 0; i < 10; ++i) {
    <@{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[i]);}@>
    sum += array[i];
  }
  <@{\sout{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[0]);}}@>
  <@{\sout{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[9]);}}@>
  sum2 = ((array[0] + array[9])*array[9])/2);
  assert(sum == sum2);
	\end{lstlisting}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}[fragile]
  \frametitle{Prořezávání}
	\begin{lstlisting}[language=C]
  int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int i, sum = 0, sum2 = 0;

  for (i = 0; i < 10; ++i) {
    <@{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[i]);}@>
    sum += array[i];
  }


  sum2 = ((array[0] + array[9])*array[9])/2);
  assert(sum == sum2);
	\end{lstlisting}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}[fragile]
  \frametitle{Prořezávání}
	\begin{lstlisting}[language=C]
  int array[10]<@\sout{ = \{1, 2, 3, 4, 5, 6, 7, 8, 9\}}@>;
  int i<@\sout{, sum = 0, sum2 = 0;}@>

  for (i = 0; i < 10; ++i) {
    <@{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[i]);}@>
    <@\sout{sum += array[i];}@>
  }


  <@\sout{sum2 = ((array[0] + array[9])*array[9])/2);}@>
  <@{\sout{assert(sum == sum2);}@>
	\end{lstlisting}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}[fragile]
  \frametitle{Prořezávání}
	\begin{lstlisting}[language=C]
  int array[10];
  int i;

  for (i = 0; i < 10; ++i) {
    <@{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[i]);}@>
  }
	\end{lstlisting}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}[fragile]
  \frametitle{Symbolická exekuce}
	\begin{lstlisting}[language=C]
  int array[10];
  int i = <@{\color[RGB]{135, 0, 0}nondet();}@>

  for (; i >= 0 && i < 10; ++i) {
    <@{\color[RGB]{0, 135,0} \_\_INSTR\_check(\&array[i]);}@>
  }
	\end{lstlisting}
  \end{frame}
  %% -------------------------------------------------------------------



  %% -------------------------------------------------------------------
  \begin{frame}[fragile]
  \frametitle{Symbolická exekuce}
  \begin{center}
  \begin{tikzpicture}[sibling distance=10em,
    every node/.style = {shape=rectangle, align=center, font=\small},
    nd/.style = {draw,font=\ttfamily\tiny},
    cond/.style = {font=\tiny},
    mem/.style = {overlay, font=\tiny, color=blue} ]
    \node [nd] (root) {int array[10];\\int i = nondet();}
      child { node [nd] {}  edge from parent node[cond, xshift=-11mm]
                              {$\alpha < 0 \lor \alpha \ge 10$}}
      child { node [nd] (fst) {\_\_INSTR\_check(\&array[i]);}
        child { node [nd] {}  edge from parent node[cond, xshift=-17mm]
                               {$(\alpha + 1) < 0 \lor (\alpha + 1) \ge 10$}}
        child { node [nd] (snd) {\_\_INSTR\_check(\&array[i]);}
          child { node [] { \vdots}  edge from parent node[cond, xshift=-17mm]
                               {$(\alpha + 2) < 0 \lor (\alpha + 2) \ge 10$}}
          child { node [] { \vdots}
            edge from parent node[cond, xshift=17mm]
                { $(\alpha + 2) \ge 0 \land (\alpha + 2) < 10$}
          }  edge from parent node[cond, xshift=17mm]
                { $(\alpha + 1) \ge 0 \land (\alpha + 1) < 10$}
        }  edge from parent node[cond, xshift=11mm]
                {$\alpha \ge 0 \land \alpha < 10$}
     };
     \node[mem, right=of root, xshift=-8mm] {i := $\alpha$};
     \node[mem, right=of fst , xshift=-8mm] {i := $\alpha + 1$};
     \node[mem, right=of snd , xshift=-8mm] {i := $\alpha + 2$};
  \end{tikzpicture}
  \end{center}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}
  \frametitle{Výsledky}
  \begin{itemize}
    \item SV-COMP 2016: bronzová medaile v kategorii \emph{Arrays}
    \item SV-COMP 2017: bronzová medaile v kategorii \emph{MemSafety}
  \end{itemize}
  \begin{center}
  \vspace*{5mm}
  \pause
  \begin{tabular}{l l r r r}
    & tool & score & CPU time [h] & solved tasks \\
    \hline
    1 & \textsc{PredatorHP} & 319 & 0.82  & 219 \\
    2 & \textsc{UAutomizer} & 308 & 1.9   & 145 \\
    3 & \textsc{Symbiotic}  & 304 & 0.08  & 233
  \end{tabular}
  \end{center}
  \end{frame}
  %% -------------------------------------------------------------------

  %% -------------------------------------------------------------------
  \begin{frame}
  \frametitle{Do budoucna}
  \begin{itemize}
    \item Chytřejší instrumentace (vkládání ještě méně kontrol)
    \item Zrychlení prořezávání (sparse analýzy)
    \item Symbolická exekuce + abstrakce (+ CEGAR),
          popř. kompoziční symbolická exekuce, sumarizace a memoizace efektů funkcí
  \end{itemize}
  \end{frame}
  %% -------------------------------------------------------------------

\section{Analýza cyklů}
  %% -------------------------------------------------------------------
  \begin{frame}
  \frametitle{Analýza cyklů}
  \begin{itemize}
  \item Marek Trtík
  \item Jirka Slabý
  \item Pavel Čadek
  \end{itemize}

  \bigskip
  \pause
  \begin{center}
    7. 11. 2017 Informatické kolokvium\\
    \alert{\bf Loop summarization  and its applications}
  \end{center}

  \bigskip
  \begin{itemize}
  \item Co jsou cykly?
  \item Co z nich lze vyčíst bez jejich spouštění?
  \end{itemize}
  \end{frame}
  %% -------------------------------------------------------------------
\end{document}
