\documentclass[11pt, a4paper, twoside]{article}
\usepackage[
    a4paper,
    headsep=5mm,
    footskip=0mm,
    top=12mm,
    left=10mm,
    right=10mm,
    bottom=10mm
]{geometry}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{makecell}
\usepackage{multicol}
\usepackage[noend]{algorithm2e}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,positioning, graphs, graphdrawing}
\usegdlibrary {trees} 
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,      
    urlcolor=cyan,
    pdftitle={Overleaf Example},
    pdfpagemode=FullScreen,
    }

\setlength{\algomargin}{0pt}

\begin{document}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[L]{Theoretische Grundlagen der Informatik}
\fancyhead[R]{Gero Beckmann - \url{https://github.com/Geronymos/}}
\fancyfoot{}
\fancyfoot[R]{\thepage}
\newenvironment{definition}[1]{\noindent\textbf{#1:}}{}
\section{Chomsky-Hierarchie}
\hspace*{-.5cm}
\begin{tabular}{ l l l l l }
  Chomsky-Typ & Wortproblem & Definition & Bsp & Maschinenmodell \\

  Typ 0 & 
  semi-entscheidbar &
  \makecell{$G = (\Sigma, V, S, R)$ \\ $R beliebig$ }&
  universelle Sprache &
  NTM/DTM akzeptiert L \\

  Typ 1 & 
  NP-Schwer &
  \makecell{$u \rightarrow v, |u| \leq |v|$ \\ $u \in V^+, S \notin V$ \\ $S \rightarrow \epsilon$ } &
  $L = \{ a^ib^ic^i | i \leq 1 \}$ &
  \makecell{NTM mit Platzbedarf n \\ erkennt Wörter der Länge n in L \\ $\Rightarrow NTAPE(n)$ } \\

  Typ 2 & 
  polynomiell & 
  \makecell{$A \rightarrow v, A \in V$ \\ $v beliebig$} &
  $L = \{ a^ib^i | i \leq 1\}$ &
  CYK-Alg. erkennt L in polynom. Zeit, Chomsky-NF, NPDA \\

  Typ 3 &
  linear &
  \makecell{$A \rightarrow v, A \in V$ \\ $V \in \epsilon \cup \Sigma \cdot V$} &
  $L = \{ a^i | i \leq 1 \}$ &
  NEA/DEA erkennt L \\
\end{tabular}

\subsection{Automaten}
DEA $A = (Q, \Sigma, \delta: Q \times \Sigma \rightarrow Q, s \in Q, F \subseteq Q)$ \\
NEA $A = (Q, \Sigma, \delta: Q \times (\Sigma \cup \{ \epsilon \} \rightarrow 2^Q, s \in Q, F \subseteq Q)$
NPDA \\
DPDA \\
DTM \\
NTM \\

\subsection{Pumping-Lemma}

\begin{multicols}{2}
Erfüllt: 
\begin{itemize}
  \item["$\exists$"] Wähle $n = 2$
  \item["$\forall$"] Betrachte beliebiges $w \in L$ mit $|w| > 2$ 
  \item["$\exists$"] Wähle zerlegung $w = uvx$ mit $u = \epsilon, v = aa, x=a^{2(j-1)}$
  \item["$\forall$"] Für alle $i \in \mathbb{N}_0: uv^ix = a^{2i}a^2(j-1) = a^{2(i+j-1)} \in L$ 
\end{itemize}
Widerlegen: 
\begin{itemize}
  \item["$\exists$"] Wähle $n = 2$
  \item["$\forall$"] Betrachte beliebiges $w \in L$ mit $|w| > 2$ 
  \item["$\exists$"] Wähle zerlegung $w = uvx$ mit $u = \epsilon, v = aa, x=a^{2(j-1)}$
  \item["$\forall$"] Für alle $i \in \mathbb{N}_0: uv^ix = a^{2i}a^2(j-1) = a^{2(i+j-1)} \in L$ 
\end{itemize}
\end{multicols}

\begin{multicols}{2}
Potenzmengenkonstuktion NEA $\rightarrow$ DEA

\begin{tabular}{c | c | c}
  Zustand & a & b \\
  \hline
  $\{\underline{s}\}$ & $\{s, q_1\}$ & $\{f\}$ \\
  $\{\underline{s}, q_1\}$ & $\{s, q_1\}$ & $\{f, q_2\}$ \\
  $\{f\}$ & $\{f\}$ & $\{f\}$ \\
  $\{f, q_2\}$ & $\{f\}$ & $\{f, q_1, q_2\}$ \\
  $\{f, \underline{s}\}$ & $\{f, s, q_1\}$ & $\{f\}$ \\
  $\{f, \underline{s}, q_1\}$ & $\{f, s, q_1\}$ & $\{f, q_2\}$ \\
\end{tabular}

\begin{tikzpicture}[initial text=,shorten >=1pt,node distance=2cm,on grid,auto]

  \node[state,initial,accepting]  (S)                   {$S$};
  \node[state]                    (q_1) [right of=S]    {$q_1$};
  \node[state]                    (q_2) [right of=q_1]  {$q_2$};
  \node[state]                    (f)   [below of=q_1] {$f$};

  \path[->] 
    (S) edge [loop above] node {a} ()
    (S) edge   node [below] {a} (q_1)
    (S) edge              node [left] {b} (f)
    (q_1) edge [bend right] node [above] {a} (S)
    (q_1) edge              node [below] {b} (q_2)
    (q_2) edge [bend right] node [above] {b} (q_1)
    (q_2) edge [loop right] node {b} ()
    (q_2) edge              node {a} (f)
    (f) edge [loop left] node {a,b} ()
  ;

\end{tikzpicture}
\end{multicols}

\begin{multicols}{2}
Entfernen von $\epsilon$-Übergängen

\begin{tabular}{c | c | c}
  Zustand & a & b \\
  \hline
  $S$ & $q_1$ & $S, q_1, q_2, q_3$ \\
  $q_1$ & $q_2, q_3$ & $q_3$ \\
  $q_2$ & $q_1$ & $S, q_2, q_3$ \\
  $q_3$ & $q_1$ & $S, q_2, q_3$ \\
\end{tabular}

\begin{tikzpicture}[initial text=,shorten >=1pt,node distance=2cm,on grid,auto]

  \node[state,initial]   (S)                   {$S$};
  \node[state,accepting] (q_1) [right of=S]    {$q_1$};
  \node[state,accepting] (q_2) [below of=q_1]  {$q_2$};
  \node[state]           (q_3) [below of=S]    {$q_3$};

  \path[->] 
    (S) edge node {b} (q_1)
    (S) edge node [above left] {$\epsilon$} (q_2)
    (q_1) edge node {a} (q_2)
    (q_1) edge [bend left] node [above right] {b} (q_3)
    (q_2) edge node {\epsilon} (q_3)
    (q_3) edge node [below left] {a} (q_1)
    (q_3) edge node {b} (S)
    (q_3) edge [loop left] node {b} ()
  ;

\end{tikzpicture}
\end{multicols}

Minimierung von Automaten
\begin{tikzpicture}[initial text=,shorten >=1pt,node distance=2cm,on grid,auto]

  \node[state,initial]  (S)                   {$S$};
  \node[state]          (p) [right of=S]    {$p$};
  \node[state]          (q) [right of=p]    {$q$};
  \node[state]          (t) [below of=p]    {$t$};
  \node[state,accepting]          (r) [below of=q]    {$r$};
  \node[state]          (v) [below of=t]    {$v$};
  \node[state]          (u) [below of=r]    {$u$};

  \path[->] 
    (S) edge [loop above] node {0} ()
    (S) edge  node {1} (p)
    (p) edge [loop above] node {1} ()
    (p) edge  node {0} (q)
    (q) edge [bend left] node {0} (S)
    (q) edge  node {1} (r)
    (t) edge  node [right] {0} (S)
    (t) edge [bend right] node {1} (r)
    (r) edge [bend right] node [above] {0} (t)
    (r) edge  node {1} (u)
    (v) edge  node {0} (S)
    (v) edge  node[left] {1} (r)
    (u) edge  node {0} (v)
    (u) edge [loop right] node {1} ()
  ;

\end{tikzpicture}

\begin{tikzpicture}[initial text=,shorten >=1pt,node distance=2cm,on grid,auto]

  \node[state,initial]  (S)  {$[S]$};
  \node[state]          (p) [right of=S] {$[p]$};
  \node[state]          (q) [right of=p] {$[q]$};
  \node[state,accepting] (r) [right of=q] {$[r]$};

  \path[->] 
    (S) edge [loop above] node {0} ()
    (S) edge  node {1} (p)
    (p) edge [loop above] node {1} (p)
    (p) edge  node {0} (q)
    (q) edge[bend left] node {0} (S)
    (q) edge node {1} (r)
    (r) edge[bend right] node [above] {1} (p)
  ;

\end{tikzpicture}



\begin{tikzpicture} [binary tree layout]
  \node[align=center] (1) {s,p,q,r,t,a,v \\ $\epsilon$ trennt}
  child { 
    node {r}
  }
  child { node[align=center] {s,p,q,t,u,v \\ 1 trennt}
    child { node[align=center] {s,p,u \\ 0 trennt}
      child { node {s} }
      child { node {p,u} }
    }
    child{
      node {q,t,v}
    }
  };
\end{tikzpicture}

\subsection{Nerode-Relation}

\subsection{Chomsky-NF}

\section{NP-Vollständigkeit}

\section{Kellerautomaten}

\subsection{$4COLOR \in NP$}

\subsection{$3COLOR \propto 4COLOR$}

\subsubsection{Transformation}
\subsubsection{Äquivalenz/Korrektheit}

\section{Approximationsalgorithmen}

\section{Huffman-Kodierung}

\end{document}
