Theory of Computation: ND Hung
Theory of Computation: ND Hung
ND HUNG
2 Combining TMs
3 Recursive languages
4 Recursive Functions
the set
. .
loop.
atsee
- -
D
never
onto
writes down
the memory
.
OnlyaHart anysnot A
ND HUNG (ICT, SIIT) Chapter 4: Turing Machines October 10, 2021 4 / 26
Turing Machines (TM)
h : halting state
transition &1 J
↓
"
D/
-
-
,
aa a a
↓ (g ,
Daaca) [D/)
↓ (gI , Dana) [a/W]
↓
(00 DWaaa) [r/-)
,
a)
w/r
Do-
68 h
0
2
DI-
cursor
input
q (q, ) M accepts aa: string
s t (q0 , !) ↓ &
.
Z
&
- (s, .taa) `M (q0 , taa) `M
q0 t (y, t) 24 - -
>
-
(q1 , taa) `M (q0 , taat) `M
q0 a (q1 , !)
M
1
(y , taat) sop/LT
q0 b
z
(q1 , !)
q1 t (n, t) M rejects a:
q1 a (q0 , !)
Z
(s, .ta) `M (q0 , ta) `M
q1 b (q0 , !) (q1 , tat) `M (n, tat)
2
STOP
/HALT
ND HUNG (ICT, SIIT) Chapter 4: Turing Machines October 10, 2021 7 / 26
Turing Machines (TM)
For eDra,
K ⇥ .⌃⇤ ⇥ (⌃⇤ ⇥ (⌃ {t}) [ {e})
Definition
-
empty strings
DLet (q1 , !1 a1 u1 ) and (q2 , !2 a2 u2 ) be configurations of M. Then
it. we can
ignore
(q1 , !1 a1 u1 ) `M (q2 , !2 a2 u2 )
D - i m RHS
Definition
2. b = , !1 = !2 a2 , and either
a. u2 = a1 u1 , if a1 6= t or u1 6= e, or
b. u2 = e, if a1 = t and u1 = e
3. b =!, !2 = !1 a1 , and either
a. u1 = a2 u2
b. u1 = u2 = e and a2 = t
(p Dabc)
,
p ,
Dab
Dah Du
·
IS ,
,
be the
same
-
Lt : Finds the first blank square to the left of the currently scanned
symbol (p Dw abcdWefg) +in (p X Wabed Lefg)
, ,
Rt : Finds the first blank square to the right of the currently scanned
symbol (p DWabedWefgWhij) thr
,
textbook (p D WabedLefgWhij)
,
YAAD
-
Recursive languages
re
defined 81
.
Lang rec can be as a recursive
-
An initial configuration is of the form (s, .t!) recursive
algo ,
Definition
Given is a Turing machine M = (K , ⌃, , s, H) with H = {y, n}. Any
halting configuration whose state is y is said to be an accepting (y ) . -
Recursive languages do
ALT
-M
has .
M tell if it
*
Deciding : can
Definition
accepts/rejects an input string.
Let ⌃0 ✓ ⌃ {t, .} be an alphabet, called input alphabet. We say
that M decides a language L ✓ ⌃⇤0 if for any string ! 2 ⌃⇤0 ,
If ! 2 L then M accepts !
If ! 62 L (i.e. ! 2 ⌃⇤0 L) then M rejects !
A language L is called recursive if it is decided by some Turing
machine.
Note: if TM M decides a language L ✓ ⌃⇤0 , then M halts on any ! 2 ⌃⇤0 ,
but M is not required to halt on ! 2 ⌃⇤ ⌃⇤0 (see supplementary note
for further discussion)
Recursive languages
Example: Show that L0 = {an bn | n 0} is recursive.
(s Dabb) in it config aabb
,. t dabb `d
.
. t dadb `d
↑
a .tdadb `Lt
. t dadb `R
+ a b b
. t dadb `d
=>
-
. t dddb `R
b
. t dddb `R +
. t dddb `d
a
Sample run: *
~.taabb `
R
. t dddd `Lt + o of $
-. t aabb `d .tdddd `R *
. t dabb `R . t dddd `⇤R -
Y. t dabb `R D . t ddddt `y
D . t ddddt
Recursive languages
- -
oo
Dr aabbxx
Recursive languages
(g -)
w
=
,
-
>
scan through
- make state trans .
Modern comp
:
We treat math &1 as
M
Let M = (K , ⌃, , s, {h}), ⌃0 ✓ (⌃ {t, .} and ! 2 ⌃⇤0 . If
, , , , , ...
Recursive Functions
Example: Show that succ(n) = n + 1 and d(n) = 2n are recursive
functions. succ(101) 110 =
0
= 1
D 0
R⊔ L 1 L⊔
L
D ↑
⊔
Me Sa
1 S! L ⊔
Revised
tru
I
DLI01
the shift-right machine
-
*
+ DW/10
ND HUNG (ICT, SIIT) Chapter 4: Turing Machines October 10, 2021 19 / 26
Recursively Enumerable Languages
↑
answer ,
3 Nondeterministism : transition f -
> tranation rel1
We focus on the multi-tape extension.
Definition
A k-tape Turing machine is a 5-tuple M = (K , ⌃, , s, H) where
statiodnetaaa
=
states
Take a
-
>
u
memory
next operation
cuw ,
y/o answer
WCW
abaa
-
c
ama
F
the power of the machines.
if and only if
L go left
3 of questions
type
R go right
① Compute arithmatic
functions :
E misd
f(n)-dif
s
R
qwEZ /num)
*
L =
Arithmicinitialth
# 2
# f(n)
contain
- In
-n
&3 f(m) = 2n +
3 @f(n) = n + 1 : mis var
len
Dr0100 + DW0101
.
& f(u)
-
= So *
D201011 D 2011
A
D41111 + D41004
25 f(a ,
b) = a + b
DLGD
L
Dr10000
Dr1d90
Espe
2
Sh misod
t
& flul =
Sh mise
s
& ful =
Tum
3
Q an yu *
(g Daabb)
.
+ (y ,
D ...
)
*
* (go Draab) + (n Dr )
an yo ,
Q2
...
n , ,
&3 an bncamym
anywanyn
I
Multi-tape Turing Machine
(M go left
Ru go right
Idea
-
temporary variables
"
③ Config :
>
Drop
ri
the take
simp :
- Trt
1
. Split the input arguments in the main tape.
Iman -
1
. Scand to tefts to find next W 4 Read t all
. .
writed y
.
2 Moved to teHS for I cell .
If not W
,
write it
?
KHS
More
move
.
3 to teHS for I cell
.
moved tells
1 2
go to 4
.
Otherwise scan
,
to LHS for L
,
2 .
Copy the
string in the main tape to the extra one .
aa
1
. Moved 200 RHS
,
.
2 Read" all
?
If not W write it
,
L
to 1
go
Otherwise scanti to LHS to find W
,
Create of the the
.
3 a reversed
capy string in
a
1
. Scan" to RHS to find W DRY-- > REir
.
2
3
.
More' to LHS
Move
?
to RHS
&
4 .
Read" all
If not W write? it
,
to 2
go
2
Otherwise scan to LHS
,
4 Check if the input is the WWWR .
.
etring in
language
Use to create wh before
the extra tape comparing
the second part of the string
.
F * second part
+
-
MOD
* RE'Ro rlf- Rhiz
42 MID ?
xt =
y -
-
create a
where return
reversed
copy x = W
-
compare
rymbd
each