Docsity

INTRODUCTION TO TURING MACHINES, Lecture notes of Theory of Automata

Partial preview of the text

Download INTRODUCTION TO TURING MACHINES and more Lecture notes Theory of Automata in PDF only on Docsity!

Turing Machines

Introduction to Turing Machine

Intro to Turing Machines

  • A Turing Machine (TM) has finite-state control (like PDA), and an infinite read-write tape. The tape serves as both input and unbounded storage device.
  • The tape is divided into cells , and each cell holds one symbol from the tape alphabet.
  • There is a special blank symbol B. At any instant, all but finitely many cells hold B.
  • Tape head sees only one cell at any instant. The contents of this cell and the current state determine the next move of the TM.

Moves

  • A move consists of:
    • replacing the contents of the scanned cell
    • repositioning of the tape head to the nearest cell

on the left, or on the right

  • changing the state
  • The input alphabet is a subset of the tape alphabet. Initially,

the tape holds a string of input symbols (the input ), starting on the left of the tape, with in infinite sequence of blanks to the right (after the input). The initial position of the head is the leftmost symbol.

Formal Definition

  • A TM is a 7-tuple M=(Q,Σ,Γ,δ,q 0 ,qaccept,qreject), where
    1. Q is a finite set of states
    2. Σ is the input alphabet (does not contain B the blank symbol)
    3. Γ is the tape alphabet, where
      1. Σ ⊆ Γ (the input alphabet is a subset of the tape alphabet)
      2. B ∈Γ (Blank is in the tape alphabet)
    4. q0 ∈ Q is the start state
    5. Q (^) accept ∈ Q is the accepting state
    6. Q (^) reject ∈ Q is the rejecting state
    7. δ : Q × Γ → Q × Γ × {L,R} is a partial function. The value of δ (q,X) is either undefined, or is a triple consisting of the new state, the replacement symbol, and direction (left/right) for the head motion.

δ(p,X) = (q,X,R) for X=0, δ(q,X) = (r,X,R) for X=0, δ(r,0) = (s,0,L) δ(r,1) = (t,1,R) δ(t,X) = (t,X,R) for X=0,1,B

Transisition Diagrams for TM

  • Pictures of TM can be

drawn like those for

PDA's. Here's the TM

of the example

below.

Implicit Assumptions

• Input is placed on tape in contiguous block of

cells (all the way to the left)

• All other cells to the right are blank: ‘B’

• Tape head positioned at Left of input block

• There is one start state

• The text uses a single accepting and rejecting

state, an alternative is to have many such states.

These are equivalent, why?

Example 3: { a

n

b

n

c

n

| n ≥ 0}

delta = (0,a,X,R,1) Replace a by X and scan right (0,Y,Y,R,0) Scan right over Y (0,Z,Z,R,4) Scan right over Z, but make final check (0,^,^,S,H) Nothing left, so its success (1,a,a,R,1) Scan right looking for b, skip over a (1,b,Y,R,2) Replace b by y, and scan right (1,Y,Y,R,1) scan right over Y (2,c,Z,L,3) Scan right looking for c, replacxe it by Z (2,b,b,R,2) scan right skipping over b (2,Z,Z,R,2) scan right skipping over Z (3,a,a,L,3) scan left looking for X, skipping over a (3,b,b,L,3) scan left looking for X, skipping over b (3,X,X,R,0) Found an X, move right one cell (3,Y,Y,L,3) scan left over Y (3,Z,Z,L,3) scan left over Z (4,Z,Z,R,4) Scan right looking for ^, skip over Z (4,^,^,S,H) Found what we’re looking for, success!

tape alphabet = a,b,c,^,X,Y,Z input alphabet = a,b,c start = 0 blank = ‘^ ' final = H

aabbcc

Xabbcc

XaYbcc

XaYbZc

XXYbZc

XXYYZc

XXYYZZ

Example Implementation level

• { 0 2^n^ | n ≥ 0}

• Stages

1. Sweep left to right across the tape. Crossing off
every other 0
2. If in stage 1, the tape conatined a single 0, accept
3. If in stage 1, the tape contained more than a single
0, and the number of 0’s was odd, reject
4. Return the head to the left-hand end of the tape
5. Goto stage 1.

What is important

• We seek to convince the student that Turing

machines are a powerful tool to describe

algorithms

• The full set of details is often too complex to

describe completely, because the details do

not add to our understanding.

• But, we could use our high level descriptions

to complete the formal description if we

desired.

Adding two to a number in unary

TM Q {0, 1, H, R}

Sigma {1} Gamma {1, ^} Delta 0 1 -> (1, R, 0) 0 ^ -> (1, R, 1) 1 ^ -> (1, S, H) q0 0 Accept H Reject R Blank ^

Adding 1 to a Binary Number

TM Q {0, 1, 2, H, R} Sigma {1, 0, ^} Gamma {1, 0, ^} Delta 0 0 -> (0, R, 0) 0 1 -> (1, R, 0) 0 ^ -> (^, L, 1) 1 0 -> (1, L, 2) 1 1 -> (0, L, 1) 1 ^ -> (1, S, H) 2 0 -> (0, L, 2) 2 1 -> (1, L, 2) 2 ^ -> (^, R, H) q0 0 Accept H Reject R Blank ^

^1011^ ^1010^ ^1000^ ^1100^

Configurations (Sipser pg. 140)

  • configurations for TM's are strings of the form α q β , where α, β ∈ Γ^ and q ∈ Q. (Assume that Q and Γ^ are disjoint sets, guaranteeing unique parsing of configurations.)
  • The string α represents the tape contents to the left of the head.
  • The string β represents the non-blank tape contents to the right of the head, including the currently scanned cell.
  • Adding or deleting a few blank symbols at the beginning or end of an confiuration results in an equivalent configuartion. Both represent the same instant in the execution of a TM.

Sipser terminology

• Other authors call configurations

instantaneous descriptions

• Starting Configuration

• Accepting Configuration

• Rejecting Configuration

Both of these are halting configurations