Turing Machines 9-0 Turing Machines Now for a machine - - PDF document

turing machines
SMART_READER_LITE
LIVE PREVIEW

Turing Machines 9-0 Turing Machines Now for a machine - - PDF document

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Sndergaard of The University of Melbourne) Turing Machines 9-0 Turing Machines Now for a machine model of much greater power. A


slide-1
SLIDE 1

✬ ✫ ✩ ✪ Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne)

Turing Machines

9-0

slide-2
SLIDE 2

✬ ✫ ✩ ✪

Turing Machines

Now for a machine model of much greater power. A Turing machine has an infinite tape through which it takes its input and performs its computations. tape head state control b a a infinite tape

  • Unlike a finite automaton it can
  • both read from and write to the tape, and
  • move either left or right over the tape.

The tape is infinite. The machine has both accept and reject states, in which it accepts/rejects irrespective of where its tape head is.

9-1

slide-3
SLIDE 3

✬ ✫ ✩ ✪

Turing Machines Formally

A Turing machine is a 7-tuple M = (Q, Σ, Γ, δ, q0, qa, qr) where

  • Q is a finite set of states,
  • Γ is a finite tape alphabet, which includes the

blank character, ,

  • Σ ⊆ Γ \ {

} is the input alphabet,

  • δ : Q × Γ → Q × Γ × {L, R} is the transition

function,

  • q0 is the initial state,
  • qa is the accept state, and
  • qr (= qa) is the reject state.

9-2

slide-4
SLIDE 4

✬ ✫ ✩ ✪

The Transition Function

A transition δ(qi, x) = (qj, y, d) depends on two things

  • 1. current state qi, and
  • 2. current symbol x under the tape head

It consists of three actions

  • 1. change state to qj,
  • 2. over-write tape symbol x by y, and
  • 3. move the tape head in direction d.

We can have a graphical notation for Turing machines similar to that for finite automata. On an arrow from qi to qj we write

  • x → d when δ(qi, x) = (qj, x, d), and
  • x → y, d when δ(qi, x) = (qj, y, d), y = x.

9-3

slide-5
SLIDE 5

✬ ✫ ✩ ✪

Example Turing Machine

  • q0

a→R b→R

  • →R
  • q1

a→R b→R

  • →R
  • qa
  • qr

This machines recognises the regular language (a ∪ b)∗aa(a ∪ b)∗. We can leave qr out with the understanding that transitions that are not specified go to qr.

9-4

slide-6
SLIDE 6

✬ ✫ ✩ ✪

Turing Machine Configurations

We write uqv for this configuration: q u v blank On input aba, the example machine goes through these configurations: ǫq0aba (or just q0aba) ⊢ aq1ba ⊢ abq0a ⊢ abaq1

aba qr We read the relation ‘⊢’ as “yields”.

9-5

slide-7
SLIDE 7

✬ ✫ ✩ ✪

Computations Formally

For all qi, qj ∈ Q, a, b, c ∈ Γ, and u, v ∈ Γ∗, we have uqibv ⊢ ucqjv if δ(qi, b) = (qj, c, R) qibv ⊢ qjcv if δ(qi, b) = (qj, c, L) uaqibv ⊢ uqjacv if δ(qi, b) = (qj, c, L) The start configuration of M on input w is q0w. M accepts w iff there is a sequence of configurations C1, C2, . . . , Ck such that

  • 1. C1 is the start configuration q0w,
  • 2. Ci ⊢ Ci+1 for all i ∈ {1 . . . k − 1}, and
  • 3. The state of Ck is qa.

9-6

slide-8
SLIDE 8

✬ ✫ ✩ ✪

Turing Machines and Languages

The set of strings accepted by M is the language

  • f M, L(M).

A language A is Turing-recognisable (or computably enumerable, or just c. e.) iff A = L(M) for some Turing machine M. Three behaviours are possible for M on input w: M may accept w, reject w, or fail to halt. If A is recognised by a Turing machine M that halts on all input, we say that M decides A. A language is Turing-decidable (or computable, or just decidable) iff some Turing machine decides it.

9-7

slide-9
SLIDE 9

✬ ✫ ✩ ✪

Turing Machine Example 2

This machine decides the language {02n | n ≥ 0}. It has input alphabet {0} and tape alphabet { , 0, x, #}.

  • q0

0→#,R

  • q1

0→x,R x→R

  • →R
  • q2
  • →L
  • 0→R

x→R

  • q3

x→R

  • 0→x,R
  • qa
  • q4

#→R

  • 0→L

x→L

  • Running the machine on input 000:

q0000 ⊢ #q100 ⊢ #xq20 ⊢ #x0q3

#x0 qr

9-8

slide-10
SLIDE 10

✬ ✫ ✩ ✪

Turing Machine Example 2 (cont.)

This machine decides the language {02n | n ≥ 0}. We can describe how this machine operates as follows: M2 = “On input string w:

  • 1. Read tape from left to right crossing off every

second 0.

  • 2. If the tape contained a single 0, accept.
  • 3. If the tape contained another odd number of

0s, reject.

  • 4. Return to the left of the tape.
  • 5. Go to step 1.”

9-9

slide-11
SLIDE 11

✬ ✫ ✩ ✪

Turing Machine Example 3

This machine decides the language {aibjck | k = i · j, i, j > 0}. The tape alphabet is { , a, b, c, A, B, C}.

  • a→A,R
  • a→L
  • A→R
  • b→R
  • C→R
  • b→B,R
  • a→R
  • B→R
  • b→L
  • a→L
  • A→R
  • B→b,L
  • →L
  • C→R
  • c→C,L

b→R C→R

  • b→L
  • B→b,L
  • C→L
  • qa

9-10

slide-12
SLIDE 12

✬ ✫ ✩ ✪

Turing Machine Example 3

This machine decides the language {aibjck | k = i · j, i, j > 0}. The machine operates as follows: M3 = “On input string w:

  • 1. Cross off the first a, and scan to the right for

the first b. Alternately cross off the first b and the first c until all bs are gone.

  • 2. Move left to the last crossed-off a, restoring

the crossed-off bs. If there is another a, return to step 1. Otherwise, move right past all crossed-off bs and cs. If no c’s remain, accept, else reject.”

9-11

slide-13
SLIDE 13

✬ ✫ ✩ ✪

Robustness of Turing Machines

Other textbooks have definitions of Turing machines that differ slightly from Sipser’s. Some differences are technical and aim at making the machines easier to program (for example, we may insist that machines start with a tape that has the first cell blank, and they try to leave that cell blank—to make it easier to compose machines). Similarly, in addition to the two kinds of tape movement, we can allow a ‘no move’ option. Turing machines are robust in the sense that such changes to the machinery does not effect what the machines are capable of computing. In the next lecture we’ll see that the robustness of Turing machines goes well beyond that.

9-12

slide-14
SLIDE 14

✬ ✫ ✩ ✪

Functionality of Turing Machines

We can also decide that a Turing machine produces output (not just accept/reject) through its tape. This means that Turing machines can be general computing devices, not just language recognisers. We can capture data other than strings through suitable representations. For example, natural numbers can be represented as strings of (unary, binary, decimal, . . . ) digits, so a Turing machine can compute number theoretic functions N → N. Or, by suitable encoding, they can take multiple arguments, and/or return multiple results. Turing machines can also solve graph problems,

  • nce we decide on a suitable representation for

graphs.

9-13