Introduction to Computer Science

Similar documents
CSCI3390-Lecture 6: An Undecidable Problem

Turing Machine Recap

Equivalence of TMs and Multitape TMs. Theorem 3.13 and Corollary 3.15 By: Joseph Lauman

The Limits of Computation

Decidable Languages - relationship with other classes.

Theory of Computation

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Computability and Complexity

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

Turing Machines Part III

Section 14.1 Computability then else

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CS6901: review of Theory of Computation and Algorithms

Data Structures in Java

CS3719 Theory of Computation and Algorithms

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

CPSC 421: Tutorial #1

Decidability and Undecidability

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

CS20a: Turing Machines (Oct 29, 2002)

Complexity Theory Part I

Theory of Computation Lecture Notes. Problems and Algorithms. Class Information

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

CHAPTER 6. Copyright Cengage Learning. All rights reserved.

Problems, and How Computer Scientists Solve Them Manas Thakur

Turing Machines. Our most powerful model of a computer is the Turing Machine. This is an FA with an infinite tape for storage.

CS154, Lecture 10: Rice s Theorem, Oracle Machines

TURING MAHINES

1 Showing Recognizability

1 Acceptance, Rejection, and I/O for Turing Machines

CSCI3390-Assignment 2 Solutions

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Computational Complexity and Intractability: An Introduction to the Theory of NP. Chapter 9

Principles of Computing, Carnegie Mellon University. The Limits of Computing

Turing Machines. Lecture 8

Introduction to Turing Machines. Reading: Chapters 8 & 9

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

Decidability: Church-Turing Thesis

CS151 Complexity Theory. Lecture 1 April 3, 2017

Turing Machines and Time Complexity

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

CSCI FOUNDATIONS OF COMPUTER SCIENCE

(a) Definition of TMs. First Problem of URMs

The Church-Turing Thesis

Computability Theory. CS215, Lecture 6,

Complexity Theory Part I

Lecture Notes: The Halting Problem; Reductions

Most General computer?

Computational Models Lecture 8 1

Busch Complexity Lectures: Turing s Thesis. Costas Busch - LSU 1

Friday Four Square! Today at 4:15PM, Outside Gates

Theory of Computation. Theory of Computation

7.1 The Origin of Computer Science

CSCE 551: Chin-Tser Huang. University of South Carolina

Analysis of Algorithms. Unit 5 - Intractable Problems

1 Computational Problems

Acknowledgments 2. Part 0: Overview 17

Computational Models Lecture 8 1

CS6902 Theory of Computation and Algorithms

Turing Machines, diagonalization, the halting problem, reducibility

MACHINE COMPUTING. the limitations

CS21 Decidability and Tractability

Predicate Logic - Undecidability

Notes for Lecture Notes 2

Turing Machines Part II

Lecture 12: Mapping Reductions

Non-emptiness Testing for TMs

Computability, Undeciability and the Halting Problem

Decidable and undecidable languages

ECS 120 Lesson 18 Decidable Problems, the Halting Problem

Computational Models Lecture 8 1

CSE 105 THEORY OF COMPUTATION

Turing Machines. 22c:135 Theory of Computation. Tape of a Turing Machine (TM) TM versus FA, PDA

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 8 Nancy Lynch

There are two main techniques for showing that problems are undecidable: diagonalization and reduction

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 20. To Infinity And Beyond: Countability and Computability

The Beauty and Joy of Computing

Set Theory. CSE 215, Foundations of Computer Science Stony Brook University

Turing Machines Part II

highlights proof by contradiction what about the real numbers?

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Lecture notes on Turing machines

Artificial Intelligence. 3 Problem Complexity. Prof. Dr. Jana Koehler Fall 2016 HSLU - JK

CS20a: Turing Machines (Oct 29, 2002)

The Turing machine model of computation

Introduction to Turing Machines

Complexity - Introduction + Complexity classes

UNIT-VIII COMPUTABILITY THEORY

CSE 105 THEORY OF COMPUTATION

Introduction to Computer Science and Programming for Astronomers

Time Complexity (1) CSCI Spring Original Slides were written by Dr. Frederick W Maier. CSCI 2670 Time Complexity (1)

Review of Complexity Theory

Week 2: Defining Computation

ACS2: Decidability Decidability

CS 154 NOTES MOOR XU NOTES FROM A COURSE BY LUCA TREVISAN AND RYAN WILLIAMS

Data Structures and Algorithms

CS4026 Formal Models of Computation

Transcription:

