Top Banner
Turing Machines CS 105: Introduction to Computer Science
42

Turing Machines CS 105: Introduction to Computer Science.

Dec 22, 2015

Download

Documents

Tyrone Lane
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Turing Machines CS 105: Introduction to Computer Science.

Turing Machines

CS 105: Introduction to

Computer Science

Page 2: Turing Machines CS 105: Introduction to Computer Science.

Some Interesting Questions

What is a computer? What is computation? Are there problems that some computers

can solve but others can’t? Are there problems that no computer can

solve?

Page 3: Turing Machines CS 105: Introduction to Computer Science.

What is a Computer?

That’s a tough question. We want to talk about the fundamental

properties of computation. We need a model that captures the essential

and throws out the rest.

Page 4: Turing Machines CS 105: Introduction to Computer Science.

What is Computation?

Mapping an input to an output. For the sake of concreteness: mapping a

binary input to a binary output. Problems describe a particular mapping we

are interested in. Decision problems are a subset of all

problems - map from inputs to 0 or 1.

Page 5: Turing Machines CS 105: Introduction to Computer Science.

First model of computation:Finite State Automata…

A B

1

0

10

Page 6: Turing Machines CS 105: Introduction to Computer Science.

Finite State Automata

A fixed number of states. The machine moves from one state to

another in response to inputs. If it ends in an ACCEPT state it accepts,

otherwise it rejects. (We’re just considering decision problems for now.)

Let’s see some examples…

Page 7: Turing Machines CS 105: Introduction to Computer Science.

FSA Example

A B

1

0

10Triangle indicates start state.

Double circle indicates accepting state.

What happens on input 100101?

Page 8: Turing Machines CS 105: Introduction to Computer Science.

FSA Example

A B

1

0

10

100101

Page 9: Turing Machines CS 105: Introduction to Computer Science.

FSA Example

A B

1

0

10

100101

Page 10: Turing Machines CS 105: Introduction to Computer Science.

FSA Example

A B

1

0

10

100101

Page 11: Turing Machines CS 105: Introduction to Computer Science.

FSA Example

A B

1

0

10

100101

Page 12: Turing Machines CS 105: Introduction to Computer Science.

FSA Example

A B

1

0

10

100101

Page 13: Turing Machines CS 105: Introduction to Computer Science.

FSA Example

A B

1

0

10

100101

ACCEPT!

Page 14: Turing Machines CS 105: Introduction to Computer Science.

The Turing Machine

Problems with the FSA as a model of computation??

