18
Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Embed Size (px)

Citation preview

Page 1: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Transparency No. P3C1-1

Turing Machines

PART III

Turing Machines and Effective Computability

Page 2: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Transparency No. P3C1-2

Turing Machines

PART III Chapter 1

Turing Machines

Page 3: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-3

Turing machines

the most powerful automata (> FAs and PDAs ) invented by Turing in 1936can compute any function normally considered computableTuring-Church Theses:

Any thing (function, problem, set etc.) that is (though to be) computable is computable by a Turing machine (i.e., Turing-computable).

Other equivalent formalisms: post systems (string rewriting system) PSG (phrase structure grammars) : on strings -recursive function : on numbers -calculus, combinatory logic: on -term C, BASIC, PASCAL, JAVA languages,… : on strings

Page 4: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-4

Informal description of a Turing machine

1. Finite automata: limited input tape: one-way, read-only no working-memory finite-control store (program)

2. PDAs: limited input tape: one-way, read-only one additional stack as working memory finite-control store (program)

3. Turing machines (TMs): a semi-infinite tape storing input and supplying additional w

orking storage. finite control store (program) can read/write and two-way(move left and right) depengin o

n the program state and input symbol scanned.

Page 5: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-5

Turing machines and LBAs

4. Linear-bounded automata (LBA): special TMs the input tape is of the same size as the input length

(i.e., no additional memory supplied except those used to stor the input)

can read/write and move left/rigth dependign on the program state and input symbol scanned.

Primitive instructions of a TMs (like +,-,*, etc in C or BASIC):

1. L, R [, or S] // moving the tape head left or right

[or remain stationary]

2. a , // write the symbol a on the current scanned position

depending on

1. current state and

2. current scanned symbol

Page 6: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-6

left-end

x1 x2 x3 x4 x5 .. xn

input: x

….

additional working memory

.

.

.

.

accept final state

reject final state

current state

initial state

control store (program)

r/w & movable tape head

memory is a one-dimensional tape

permitted actions:1. read/write2. move left/rightdepending on scanned symbol and current state

The model of a Turing machine

no right-end for TM

Page 7: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-7

The structure of a TM instruction:An instruction of a TM is a tuple:

(q, a, p, b, d) Q x x Q x x {L,R [,S] }

where q is the current state a is the symbol scanned by the tape head(q,a) define a condition that the machine may encounter

(p,b,d) specify the actions that can be done by the TM once the machine is entering into the condition (i.e., the symbol scanned by the tape head is ‘a’ and the machine is at state q )

p is the next state that the TM will enter into b is the symbol to overwrite the symbol a on the tape pos cu

rrently scanned by the tape head. d is the direction in which the tape head will move one cell

A Determinitic TM program is simply a set of TM instructions (or more formally) a function: : Q x --> Qx x{L,R}

Page 8: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-8

Formal Definiiton of a standard DTM

A deterministic 1-tape Turing machine (STM) is a 9-tuple

M = (Q,,, , , , s, t,r ) where Q : is a finite set of (program) states liking labels in traditi

onal programs : tape alphabet : input alphabet The left end-of-tape mark is the blank tape symbol s Q : initial state t Q : the accept state r t Q: the reject state and : Q - {t,r} --> Qxx{L,R} is a total transition function with t

he restriction: if (p, ) =(q, b,d) then b = and d = R. i.e., the STM cannot overwrite other symbol at left-end and never move off the tape to the left.

Page 9: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-9

Configurations and acceptances

Issue: h/w to define configurations like those defined at FAs PDAs ?

At any time t0 the TM M contains a semi-infinite string of the form

Tape(t0) = y1y2…ym ….. (ym )Let denotes the semi-infinite string:

…..

Note: Although Tape is an infinite string, it has a finite representation: y where y = y1…ym ... . (not unique!)

A configuration of the TM M is a global state giving a snapshot of all relevant info about M’s computation at some instance in time.

Page 10: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-10

Formal definition of a configuration

Def: a cfg of a STM M is an element of

CFM =def Qx{y | y in } x N // N = {0,1,2,…} //

When the machine M is at cfg (p, z, n) it means M is

1. at state p

2. Tape head is pointing to position n and

3. the input tape contnet is z.

Obviously cfg gives us sufficient information to continue the execution of the machine.

Def: [Initial configuration:] Given an input x and a STM M,

the initial configuration of M on input x is the triple:

