Turing Machines string x, will be left on the tape when the machine - - PDF document

turing machines
SMART_READER_LITE
LIVE PREVIEW

Turing Machines string x, will be left on the tape when the machine - - PDF document

Computation with Turing Machines Computing functions with TMs The result of the function applied to an input Turing Machines string x, will be left on the tape when the machine halts. Note: it doesnt matter if the machine halts


slide-1
SLIDE 1

1

Turing Machines

Computation and programming

Computation with Turing Machines

  • Computing functions with TMs

– The result of the function applied to an input string x, will be left on the tape when the machine halts.

  • Note: it doesn’t matter if the machine halts in a final

state.

– Functions with multiple arguments can be placed on the input tape with arguments separated by some character.

Computation with Turing Machines

  • Turing’s original use of his machine was to

calculate integer valued functions.

– Integers were represented in unary as blocks of a single symbol. – Example

  • 000000 would represent 6
  • 0000 would represent 4

– In our text

  • 0s are used as the unary symbol
  • 1s are used to separate arguments

Computation with Turing Machines

  • Computing functions with TMs

– Formally,

  • Let M = (Q, Σ, Γ , δ, q0, B, F) be a TM and let f be a

partial function on Σ*. We say T computes f if for every x ∈ Σ* where f is defined:

– q0x a* pf(x)

  • And for every other x, T fails to halt on input x.

Computation with Turing Machines

  • Computing functions with TMs

– Formally (with multiple arguments)

  • Let M = (Q, Σ, Γ , δ, q0, B, F) be a TM and let f be a

partial function on (Σ*) k. We say T computes f if for every (x1, x2. …, xk) where f is defined:

– q0x1 1x2… 1xk a* pf(x1, x2. …, xk)

  • And for every other k-tuple, T fails to halt on input

x.

Computation with Turing Machines

  • Example

– Proper subtraction:

  • m – n = max (m-n, 0)
  • Use 0 as unary symbol
  • M will start with 0m10n
  • M will halt with 0(m-n) on it’s tape
slide-2
SLIDE 2

2

Computation with Turing Machines

  • Example

– Proper subtraction:

  • Basic idea:

– Finds leftmost 0 and replaces with blank, – Finds first 1 – Finds first 0 after 1, replaces with a 1. – Repeat until » When searching for first 0 after the 1 it doesn’t find it » Cannot find leftmost 0.

Computation with Turing Machines

  • Proper subtraction

Computation with Turing Machines

  • Questions?

Combining Turing Machines

  • Suppose an algorithm has a number of tasks

to perform

– Each task has its own TM

  • Much like subroutines or functions

– They can be combined into a single TM

  • T1T2 is the composite TM
  • T1 → T2

Combining Turing Machines

  • Composite TMs

– T1T2

  • Start at start state of T1
  • For any move that causes T1 to enter the halt state,

have T1 move to the start state of T2.

  • So T2 will get executed immediately after T1 as long

as T1 will halt on a given input.

– Allows one to define subroutines.

Let’s try a non-context free language

slide-3
SLIDE 3

3

Combining Turing Machines

  • Useful “subroutines”

– Copy TM

  • Creates a copy of a “block” of 0s to the right of the input

– 0i1q10n10j a* 0i1q50n10j+n

  • Basic idea

– Marks first 0 with an X – Move right to first blank and write a 0 – Move left until X is found – Repeat until all 0’s are converted to X – When finished, coverts Xs back to 0s.

Combining Turing Machines

  • Copy TM
  • See in action

Combining Turing Machines

  • Useful “subroutines”

– Something to note

  • The TM must be set up to be in the correct

configuration before delete is “called”

  • I.e. the tape head must be at the character to be

deleted.

– Questions?

Computation with Turing Machines

  • Characteristic function of a set:

– For any language L, the characteristic function is defined as:

  • 1 if x ∈ L
  • 0 otherwise

– If a TM computes the characteristic function of a language, it will always halt with either a 1 or 0 left on the tape

  • This is stronger than saying that x is accepted by the TM since

if x ∉ L, for a TM that accepts L, there is no guarantee that the the machine will halt.

Turing Machine Variants

  • Some variants of the TM

– Multitaped TMs

  • Have multiple tapes
  • With a multiple tape heads that is read/writing a

different position on each tape at any one given time.

Turing Machine Variants

slide-4
SLIDE 4

4

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 Multitape TM

  • Let’s go to the video tape

Turing Machine Variants

  • Multitape TM

– Thankfully, the multiTape TM can be shown to be equivalent to the “vanilla” TM.

  • You can simulate the workings of a multitape TM
  • n a single tape TM.
  • See Theorem 8.9 in text.

Turing Machine Variants

  • Some other variants of the TM

– Non-deterministic TMs

  • More than 1 move is possible from any given

configuration.

slide-5
SLIDE 5

5

Turing Machine Variants

  • Some variants of the TM

– Semi-infinite TM

  • What some books calls the “basic” TM.
  • Input tape is bounded on the left

Turing Machine Variants

  • Thankfully, all these variants can be shown

to be equivalent to the “basic” TM.

– Specifically, non-determinism does not add extra computing power to a TM

  • Much like FAs
  • But unlike PDAs

– Multitape TMs will be handy in future lectures.

  • No better or worse than the basic TM.

Summary

  • Turing Machines
  • Computation on TMs
  • Subroutines
  • TM variants

– Non-deterministic – Multitape TM

  • Questions

To come

  • Next time:

– The classes of languages associated with TMs – Chomsky Heirarchy.