440 likes | 556 Views
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?. What is a Computer?.
E N D
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?
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.
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.
First model of computation:Finite State Automata… 0 1 1 A B 0
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…
FSA Example Triangle indicates start state. 0 1 1 Double circle indicates accepting state. A B 0 What happens on input 100101?
FSA Example 0 1 1 A B 0 100101
FSA Example 0 1 1 A B 0 100101
FSA Example 0 1 1 A B 0 100101
FSA Example 0 1 1 A B 0 100101
FSA Example 0 1 1 A B 0 100101
FSA Example 0 1 ACCEPT! 1 A B 0 100101
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
How does it work? ... Tape Read/Write Head Current State: Rules: Control Device
What can it do? ... Tape • Write a character to the current tape cell • Move Read/Write Head one cell to the left or right • Go into a new state Read/Write Head Current State: Rules: Control Device
How does it decide what to do? ... Tape Behavior is based on: • Input: the character in the current tape cell • State: the current state Read/Write Head Current State: Rules: Control Device
Let’s see one in action ... Tape 1 0 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2
What are current state and input? ... Tape 1 0 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2
Which rule will the TM follow? ... Tape 1 0 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 1 1 | 1 R 1
Write to the tape ... Tape 1 0 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 1 1 | 1 R 1
Move right or left ... Tape 1 0 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 1 1 | 1 R 1
Go to new state: Done with rule ... Tape 1 0 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 1 1 | 1 R 1
What are current state and input? ... Tape 1 0 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2
Which rule will the TM follow? ... Tape 1 0 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 1 0 | 1 R 2
Write to the tape ... Tape 1 1 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 1 0 | 1 R 2
Move right or left ... Tape 1 1 0 1 Read/Write Head Current State: 1 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 1 0 | 1 R 2
Go to new state: Done with rule ... Tape 1 1 0 1 Read/Write Head Current State: 2 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 1 0 | 1 R 2
What are current state and input? ... Tape 1 1 0 1 Read/Write Head Current State: 2 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2
Which rule will the TM follow? ... Tape 1 1 0 1 Read/Write Head Current State: 2 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 2 0 | 1 R 2
Write to the tape ... Tape 1 1 1 1 Read/Write Head Current State: 2 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 2 0 | 1 R 2
Move right or left ... Tape 1 1 1 1 Read/Write Head Current State: 2 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 2 0 | 1 R 2
Go to new state: Done with rule ... Tape 1 1 1 1 Read/Write Head Current State: 2 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 2 0 | 1 R 2
What are current state and input? ... Tape 1 1 1 1 Read/Write Head Current State: 2 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2
Which rule will the TM follow? ... Tape 1 1 1 1 Read/Write Head Current State: 2 Rules: Control Device State Symbol | Write Move State 1 1 | 1 R 1 1 0 | 1 R 2 2 0 | 1 R 2 No Rule: Done!
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.
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.
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.
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.
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.
Are there things we can’t compute on a Turing Machine? YES An Example: The Halting Problem
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.