Docsity

Understanding Turing Machines: Definition, Configurations, and Variations, Study notes of Computer Science

Toggle sidebar
bg1
CS 273, Lecture 18
More on Turing Machines
25 March 2008
This lecture covers the formal definition of a Turing machine and related concepts such as
configuration and Turing decidable. It surveys a range of variant forms of Turing machines
and shows for one of them (multi-tape) why it is equivalent to the basic model.
1 A Turing machine
ATuring machine is a 7-tuple
(Q, Σ,Γ, δ, q0, qacc, qrej),
where
•Q: finite set of states.
•Σ: finite input alphabet.
•Γ: finite tape alphabet.
•δ:Q×Γ→Q×Γ× {L,R}.
•q0∈Qis the initial state.
•qacc ∈Qis the accepting /final state.
•qrej ∈Qis the rejecting state.
TM has a working space (i.e., tape) and its deterministic. It has a reading/writing head
that can travel back and forth along the tape and rewrite the content on the tape. TM halts
immediately when it enters the accept state (i.e., qacc) and then it accepts the input, or when
the TM enters the reject state (i.e., qrej), and then it rejects the input.
Example 1.1 Here we describe a TM that takes it input on the tape, shifts it to the right
by one character, and put a $ on the leftmost position on the tape.
So, let Σ = {a,b}(but the machine we describe would work for any alphabet). Let
Q={q0, qacc, qrej} ∪ nqcc∈Σo.
1
pf3
pf4
pf5

Partial preview of the text

Download Understanding Turing Machines: Definition, Configurations, and Variations and more Study notes Computer Science in PDF only on Docsity!

CS 273, Lecture 18

More on Turing Machines

25 March 2008

This lecture covers the formal definition of a Turing machine and related concepts such as configuration and Turing decidable. It surveys a range of variant forms of Turing machines and shows for one of them (multi-tape) why it is equivalent to the basic model.

1 A Turing machine

A Turing machine is a 7-tuple

(Q, Σ, Γ, δ, q 0 , qacc, qrej) ,

where

  • Q: finite set of states.
  • Σ: finite input alphabet.
  • Γ: finite tape alphabet.
  • δ : Q × Γ → Q × Γ × {L, R}.
  • q 0 ∈ Q is the initial state.
  • qacc ∈ Q is the accepting /final state.
  • qrej ∈ Q is the rejecting state.

TM has a working space (i.e., tape) and its deterministic. It has a reading/writing head that can travel back and forth along the tape and rewrite the content on the tape. TM halts immediately when it enters the accept state (i.e., qacc) and then it accepts the input, or when the TM enters the reject state (i.e., qrej), and then it rejects the input.

Example 1.1 Here we describe a TM that takes it input on the tape, shifts it to the right by one character, and put a $ on the leftmost position on the tape. So, let Σ = {a, b} (but the machine we describe would work for any alphabet). Let

Q = {q 0 , qacc, qrej} ∪

qc

∣ c^ ∈^ Σ

Figure 1: A TM that shifts its input right by one position, and inserts $ in the beginning of the tape.

Now, the transitions function is

∀s ∈ Σ δ(q 0 , s) = (qs, $, R) ∀s, t ∈ Σ δ(qs, t) = (qt, s, R) ∀s ∈ Σ δ(qs, ) = (qacc, $, R). δ(q 0 , ) = (qacc, $, R)

The resulting machine is depicted in Figure 1, and here its pseudo-code: Shift Tape Right At first tape position, remember character and write $ At later positions, remember character on tape, and write previously remembered character. On blank, write remembered character and halt accepting.

2 Turing machine configurations

Consider a TM where the tape looks as follows,

Tape: α^ b~^ β^... w w The read/write head

3 The languages recognized by Turing machines

Definition 3.1 For a TM M and a string w, the Turing machine M accepts w if there is a sequence of configurations C 1 , C 2 ,... , Ck,

such that

  • C 1 = q 0 w, where q 0 is the start state of M ,
  • for all i, we have Ci yields Ci+1 (using M transition function, naturally),
  • and Ck is an accepting configuration.

Definition 3.2 The language of a TM M (i.e., Turing machine M ) is

L(M ) =

w

∣ M^ accepts^ w

The language L is called Turing recognizable.

Note, that if w ∈ L(M ) then M halts on w and accepts it. On the other hand, if w /∈ L(M ) then either M halts and rejects w, or M loops forever on the input w. Specifically, for an input w a TM can either

  1. accept (and then it halts),

  2. reject (and then it halts),

  3. or be in infinite loop.

Definition 3.3 A TM that halts on all inputs is called a decider. As such, a language L is Turing decidable if there is a decider TM M , such that L(M ) = L.

The hierarchy of languages looks as follows:

Regular

Context free grammar Turing decidable Turing recognizable Not Turing recognizable.

4 Variations on Turing Machines

There are many variations on the definition of a Turing machine which do not change the languages that can be recognized. Well-known variations include doubly-infinite tapes, a stay-put option, non-determinism, and multiple tapes. Turing machines can also be built with very small alphabets by encoding symbol names in unary or binary.

4.1 Doubly infinite tape

What if we allow the Turing machine to have an infinite tape on both sides? It turns out the resulting machine is not stronger than the original machine. To see that, we will show that a doubly infinite tape TM can be simulated on the standard TM. So, consider a TM M that uses a doubly infinite tape. We will simulate this machine by a standard TM. Indeed, fold the tape of M over itself, such that location i ∈ [−∞, ∞] is mapped to location

h(i) =

2 |i| i ≤ 0 2 i − 1 i > 0.

on the usual tape. Clearly, now the doubly infinite tape becomes the usual one-sided infinite tape, and we can easily simulate the original machine on this new machine. Indeed, as long as we are far from the folding point on the tape, all we need to do is to just move in jumps of two (i.e., move L is mapped into move LL). Now, if we reach the beginning of the tape, we need to change between odd location and even location, but that’s also easy to do with a bit of care. We omit the easy but tedious details. Another approach would be to keep the working part of the doubly-infinite tape in its original order. When the machine tries to move off the lefthand end, push everything to the right to make more space.

4.2 Allow the head to stay in the same place

Allowing the read/write head to stay in the same place is clearly not a significant extension, since we can easily simulate this ability by moving the head to the right, and then moving it back to the left. Formally, we allow transitions to be of the form

δ(q, c) = (q′, d, S),

where S denotes the command for the read/write head to stay where it is (rewriting the character on the tape from c to d).

4.3 Non-determinism

This does not buy you anything, but the details are not trivial, and we will delay the discussion of this issue to later.

4.4 Multi-tape

Consider a TM that has k tapes, where k > 1 is a some finite integer constant. Here each tape has its own read/write head, but there is only one finite control. The transition function of this machine, is a function

δ : Q × Γk^ → Q × Γk^ × {L, R, S}k^ ,

and the initial input is placed on the first tape.

By doing this shift-right operation to all the dotted $’s, we end up with a new tape that is guaranteed to have enough space if we decide to write new characters to any of the k tapes of N. Its easy to now verify that we can now simulate N on this Turing machine M , which uses a single tape. In particular, any language that N recognizes is also recognized by M , which is a standard TM, establishing the claim.