Introduction to Computer Science
CSCI 109
Andrew Goodney
Spring 2018
China – Tianhe-2
Introduction to Computer Science CSCI 109 China Tianhe-2 Andrew - - PowerPoint PPT Presentation
Introduction to Computer Science CSCI 109 China Tianhe-2 Andrew Goodney Spring 2018 Lecture 11: Abstract Machines and Theory Apr 9th, 2018 Schedule 1 Abstract machines and theory u What is theoretical computer
Spring 2018
China – Tianhe-2
1
uWhat is theoretical computer
uFinite state machines uThe Turing machine
u The Church-Turing thesis u The halting problem
uThe analysis of algorithms uThe analysis of problems
2
3
4
Crying Asleep
Awake, not crying
5
uIf a finite state machine with n states is given
uNo way to tell if revisited state is being visited for
uThe pigeonhole principle uProblems an FSM cannot solve:
v Given a string of As and Bs, tell if the number of As
v Tell if a string is a palindrome
6
7
u An infinite tape, with squares marked on it u Each square can be blank or hold a symbol u A machine moves over the tape u When positioned over a square,
v Read a symbol from the tape v Erase a symbol from the tape v Write a symbol onto the tape (erasing what was
v Do nothing
u The machine can move either one square
8
9
10
11
12
13
14
15
16
17
u Assume the machine always begins in state 0 with the head
u The machine stops when it is in state 4 (called an accept state) u The machine stops when it is in state 5 (called a reject state) u How does the execution look if the tape has an input of 10
18
19
20
21
22
23
24
uAre there problems that are not effectively
uYes, infinite such problems uCould these be computable someday ? uPerhaps, but not on a Turing-equivalent
25
uDeciding whether a program will halt (terminate) uDoes the following program halt ?
26
uDeciding whether a given program will halt
uIn 1936, Turing proved that a general algorithm
27
u Want to decide if program A halts on input a u Need to write a program, lets call it halter
v Inputs: A, a v Output: Yes (if program A halts on input a) or No (if program A
28
i.e analyze A for input a
29
uAssume that a general version of halter exists uShow that this assumption leads to a contradiction uInvent a new program called clever
30
uWhat does clever do when given itself as
31
u If halter says
u If halter says
32
u In a hypothetical small
v There is one male barber v The barber shaves all those
v All men stay clean shaven
u Who shaves the barber?
33
u More generally:
v Let R be the set of all sets
v If R is not a member of itself,
u Study of algorithms illuminates the study of classes of
u If a polynomial time algorithm exists to solve a problem
u If a problem cannot be solved by a polynomial time
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
34
u Tractable problems (P)
v Sorting a list v Searching an unordered list v Finding a minimum spanning tree
in a graph
35
u Intractable
v Listing all permutations (all
possible orderings) of n numbers
u Might be (in)tractable
v Subset sum: given a set of
numbers, is there a subset that adds up to a given number?
v Travelling salesperson: n cities, n!
routes, find the shortest route These problems have no known polynomial time solution However no one has been able to prove that such a solution does not exist
u ‘Properties of problems’ (NOT ‘properties of algorithms’) u Tractable: problem can be solved by a polynomial time algorithm (or
u Intractable: problem cannot be solved by a polynomial time algorithm
u Unknown: not known if the problem is tractable or intractable (no
u Undecidable: decision problem for which there is (provably) no
v Non-existence v Not a matter of efficiency 36
uWhat is theoretical computer
uFinite state machines uThe Turing machine
u The Church-Turing thesis u The halting problem
uThe analysis of algorithms uThe analysis of problems
37
38
39