BU CS 332 Theory of Computation Lecture 10: Reading: Turing - - PowerPoint PPT Presentation

bu cs 332 theory of computation
SMART_READER_LITE
LIVE PREVIEW

BU CS 332 Theory of Computation Lecture 10: Reading: Turing - - PowerPoint PPT Presentation

BU CS 332 Theory of Computation Lecture 10: Reading: Turing Machines Sipser Ch 3.1 3.2 TM Variants Mark Bun February 26, 2020 Turing Machines Motivation So far in this class weve seen several limited models of computation


slide-1
SLIDE 1

BU CS 332 – Theory of Computation

Lecture 10:

  • Turing Machines
  • TM Variants

Reading: Sipser Ch 3.1‐3.2

Mark Bun February 26, 2020

slide-2
SLIDE 2

Turing Machines – Motivation

So far in this class we’ve seen several limited models of computation Finite Automata / Regular Expressions

  • Can do simple pattern matching (e.g., substrings), check

parity, addition

  • Can’t recognize palindromes

Pushdown Automata / Context‐Free Grammars

  • Can count and compare, parse math expressions
  • Can’t recognize 𝑏𝑐𝑑 𝑜 0

2/26/2020 CS332 ‐ Theory of Computation 2

slide-3
SLIDE 3

Turing Machines – Motivation

Goal: Define a model of computation that is 1) General purpose. Captures all algorithms that can be implemented in any programming language. 2) Mathematically simple. We can hope to prove that things are not computable in this model.

2/26/2020 CS332 ‐ Theory of Computation 3

slide-4
SLIDE 4

A Brief History

2/26/2020 CS332 ‐ Theory of Computation 4

slide-5
SLIDE 5

1900 – Hilbert’s Tenth Problem

2/26/2020 CS332 ‐ Theory of Computation 5

David Hilbert 1862‐1943

Given a Diophantine equation with any number of unknown quantities and with rational integral numerical coefficients: To devise a process according to which it can be determined in a finite number of

  • perations whether the equation is

solvable in rational integers.

slide-6
SLIDE 6

1928 – The Entscheidungsproblem

2/26/2020 CS332 ‐ Theory of Computation 6

David Hilbert 1862‐1943

The “Decision Problem” Is there an algorithm which takes as input a formula (in first‐order logic) and decides whether it’s logically valid?

Wilhelm Ackermann 1896‐1962

slide-7
SLIDE 7

1936 – Solution to the Entscheidungsproblem

2/26/2020 CS332 ‐ Theory of Computation 7

Alonzo Church 1903‐1995 Alan Turing 1912‐1954

"An unsolvable problem of elementary number theory“ Model of computation: 𝜇‐calculus (CS 320) “On computable numbers, with an application to the Entscheidungsproblem” Model of computation: Turing Machine

slide-8
SLIDE 8

Turing Machines

2/26/2020 CS332 ‐ Theory of Computation 8

slide-9
SLIDE 9

The Basic Turing Machine (TM)

2/26/2020 CS332 ‐ Theory of Computation 9

Tape 𝑏 𝑐 𝑏 𝑏 Finite control …

  • Input is written on an infinitely long tape
  • Head can both read and write, and move in both

directions

  • Computation halts when control reaches

“accept” or “reject” state

Input

slide-10
SLIDE 10

0 → 0, 𝑆 ⊔ → ⊔, 𝑆

accept reject

0 → 0, 𝑆 ⊔ → ⊔, 𝑆

Example

𝑟0 𝑟1

slide-11
SLIDE 11

Example

0 → 0, 𝑆 ⊔ → ⊔, 𝑆

accept reject

0 → 0, 𝑆 ⊔ → ⊔, 𝑆 0 → 0, 𝑆 ⊔ → ⊔, 𝑀 𝑟0 𝑟1 𝑟3

slide-12
SLIDE 12

TMs vs. Finite / Pushdown Automata

2/26/2020 CS332 ‐ Theory of Computation 12

slide-13
SLIDE 13

Three Levels of Abstraction

High‐Level Description An algorithm (like CS 330) Implementation‐Level Description Describe (in English) the instructions for a TM

  • How to move the head
  • What to write on the tape

Low‐Level Description State diagram or formal specification

2/26/2020 CS332 ‐ Theory of Computation 13

slide-14
SLIDE 14

Example

Decide if

  • High‐Level Description

Repeat the following:

  • If there is exactly one in , accept
  • If there is an odd number of s in

, reject

  • Delete half of the s in

2/26/2020 CS332 ‐ Theory of Computation 14

slide-15
SLIDE 15

Example

Decide if

  • Implementation‐Level Description
  • 1. While moving the tape head left‐to‐right:

a) Cross off every other 0 b) If there is exactly one 0 when we reach the right end of the tape, accept c) If there is an odd number of 0s when we reach the right end of the tape, reject

  • 2. Return the head to the left end of the tape
  • 3. Go back to step 1

2/26/2020 CS332 ‐ Theory of Computation 15

slide-16
SLIDE 16

Example

Decide if

  • Low‐Level Description

2/26/2020 CS332 ‐ Theory of Computation 16

slide-17
SLIDE 17

Formal Definition of a TM

A TM is a 7‐tuple

  • is a finite set of states
  • is the input alphabet (does not include )
  • is the tape alphabet (contains

and )

  • is the transition function

…more on this later

  • is the start state
  • is the accept state
  • is the reject state (

)

2/26/2020 CS332 ‐ Theory of Computation 17

slide-18
SLIDE 18

TM Transition Function

means “move left” and means “move right” means:

  • Replace 𝑏 with 𝑐 in current cell
  • Transition from state 𝑞 to state 𝑟
  • Move tape head right

means:

  • Replace 𝑏 with 𝑐 in current cell
  • Transition from state 𝑞 to state 𝑟
  • Move tape head left UNLESS we are at left end of tape, in

which case don’t move

2/26/2020 CS332 ‐ Theory of Computation 18

slide-19
SLIDE 19

Configuration of a TM

A string with captures the state of a TM together with the contents of the tape

2/26/2020 CS332 ‐ Theory of Computation 19

slide-20
SLIDE 20

Configuration of a TM: Formally

A configuration is a string where and

  • Tape contents =

(followed by blanks )

  • Current state =
  • Tape head on first symbol of

2/26/2020 CS332 ‐ Theory of Computation 20

Example:

slide-21
SLIDE 21

How a TM Computes

Start configuration: One step of computation:

  • yields

if

  • yields

if

  • yields

if Accepting configuration: = Rejecting configuration: =

2/26/2020 CS332 ‐ Theory of Computation 21