476 lines
43 KiB
TeX
476 lines
43 KiB
TeX
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% writeLaTeX Example: A quick guide to LaTeX
|
|
%
|
|
% Source: Dave Richeson (divisbyzero.com), Dickinson College
|
|
%
|
|
% A one-size-fits-all LaTeX cheat sheet. Kept to two pages, so it
|
|
% can be printed (double-sided) on one piece of paper
|
|
%
|
|
% Feel free to distribute this example, but please keep the referral
|
|
% to divisbyzero.com
|
|
%
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% How to use writeLaTeX:
|
|
%
|
|
% You edit the source code here on the left, and the preview on the
|
|
% right shows you the result within a few seconds.
|
|
%
|
|
% Bookmark this page and share the URL with your co-authors. They can
|
|
% edit at the same time!
|
|
%
|
|
% You can upload figures, bibliographies, custom classes and
|
|
% styles using the files menu.
|
|
%
|
|
% If you're new to LaTeX, the wikibook is a great place to start:
|
|
% http://en.wikibooks.org/wiki/LaTeX
|
|
%
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
\documentclass[10pt,landscape]{article}
|
|
\usepackage{amssymb,amsmath,amsthm,amsfonts}
|
|
\usepackage{multicol,multirow}
|
|
\usepackage{calc}
|
|
\usepackage{ifthen}
|
|
\usepackage[document]{ragged2e}
|
|
\usepackage{helvet}
|
|
\renewcommand{\familydefault}{\sfdefault}
|
|
\usepackage{wrapfig}
|
|
\usepackage[fontsize=8pt]{fontsize}
|
|
|
|
\usepackage[landscape]{geometry}
|
|
|
|
\geometry{a4paper, landscape, margin=0.25cm}
|
|
\usepackage[colorlinks=true,citecolor=blue,linkcolor=blue]{hyperref}
|
|
\usepackage[
|
|
protrusion=true,
|
|
activate={true,nocompatibility},
|
|
final,
|
|
tracking=true,
|
|
kerning=true,
|
|
spacing=true,
|
|
factor=1100]{microtype}
|
|
\SetTracking{encoding={*}, shape=sc}{40}
|
|
%%Packages added by Sebastian Lenzlinger:
|
|
\usepackage{enumerate} %% Used to change the style of enumerations (see below).
|
|
|
|
\newtheorem{definition}{Definition}
|
|
\newtheorem{theorem}{Theorem}
|
|
\newtheorem{axiom}{Axiom}
|
|
\newtheorem{lem}{Lemma}
|
|
\newtheorem{corr}{Corollary}
|
|
|
|
\usepackage{tikz} %% Pagacke to create graphics (graphs, automata, etc.)
|
|
\usetikzlibrary{automata} %% Tikz library to draw automata
|
|
\usetikzlibrary{arrows} %% Tikz library for nicer arrow heads
|
|
%%End
|
|
%\microtypecontext{spacing=nonfrench}
|
|
|
|
\ifthenelse{\lengthtest { \paperwidth = 11in}}
|
|
{ \geometry{top=.5cm,left=.5cm,right=.5cm,bottom=.5cm} }
|
|
{\ifthenelse{ \lengthtest{ \paperwidth = 297mm}}
|
|
{\geometry{top=0.3cm,left=0.3cm,right=0.3cm,bottom=0.3cm} }
|
|
{\geometry{top=0.5cm,left=0.5cm,right=0.5cm,bottom=0.5cm} }
|
|
}
|
|
\pagestyle{empty}
|
|
\makeatletter
|
|
%% Renew default font
|
|
|
|
\renewcommand{\section}{\@startsection{section}{1}{0mm}%
|
|
{0.1mm}%
|
|
{0.0001mm}%x
|
|
{\normalfont\normalsize\bfseries}}
|
|
\renewcommand{\subsection}{\@startsection{subsection}{2}{0mm}%
|
|
{0.0001mm}%
|
|
{0.00001mm}%
|
|
{\normalfont\small\bfseries}}
|
|
\renewcommand{\subsubsection}{\@startsection{subsubsection}{3}{0mm}%
|
|
{-1ex plus -.5ex minus -.2ex}%
|
|
{1ex plus .2ex}%
|
|
{\normalfont\small\bfseries}}
|
|
\makeatother
|
|
\setcounter{secnumdepth}{0}
|
|
\setlength{\parindent}{0pt}
|
|
\setlength{\parskip}{0pt plus 0.5ex}
|
|
|
|
% -----------------------------------------------------------------------
|
|
|
|
\title{Pattern Recognition}
|
|
|
|
\begin{document}
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
% Custom Commands
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\renewcommand{\l}[1]{\mathcal{L}(#1)}
|
|
\newcommand{\s}{\Sigma}
|
|
\newcommand{\then}{\rightsquigarrow}
|
|
\renewcommand{\empty}{\varnothing}
|
|
\newcommand{\any}{$\forall$}
|
|
\newcommand{\some}{$\exists$}
|
|
\newcommand{\predux}{$\leq_p$}
|
|
\newcommand{\tin}{$\in$}
|
|
\newcommand{\ntin}{$\not\in$}
|
|
\newcommand{\ffrom}[1]{\stackrel{(#1)}{\Rightarrow}}
|
|
\raggedright
|
|
\footnotesize
|
|
\microtypecontext{spacing=nonfrench}
|
|
\begin{multicols*}{4}
|
|
\setlength{\premulticols}{0.1cm}
|
|
\setlength{\postmulticols}{0.1cm}
|
|
\setlength{\multicolsep}{0.1cm}
|
|
\setlength{\columnsep}{0.1cm}
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Finite Automata
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Finite Automata}
|
|
\textbf{From Lang. }over an alphabet $\Sigma$ is a subset of $\Sigma^*$
|
|
\textbf{DFA} is a 5-tuple $M=\langle Q\text{ the finite set of states}, \Sigma \text{ input alphabet }, \delta: Q \times \Sigma \rightarrow Q\text{ transition function }, q_0 \text{ start state }, F \subseteq Q \text { set of accept states}\rangle$
|
|
\textbf{Def. } A DFA \emph{accepts} a word $w=a_1...a_2$ if $\exists$ a seq. of states $q'_0,...,q'_n \in Q$, s.t. $q'_0=q_0,\ \delta(q'_{n-1},a_i)=q'_i, \forall i \in \{0,...,n\}$ and $q'_n\in F$.
|
|
\textbf{Def. } $\mathcal{L}(M)=\{w\in\Sigma^* | w \text { is accepted by } M\}$ is the language \emph{recognized} by $M$
|
|
\textbf{NFA} is 5-tuple like \emph{DFA}, but $\delta:Q\times (\Sigma \cup \{\epsilon\}) \rightarrow \mathcal{P}(Q)$. Other diffs: $\delta$ can lead to 0 or more succ states for same $a\in\Sigma$. Can take $\epsilon$-transitions w.o. using symbol from input. \emph{NFA accepts} if $\exists$ \emph{at least one} acc. seq. of states.
|
|
\textbf{$\epsilon$-closure} NFA $M$, $q\in Q$: $p$ is in $\epsilon$-closure $E(q)$ of $q$ \emph{iff.} $\exists$ seq. of states
|
|
$q_{0ton}$, s.t. (1) $q'_0 = q$ (2) $q'_i \in \delta(q'_{i-1},\epsilon), \forall i\in\{1,..,n\}$ and (3) $q'_n = p$
|
|
\textbf{NFA accepts} word $w=a_1..a_n$ if $\exists$ seq. of states $q'_{0\ to \ n}$ s.t. (1) $q'_0\in E(q_0)$ (2) $q'_i\in \bigcup_{q\in\delta(q'_{i-1},a_i)} E(q), \forall i \in \{1,..,n\}$ (3) $q'n\in F$
|
|
\textbf{Thm. } Every lang. recognize by an NFA is also recognized by a DFA.
|
|
\textbf{Remark } Specification of an automaton is always finite, while the recognized lang can be infinite.
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Grammars
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Grammars}
|
|
\textbf{Grammar} is a 4-tuple $G = \langle V \text{ finite set of \emph{variables} }, \Sigma \text{ finite alphabet of \emph{terminal symbols} with } V\cup\Sigma=\empty, R\subseteq(V\cup\Sigma)^*V(V\cup\Sigma)^* \text{ finite set of \emph{rules} }, S\in V \textit{ start variable}\rangle$
|
|
\textbf{Derivation} ($u\Rightarrow V)$ word $v\in (V\cup \Sigma)^*$ from $u\in (V\cup \Sigma)^+$ if (1) $u=xyz, v=xy'z$ with $x,z\in (V\cup \Sigma)^*$ (2) $\exists$ rule $y\rightarrow y'\in R$. Write $u\Rightarrow^*v$ if v can be derived from u in finitely many steps.
|
|
\textbf{Lang. generated} by grammar G, $\mathcal{L}(G)=\{w\in\Sigma^* | S \Rightarrow^* w\}$
|
|
|
|
%%%%%%%%%%%%%%%%%%%%
|
|
%% Chomsky Hierarchy
|
|
%%%%%%%%%%%%%%%%%%%%
|
|
\textbf{G is \emph{type 0}}: all rules allowed
|
|
\textbf{G is \emph{type 1 (context-sensitive)}}: all rules have form $\alpha B\beta \rightarrow \alpha\beta\gamma$ with $B\in V, \alpha\gamma\in (V\cup\Sigma)^*, \beta\in (V\cup\Sigma)^+$
|
|
\textbf{G is \emph{type 2 (context-free}}: all rules have from $A\rightarrow w: A\in V, w\in (V\cup\Sigma)^+$
|
|
\textbf{G is \emph{type 3 (regular)}}: all rules have form $A\rightarrow w: A\in V, w\in \Sigma \cup \Sigma V$
|
|
\textbf{Regular Grammar: } $S\rightarrow \epsilon$ always allowed if $S$ is start variable and never occurs on right side of any rule
|
|
\textbf{Type 0-3 Lang} Lang $L\subseteq \Sigma^*$ is type 0/1/2/3 if $\exists$ a type 0/1/2/3 grammar $G$ with $\mathcal{L}(G)=L$
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Regular Languages
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Regular Languages}
|
|
A language is regular if it generated by some regular grammar (i.e. $S\rightarrow\epsilon$ iff $S$ never on RHS). Regular grammars restrict usage of $\epsilon$ rules. But it is not necessary for the characterization of reg langs.
|
|
\textbf{Thm.} $\forall G=\langle V,\Sigma, R, S\rangle \exists G'=\langle V',\Sigma, R', S\rangle, R'\subseteq (V'\cup \Sigma)^*V'(V'\cup\Sigma)*\times(V'\setminus\{S\}\cup\Sigma)^*$ s.t. $\mathcal{L}(G)=\mathcal{L}(G')$ NOTE: true for all grammars. \textbf{\emph{Proof.}} add new variable $S'\not\in V$ (1) $\forall r\in R$ add a rule $r'$ to R', where $r'$ is result of replacing all occurrences of $S$ in $w$ with $S'$ (2) $\forall\text{rules } S\rightarrow w\in R$ add a rule $S\rightarrow w'$ to $R'$, where $w'$ is result of replacing all occ. of $S$ in $w$ with $S'$. Then $\mathcal{L}(G) = \mathcal{L}(\langle V\cup\{S'\}, \Sigma, R', S\rangle\Box$
|
|
\textbf{Thm.} $\forall$ grammar $G$ with rules $R\subseteq V \times (\Sigma\cup\Sigma V \cup \{\epsilon\}), \exists$ regular grammar $G'$ with $\mathcal{L}(G)=\mathcal{L}G')$
|
|
\textbf{Thm.} Every lang recog by DFA is regular.
|
|
\textbf{Thm.} For every reg grammar G $\exists$ NFA M with $\l{G}=\l{M}$
|
|
\textbf{Equivalence}$NFA \rightarrow DFA \rightarrow reg \ gram \rightarrow NFA$
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Closure props and decidablity
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%---- Closure
|
|
\subsection{Def: Closure Props and Dec.ability}
|
|
\textbf{Concat:} Langs $L_1, L_2$ over $\s_1,\s_2$, concat is $L_1L_2=\{w_1w_2\in (\s_1\cup\s_2)^* | w_1\in L_1, w_2\in L_2$
|
|
\textbf{Star: } Let $L^0=\{\epsilon\}, L^1=L, L^{i+1}=L^iL\ for \ i\in\mathbf{N}_0$. \emph{star} on $L$: $L^*=\bigcup_{i\geq 0}L^i$
|
|
\textbf{Closure:} $\mathcal{K}$ class of langs, $\mathcal{K}$ is \emph{closed under $\oplus$} if $L,L'\in\mathcal{K}$ implies $L\oplus L'\in \mathcal{K}$
|
|
\textbf{Thm. } RL are closed under $\cup,\cap$, complement, concat and star
|
|
%---- Decidability
|
|
\textbf{Decidability:} A \emph{decision problem} is a problem where (1) for given \emph{input} (2) an \emph{algo} determines if input has a given \emph{property} (3) then outputs yes/no
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Regular Expressions
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\subsection{RL: Regex}
|
|
\textbf{Regular expressions } over alphabet $\s$ are defined inductively: (1) $\empty, \epsilon$ are a regex (2) If $a \in \s$, then $a$ is a regex (3) If $\alpha, \beta$ are regex, then also $(\alpha\beta)\text{ concat }, (\alpha|\beta) \text{ alternative }, (a^*)\text{ Kleene closure }$
|
|
\textbf{Conventions:} ommit parenthesis, then kleene binds more than concat bind more than alternative, and parentheses for nested concat/alt are ommited, treat as left-associative, but doesn't matter.
|
|
\textbf{Lang described by a Regex:} Defined inductively: Assume $\alpha,\beta$ are regex. (1) $\l{\empty}=\empty$ (2) $\l{\epsilon}=\{\epsilon\}$ (3) $\gamma=a,a\in\s,\then\l{\gamma}=\{a\}$ (4) $\gamma=(\alpha\beta)\then\l{\gamma}=\l{\alpha}\l{\beta}$ (5) $\l{(\alpha|\beta)}=\l{\alpha}\cup\l{\beta}$ (6) $\l{(\alpha^*)}=\l{\alpha}^*$
|
|
\textbf{Thms.} (1) Every \emph{finite} language can be described by a regex. (2) \any lang that can be descr. by a regex, \some NFA accepts it (3) \any lang \emph{recognized} by a DFA can be descr. by a regex (4) The set of langs that can be descr. by regexs are exactly the regular languages!
|
|
%---- Generalized Nodeterministic Finite Automata
|
|
\textbf{GNFAs} are like NFAs but transition labals can be arbitrary regex over input alphabet. We use special form: (1) Start state has transition to all others, but no incoming (2) one accept state $\not =$ start state (3) accept state has incomiong trans from every other state, but no outgoing (4) \any other states, one transition goes from every state to every other state \emph{including} self
|
|
\textbf{GNFA accepts w} if $w=w_1...w_k$ where each $w_i\in\s^*$ and \some seq of states $q_0,...,q_k\in Q$ with (1) $q_0=q_s$ (2) $\forall i: w_i\in\l{R_i(=\delta(q_{i-1},q_i))}$ and (3) $q_k=q_a$
|
|
\textbf{DFA to GNFA: }(1) add new start state with $\epsilon$-trans to origianl start state (2) add new accept state with $\epsilon$-trans from og. acc. states (4) combine parallel transitions into one, labelled with the alternative of og labels (5) if required trans missing, add labbeled with $\empty$
|
|
\textbf{GNFA to regex (Algo)} \emph{Convert($M=\langle Q, \s, \delta, q_s, q_a\rangle)$} (1) If $|Q|=2$ return $\delta(q_s,q_a)$ (2) Select any $q\in Q\setminus\{q_s,q_a\}$ and let $M'=\langle Q\setminus \{q\}, \s, \delta', q_s, q_a\rangle$, where $\forall q_i\not = q_a, q_j\not = q_s$ we define $\delta'(q_i,q_j)=(\gamma_1)(\gamma_2)^*(\gamma_3)|(\gamma_4)$, where $\gamma_1=\delta(q_i,q),\gamma_2=\delta(q,q),\gamma_3=\delta(q,q_j),\gamma_4=\delta(q_i,q_j)$
|
|
\textbf{Thm. }Set of langs that can be descr. by regexs is exaclty the set of RLs.
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Pumping Lemma
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\subsection{RL: Pumping Lemma}
|
|
If L is an RL then $\exists p\in\mathbf{N}$ ( a\emph{ pumping number} for L) s.t. $\forall x \in L, |X|\geq p$ can be split into $x=uvw$ with (1) $|v|\geq1$ (2) $|uv|\leq p$ and $uv^iw\in L, \forall i=0,1,2,...$
|
|
\textbf{Application:} If L is regular, than the pumping lemma holds for L. By Controposition: If PL does not hold for L, then L cannot be regular.
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% CF langs
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Context-Free Languages}
|
|
\textbf{Thm. }\any Context-free grammer G with rules $P\subseteq V\times (V\cup\s)^* \exists \text{ context-free grammar } G', \l{G}=\l{G'}$
|
|
\textbf{$\epsilon$-Rules: }As with RLs, restriction of $\epsilon$ occurances in rules is not necessary to characterize the set of context-free languages
|
|
%------ CNF
|
|
\textbf{CNF: } A CF grammar G is in \emph{Chomsky Normal Form} if all rules have following three forms (1) $A\rightarrow BC, A,B,C$ variables (2) $A\rightarrow a$, var A and terminal $a$ or (3) $S\rightarrow \epsilon$ start variable $S$, i.e. $P\subseteq (V\times (V'V'\cup \s))\cup \{\langle S,\epsilon\rangle\}, V'=V\setminus\{S\}$
|
|
\textbf{Thm.} \any CF grammar G \some G' in CNF with $\l{G}=\l{G'}$
|
|
\textbf{Observation} $G$ grammar in CNF and $w\in\l{G}$ non empty word generated by $G$, $\then$ \any derivations of $w$ have exactly $2|w|-1$ derivation steps! \textbf{\emph{Proof.}} \textbf{Base Case} ($|w| = 1$ since $w\not = \epsilon$): Since by construction $w\in\mathcal{L}(G)$, there is some rule $S\rightarrow w \in R$ from the start variable. Since $|w|=1$ we have $w=a\in\Sigma$ for some terminal $a$. We apply this rule in one step, and since $2\cdot |w| - 1 = 2 \cdot 1 - 1 = 1$, the base case holds.\\
|
|
\textbf{Induction Hypothesis:} Assume the statement holds for any strings $a<k$. We show that this implies that the statement holds for strings of length $k$. Let $w$ be such a string where $|w| = k$. Since $w\in \mathcal{L}(G)$ there is some derivation of $w$ starting from the start variable. We consider the first step of this derivation. Notice that by construction $w\not = \epsilon$, so we are left with two cases:\\
|
|
Case 1: If we apply a rule $S\rightarrow a$ for some terminal $a$, then $w=a$ and we are in the base case. \\
|
|
Case 2: We apply a rule of the form $S\rightarrow AB$. Then $|w|\geq2$ and we can partition $w$ in to substrings $w=xy$. Suppose we first derive $A\ffrom{*}x$ and then $B\ffrom{*}y$. Since $|w|=k$ it follows that $|w|=|x|+|y|=k$ where $1\leq|x| < k$ and $1\leq|y|<k$.Since $|x|<k$ and $|y|<k$, we can apply our induciton hypothesis. So we derive
|
|
Applying our I.H. $\Box$
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% PDAs
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\subsection{Push-Down Automata}
|
|
\textbf{PDA} is a 6-tuple $M=\langle Q \text{ finite set of states }, \s \text{ input alphabet }, \Gamma \text{ stack alphabet }, \delta:Q\times (\s\cup\{\epsilon\})\times(\Gamma\cup\{\epsilon\}) \rightarrow \mathcal{P}(Q\times (\Gamma \cup\{\epsilon\})) \text { transition function }, q_0\in Q \text{ start state }, F\subseteq Q \text{ set if accept states}\rangle$
|
|
\textbf{Intuition $\delta$} (1) $\langle(q',B\rangle \in \delta(q,a,A)$: If M is in state q, reads a and has A as top stack symbol, M \emph{can} trans to q' in next step popping A off stack and pushing B on stack (2) $a=\epsilon$ allowed (spontaneous trans) (3) $A=\epsilon$ allowed (no pop) (4) $B=\epsilon$ allowed (no push)
|
|
TODO: PDA accepts w b08 p. 13
|
|
\textbf{Thm.} Lang L is CF iff L is recognized by a PDA.
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Closure and decidability
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\textbf{Deterministic PDA} have restriction $|\delta(q,a,A)| + |\delta(q,\epsilon, A)|\leq 1, \forall q\in Q, a\in \s, A\in \Gamma$.
|
|
\textbf{Lang recognized by DPDA} are the called \emph{deterministic CF langs} and are \emph{strict} subset of CF langs
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Turing Machines
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Turing Machines I \& II}
|
|
\textbf{Deterministic Turing Machine} DTM given by 7-tuple $M=\langle Q \text{ set of states }, \s \text{ input alphabet, \emph{not} containing blank symbol } \Box,$
|
|
\\ $\Gamma \text{ tape alphabet, where } \Box \in \Gamma \land \s\subseteq\Gamma, \delta:(Q\setminus\{q_{acc},q_{rej}\})\times\Gamma \rightarrow Q\times\Gamma\times\{L,R\} \text{ trans func }, q_0 \text{ start state }, q_{acc}, q_{rej}(\not = q_{acc})\rangle$
|
|
\textbf{Intuition $\delta$:} $\delta(q,a)=\langle q',b, D\rangle$: (1) If $M$ in state $q$, reads $a\then$ (2.1) $M$ trans to state $q'$ in next step (2.2) replaceing $a$ with $b$ and (2.3) moving head in direction $D\in\{L,R\}$ \textbf{\emph{Remark: }} IF head in leftmost state, then going left is no movement!
|
|
\textbf{Config of a TM} given by triple $c\in \Gamma^* \times Q \times \Gamma^+$. I.e. $(w_1,q,w_2)$ means (1) non empty or already visited part contains word $w_1w_2$ (2) R/W head on first symbol of $w_2$ (3) TM is in state $q$
|
|
\textbf{DTM accepts word} $w$ if terminates in accept state doing only legal steps
|
|
\textbf{Lang recognized by DTM M} $\l{M}=\{w\in\s^*|w \text{ is accepted by } M\}$
|
|
\textbf{Turing-recognizable language }if some \emph{DTM} recognizes it
|
|
\textbf{Decider} TM that halts (in $q_{acc}$ or $q_{rej}$) on all inputs $\then$ \textbf{T-decidable lang} if some DTM decides it
|
|
\textbf{Remark:} TMs finite states but \emph{unbounded} tape as "memory"
|
|
%%%%%%%%%%%%
|
|
%% TM Variants
|
|
%%%%%%%%%%%%
|
|
\subsection{TM Variants}
|
|
\textbf{Neutral Move} Just add xtra state and go there on neural move then back but without changing tape
|
|
\textbf{\any Multi Tape TM} has an equivalent single-tape TM
|
|
\textbf{Thm.} Lang is T-recog iff \some Multi Tape TM recognizes it.
|
|
\textbf{Nondeterministic TM} Like DTM but (1) $\delta:(Q\setminus\{q_{acc},q_{rej}\})\times\Gamma\rightarrow \mathcal{P}(same as DTM)$ (2) for given input consider computatino tree with branche as different possibilities (3) if \some branch leads to accept, then NTM accepts
|
|
\textbf{Thm.} \any NTM N \some DTM D: N$\equiv$D
|
|
$\then$\textbf{Thm. } Lang is turing recog iff \some NTM recogs it
|
|
\textbf{Remark: } \emph{All variants of TM recognize the same languages}
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% TMs vs. Grammars
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{TMs vs. Grammars}
|
|
\textbf{Linear Bounded Automata} is an NTM M if $\forall q\in Q\setminus\{q_{acc},a_{rej}\}$ and all trans rules $\langle q',c'y\rangle\in\delta(q,\Box)$, we have $c=\Box$!
|
|
\textbf{Thm.} LBAs recog exaclty the context-sensitive languages
|
|
\textbf{Thm.} NFAs recog exactly type-0 langs $\then$ \textbf{Corr.} Since DTMs and NTMs recognize same langs type-0 langs are exactly the Turing-recognizablelangs
|
|
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% TMs and fromal Model of Computation
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Formal Model of Computation}
|
|
\textbf{Church-Turing Thesis} All functions that can be \emph{computed in the intuitive sense} can be computed by a \emph{TM}.
|
|
\textbf{Problem} TM have infinite tape. Computers do not. \emph{BUT} A \emph{halting (in particular accepting} computation of a TM only uses \emph{finite} pat of tape. $\then$ If problem undecidable then not solvable with computer
|
|
\textbf{Encoding a TM as Word:} Encode a TM as word over $\{0,1,\#\}$ \emph{Idea: } (1) $\s$ should always be $\{0,1\}$ (2) enumerate states in Q and symbols in $\Gamma$ as number 0,1,2,... (3) blank symbol is always number 2 (4) start state always number 0, accept state always 1, reject state always no 2 $\then$ Sufficient to only encode $\delta$ explicitly: (1) Q: all states mentioned in the encoding of $\delta$ (2) $\Gamma=\{0,1,\Box,a_3,a_4,...,a_k\}$ where $k$ is largest symbol number mentioned in the $\delta$-rules
|
|
\textbf{\emph{Encode the rules}} Let $\delta(q_i,a_j)=\langle q_{i'}, a_{j'}, D\rangle$ be a rule in $\delta$, where indecies $i,i',j,j'$ correspond to enumaration of state/symbols and $D\in\{L,R\}$. Encode this rule as: $w_{i,j,i',j',D}=\#\#bin(i)\#bin(j)\#bin(i')\#bin(j')\#bin(m)$ where $m=0(D=L),m=1(D=R)$. Do for each rule, then all these words in (arbitrary) sequence encode the TM.
|
|
\emph{Last Step: } Transform into word over $\{0,1\}$ with $0\mapsto 00, 1\mapsto 01, \#\mapsto 11$
|
|
\textbf{TM encoded by a word:} \emph{goal: } function that maps any word in $\{0,1\}^*$ to a TM \emph{problem:} not all words in $\{0,1\}^*$ are encodings of a TM \emph{solution: } Let $\Hat{M}$ be an arbitray fixed DTM. Then: $\forall w\in\{0,1\}^*: M_w=M' \text{ if } w \text{ is the encoding if some DTM } M', \Hat{M} \text{ otherwise}$
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Halting Problem
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{The Halting Problem}
|
|
\textbf{Decidable vs. T-recognizable} A language $L$ is decidable iff \emph{both} $L$ and $\Bar{L}$ are T-recognizable \textbf{\emph{Proof.}} $(\Rightarrow)$: obvious because If TM accepts L, then TM' where accept and reject state are switched accepts $\Bar{L}$. $(\Leftarrow)$: Let $M_L$ be a DTM that recognizes $L$, and let $M_{\Bar{L}}$ be a DTM that recognizes $\Bar{L}$. Algo that decides $L$:
|
|
On given input word $w$ proceed as follows: FOR $s:=1,2,3,...$: IF $M_L$ stops on $w$ in $s$ steps in the accept state: ACCEPT; IF $M_{\Bar{L}}$ stops on $w$ in $s$ steps in the accept state: REJECT $\Box$
|
|
\textbf{The Halting Problem} is the lang $H=\{w\#x\in\{0,1,\#\}^* | w,x\in\{0,1\}^*, M_w \text{ started on } x \text{ terminates}\}$
|
|
\textbf{Thm. } $H$ is T-recognizable \textbf{\emph{Proof.}} TM $U$ recogs $H$: On input $w\#x$: (1) If input has more than one \# REJECT (2) Simulate $M_w$ on $x$ (3) If $M_w$ halts, ACCEPT
|
|
\textbf{Thm. } $H$ is undecidable
|
|
\textbf{\emph{Proof.}} Assume $H$ is decidable. Let $D$ be a DTM that decides it. Construct new TM $M$ that takes a word $x\in\{0,1\}^*$ as input: (1) Execute D on input $x\#x$ (2) If rejects: ACCEPT (3) Else: enter endless loop.
|
|
Let $w$ be the encoding of $M\then$ $M$ run on $w$ stops iff $D$ run on $w\#w$ rejects iff $w\#w\not\in H$ iff $M$ run on $w$ does not stop (reminder: $w$ encodes $M$) \emph{CONTRADICTION} DTM M cannot exist $\Rightarrow$ DTM D cannot exist, hence $H$ is not decidable $\Box$
|
|
\textbf{Corr.} The complement of the halting problem $\Bar{H}$ is \emph{not T-recognizable}, i.e. \emph{not even} type-0
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Turing-Computability
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Turing-Computability}
|
|
\textbf{Function (on word) Computed by a TM: }A DTM $M$ \emph{computes} the (partial) function $f:\s^*\rightarrow_p\s^*$ for which $\forall x,y\in\s^*$: $f(x)=y \ iff.\ \langle\epsilon,q_0,x\rangle \vdash^* \langle\epsilon,q_{acc},y\Box...\Box\rangle$ (special case: \\ init config is $\langle\epsilon,q_0,\Box\rangle$ if $x=\epsilon$)
|
|
\textbf{Turing-Computable:} a partial function is T-Compable if a \some DTM that computes it.
|
|
\textbf{Encoded Function: } $f:\mathbf{N}^k_0 \rightarrow_p \mathbb{N}_0$ (partial) functions. $f^{code}:\s^*\rightarrow_p\s^*, \s=\{0,1,\#\}, f^{code}(w)=w'$ iff (1) $\exists n_1,...,n_k,n'\in \mathbb{N}_0$ s.t. (2) $f(n_1,...,n_k)=n'$ (3) $w=bin(n_1)\#...\#bin(n_k)$ and (4) $w'=bin(n')$
|
|
\textbf{T-Comp for numeric functions: } $f:\mathbb{N}^k_0\rightarrow_p\mathbb{N}_0$ is T-Comp if \some DTM that computes $f_{code}$
|
|
\textbf{Remark: } If the DTM does not stop in a valid config or does not stop at all, then $f(w)$ is undefined for that $w$.
|
|
%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Decidable v computable
|
|
%%%%%%%%%%%%%%%%%%%%%%%
|
|
\subsection{Decidable vs. Compatibility}
|
|
\textbf{Thm.} Lang $L\subseteq\s^*$ is decidable iff $\chi_L:\s^*\rightarrow \{0,1\}$ the \emph{characteristic function of }$L$, is computable, where $\forall w \in \s^*$: $\chi_L(w):= 1(w\in L); 0(w\not\in L)$
|
|
\textbf{Thm.}Lang $L\subseteq\s^*$ is T-recognizeable iff the following function $\chi'_L:\s^*\rightarrow \{0,1\}$ is computable, where $\forall w \in \s^*$: $\chi'_L(w):= 1(w\in L); undefinded(w\not\in L)$
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Reductions
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Reductions}
|
|
\textbf{Reduction} of lang $A\subseteq\s^*$ to $B\subseteq\Gamma^*$ (write $A\leq B$), with \emph{total and computable} func $f:\s^*\rightarrow\Gamma$ s.t. $\forall x\in\s^*$: $x\in A \iff f(x)\in B$.
|
|
\textbf{Thm. } $A, B, A\leq B$. Then: (1) $B$ decidable $\then$ A decidable (2) $B$ T-recable $\then$ $A$ T-recable (3) $A$ not decidable $then$ B not decidable (4) $A$ not T-recable $\then$ $B$ neither.
|
|
\section{Post Correspondence Problem}
|
|
\textbf{PCP} \emph{Given:} Finite sequence of pairs of words $(t_1,b_1),(t_2,b_2),...,(t_k,b_k), t_i,b_i\in\s^+$ for arbitrary $\s$. \emph{Question: }\some sequence $i_1,i_2,...,i_n\in\{1,...,k\}, n\geq 1$, with $t_{i1}t_{i2}...t_{in}=b_{i1}b_{i2}...b_{in}$? Solution is called \emph{match}.
|
|
\textbf{Thm.} PCP is T-recognizable. \textbf{Thm.} PCP is \emph{not} decidable.
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Rice's Theorem
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Rice's Theorem}
|
|
Let $\mathcal{R}$ be the class of all \emph{computable partial functions}. Let $\mathcal{S}$ be an \emph{arbitrary}$\subseteq \mathcal{R}, \mathcal{S}\not= \empty,\mathcal{S}\not = \mathcal{R} $. Then the lang $\mathcal{C}(S) = \{ w \in\{0,1\}^* | (\text{ the (partial) function computed by} M_w) \in \mathcal{S} \}$ is \emph{undecidable}. I.e. every non trivial($\mathcal{S}\not= \empty,\mathcal{S}\not = \mathcal{R} $) property about \emph{what a given} TM computes is undecidable. \textbf{\emph{Consequence: }} Full automization of software verification is impossible!
|
|
\emph{Some undecidable Grammar Problems: } given CF grammars $G,G'$: $\l{G}\cap\l{G'}=\empty$?$|\l{G}\cap\l{G'}|=\infty$? is $\l{G}\cap\l{G'}$ CF? $\l{G}\subseteq\l{G'}$? $\l{G}=\l{G'}$? given CS grammar $G$: $\l{G}=\empty$?$|l{G}|=\infty$?
|
|
\textbf{Gödel's First Incompleteness Theorem: } Deciding if a given arithmetic formula is true is undecidable. Actually, neither it nor its complement are T-recognizable. SO, not \some sound and complete proof system for arithmetic formulas!
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Overview Closure and Decidability
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\textbf{Overview Closure and Decabl:}\emph{Closure:} Intersection: 3,1,0. Union: 3,2,1,0. Comp: 3,1. Concat: 3,2,1,0. Star:3,2,1,0. \emph{Decable:} WordP: 3,2,1. Empti: 3,2. Equiv: 3. Intersec: 3.
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Nondeterminbistic Algos, P and Np
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Nondeterministic Algos, P and NP}
|
|
\textbf{TIME and NTIME} $t:\mathbf{N}\rightarrow\mathbf{R}$: (1) $TIME(t(n))$ is the collection of all langs that are decidable by an $O(t)$ time single tape TM. (2) $NTIME(t(n))$ like $TIME$ but by a \emph{nondeterministic TM}.
|
|
\textbf{P and NP} $P$ is class of langs decidable in \emph{polynomial time} by a single tape DTM: $P=\bigcup_k TIME(n^k)$. $NP$ like $P$ but $NP = \bigcup_k NTIME(n^k)$.
|
|
\emph{Remark: } nondeterministic algos can guess (i.e. perform multiple comps "at same time") corresponds to going through all computation branches at same time.
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Polynomial Reductions and NP-Completeness
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Poly. Red. and NP-Completeness}
|
|
\textbf{Polynomial Reduction: } Like general reduction, but aditionally function $f$ needs to be computed in \emph{polynomial time} by a DTM, i.e. \some polynomail $p$ and DTM $M$ s.t. $M$ computesw $f(w)$ in at most $p(|w|)$ steps, given input $w\in\s^*$.
|
|
Write $A\geq_p B$.
|
|
\textbf{Properties of poly redux: }Decision probs A,B and C. (1) If A \predux B and B \tin P/NP, then A \tin P/NP. (2) If A \predux B and A \ntin P/NP, then B\ntin NP. (3) If A \predux B and B\predux C, then A \predux C.
|
|
\textbf{NP-Hard, NP-Complete: } Decision problem B. B \emph{NP-Hard} if A \predux B \any A \tin NP. B \emph{NP-Complete} if B \tin NP and B is NP-Hard. \textbf{\emph{Meaning: }} NP-Hard probs \emph{"at least as difficult"} as all probs in NP. NP-Complete Problems are \emph{"the most difficult"} in NP: all probs in NP can be reduces to them. If \some A\tin P and A is NP-Complete, then P = NP.
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Proving NP-Completeness
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Proving NP-Completeness}
|
|
\textbf{Thm.} A,B problems s.t.: (1) A is NP-Hard, and (2) A\predux B. Then B is also NP-Hard. If also B\tin NP, then B is NP-Complete.
|
|
\textbf{SAT} \emph{Given:} prop logic formula $\varphi$ \emph{Question: } Is $\varphi$ satisfiable? \textbf{Cook- Levin Thm. } SAT is NP-Complete.
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Proof SAT is NP-Complete
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\subsection*{Proof SAT is NP-Complete}
|
|
\textbf{SAT \tin NP}: Guess and Check
|
|
\textbf{SAT is NP-Hard}:
|
|
We must show A \predux SAT \any A \tin NP. Let A be arb prob in NP. We need to find a poly redux form A to SAT, i.e. a function $f$ \emph{computable} in poly time s.t. for any input w\tin $\text{A}^*$: w\tin A iff f(w) is a satisfiable prop formula. Since A \tin NP, \some NTM M and polynomial p s.t. M \emph{decides} A in time p. \textbf{\emph{IDEA: }} Construct formula that encodes the \emph{possible configurations} which M can reach in time $p(|w|)$ on input w and that \emph{is satisfiable iff an accepting config can be reached} in this time.
|
|
|
|
Let M be an NTM for A and let p be a polynomial bounding the computation time for M. W.o.l.g. $p(n)\geq n\forall n$. Let $w=w_1..w_n\in\s^*$ be input for $M$. We number the tape positions with natural numbers s.t. the TM head initially is on pos 1. \emph{Observation:} within $p(n)$ comp steps TM head can only reach positions in the set $Pos=\{1,..,p(n)+1\}$. So only need consider these pos.
|
|
We encode configs of $M$ by specifzing: (1) state, head pos, symbols on tape at positions Pos (2) since we want to encode full computation we need copies for each comp step (3) only need to consider $Steps=\{0,1,...,p(n)\}$ because M must acc within $p(n)$ steps!
|
|
For vars in formula $f(w)(t\in Steps, q\in Q, a\in\Gamma)$: (1) $state_{t,q}$ state of TM in $t-th$ config (2) $head_{t,i}$ head pos (3) $tape_{t,i,a}$ tape content.
|
|
Construct $f(w)$ such that every sat interpretation (1) descr a seq of NTM configs (2) begins in start config (3) reaches acc config (4) follows NTM rules in $\delta$.
|
|
\textbf{All together:} Set $f(w):= Valid \land Init \land Accept \land Trans$, (1) $f(w)$ can be constructed in time polynomial in $|w|$ (2) $w\in A $ iff M accepts $w$ in $p(|w|)$ steps iff $f(w)$ is satisfiable iff $f(w)\in SAT \then$ A \predux SAT. Since $S\in NP$ arbitrary, this is true for every $A\in NP$ hence $SAT$ is NP hard and also NP-Complete.
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Some More NP-Compelete Problems
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Some NP-Complete Problems I \&II}
|
|
\textbf{Clique:} \emph{G}: undirected graph $\langle V,E \rangle$, number $K \in \mathbf{N_0}$
|
|
\emph{Q:} Does $G$ have a clique of size at least $K$, i.e., a set of vertices $C\subseteq V$ with $|C| \geq K$ and $\{u,v\} \in E$ for all $u,v \in C$ with $u \not = v$
|
|
\textbf{IndSet:} \emph{G}: undirected graph $G = \langle V,E \rangle$, number $K \in \mathbb{N_0}$
|
|
\emph{Q:} Does $G$ have independent set (i.e. vertices not connected by an edge) of at least size $K$? \emph{Clique \predux IndSet:} Use complement graph ($\Bar{G}=(V,\Bar{E})$ of Clique.
|
|
\textbf{VertexCover:}\emph{G:} undirected graph and natural number $K$. \emph{Q:} Does G have a vertex cover C (i.e. a set of vertices such that every edge of G has at least one vertex in C) of AT MOST(!) size $K$? \emph{IndSet \predux VC:}A set of vertices is a cover iff. its complement is and independent set, i.e $f(\langle G,K\rangle)=\langle G,|V|-K\rangle$.
|
|
\textbf{(Dir)HamCycle:}\emph{G:} (DIRECTED) graph \emph{Q:}Does G have a Hamilton Cycle (visit each vertex exactly once).
|
|
\textbf{TSP:}\emph{G:} finite $S\not=\empty$ (Cities), symmetric cost function $cost:S\times S\rightarrow\mathbb{N}_0$, cost bound $K\in\mathbb{N}_0$ \emph{Q:}\some tour with total cost $K$?
|
|
\textbf{SubsetSum}\emph{G:} numbers $a_1,..,a_k\in\mathbb{N}_0,b\in\mathbb{N}_0$\emph{Q:}
|
|
\some $J\subseteq\{1,..,k\}:\sum_{i\in J}a_i=b$?
|
|
\textbf{Partition:}\emph{G:}$a_1,..,a_k\in\mathbb{N}_0$\emph{Q:}\some $J\in\{1,..,k\}:\sum_{i\in j}a_i=\sum_{i\in\{1..k\}\setminus J}a_i$?\emph{SubsetSum\predux Part:} input for Part is input for SS and $(\sum_{i=1}^ka_i=)M+1,2b+1$. Since $M+(M+1)+(2b+1)=2M+1b+2$ a solution partitions in to two subsets with size $M+b+1$. If $J\subseteq\{1,,k\}$ is a subsetsum sol, then $J$ with (index of)$M+1$ is a partition sol.$\Box$
|
|
\textbf{BinPacking:}\emph{G:}bin size $b$,no of bins $k$,$b,k\in\mathbb{N}_0$, objects $a_1,..,a_n\in\mathbb{N}_0$\emph{Q:}Do the objects fit into the bins?
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Beyond NP
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{Beyond NP}
|
|
\textbf{coNP:} is the set off all languages $L$ and $\overline{L} \in NP$.
|
|
$P \subseteq coNP$, if $x \in NP-complete \rightarrow \overline{X} \in coNP-complete$, $NP \not = coNp \rightarrow P \not = NP$,$coNP-complete problem \in NP \rightarrow NP = coNP$,$coNP-complete problem \in P \rightarrow P = NP = coNP$
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% LOOP and WHILE Computablility
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section{LOOP and WHILE Computability}
|
|
\textbf{Loop:} $x_i := x_j \pm c | i,j \in \mathbb N_0 $ is a Loop-prog (addit/modif-substract)
|
|
if $P_1 \& P_2 $ loop-prog, then $P_1;P_2$ (compo), loop-prog nested in loop-prog, is still loop-prog. Non-total functions are never Loop-computable.
|
|
\textbf{While:} add, subtract, concat and nesting same as in loop. $\forall$ loop-comput func is while-comput,$ \not \forall$ while-comput is loop-comput. While is strictly more powerful than loop. Ex. Ackermann function.
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% GOTO Comp. and Comparison
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %
|
|
\section{GOTO Computability and Comparison }
|
|
DTM = While-prog = Goto-prog $\rightarrow$ Equally powerful.
|
|
Let $f: \mathbb N_0^k \rightarrow _p \mathbb N_0$. f is turing-, while-, goto-compu
|
|
$\forall$ loop-compu is turing-, while-, goto-compu
|
|
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Examples
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\section*{Examples}
|
|
\textbf{RLs}
|
|
\emph{G:} regular Grammars $G_1,G_2$ \emph{Q:} Is $\mathcal{L}(G_!)=\l{G_2}$ \emph{R:}Generally, for languages $L,L'$ we have $L \subseteq L'$ iff. $L \cap L' = L$. Since $G_1,G_2$ are regular grammars, it follows that $\mathcal{L}(G_1), \mathcal{L}(G_2)$ both are regular languages. Since regular languages are closed under intersection, we can construct the intersection language $L_{\cap}=\mathcal{L}(G_1)\cap \mathcal{L}(G_2)$ and then, using the algorithm for the equivalence problem for regular languages, we check if $\mathcal{L}(G_1) = L_{\cap}$ and propagate the outcome. Since at every step we can use known algorithms, we have found a procedure for our problem and it follows that the problem is decidable $\Box$
|
|
\textbf{PL:}\emph{Q:} Is $L_1=\{a^nb^mc^{m+n} | n,m\in\mathbb{N}_0\}$ a RL? \emph{R:} Assume $L_1$ is regular. Then let $p$ be a pumping number for $L_1$. The word $a^pb^pc^{p+p}$ is in $L_1$ and has length $\geq p$. Let $x=uvw$ be a split with the properties of the PL. Then $x'=uv^2w$ is also in $L_1$. Since $|uv|\leq p$, we know that $uv$ consists only of $a$s and $x'=a^{|u|}a^{2|v|}a^{p-|uv|}b^{p}c^{2p} = a^{p+|v|}b^pc^{2p}$. Since $|V| \geq 1$ we have that $p+|v| \not = p$ and thus $x'\notin L_1$. This is a contradiction to the PL and we conclude that $L_1$ is not regular.$\Box$
|
|
\textbf{CFLs Closure and Dec:} \emph{Q:} If $L$ is CF, then $\Bar{L}$ is not CF. \emph{R:}This statement is false. We know that every regular language is also a context free language. Furthermore, we know that the regular languages are closed under complement IE. for any regular language $L_{reg}$, $\overline{L_{reg}}$ is also a regular language. In particular, they are both context free. And the given statement does not hold. $\Box$
|
|
\emph{Q:} $L=\{a^nb^nb^ma^m|m,n\in\mathbb{N}_0\}$ is CF \emph{R:}From the lecture we know that languages of the form $\{x^zy^z\} | z\in \mathbb N_0$ are context free. Now we can instantiate: $L' = \{a^nb^n\} | n \in \mathbb N_0$ and $L' = \{b^ma^m\} | m \in \mathbb N_0$ are context free. Then $L'L'' = L$ is the concatenation language and since context free languages are closed under concatenation, $L$ is context free.$\Box$
|
|
\emph{Q:} Given CFGs $G_1,G_2$, "Is $w\in\l{G_1}\cap\l{G_2}$" is decidable. \emph{R:}Notice that $w\in \mathcal{L}(G_1) \cap \mathcal{L}(G_2) \ $iff.$ \ w\in \mathcal{L}(G_1) \ and \ w\in \mathcal{L}(G_2)$. Furthermore, we know that the word problem is decidable for context-free languages. Thus, we first use the algorithm to solve the word problem separately for $\mathcal{L}(G_1)$ and $\mathcal{L}(G_2)$ and return true if $w$ is in both and $false$ otherwise. This algorithm decides $w\in \mathcal{L}(G_1) \cap \mathcal{L}(G_2)$ for context-free grammars $G_1$ and $G_2$.$\Box$
|
|
%%%%%%%%%%%%%%%%%%
|
|
%% Proof exp is t-comp
|
|
%%%%%%%%%%%%%%%%%
|
|
\textbf{Proof Exponentiation is T-Compable}Consider the following algorithm to compute $exp(n_1,n_2)=n_1^{n_2}$.
|
|
(1) Check if input on tape is legal ($n_1,n_2>=0$).
|
|
(2) Write $n_3=1$ on to tape such that $(n_1,n_2,n_3)$ is on the tape.
|
|
(3) If $n_2=0$, go to 6.
|
|
(4) Simulate $M_{pred}(n_2)$ and write in to $n_2$.
|
|
(5) Simulate $M_{mult}(n_1,n_3)$ and write in to $n_3$. Go to 2.
|
|
(6) Move $n_3$ to beginning of the tape overwriting whats under it and deleting everything after it. Then $n_3=n_1^{n_2}$ is on the tape.$\Box$
|
|
%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Comp of comput func is comput
|
|
%%%%%%%%%%%%%%%%%%%%%
|
|
\textbf{Composition of Comp Functions}Since $g$ and $f$ are computable, there are TMs that compute them. Call them $C_g$ and $C_f$. The following TM computes $(f \circ g)(x): \Sigma^*_1 \rightarrow_p \Sigma^*_3$:\\
|
|
$C_{fg}$ = On input $\langle\langle C_f,C_g,x\rangle\rangle$:
|
|
(1)If the input is malformed, reject. (Can not really happen, we assumed well formed input.)
|
|
(2) Run $C_g$ on $x$ and store it on tape where $\langle C_g, x\rangle$ was, such the tape contents are $\langle\langle C_f,C_g(x)\rangle\rangle$ If it rejects or is undefined, reject.
|
|
(3)Run $C_f$ on the above result. Then we have $\langle\langle C_f(C_g(x))\rangle\rangle$ on the tape.
|
|
(4) Check if what is on the tape represents anything but a correct result of computing. If not, move into a reject state.
|
|
(5) Format tape content to match the definition of computing a function value of a computable function.
|
|
(6) Move into an accept state.
|
|
$C_{fg}$ computes $(f\circ g)(x)$, such that in the end we have $\langle\langle f(g(x))\rangle\rangle$ on the tape, and is undefined when $g(x)$ is undefined or $f(g(x))$ is undefined. $\Box$
|
|
%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Trans of Redux
|
|
%%%%%%%%%%%%%%%%%%%%%%
|
|
\textbf{Transitivity of Redux:}Let $A\subseteq\Sigma_A^*$, $B\subseteq\Sigma_B^*$ and $C\subseteq \Sigma_C^*$ for some arbitray sets of symbols $\Sigma_A, \Sigma_B$ and $\Sigma_C$. Furthermore assume that $A\leq B$ and $B\leq C$.
|
|
Since $A\leq B$, there is some total computable function $f:\Sigma_A^*\rightarrow \Sigma_B^*$.
|
|
And since $B\leq C$, there is some total computable function $g:\Sigma_B^*\rightarrow\Sigma_C^*$. Note that any total function is also a partial function over the same domain.
|
|
Now consider the following function $g\circ f:\Sigma_A^* \rightarrow \Sigma_C^*$. This function is computable, since the compositon of computable, partial functions is also a computable, partial function. In particular this holds for total functions. Additionally the following must hold: $x\in A\text{ iff. }g(f(x))\in C$. We distinguish two cases:\\
|
|
\textbf{Case 1:} If $x\not\in A$, then from $A\leq B$, $f(x)\not\in B$. Therefore, since $B\leq C$ we get that $g(f(x))\not\in C$.\\
|
|
\textbf{Case 2:} If $x\in A$, then, analogous to Case 1, $f(x)\in B$. It follows that since $B\leq C$, $g(f(x))\in C$.\\
|
|
Both cases are well defined because of the totality of $f$ and $g$ and $x\in A \text{ iff. } g(f(x))\in A$, given- $A\leq B$ and $B\leq C$.$\Box$
|
|
%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Using RT
|
|
%%%%%%%%%%%%%%%%%%%%%%
|
|
\textbf{Using Rice's Theorem:}
|
|
(1)$L=\{w\in\{0,1\}^*|M_w$\\$ \text{ computes unary func over nat nos which is undef on input 0}\}$ \emph{Sol:} Use RT with $\mathbf{S}=\{f\in\mathbf{R}|f:\mathbb{N}_0\rightarrow\mathbb{N}_0, f(0)=undef\}$
|
|
(2)$L = \{ w \in \{0,1\}^* \mid M_w \text{ halts on all inputs} \} $\emph{Sol:} RT not applicable, but if was asked to halt also in valid config, then use set of all total comp funcs.
|
|
(3)$L = \{ w \in \{0, 1, \}^* \mid M_w \text{ always halts after an even number of steps} \}$ \emph{Sol:} RT not app since even no of steps prop of computation, not computed func.
|
|
(4) $L = \{ w \in \{0, 1, \}^* \mid M_w \text{ computes the binary multiplication function } \text{mul} : \mathbb{N}_0^2 \rightarrow \mathbb{N}_0 \text{ with } \text{mul}(x, y) = x \cdot y \}$\emph{Sol:} RT applicable with $\mathbf{S}=\{mul\}$.
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Undecidability of emptyness problem
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\textbf{Undec if Emptiness problem:}\emph{Def:} Given general (type-0) grammar $G$, is $\l{G}=\empty$? \emph{Proof:} Use $\text{ComputesUndef} = \{ w \in \{0, 1\}^* \mid \text{DTM } M_w \text{ computes the partial function } \Omega \}$ $\Omega$ is part func undef on all input words. it is computable with DTM that always enters infinite loop. With $\mathbf{S}=\{\Omega\}$ and RT it is undec. Now $CompUndef\leq Emptyness$:
|
|
M:
|
|
Input $w \in \{0, 1\}^*$:
|
|
Sim $M_w$ on input $x$.
|
|
If the sim rejects or does not terminate, $M$ does the same.
|
|
If the sim of $M_w$ on $x$ accepts, $M$ then checks if the tape content
|
|
and head position correspond to a configu of a valid computation result.
|
|
If yes, $M$ accepts $x$; otherwise, it rejects.
|
|
$f(w) = \text{the grammar equivalent to the comp func from hint}$
|
|
where $f(w)$ computes $\Omega$
|
|
Redux $f$ is total and computable. And, it holds that
|
|
$w \in \text{ComputesUndef} \iff M_w$ computes $\Omega$
|
|
$\iff M$ does not accept any input
|
|
$\iff L(M) = \emptyset \iff L(f(w)) = \emptyset \iff f(w) \in \text{Emptiness}$
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
%% Nodeterministic Algos
|
|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
\textbf{HittingSet}\emph{G:} finit $U\not=\empty$, finite set of sets $S=\{S_1,..,S_n\},S_i\subseteq U \forall S_i\in S$, $k\in\mathbb{N}_0$ \emph{Q:}$\exists H\subseteq U, |H|\leq k, s.t. \ \S_i\cap H\not=\empty \forall S_i\in S$?
|
|
\textbf{HS G\& Check algo:} In: $U, S_i \ for \ i\in\{1,..,n\},k\then$ $rem:= S$; FOR $i=1$ TO $k$:\{ GUESS $e\in U$; $rem:= rem\setminus\{S_i|S_i\in S, e \in S_i\};$\} IF $rem==\empty$:\{ACCEPT;\} REJECT $\Box$
|
|
\textbf{SetPacking is NP-Compete:}
|
|
\emph{G:} fin set $M$, Set of Sets $\mathbf{S}=\{S_1,..,S_n\},S_i\subseteq M \forall i\in\{1,..,n\}$, $k\in\mathbb{N}_0$
|
|
\emph{Q:} \some $\mathbf{S}'\subseteq\mathbf{S}, |\mathbf{S}'|\geq k$ s.t. \any set in $\mathbf{S}' $ are pairwise disjoint.
|
|
\emph{SOL}(1) SetPacking is in NP: Input $S,k$: $\mathbf{S}' =\empty $; FOR $i=1$ TO $k$: \{ GUESS $S\in \mathbf{S}$; if $S\in\mathbf{S}'$: REJECT;
|
|
FOR $S'\in \mathbf{S} '$: \{ IF $S\cap S'$: REJECT\}; $\mathbf{S} ':= \mathbf{S} ' \cup \{S\}$ END;\} ACCEPT$\Box$
|
|
|
|
|
|
|
|
|
|
|
|
\end{multicols*}
|
|
\end{document} |