(s, x, 0)

Page 11: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-11

One-step and multi-step TM computations

one-step Turing computation ( |--M) is defined as follows:

|--M CFM2 s.t.

1. (p,z,n) |--M ? (q,snb(z), n-1) if (p,zn) = (q, b, L)

2. (p,z,n) |--M ? (q,snb(z), n+1) if (p,zn) = (q, b, R)

where snb(z) is the resulting string with the n-th symbol repl

aced by ‘b’. ex: s4

b(baaacabc…) = baabcabc...

|--M is defined to be the set of all pairs that can be included by the above two rules.

Notes:

1. if C=(p,z,n) |--M (q,y,m) and n 0 then m 0 (why?)

2. |--M is a partial function (i.e., if C |--M D & C |--M E then D=E).

3. define |--nM and |--M (ref. and tran. closure of |--M) as usual.

Page 12: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-12

accept and reject of TM on inputsx is said to be accepted by a STM M if

(s, x, 0) |--*M (t,y,n) for some y and n I.e, there is a finite computation

(s, x, 0) = C0 |--M C1 |-- M …. |--M Ck = (t,y,n)

starting from the initial configuration and ending at an accept configuration.

x is said to be accepted by a STM M if

(s, x, 0) |--*M (r,y,n) for some y and n

I.e, there is a finite computation (s, x, 0) = C0 |--M C1 |-- M …. |--M Ck = (t,y,n)

starting from the initial configuration and ending at a reject configuration.

Notes: 1. It is impossible that x is both accepted and rejected by a STM. (why ?)

2. It is possible that x is neither accepted nor rejected. (why ?)

Page 13: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-13

Languages accepted by a STM

Def:

1. M is said to halt on input x if either M accepts x or rejects x.

2. M is said to loop on x if it does not halt on x.

3. A TM is said to be total if it halts on all inputs.

4. The language accepted by a TM M,

L(M) =def {x in * | x is accepted by M, i.e., (s,x |--*M (t, -,-) }

5. If L = L(M) for some STM M

==> L is said to be recursively enumerable (r.e.)

6. If L = L(M) for some total STM M

==> L is said to be recursive

7. If * - L = L(M) for some STM M

==> L is said to be Co-r.e.

Page 14: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-14

Some examples

Ex1: Find a STM to accept L1 = { w # w | w {a,b}* }

note: L1 is not CFL.

The STM behaves as follows: on input z = w # w 1. if z is not of the form {a,b}* # {a,b}* => reject 2. move left until ‘[‘ is encountered and in that case move right 3. while I/P = ‘-’ move right 4. if I/P = a then 4.1 move right until # is encountered 4.2 while I/P = ‘-” move right 4.3 case (I/P) of { a : goto 2; o/w: reject } 5. if I/p = b then … // like 4.1~ 4.3 6. If I/P = # then // symbols left to # have been compared// 6.2 while I/P = ‘-” move right

6.3 case (I/P) of { : goto Accept; o/w: go to Reject }

Page 15: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-15

More detail of the STM

Step 1 can be accomplished as follows:

1.1 while (~# /\ ~ ) R;

if => reject // no # found on the input //

if # => R;

1.2 While ~# /\ ~ R;

if => accept [or goto 2 if regarded as a subroutine]

if # => Reject; // more than one #s found //

Step 1 require only two states:

Page 16: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-16

Graphical representation of a TM

R~# /\ ~

R#

tr

R~# /\ ~

R#

s

u

ACscnd

p qmeans: if (state = p) /\ (cond true for i/p) then 1. perform ACs and 2. go to qACs can be primitive ones: R, La,…or another subroutineTM M1.

Ex: the arc from s to s implies the existence of 4 instructions: (s, a, s,a, R), (s,b,s,b,R), (s,[,s,[,R), and (s,-, s,-,R)

Page 17: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-17

Tabular form of a STM

Translation of the graphical form to tabular form of a STM

[ a b # -

>s s,[,R S,a,R S,b,R u,#,R x r,x,x

u x u,a,R u,b,R r,x,x x u,#,R

tF halt halt halt halt halt halt

rF halt halt halt halt halt halt

X means don’t care

The rows for t & r indeed need not be listed!!

Q

Page 18: Transparency No. P3C1-1 Turing Machines PART III Turing Machines and Effective Computability

Turing Machines

Transparency No. P3C1-18

The complete STM accepting L1