Introduction to Computer Science
CSCI 109
Andrew Goodney
Fall 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 Fall 2018 Lecture 11: Abstract Machines and Theory Nov. 12th, 2018 Schedule 1 Abstract machines and theory u What is theoretical computer
Fall 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
u Why look at FSMs? u They “compute”
v Sort-of… lots of limitations
u They are simple
v Can be modeled mathematically
6
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
7
u FSM can’t do general computation u Their simplicity is alluring u Can we do better?
v Combine FSM + Memory
u Several forms
v Most famous is Turing Machine v Memory is a “tape”
8
9
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
10
11
u “Alan Turing and his Ph.D. advisor Church studied the
at Michigan
u “As others have correctly pointed out that the purpose ‘was
Leader, Karolinska - Senior Researcher, Oxford
12
u “A Turing machine can perform any algorithm -- it can always
13
u “…Newman mentioned Hilbert's Entscheidungsproblem which
Professor
14
15
16
17
18
19
20
21
22
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
23
24
25
26
27
28
29
uAre there problems that are not effectively
uYes, infinite such problems uCould these be computable someday ? uPerhaps, but not on a Turing-equivalent
30
uDeciding whether a program will halt (terminate) uDoes the following program halt ?
31
uDeciding whether a given program will halt
uIn 1936, Turing proved that a general algorithm
32
u Undecidable Problem:
v Problem requires a yes/no answer v But no program exists that will always give the correct answer
33
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
34
i.e analyze A for input a
35
uAssume that a general version of halter exists uShow that this assumption leads to a contradiction uInvent a new program called clever
36
uWhat does clever do when given itself as
37
u If halter says
u If halter says
38
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?
39
u More generally:
v Let R be the set of all sets
v If R is not a member of itself,
u Both of these proved by showing an implementation on a Turing machine
would just be the halting problem
u Matrix mortality: given a finite set of n x n sized matrices, does a sequence of
matrix multiplications (repetitions allowed) exist that yields the zero matrix?
v Undecidable for a set of six or more 3 x 3 matrices
u Post’s Correspondence Problem
v Given two equal length lists of strings written in the same alphabet, (list A, list B) where
the strings are indexed 1….|A|, does a sequence of indexes exist that when applied to each list, generates the same compound word?
40
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
41
u Tractable problems (P)
v Sorting a list v Searching an unordered list v Finding a minimum spanning tree
in a graph
42
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 43