Today - Limits of computation - Complexity analysis examples.

Slides:



Advertisements
Similar presentations
David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
Advertisements

Lecture 19. Reduction: More Undecidable problems
CS 461 – Nov. 9 Chomsky hierarchy of language classes –Review –Let’s find a language outside the TM world! –Hints: languages and TM are countable, but.
1 Programming Languages (CS 550) Lecture Summary Functional Programming and Operational Semantics for Scheme Jeremy R. Johnson.
Hard problems November Administrivia Ps 8 –Handed out Tuesday (12/4) –Due Tuesday (12/11) or Tuesday (12/18) your choice Ps 9 –Handed out Thursday.
Chapter 3 Functional Programming. Outline Introduction to functional programming Scheme: an untyped functional programming language.
Lecture: Algorithmic complexity
Computability & Complexity. Scenario I can’t write this program because I’m too dumb.
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 5. Outline Let* List and pairs manipulations –Insertion Sort Abstraction Barriers –Fractals –Mobile 2.
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
1 Section 14.1 Computability Some problems cannot be solved by any machine/algorithm. To prove such statements we need to effectively describe all possible.
1 Introduction to Computability Theory Lecture15: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Lecture 4 Topics –Problem solving Subroutine Theme –REC language class The class of solvable problems Closure properties.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 Module 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 19 Instructor: Paul Beame.
CS 330 Programming Languages 11 / 20 / 2007 Instructor: Michael Eckmann.
CS 330 Programming Languages 11 / 18 / 2008 Instructor: Michael Eckmann.
CHAPTER 4 Decidability Contents Decidable Languages
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 5. Outline Abstraction Barriers –Fractals –Mobile List and pairs manipulations –Insertion Sort 2.
CS 310 – Fall 2006 Pacific University CS310 The Halting Problem Section 4.2 November 15, 2006.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
CS21 Decidability and Tractability
Halting Problem. Background - Halting Problem Common error: Program goes into an infinite loop. Wouldn’t it be nice to have a tool that would warn us.
Cardinality of Sets Section 2.5.
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
CSE 311 Foundations of Computing I Lecture 30 Computability: Other Undecidable Problems Autumn 2012 CSE 3111.
1 Ethics of Computing MONT 113G, Spring 2012 Session 13 Limits of Computer Science.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
Cs3102: Theory of Computation Class 24: NP-Completeness Spring 2010 University of Virginia David Evans.
Great Theoretical Ideas in Computer Science for Some.
Great Theoretical Ideas in Computer Science about AWESOME Some Generating Functions Probability Infinity Computability With Alan! (not Turing) Mind-
Halting Problem Introduction to Computing Science and Programming I.
CSE 311 Foundations of Computing I Lecture 26 Computability: Turing machines, Undecidability of the Halting Problem Spring
CSE 311 Foundations of Computing I Lecture 29 Computability: Turing machines, Undecidability of the Halting Problem Autumn 2012 CSE 3111.
Halting Problem and TSP Wednesday, Week 8. Background - Halting Problem Common error: Program goes into an infinite loop. Wouldn’t it be nice to have.
CS 3813: Introduction to Formal Languages and Automata Chapter 12 Limits of Algorithmic Computation These class notes are based on material from our textbook,
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Complexity & Computability. Limitations of computer science  Major reasons useful calculations cannot be done:  execution time of program is too long.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
CompSci On the Limits of Computing  Reasons for Failure 1. Runs too long o Real time requirements o Predicting yesterday's weather 2. Non-computable.
Fundamentals of Informatics Lecture 12 The Halting Problem Bas Luttik.
CSE 311: Foundations of Computing Fall 2014 Lecture 27: Cardinality.
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 6. 2 List Utilities Scheme built-in procedures –(list x y z...) –(list-ref lst index) –(length lst) –(append.
Spring 16 CSCI 4430, A Milanova/BG Ryder 1 Announcements HW5 due March 28 Homework Server link is up I will have office hours, Fri or Mon, check Announcements.
CompSci Today’s Topics Computer Science Noncomputability Upcoming Special Topic: Enabled by Computer -- Decoding the Human Genome Reading Great.
MA/CSSE 474 Theory of Computation How many regular/non-regular languages are there? Closure properties of Regular Languages (if there is time) Pumping.
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
Fall 2014 Lecture 29: Turing machines and more decidability CSE 311: Foundations of Computing.
Module 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex 1.
CSE 311: Foundations of Computing Fall 2014 Lecture 28: Undecidability.
CS314 – Section 5 Recitation 9
CS314 – Section 5 Recitation 10
The Acceptance Problem for TMs
CSE 311 Foundations of Computing I
CSE 311 Foundations of Computing I
Discrete Math for CS CMPSC 360 LECTURE 43 Last time: Variance
CSE 311: Foundations of Computing
Formal Languages, Automata and Models of Computation
CS21 Decidability and Tractability
CSE 311: Foundations of Computing
Rehearsal: Lazy Evaluation Infinite Streams in our lazy evaluator
Algorithms CSCI 235, Spring 2019 Lecture 37 The Halting Problem
Lecture 4: Unsolvable Problems
Lecture 23: Computability CS200: Computer Science
Presentation transcript:

Today - Limits of computation - Complexity analysis examples

The “Hello” Assignment Suppose I gave you an assignment to write a computer program which returns “Hello!” and stops. (Assume this is a procedure with no parameters). Suppose I promised you full credit for ANY working program which returns “Hello!” and halts, and no credit if it didn’t work.

The “Hello” Assignment Can I write a program that automatically grades your homework?

The “Hello” Assignment Can I write a program that automatically grades your homework? Sure, right? (define (GradeHello P) (let ((out (P))) (if (eq? out ‘Hello!) 100 0)))

The “Hello” Assignment No! What if a student submits: (define (p) (define (q n) (cond ((> n 0) (q n)) (else 'Hello))) (q 10)) Student’s program runs forever! This means the grading program would run forever. It would never tell me that the student should fail… Maybe we can stop the Program after 1 hour and fail the student if the program hasn’t stopped yet.

The “Hello” Assignment Well, in that case lets submit: (define (p) (hanoi );; hanoi with 50 pegs 'Hello) My grading program would say to fail you. But technically you deserve to Pass.

The “Hello” Assignment We keep running in to problems… Could it be that writing a computer program to grade such a simple assignment is impossible? YES! We’ll prove it…

Is there a limit to the power of computers? Q: Is there any problem a computer cannot solve? What is a “problem”? We need some definition to start with: And what is a “computer”?

What is a “computer”? A1: Fortran program running on PDP 11. A3: C++ program running on MAC G4 under OSX at 800MHz. A4: All of the above A2: Java program running on a PC with Pentium V under Windows XP at 3GHz. A5: None of the above

Church-Turing Thesis All “reasonable” models of programming languages and computers are equivalent. Each can emulate the other. There is nothing essential in Java, C+ +, Cobol, Lambda Calculus, Mathematica, (or even Scheme).

Is there a limit to the power of computers? Q: Is there any problem a computer cannot solve? We still have to define what a “problem” means. We will restrict ourselves to well posed problems with a yes/no answer. A solution will be a scheme procedure.

The halting problem The halting problem H: Given a pair of expressions x and y. x is viewed as a Scheme procedure. H(x,y) is true iff x is a valid procedure and it stops on the input y. Example x = (define (f z) (if (= z 1) 1 (+ z (f z)))), y = 1 H(x,y) is true x = (define (f z) (if (= z 1) 1 (+ z (f z)))), y = 2 H(x,y) is false

The halting problem The halting problem is a very natural problem. For the previous example, it is easy to check halting. But in general this problem is hard because the dynamics of programs is very complicated. Halting is a specific requirement of program correctness.

The halting problem is not solvable Proof: By contradiction. Suppose there is a Scheme procedure halt that solves the halting problem. This means that for all x,y (halt x y) always terminates for all x,y (halt x y) returns true if and only if the procedure x stops when applied to argument y. Now consider the following program D: (define (D x) (define (loopy) (loopy)) (if (halt x x) (loopy) #t))

The halting problem is not solvable Now we run D giving it as argument D: (D D) (define (D x) (define (loopy) (loopy)) (if (halt x x) (loopy) #t)) If D stops on D, then by def of halt procedure (halt D D) returns #t. then from the code of D, D enters an infite loop on D, a contradiction. If D does not stop on D, then by def of halt procedure (halt D D) returns #f. then from the code of D, D stops on D, a contradiction. Conclusion: Both possibilities lead to a contradiction. Therefore a procedure halt that solves the halting problem does not exist.

Is there a limit to the power of computers? Q: Is there any problem a computer cannot solve? A: YES. There are well posed problems a computer cannot solve! In fact there are many well posed problems a computer cannot solve! A counting argument: The number of computer programs is countable (since each is a finite string). The number of problems/languages is uncountable. So most problems are not solvable. But we did not just showed existence, but pointed out a specific non-computable problem.

Final Exam ~4 Questions 3 Hours You may bring any written or printed material (no laptops..) You can use every function studied in class \ recitation \ exercise All covered material except for computability (first part of this lecture) and parallel computation (previous lecture) Good Luck and have a nice vacation!

Complexity Analysis Examples

19 Common Recurrences T(n) = T(n-1) +  (1)   (n) T(n) = T(n-1) +  (n)   (n 2 ) T(n) = T(n/2) +  (1)   (logn) T(n) = T(n/2) +  (n)   (n) T(n) = 2T(n-1) +  (1)   (2 n ) T(n) = 2T(n/2) +  (1)   (n) T(n) = 2T(n/2) +  (n)   (nlogn)

20 (filter (lambda (positions) (safe? positions)) (accumulate append null (map (lambda (rest-of-queens) (map (lambda (new-row) (adjoin-position new-row rest-of-queens)) (enumerate-interval 1 board-size))) (queen-cols (- k 1)))))

(define (mean-record ds) (let ((records ds)) (let ((n (length records))) (map (lambda (x) (/ x n)) (accumulate (lambda (x y) (map + x y)) (car records) (cdr records)))))

(define (onto? n m f) (define (rem-dup s) (if (null? s) s (cons (car s) (filter (lambda(x) (not (eq? (car s) x))) (rem-dup (cdr s)))))) (define (image f n) (rem-dup (map f (integers-between 1 n)))) (eq? m (length (image f n)))

23 Mobile weight (define (total-weight mobile) (if (atom? mobile) mobile (+ (total-weight ) (total-weight ) ))) (define (atom? x) (and (not (pair? x)) (not (null? x)))) (branch-structure (left-branch mobile)) (branch-structure (right-branch mobile))

24 balanced? (define (balanced? mobile) (or (atom? mobile) (let ((l (left-branch mobile)) (r (right-branch mobile))) (and (= ) (balanced? ) (balanced? ))))) (* (branch-length l) (total-weight (branch-structure l))) (* (branch-length r) (total-weight (branch-structure r))) (branch-structure l) (branch-structure r)

25 Complexity –Worst case scenario for size n Need to test all rods May depend on mobile structure –Upper bound Apply total-weight on each sub-mobile O(n 2 ) –Lower bound

26 Mobile structures n n-1 n-2 n-3... T(n) = T(n-1) +  (n)(for this family of mobiles) T(n) =  (n 2 )

27 Mobile structures n/2 T(n) = 2T(n/2) +  (n)(for this family of mobiles) T(n) =  (nlogn) n/2 n/4 n/8