Today, we will dispel the notion that Java is a magical language that allows us to solve any problem we want if we re smart enough.

Similar documents
Theory of Computation, Homework 3 Sample Solution

Material from Recitation 1

CSE 105 THEORY OF COMPUTATION

Midterm Exam II CIS 341: Foundations of Computer Science II Spring 2006, day section Prof. Marvin K. Nakayama

CSCI 270: Introduction to Algorithms and Theory of Computing Fall 2017 Prof: Leonard Adleman Scribe: Joseph Bebel

CSE 105 THEORY OF COMPUTATION

Computer Sciences Department

THE HALTING PROBLEM. Joshua Eckroth Chautauqua Nov

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

Chapter 8 Algorithms 1

Lecture 1: Overview

Lecture 5: The Halting Problem. Michael Beeson

Rice s Theorem and Enumeration

CSE 120. Computer Science Principles

Lecture 2 Finite Automata

I have read and understand all of the instructions below, and I will obey the Academic Honor Code.

Does this program exist? Limits of computability. Does this program exist? A helper function. For example, if the string program is

Theory of Computations Spring 2016 Practice Final Exam Solutions

University of Nevada, Las Vegas Computer Science 456/656 Fall 2016

CSE 105 THEORY OF COMPUTATION

Final Exam 1, CS154. April 21, 2010

What computers just cannot do. COS 116: 2/28/2008 Sanjeev Arora

Outline. Language Hierarchy

CSE450. Translation of Programming Languages. Lecture 20: Automata and Regular Expressions

Context-Free Grammars

COMPUTABILITY THEORY AND RECURSIVELY ENUMERABLE SETS

Universal Turing Machine Chomsky Hierarchy Decidability Reducibility Uncomputable Functions Rice s Theorem Decidability Continued

Recursively Enumerable Languages, Turing Machines, and Decidability

COS 126 Written Exam 2 (Spring 2015)

Theory of Programming Languages COMP360

p x i 1 i n x, y, z = 2 x 3 y 5 z

CSE 105 THEORY OF COMPUTATION

UNIT 14C The Limits of Computing: Non computable Functions. Problem Classifications

Computability Summary

CS 125 Section #4 RAMs and TMs 9/27/16

Diagonalization. The cardinality of a finite set is easy to grasp: {1,3,4} = 3. But what about infinite sets?

The Undecidable and the Unprovable

Programming Languages and Techniques (CIS120)

Recursion CSCI 136: Fundamentals of Computer Science II Keith Vertanen Copyright 2011

COMP 382: Reasoning about algorithms

Regular Languages (14 points) Solution: Problem 1 (6 points) Minimize the following automaton M. Show that the resulting DFA is minimal.

introduction to Programming in C Department of Computer Science and Engineering Lecture No. #40 Recursion Linear Recursion

Lambda Calculus and Computation

ECS 120 Lesson 16 Turing Machines, Pt. 2

Static Vulnerability Analysis

The Turing Machine. Unsolvable Problems. Undecidability. The Church-Turing Thesis (1936) Decision Problem. Decision Problems

Problems, Languages, Machines, Computability, Complexity

MATH Iris Loeb.

CS21 Decidability and Tractability

Loops. In Example 1, we have a Person class, that counts the number of Person objects constructed.

CISC 4090 Theory of Computation

CS61A Lecture 38. Robert Huang UC Berkeley April 17, 2013

Exam 2. cs3102: Theory of Computation. Class 20: Busy Beavers

1. [5 points each] True or False. If the question is currently open, write O or Open.

(a) R=01[((10)*+111)*+0]*1 (b) ((01+10)*00)*. [8+8] 4. (a) Find the left most and right most derivations for the word abba in the grammar

1 Algorithms, Inputs, Outputs

Type Checking and Type Equality

Introduction to Computers & Programming

14.1 Encoding for different models of computation

Source of Slides: Introduction to Automata Theory, Languages, and Computation By John E. Hopcroft, Rajeev Motwani and Jeffrey D.

Semantic Analysis. Lecture 9. February 7, 2018

Last lecture CMSC330. This lecture. Finite Automata: States. Finite Automata. Implementing Regular Expressions. Languages. Regular expressions

Enumerations and Turing Machines

Decidable Problems. We examine the problems for which there is an algorithm.

System Correctness. EEC 421/521: Software Engineering. System Correctness. The Problem at Hand. A system is correct when it meets its requirements

Computable Sets. KR Chowdhary Professor & Head.

CS 531: Notes II. January 31, 2014

How convincing is our Halting Problem proof? Lecture 36: Modeling Computing. Solutions. DrScheme. What is a model? Modeling Computation

Recursion. Fundamentals of Computer Science

Recursion. Overview. Mathematical induction. Hello recursion. Recursion. Example applications. Goal: Compute factorial N! = 1 * 2 * 3...

CS/ECE 374 Fall Homework 1. Due Tuesday, September 6, 2016 at 8pm

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2016

CS 374 Fall 2014 Homework 2 Due Tuesday, September 16, 2014 at noon

CSE 113 A. Announcements - Lab

CpSc 421 Final Solutions

Theory of Computation Dr. Weiss Extra Practice Exam Solutions

Lecture 4: examples of topological spaces, coarser and finer topologies, bases and closed sets

Computer Science 236 Fall Nov. 11, 2010

Operational Semantics. One-Slide Summary. Lecture Outline

Lecture T4: Computability

Context-Free Grammars

We show that the composite function h, h(x) = g(f(x)) is a reduction h: A m C.

Languages and Automata

Theory of Computations Spring 2016 Practice Final

8 Algorithms 8.1. Foundations of Computer Science Cengage Learning

Controls Structure for Repetition

CS110D: PROGRAMMING LANGUAGE I

6.045J/18.400J: Automata, Computability and Complexity. Practice Quiz 2

5. Introduction to the Lambda Calculus. Oscar Nierstrasz

5) Attacker causes damage Different to gaining control. For example, the attacker might quit after gaining control.

Automata & languages. A primer on the Theory of Computation. The imitation game (2014) Benedict Cumberbatch Alan Turing ( ) Laurent Vanbever

Name: CS 341 Practice Final Exam. 1 a 20 b 20 c 20 d 20 e 20 f 20 g Total 207

Chapter 13. Recursion. Copyright 2016 Pearson, Inc. All rights reserved.

Regular Expressions. Agenda for Today. Grammar for a Tiny Language. Programming Language Specifications

Discrete Mathematics Lecture 4. Harper Langston New York University

English for Computer Science

(0) introduction to the course. how to learn a programming language. (0) course structure

6. Advanced Topics in Computability

Course notes for Data Compression - 2 Kolmogorov complexity Fall 2005

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Transcription:

CSE 311: Foundations of Computing Lecture 25: Limits of Computation Showing a Language L is not regular 1. Suppose for contradiction that some DFA M accepts L. 2. Consider an INFINITE set of half strings (which we intend to complete later). It is imperative that every string in our set have a DIFFERENT, SINGLE accept completion. 3. Since S is infinite and M has finitely many states, there must be two strings s i and s j in S for some i j that end up at the same state of M. 4. Consider appending the (correct) completion to one of the two strings. 5. Since s i and s j both end up at the same state of M, and we appended the same string t, both s i t and s j t end at the same state of M. Since s i t L and s j t L, M does not recognize L. 6. Since M was arbitrary, no DFA recognizes L. Prove A = {0 n 1 n : n 0 is not regular Prove A = {0 n 1 n : n 0 is not regular Suppose for contradiction that some DFA, M, accepts A. Suppose for contradiction that some DFA, M, accepts A. Let S = Let S = {0 n : n 0. Since S is infinite and M has finitely many states, there must be two strings, 0 i and 0 j (for some i j) that end in the same state in M. Consider appending 1 i to both strings. Note that 0 i 1 i A, but 0 j 1 i A since i j. But they both end up in the same state of M. Since that state can t be both an accept and reject state, M does not recognize A. Since M was arbitrary, no DFA recognizes A. Languages and Machines! 0* All Java Context-Free Binary Palindromes Regular Finite {001, 10, 12 Are there things Java can t do? DFA NFA Regex What We re About To Do. Today, we will dispel the notion that Java is a magical language that allows us to solve any problem we want if we re smart enough.

An Assignment Too Simple for 142! Students should write a Java program that Prints Hello to the console Eventually exits GradeIt, PracticeIt, etc. need to grade the students. How do we write that grading program? Follow Up Question What does this program do? _(,, ){ / <=1?_(, +1, ):!( % )?_(, +1,0): % == / &&!?(printf("%d\t", / ),_(, +1,0)): % >1&& % < /?_(,1+, +!( / %( % ))): < *?_(, +1, ):0;main(){_(100,0,0); Follow Up Question public static int collatz(n) { if (n == 1) { return 1; if (n % 2 == 0) { return collatz(n/2) return collatz(3n + 1) What is in the set {x : collatz(n) = 1? Some Notation and Starting Ideas We re going to be talking about Java code a lot. CODE(P) will mean the code of the program P So, consider the following function: public String P(String x) { return new String(Arrays.sort(x.toCharArray()); What is P(CODE(P))? ((()))..;AACPSSaaabceeggghiiiilnnnnnooprrrrrrrrrrrsssttttttuuwxxyy{ The Halting Problem Given: CODE(P) for a program P Output: true if P halts false if P does not halt The standard version of the halting problem takes some number as input. We consider this one, because it s easier to think about.

if (/* I should halt */) { /* don t halt */ /* halt */ if (/* I should halt */) { if (HALT(MY_SOURCE_CODE)) { Suppose for contradiction we had a HALT(X) function which public static void P(String input) { Quick Question. What does this do? OnMySourceCodeGENERATOR(P) Suppose for contradiction we had a HALT(X) function which public static void P(String input) { Does POnMySourceCode halt? Does POnMySourceCode halt? void P(String input) { Recall that POnMySourceCode does the same thing as P(CODE(POnMySourceCode)).

Suppose POnMySourceCode halts. HALT(CODE(POnMySourceCode)) is true. So, this if statement is true! So, the code loops forever! This is a contradiction, so POnMySourceCode does not halt. Suppose POnMySourceCode does not halt. HALT(CODE(POnMySourceCode)) is false. So, this if statement is false! So, the code halts! This is a contradiction, so POnMySourceCode can t not halt. Suppose for contradiction we had a HALT(X) function which solved the halting problem Suppose POnMySourceCode halts. Then, HALT(CODE(POnMySourceCode)) is true. So, the if statement in POnMySourceCode is true! So, the code loops forever! This is a contradiction, so POnMySourceCode does not halt. Suppose POnMySourceCode does not halt. Then, HALT(CODE(POnMySourceCode)) is false. So, the if statement in POnMySourceCode is true! So, the code halts! This is a contradiction, so POnMySourceCode can t not halt. We proved that there is no Java program that can solve the Halting Problem. This tells us that there is no compiler that can check our programs and guarantee to find any infinite loops they might have. So, POnMySourceCode. So, P does not exist. So, HALT does not exist. BUT WAIT public static void D(String input) { // Returns true if, when run, input // does X. Is D(POnMySourceCode)true? void P(String input) { if (D(input)) { D_IS_FALSE(); D_IS_TRUE(); THERE S MORE! Recall that POnMySourceCode does the same thing as P(CODE(POnMySourceCode)). if (D(CODE(POnMySourceCode))) { D_IS_FALSE(); D_IS_TRUE();

Rice s Theorem We ve now proven that for any property about the behavior of programs, D, if There is some program D_IS_FALSE() for which D is false. There is some program D_IS_TRUE() for which D is true. Then, D does not exist. Rice s Theorem Does P have a NullPointerException? Do P and Q do the same thing? Does P output 0 on any input? Does P have a buffer overflow? Does P have a virus? Does P have dead code? BUT WAIT THERE S MORE! Church-Turing Thesis All physically computable functions are Java-decidable That is, there is no programming language more powerful than Java.