Data Structures in Scheme Building data structures: Java class Circle { private double center_x, center_y, radius; Circle(double x, double y, double r)

Slides:



Advertisements
Similar presentations
Whiteboardmaths.com © 2004 All rights reserved
Advertisements

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 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Prof. Busch - LSU1 Decidable Languages. Prof. Busch - LSU2 Recall that: A language is Turing-Acceptable if there is a Turing machine that accepts Also.
Great Theoretical Ideas in Computer Science.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Recursively Enumerable and Recursive Languages
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
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.
1 Lecture 7 Topics –Problems about program behavior At least problem input is a program/algorithm –Halting Problem Fundamental problem about program behavior.
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
Lecture 27UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 27.
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
Lecture , 3.1 Methods of Proof. Last time in 1.5 To prove theorems we use rules of inference such as: p, p  q, therefore, q NOT q, p  q, therefore.
Cantor’s Legacy: Infinity And Diagonalization Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 25Apr 13, 2004Carnegie.
Algorithms: Selected Exercises Goals Introduce the concept & basic properties of an algorithm.
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
F22H1 Logic and Proof Week 6 Reasoning. How can we show that this is a tautology (section 11.2): The hard way: “logical calculation” The “easy” way: “reasoning”
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
1 The Halting Problem and Decidability How powerful is a TM? Any program in a high level language can be simulated by a TM. Any algorithmic procedure carried.
Lecture 18. Unsolvability Before the 1930’s, mathematics was not like today. Then people believed that “everything true must be provable”. (More formally,
Course Overview and Road Map Computability and Logic.
1 Computability CS 101E Spring 2007 Michele Co. 2 So Far In Class We’ve seen the following programming constructs –if, if-else, if-else-if –switch –for.
Great Theoretical Ideas in Computer Science.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Computability Universal Turing Machine. Countability. Halting Problem. Homework: Show that the integers have the same cardinality (size) as the natural.
Russell’s Paradox and the Halting Problem Lecture 24 Section 5.4 Wed, Feb 23, 2005.
SNU OOPSLA Lab. 1 Great Ideas of CS with Java Part 1 WWW & Computer programming in the language Java Ch 1: The World Wide Web Ch 2: Watch out: Here comes.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
CSE 311: Foundations of Computing Fall 2014 Lecture 27: Cardinality.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Recursively Enumerable and Recursive Languages
Data Structures in Scheme Building data structures: Java class Circle { private double center_x, center_y, radius; Circle(double x, double y, double r)
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
On computable numbers, with an application to the ENTSCHEIDUNGSPROBLEM COT 6421 Paresh Gupta by Alan Mathison Turing.
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
CompSci Today’s Topics Computer Science Noncomputability Upcoming Special Topic: Enabled by Computer -- Decoding the Human Genome Reading Great.
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:
1 Recursively Enumerable and Recursive Languages.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
Fall 2013 Lecture 27: Turing machines and decidability CSE 311: Foundations of Computing.
The Acceptance Problem for TMs
Set Operations CS 202, Spring 2008 Epp, chapter 5.
Recursively Enumerable Languages
Data Structures in Scheme
Gödel's Legacy: The Limits Of Logics
Recursively Enumerable and Recursive Languages
Hilbert’s Hotel
This statement is false.
CSE 311 Foundations of Computing I
CS154, Lecture 11: Self Reference, Foundation of Mathematics
Great Theoretical Ideas in Computer Science
Homework: Friday Read Section 4.1. In particular, you must understand the proofs of Theorems 4.1, 4.2, 4.3, and 4.4, so you can do this homework. Exercises.
CSCE 411 Design and Analysis of Algorithms
CSE 311 Foundations of Computing I
Decidable Languages Costas Busch - LSU.
Turing acceptable languages and Enumerators
Discrete Math for CS CMPSC 360 LECTURE 43 Last time: Variance
Formal Languages, Automata and Models of Computation
CSE 311: Foundations of Computing
Instructor: Aaron Roth
Computability and Undecidability
Intro to Theory of Computation
Presentation transcript:

Data Structures in Scheme Building data structures: Java class Circle { private double center_x, center_y, radius; Circle(double x, double y, double r) { this.center_x = x; this.center_y = y; this.radius = r; } }; (define make-circle (lambda (center-x center-y radius) (list center-x center-y radius)))

Data Structures in Scheme Building data structures: Scheme - use list in a constructor function: (define make-circle (lambda (center-x center-y radius) (list center-x center-y radius)))

Data Structures in Scheme Accessing fields: use list-ref in a selector function: double getRadius () {// Java return radius; } (define get-radius; Scheme (lambda (circle) (list-ref circle 2)))

Local declaration/scope via let double area() { double pi = , r = radius; return (pi * r * r); } (define area (lambda (circle) (let ((pi ) (r (get-radius circle))) (* pi r r))))

Local declaration/scope via let (let ( (var1 val1) (var2 val2).. (varN valN) ) result )

Shortcut with letrec > (letrec ((a 3) (b (* 2 a)) (c (+ b 1))) c) 7  > (let ((a 3)) ; long version  (let ((b (* 2 a)))  (let ((c (+ b 1)))  c))) 7

Sequential execution via begin (define (prompt-for-command-char prompt) (begin (write prompt) (read)))

The Main Course: Essentials of Programming Languages The Big Idea: The interpreter for a computer language is just another program. Think of quotes: The claim “Nerds are cool” is very true. This simple fact has profound implications. Brings us to the Halting Problem (Turing), and related diagonalization proofs (Cantor, Gödel)

The Halting Problem Formulated by Hilbert as the Entscheidungsproblem (lit., “Decision Problem”, 1928) Is there a general method that will tell us whether or not a given statement is true? Gödel: NO! (For arithmetic at least, 1930's) “Cocktail party” proof: There is no proof for this statement.

The Halting Problem Is there a general program that will tell us whether or not a given program halts on a given input? Turing: NO! (1937) “Cocktail party” proof:

(define run-forever (lambda () (run-forever))) (define invert (lambda (program) (if (halts? program program) (run-forever) 'halted))) The Halting Problem (à la Abelson & Sussman) Can we write the (general) halts? predicate? function input

The Halting Problem (define halts? (lambda (program input)... ) (define invert (lambda (program) (if (halts? program program) (run-forever) 'halted))) (invert invert) ; uh-oh!

The Halting Problem If invert halts on itself, then it runs forever. If it runs forever, then it halts: CONTRADICTION This means that our assumption (the existence of halts? ) must have been wrong, Q.E.D. Reductio ad absurdum by diagonalization:

Diagonalization #1: Halting Problem length exit (exits) (exits)... (exits)... invert (loops) (loops)... ????? input program length exit... invert...

Diagonalization #2: Cantor's Proof Can the real numbers be counted (matched 1:1 with the positive integers?) Cantor (~1897): NO! Proof: If reals (-∞... +∞) can be counted, then certainly reals in (0... 1) can be counted. So let's try:

Diagonalization: Cantor's Proof So, now we've enumerated every real in (0,1), right?

Diagonalization: Cantor's Proof Lets invert every number on the diagonal, by subtracting it from 9: Now look at the number on the diagonal:

This diagonal number can't be in the first row, because it differs in the first digit from the number in that row. It can't be in the second row, because it differs in the second digit. It can't be in the Nth row, because it differs in the Nth digit. Therefore it can't be in the table. Therefore we haven't enumerated the reals in (0,1). Therefore we can't enumerate the reals, Q.E.D.

Diagonalization #3: Do Mathematicians Work Harder than Computer Scientists? Are there some functions that cannot be computed – ie., for which we cannot write a computer program? Consider a program to be a finite sequence of bits (certainly valid!), so we can count programs. Consider just the class of functions that input a natural number and output true or false (e.g., test for even, prime, perfect) Assume there is a program that computes each such function….

even? T F T F T F T F T F … prime? F F T T F T F T F F … perfect?T F F F F F T F F F … p-o-2?F T T F T F F F T F … input program …

input program … Invert diagonal: even? F F T F T F T F T F … prime? F T T T F T F T F F … perfect?T F T F F F T F F F … p-o-2?F T T T T F F F T F …

The diagonal is now A valid function (assigns a unique value to each number) Not in any row of the table So there is at least one function that cannot be computed!

Diagonalization: What to Do? Go insane! (Cantor, Gödel, Turing) Use type systems (Russell, Wittgenstein, Church, Curry) e.g., square is undefined (type error) on strings. Denial: Die ganzen Zahlen hat der liebe Gott gemacht, alles andere ist Menschenwerk (Kronecker 1886) Surrealism / Postmodernism: