-
Notifications
You must be signed in to change notification settings - Fork 7
/
chap3_TM3.tex
228 lines (191 loc) · 6.68 KB
/
chap3_TM3.tex
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
\input{header}
\AtBeginSubsection[]
{
\begin{frame}<beamer>
\frametitle{Outline}
\tableofcontents[current,currentsubsection]
\end{frame}
}
\begin{document}
\begin{frame}[allowframebreaks] \frametitle{Configuration of TM:}
\begin{itemize}
\item The current configuration means
\begin{center}
current state, tape contents, head location
\end{center}
\item $uqv$: $q$: current state
\item [] $uv$: current tape content
\item [] $u$: left, $v$: right
\item [] head: first of $v$
\end{itemize}\end{frame} \begin{frame}[allowframebreaks] \frametitle{Example of configuration}
\begin{itemize}
\item $a,b,c \in \Gamma, u,v \in \Gamma^*$ (i.e., strings from
$\Gamma$)
\item [] $q_i, q_j$: states
\item if $\delta(q_i,b) =(q_j, c, L)$
\begin{equation*}
uaq_i bv \mbox{ yields } uq_j a cv
\end{equation*}
\item if $\delta(q_i,b) = (q_j, c, R)$
\begin{equation*}
uaq_i bv \mbox{ yields } uacq_j v
\end{equation*}
\end{itemize}\end{frame} \begin{frame}[allowframebreaks] \frametitle{More about Configurations}
\begin{itemize}
\item start configuration: $q_0 w$
\item accepting configuration: $q_{accept}$
\item rejecting configuration: $q_{reject}$
\item A TM accepts $w$ if configurations
$c_1 \cdots c_k$
\begin{enumerate}
\item $c_1$: start configuration
\item $c_i$ yields $c_{i+1}$
\item $c_k$ accepting configuration
\end{enumerate}
\item Language: $L(M)$: strings accepted by $M$
\end{itemize}\end{frame}
\begin{frame}[allowframebreaks] \frametitle{Turing-recognizable}
\begin{itemize}
\item A language is Turing-recognizable if it is recognized by a TM
\item For a Turing machine, there are three possible outcomes
\begin{center}
accept, reject, loop
\end{center}
\item If an input fails: reject or loop
\item [] This is difficult to decide
\item We prefer a TM that never loops
\item [] Deciders: only accept or reject
\item A language is Turing-decidable if some TM decides it
\item In Chapter 4 we will discuss decidable languages
\end{itemize}\end{frame} \begin{frame}[allowframebreaks] \frametitle{Example 3.9}
\begin{itemize}
\item Consider the following language
\begin{equation*}
\{w\# w\mid w\in \{0,1\}^*\}
\end{equation*}
\item Fig 3.10
\end{itemize}
\begin{tikzpicture}
\node[state,initial left] (q_1) {$q_1$};
\node[state] (q_2) [below left of=q_1,yshift=0.7cm,xshift=-2.5cm] {$q_2$};
\node[state] (q_8) [below of=q_1,yshift=1cm] {$q_8$};
\node[state] (q_3) [below right of=q_1,yshift=0.7cm,xshift=2.5cm] {$q_3$};
\node[state] (q_4) [below of=q_2,yshift=1.2cm] {$q_4$};
\node[state] (q_a) [below of=q_8,yshift=1.2cm] {$q_a$};
\node[state] (q_5) [below of=q_3,yshift=1.2cm] {$q_5$};
\node[state] (q_6) [below of=q_a,yshift=1.3cm] {$q_6$};
\node[state] (q_7) [left of=q_6,xshift=0cm] {$q_7$};
\path
(q_1) edge[above] node {$0 \rightarrow$ x, R} (q_2)
(q_1) edge[right] node {$\# \rightarrow$ R} (q_8)
(q_1) edge[above] node {$1 \rightarrow$ x, R} (q_3)
(q_2) edge[loop above] node {0,1 $ \rightarrow $ R} (q_2)
(q_2) edge[right] node {$\# \rightarrow$ R} (q_4)
(q_8) edge[loop right] node {x $ \rightarrow $ R} (q_8)
(q_8) edge[right] node { $\sqcup \rightarrow $ R} (q_a)
(q_3) edge[loop above] node {0,1 $ \rightarrow $ R} (q_3)
(q_3) edge[left] node {$\# \rightarrow$ R} (q_5)
(q_4) edge[loop below] node {x $\rightarrow$ R} (q_4)
(q_4) edge[above] node {0 $\rightarrow$ x, L} (q_6)
(q_5) edge[loop below] node {x $\rightarrow$ R} (q_5)
(q_5) edge[above] node {1 $\rightarrow$ x, L} (q_6)
(q_6) edge[loop right] node {0, 1, x $\rightarrow$ L} (q_6)
(q_6) edge[below] node {$\# \rightarrow$ L} (q_7)
(q_7) edge[loop left] node {0, 1 $\rightarrow$ L} (q_7)
(q_7) edge[bend right=15, left] node {x $\rightarrow$ R} (q_1)
;
\end{tikzpicture}
\begin{itemize}
\item Links to $q_r$ are not shown
\item Simulate $01\#01$
\begin{center}
\begin{tabular}{llll}
$q_1 0 1 \# 01$ & $x q_2 1 \# 01$ & $x1 q_2 \# 01$ & $x1\# q_4 01$
\\
$x1 q_6 \# x 1$ & $x q_7 1 \# x 1$ & $ q_7 x 1 \# x 1$ & $x q_1 1 \# x 1$
\\
$xx q_3 \# x 1$ & $xx \# q_5 x 1$ & $xx \# x q_5 1$ & $xx \# q_6 xx$ \\
$xx q_6 \# xx$ & $x q_7 x \# xx$ & $xx q_1 \# xx$ & $xx \# q_8 xx$ \\
$xx \# xx q_8 \sqcup$ & $xx \# xx \sqcup q_a$ &&
\end{tabular}
\end{center}
\item Idea of the diagram:
\begin{equation*}
q_1 \rightarrow q_2 \rightarrow q_4 \rightarrow q_6
\end{equation*}
check 0 at the same position of the two strings
\begin{equation*}
q_1 \rightarrow q_3 \rightarrow q_5 \rightarrow q_6
\end{equation*}
check 1
at the same position of the two strings
\item $q_6$: move left to the beginning of the second string
\item $q_7$: move left by
\begin{equation*}
q_7 \xrightarrow{0, 1 \rightarrow L} q_7
\end{equation*}
until finding the first 0, 1 not handled yet:
\begin{equation*}
q_7 \xrightarrow{x \rightarrow R} q_1
\end{equation*}
\item Thus $q_6$ and $q_7$ cannot be combined. At $q_6$,
\begin{equation*}
x \rightarrow L
\end{equation*}
but at $q_7$
\begin{equation*}
x \rightarrow R
\end{equation*}
\end{itemize}
\end{frame}
\begin{frame}[allowframebreaks] \frametitle{Example 3.11}
\begin{itemize}
\item $C=\{a^i b^j c^k\mid i\times j=k, i,j,k \geq 1\}$
\item Procedure
\begin{enumerate}
\item check if the input is $a^+ b^+ c^+$
\item back to start
\item fix $a$, for each $b$, cancel $c$
\item store $b$ back, cancel one $a$, go to step 3
\end{enumerate}
\item Too complicated to draw state diagram
\item But one may wonder if TM can really do the above procedure
\item Here are more details
\item Step 1 can be done by a DFA (as DFA is a special case of TM)
\item Step 2 can be done by using a special symbol in the beginning
\item Step 3 is similar to the procedure of handling $w\#w$
\item [] Now we see the concept of subroutines
\end{itemize}\end{frame} \begin{frame}[allowframebreaks] \frametitle{Example 3.12}
\begin{itemize}
\item $E=\{\#x_1\# x_2 \cdots \# x_l\mid x_i \in
\{0,1\}^*, x_i \neq x_j\}$
\item Idea: sequentially compare every pair
\begin{equation*}
\begin{split}
& x_1 x_2, x_1 x_3, \ldots, x_1 x_l \\
& x_2 x_3, \ldots, x_2 x_l \\
& x_{l-1} x_l
\end{split}
\end{equation*}
\item This description is rough. Let's check more details
\item [] For $x_i, x_j$ mark \#'s of both strings
by $\dot{\#}$
\item [] $\dot{\#}x_1\#x_2 \dot{\#}x_3$: $x_1$ and $x_3$
being compared
\item Compare $x_i$ and $x_j$:
\item [] Can use a TM similar to that for $w \# w$
\item We can copy $x_i, x_j$ to the end
and do the comparison there
% $\dot{\#}x_1\dot{\#}x_2 \# x_3 \hat{\#}x_1
% \hat{\#}x_2$
% $\dot{\#}x\ldots x\dot{\#}x\ldots x \ldots \# x_3 \hat{\#}x_1
% \hat{\#}x_2$
% Copy $x_1,x_2$ back
% remove $\hat{\#}x_1
% \hat{\#}x_2$
\end{itemize}\end{frame}
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: