Turing Machine properties There are many ways to skin a cat Turing - - PDF document

turing machine properties
SMART_READER_LITE
LIVE PREVIEW

Turing Machine properties There are many ways to skin a cat Turing - - PDF document

Turing Machine properties There are many ways to skin a cat Turing Machines And many ways to define a TM The books Standard Turing Machines Tape unbounded on both sides Deterministic (at most 1 move / configuration) TM


slide-1
SLIDE 1

1

Turing Machines

TM Variants and the Universal TM

Turing Machine properties

 There are many ways to skin a cat

 And many ways to define a TM

 The book’s “Standard Turing Machines”

 Tape unbounded on both sides  Deterministic (at most 1 move / configuration)  Tape acts as both input and output

 The books looks at a number of

“alternate” (and equivalent) definitions.

Alternate TM definitions

 Turing Machines with a “STAY” Option

 Allows the tape head to stay where it is

 δ: Q x Γ → Q x Γ x {R, L, S}  Basic TM defined in JFLAP

 TM with semi-infinite tape

 Tape is bounded on the left  Any attempt to go beyond this boundary will result

in halt and reject.

Alternate TM definitions

 Off-line TM

 TM with 2 tapes

 Read-only input tape  Read-write tape

 Input file + memory

 Non-deterministic TM

 Machine has a choice of moves

 δ: Q x Γ → 2 Q x Γ x {R, L}

 More on this next week.

Alternate TM definitions

 All of the alternate definitions are

equivalent to the standard TM

 I.e Given an alternate TM that accepts L,

  • ne can construct a standard TM that

accepts the same language.

Alternate TM definitions

 Multi-taped TMs

 Have multiple tapes  With a multiple tape heads that is read/

writing a different position on each tape at any one given time.

 δ: Q x Γn → Q x Γn x {R, L}n

 where n is #of tapes

slide-2
SLIDE 2

2

Turing Machine Variants Turing Machine Variants

 Multitape TM

 Move of a multitape TM

 Will depend upon:  The state of the machine  The symbol being read on all of the tape heads  Result:  Each of the tape heads will write a new symbol on

the tape

 Each of the tape heads will move left, right, or

stationery

 Tape heads can move independently.

Multitape TM

 Example

 {wwR | w is a string in {a,b}* }  Even length palandromes  2-tapes

 Step 1: Copy contents of tape 1 to tape 2  Step 2: position head of tape 1 at beginning of

tape and head of tape 2 at end

 Step 3: Compare strings character by character

Multitape TM

Questions?

Universal Turing Machine

 Universal Turing Machine

 A TM Mu that takes as input, an encoded version

  • f another TM M and an input w to M’.

 Mu will simulate the processing w on M’

 If M halts on input w, Mu will halt  If M rejects on input w,Mu will reject.

 Mu is a general purpose TM

 M is a program run on the general purpose TM

Universal Turing Machine

 Encoding scheme

 We need a way to encode a TM so that it can be

provided as input to Tu

 Define sets:

 Q = {q1, q2, … } = set of all possible states that may

appear in any TM

 S = {a1, a2, a3, …} = set of all possible tapes symbols

that can be written on any TM.

 So for any TM

 Q ⊆ Q and Γ ⊆ S

slide-3
SLIDE 3

3

Universal Turing Machine

 Assumptions

 q1 will always be the start state  There will only be 1 final state

 It will be q2  The machine always halts in q2

Universal Turing Machine

 Encoding scheme

 Associate states, symbols, and directions with

binary numbers:

 States:  s(qi) → 1i  Symbols  s(ai) → 1i  Directions:  s(L) → 1  s(R) → 11

Universal Turing Machine

 Encoding scheme

 Encoding transitions:

 Encode each state, symbol, direction  Separate by 0

 The transition δ (p,a) = (q, b, D) can be

encoded as:

 s(p)0s(a)0s(q)0s(b)0s(D)

Universal Turing Machine

 Encoding

 Encoding for a TM

 Encode each of it’s moves  Separate by 0’s

 e(T) = e(m1)0e(m2)0…0e(mk)0

Universal Turing Machine

 The input to Mu will be

 an encoded TM and  a string w to run on that TM  We encode x by individually encoding the

characters of x (separated by 1’s)

 x = z1z2…zn  e(x) = s(z1)0s(z2)0…0s(zn)0

Universal Turing Machine

 Encoding Scheme

 Finally, the description of the TM and the

encoding of the string to run on the TM will be separated by a blank

 Input to Mu  e(M) e(x)

slide-4
SLIDE 4

4

Universal Turing Machine

 Encoding example

 States

 q1 – state 1  q2 – state 2  q3 – state 3  q4 – state 4

 Symbols

 B – symbol 1  a – symbol 2  b – symbol 3

Universal Turing Machine

 Encoding example

 States

 q1 – state 1  q2 – state 2  q3 – state 3  q4 – state 4

 Symbols

 B – symbol 1  a – symbol 2  b – symbol 3

 Directions

 s(L) → 1  s(R) → 11

1 0 1 0 111 0 11 1 0

Universal Turing Machine

 Encoding scheme

 The actual scheme isn’t really important (in

fact, there are many)

 What is important is that we can encode a

TM and it’s input as a binary string.

 This encoding defines a unique “serial

number” to each TM

Universal Turing Machine

 The set of all TMs is countably infinite

 We can define a one-to-one and onto

function between the set of TMs and the set of natural numbers { 0, 1, 2, …}

 Uncountably infinite sets are larger than

countably infinite sets

Universal Turing Machine

 How it works

 3 tape TM

 Tape 1 – Working tape  Tape 2 – Input and output tape  Tape 3 – encoded form of the state that

machine being simulated is in

 Note that a 3 tape TM is equivalent to a

“basic” TM.

Universal Turing Machine

 How it works  On a single move,

 The symbol on each

tape is read

 The symbol on each

tape is written

 The tape head for

each tape is moved independently ... State Machine (program) Read head(s) ... ...

slide-5
SLIDE 5

5

Universal Turing Machine

 How it works

 When we start e(T) e(x) is on tape 1  Step 1: Move e(x) from tape 1 to tape 2

and delete from tape 1

 Tape 2: e(x)

 Step 2: Copy encoded initial state of T to

tape 3

 Tape 3: s(q1)

Universal Turing Machine

 How it works

 Step 3: Now simulation begins

 “read” and replace character on tape 2  “read” state on tape 3  “find” a transition in the encoded machine on

tape 1.

 Replace destination state onto tape 3  Replace character on tape 2.  Move head on tape 2 appropriately

Universal Turing Machine

 How will the machine finish?

 The TM being simulated has nowhere to go.

 Mu will never find a suitable transition

 The TM being simulated goes into an infinite loop

 Mu will continually simulate these moves

 The TM being simulated halts

 Mu will halt with halt state on it’s 3rd tape  Mu will copy the contents of Tape 2 to Tape 1

Universal Turing Machine

 Reality check: What have we done?

 Defined:

 A means to encode a TM as a binary string  Defines it’s “serial number”  Set of all TMs is infinitely countable  A Universal TM (Mu) that takes as input:  An encoded TM, M  An encoded input string, w  That will simulate the running of w on M

Questions?

 Next time (Monday):

 Languages and TMs  Godel, Escher, Bach!

 Next class:

 Exam 2