– Does an input string have matched parentheses? E.g., 01(0(10)101)110(1

With a slight modification we get the Turing machine.

First described in 1937 by Alan Turing

Page 15: Turing Machines CS 105: Introduction to Computer Science.

How does it work?

... Tape

Read/Write Head

Control DeviceCurrent State:Rules:

Page 16: Turing Machines CS 105: Introduction to Computer Science.

What can it do?

Write a character to the current tape cell Move Read/Write Head one cell to the left or

right Go into a new state

... Tape

Read/Write Head

Control DeviceCurrent State:Rules:

Page 17: Turing Machines CS 105: Introduction to Computer Science.

How does it decide what to do?

Behavior is based on: Input: the character in the current tape cell State: the current state

... Tape

Read/Write Head

Control DeviceCurrent State:Rules:

Page 18: Turing Machines CS 105: Introduction to Computer Science.

Let’s see one in action

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

1Rules:

1 0 0 1

Page 19: Turing Machines CS 105: Introduction to Computer Science.

What are current state and input?

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

1Rules:

1 0 0 1

Page 20: Turing Machines CS 105: Introduction to Computer Science.

Which rule will the TM follow?

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

1 0 0 1

1 1 | 1 R 1

1

Page 21: Turing Machines CS 105: Introduction to Computer Science.

Write to the tape

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

1 0 0 1

1 1 | 1 R 1

1

Page 22: Turing Machines CS 105: Introduction to Computer Science.

Move right or left

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

1 0 0 1

1 1 | 1 R 1

1

Page 23: Turing Machines CS 105: Introduction to Computer Science.

Go to new state: Done with rule

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

1 0 0 1

1 1 | 1 R 1

1

Page 24: Turing Machines CS 105: Introduction to Computer Science.

What are current state and input?

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

1Rules:

1 0 0 1

Page 25: Turing Machines CS 105: Introduction to Computer Science.

Which rule will the TM follow?

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

0 1

1 0 | 1 R 2

1

1 0

Page 26: Turing Machines CS 105: Introduction to Computer Science.

Write to the tape

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

0 1

1

1 0 | 1 R 2

1 1

Page 27: Turing Machines CS 105: Introduction to Computer Science.

Move right or left

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

0 1

1

1 0 | 1 R 2

1 1

Page 28: Turing Machines CS 105: Introduction to Computer Science.

Go to new state: Done with rule

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

0 1

2

1 0 | 1 R 2

1 1

Page 29: Turing Machines CS 105: Introduction to Computer Science.

What are current state and input?

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

1 0 1

2

1

Page 30: Turing Machines CS 105: Introduction to Computer Science.

Which rule will the TM follow?

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

1

2 0 | 1 R 2

1 0

2

1

Page 31: Turing Machines CS 105: Introduction to Computer Science.

Write to the tape

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

11

2 0 | 1 R 2

1

2

1

Page 32: Turing Machines CS 105: Introduction to Computer Science.

Move right or left

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

11

2 0 | 1 R 2

1

2

1

Page 33: Turing Machines CS 105: Introduction to Computer Science.

Go to new state: Done with rule

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

11

2 0 | 1 R 2

1

2

1

Page 34: Turing Machines CS 105: Introduction to Computer Science.

What are current state and input?

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

11 1

2

1

Page 35: Turing Machines CS 105: Introduction to Computer Science.

Which rule will the TM follow?

... Tape

Read/Write Head

Control DeviceCurrent State:

State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2

Rules:

11 1

2

1

Page 36: Turing Machines CS 105: Introduction to Computer Science.

Is the Turing Machine The Right Model?

The Church Turing Thesis:

– Any reasonable model of computation is equivalent to the Turing machine.

“Equivalence” here refers to what can be computed, not how fast it can be done.

Not something that can be proved.

Page 37: Turing Machines CS 105: Introduction to Computer Science.

Why do we believe it?

Every TM extension to make it “more powerful” (e.g., multiple-tape TMs) has been shown to be equivalent to the basic Turing Machine.

Other models of computation have been shown to be weaker (e.g., Finite State Machines) or equivalent.

Page 38: Turing Machines CS 105: Introduction to Computer Science.

What is the significance of the Church-Turing Thesis?

Church-Turing Thesis:

Anything you can do on any computer you can do with a Turing Machine.

So, no computer is more “powerful” (can compute more) than a TM.

Page 39: Turing Machines CS 105: Introduction to Computer Science.

Is my computer LESS powerful than a Turing Machine?

No. Given an infinite input device (infinite tape,

infinite number of floppies, infinite keyboard input), you can simulate a TM.

Therefore, anything that can be computed on a TM can be computed on your computer.

Page 40: Turing Machines CS 105: Introduction to Computer Science.

The Important Implication

If there’s anything that we CAN’T do with a Turing Machine

then ...

we can’t do it on any computer now or in the future.

Page 41: Turing Machines CS 105: Introduction to Computer Science.

Are there things we can’t compute on a Turing Machine?

YES

An Example: The Halting Problem

Page 42: Turing Machines CS 105: Introduction to Computer Science.

Last Words.

Turing machines are

– Hard to program.

– Easy to prove things about. If we can prove something about the

capabilities of Turing machines, we can immediately apply it to all computers.