Introduction to Computer Science CSCI 109 China Tianhe-2 Andrew Goodney Fall 2017 Lecture 11: Abstract Machines and Theory Nov. 13th, 2017

Schedule 1

Abstract machines and theory uwhat is theoretical computer science? ufinite state machines uthe Turing machine u The Church-Turing thesis u The halting problem uthe analysis of algorithms uthe analysis of problems Reading: St. Amant Ch. 8 2

What is theoretical computer science? uthe study of what can be computed and how efficiently it can be computed ubased on abstract mathematical models uinsight into the behavior of a real computer any real computer 3

Finite state machines Up On Crying Fed Hungry Asleep Down Up More hungry Hungry Down Off Light switch Awake, not crying 1 day old infant 10 day old infant 4

Finite state machines Add M Add M Add M Add M M+1 M+2 M+3 M+4 Add F Add F Add F M=F Add F Add F Add F Add F Add F Add M F+1 F+2 F+3 F+4 Add M Add M Add M Add M Add F St. Amant pp. 152 5

Finite state machine limitations uif a finite state machine with n states is given n+1 symbols, it will revisit one state at least once uno way to tell if revisited state is being visited for the 1 st time or 5 th time uthe pigeonhole principle uproblems an FSM cannot solve: v Given a string of As and Bs, tell if the number of As and Bs are the same v Tell if a string is a palindrome 6

The Turing machine 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, the machine can v v v v Read a symbol from the tape Erase a symbol from the tape Write a symbol onto the tape (erasing what was on the square) Do nothing u The machine can move either one square to right or left 7

Simple Turing Machine with 1 symbol 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 u Assume the machine always begins in state 0 with the head positioned on the rightmost non-blank square 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 written on it at the beginning? 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? uchecks if a binary string has the same number of 1 s and 0 s and enters the accept state if it does, otherwise it enters the reject state. 22

Turing Machine Programming uwriting programs for a Turing machine is very tedious uhowever 23

The Church-Turing thesis Turing machines are capable of solving any effectively solvable algorithmic problem Turing machines are thus excellent models for what (all) real computers are capable of doing 24

Problems not effectively computable uare there problems that are not effectively computable? u Yes, infinite such problems ucould these be computable someday? uperhaps, but not on a Turing-equivalent computer 25

A halting question udeciding whether a program will halt (terminate) udoes the following program halt? Input number While number is not 0 Print number number = number 1 26

The halting problem udeciding whether a given program will halt (terminate) on an arbitrary input uin 1936, Turing proved that a general algorithm to the halting problem for all possible programs over all possible inputs cannot exist The halting problem is undecidable 27

Proof sketch for halting problem 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 does not halt on input a) halter(a,a) if(some complex computation)is true Return Yes else Return No 28

The halting problem is undecidable uin 1936, Turing proved that a general algorithm to the halting problem for all possible programs over all possible inputs cannot exist uin other words, a general version of halter (one that works for all programs and their inputs) does not exist 29

Proof by contradiction u Assume that a general version of halter exists u Show that this assumption leads to a contradiction u Invent a new program called clever clever(program,input) result = halter(program,input) if result is No return Yes else loop forever 30

Proof by contradiction uwhat does clever do when given itself as input? clever(program,input) result=halter(program,input) if result is No else return Yes loop forever 31

Proof by contradiction u If halter says that clever halts, then clever loops forever (which means it doesn t halt) clever(program,input) result=halter(program,input) if result is No else return Yes 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 town: v There is one male barber v The barber shaves all those and only those men in town who do not shave themselves v All men stay clean shaven either by shaving themselves or going to the barber u Who shaves the barber? u More generally: v Let R be the set of all sets that are not members of themselves v If R is not a member of itself, then its definition dictates that it must contain itself, and if it contains itself, then it contradicts its own definition as the set of all 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) v v v Sorting a list Searching an unordered list Finding a minimum spanning tree in a graph 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 u Intractable v Listing all permutations (all possible orderings) of n numbers These problems have no known polynomial time solution However no one has been able to prove that such a solution does not 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 v Non-existence Not a matter of efficiency 36

Abstract machines and theory uwhat is theoretical computer science? ufinite state machines uthe Turing machine u The Church-Turing thesis u The halting problem uthe analysis of algorithms uthe analysis of problems Reading: St. Amant Ch. 8 37

Overview Problems Solution: Algorithms + Data Structures Pseudocode Low-level Low-level instructions Low-level instructions instructions Executions managed by Operating System Program Program Program Program Compile to CPU, Memory, Disk, I/O 38

Quiz #6 http://bit.ly/2yxjboq 39