Lecture11 Abstract Machines Theory
Lecture11 Abstract Machines Theory
CSCI 109
China – Tianhe-2
Andrew Goodney
Fall 2017
1
Abstract machines and theory
u What is theoretical computer
science?
u Finite state machines
2
What is theoretical computer science?
3
Finite state machines
Up
Fed
Crying Asleep
On
Hungry
Down Up More
Hungry
hungry
Awake,
Off not
crying
Down
https://vimeo.com/46913004
8
Alan Turing
9
Turing Machine Representation: Table
This machine has 4 symbols: 0, 1, _ and *
L means the head moves to the left
R means the head moves to the right
10
Turing Machine Representation: Table
11
Turing Machine Representation: Table
12
Turing Machine Representation: Table
write_symbol, head_move_direction, state_update
13
Turing Machine Representation: Table
write_symbol, head_move_direction, state_update
14
Same Machine as a State Diagram
read_symbol,write_symbol,head_position_move 15
Same Machine as a State Diagram
read_symbol,write_symbol,head_position_move 16
17
Example execution
18
Behavior of the machine on input 10
19
Behavior of
the machine
on input 10
20
Behavior of
the machine
on input 1010
21
What does this Turing machine do?
22
Turing Machine Programming
23
The Church-Turing thesis
25
A halting question
u Deciding whether a program will halt (terminate)
u Does the following program halt ?
Input number
While number is not 0
Print number
number = number – 1
26
The halting problem
u Deciding whether a given program will halt
(terminate) on an arbitrary input
u In 1936, Turing proved that a general algorithm
to the halting problem for all possible programs
over all possible inputs cannot exist
clever(program,input)
result = halter(program,input)
if result is No
return Yes
else
loop forever
30
Proof by contradiction
u What does clever do when given itself as
input?
clever(program,input)
result=halter(program,input)
if result is No
return Yes
else
loop forever
31
Proof by contradiction
u If halter says clever(program,input)
that clever halts,
result=halter(program,input)
then clever
loops forever if result is No
(which means it return Yes
doesn’t halt) else
u If halter says loop forever
that clever does
not halt then Conclusion: The program
clever halts and halter cannot exist
returns Yes 32
Russell’s Paradox
u In a hypothetical small u More generally:
town: v Let R be the set of all sets
v There is one male barber that are not members of
v The barber shaves all those themselves
and only those men in town v If R is not a member of itself,
who do not shave themselves then its definition dictates
v All men stay clean shaven that it must contain itself,
either by shaving themselves and if it contains itself, then
or going to the barber it contradicts its own
definition as the set of all
u Who shaves the barber? sets that are not members
of themselves
33
Analysis of problems
u Study of algorithms illuminates the study of classes of
problems
u If a polynomial time algorithm exists to solve a problem
then the problem is called tractable
u If a problem cannot be solved by a polynomial time
algorithm then it is called intractable
u This divides problems into three groups:
v Problems with known polynomial time algorithms
v Problems that are proven to have no polynomial-time algorithm
v Problems with no known polynomial time algorithm but not yet
proven to be intractable
34
Tractable and Intractable
u Tractable problems (P) u Intractable
v Sorting a list v Listing all permutations (all
v Searching an unordered list possible orderings) of n numbers
v Finding a minimum spanning tree
in a graph
u Might be (in)tractable
v Subset sum: given a set of These problems have no known
numbers, is there a subset that polynomial time solution
adds up to a given number? However no one has been able to
v Travelling salesperson: n cities, n! prove that such a solution does not
routes, find the shortest route exist
35
Tractability, Intractability, Undecidability
u ‘Properties of problems’ (NOT ‘properties of algorithms’)
u Tractable: problem can be solved by a polynomial time algorithm (or
something more efficient)
u Intractable: problem cannot be solved by a polynomial time algorithm
(all solutions are proven to be more inefficient than polynomial time)
u Unknown: not known if the problem is tractable or intractable (no
known polynomial time solution, no proof that a polynomial time
solution does not exist)
u Undecidable: decision problem for which there is (provably) no
algorithmic solution on a Turing machine
v Non-existence
v Not a matter of efficiency
36
Abstract machines and theory
u What is theoretical computer
science?
u Finite state machines
37
Overview
Problems Low-level
Low-level
Low-level
instructions
instructions
instructions
Solution:
Algorithms + Executions
Data Structures managed by
Operating System
Pseudocode
39