INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.

Slides:



Advertisements
Similar presentations
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Advertisements

David Evans cs302: Theory of Computation University of Virginia Computer Science Lecture 17: ProvingUndecidability.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
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.
The Recursion Theorem Sipser – pages Self replication Living things are machines Living things can self-reproduce Machines cannot self reproduce.
Turing -Recognizable vs. -Decidable
Nathan Brunelle Department of Computer Science University of Virginia Theory of Computation CS3102 – Spring 2014 A tale.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
Prof. Busch - LSU1 Decidable Languages. Prof. Busch - LSU2 Recall that: A language is Turing-Acceptable if there is a Turing machine that accepts Also.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
Reducibility A reduction is a way of converting one problem into another problem in such a way that a solution to the second problem can be used to solve.
Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages.
Fall 2003Costas Busch - RPI1 Decidability. Fall 2003Costas Busch - RPI2 Recall: A language is decidable (recursive), if there is a Turing machine (decider)
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
Computability and Complexity 7-1 Computability and Complexity Andrei Bulatov Recursion Theorem.
Recursively Enumerable and Recursive Languages
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
Fall 2004COMP 3351 The Chomsky Hierarchy. Fall 2004COMP 3352 Non-recursively enumerable Recursively-enumerable Recursive Context-sensitive Context-free.
Fall 2004COMP 3351 Reducibility. Fall 2004COMP 3352 Problem is reduced to problem If we can solve problem then we can solve problem.
Linear Bounded Automata LBAs
Fall 2005Costas Busch - RPI1 Recursively Enumerable and Recursive Languages.
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
Fall 2006Costas Busch - RPI1 Undecidable Problems (unsolvable problems)
Prof. Busch - LSU1 Undecidable Problems (unsolvable problems)
Prof. Busch - LSU1 Reductions. Prof. Busch - LSU2 Problem is reduced to problem If we can solve problem then we can solve problem.
1 Reducibility. 2 Problem is reduced to problem If we can solve problem then we can solve problem.
CS5371 Theory of Computation Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)
Cs3102: Theory of Computation Class 18: Proving Undecidability Spring 2010 University of Virginia David Evans.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
Turing -Recognizable vs. -Decidable
Recursively Enumerable and Recursive Languages
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Productions String of variables and terminals String of variables and terminals.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
THE HALTING PROBLEM - PROOF. Review  What makes a problem decidable?  3 properties of an efficient algorithm?  What is the meaning of “complete”, “mechanistic”,
Costas Busch - RPI1 Decidability. Costas Busch - RPI2 Another famous undecidable problem: The halting problem.
1 Recursively Enumerable and Recursive Languages.
CSC 3130: Automata theory and formal languages Andrej Bogdanov The Chinese University of Hong Kong Undecidable.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Decidability.
Fall 2006Costas Busch - RPI1 RE languages and Enumerators.
Recursively Enumerable Languages
Busch Complexity Lectures: Reductions
Linear Bounded Automata LBAs
Reductions.
Undecidable Problems Costas Busch - LSU.
Reductions Costas Busch - LSU.
Reducibility The Chinese University of Hong Kong Fall 2010
Intro to Theory of Computation
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
Turing acceptable languages and Enumerators
CS154, Lecture 8: Undecidability, Mapping Reductions
CS154, Lecture 8: Undecidability, Mapping Reductions
Decidable Languages Costas Busch - LSU.
Turing acceptable languages and Enumerators
Undecidable problems:
Computability and Complexity
More undecidable languages
CS154, Lecture 11: Self Reference, Foundation of Mathematics
More undecidable languages
CSCI 2670 Introduction to Theory of Computing
Theory of Computability
Presentation transcript:

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011

UN DECIDABILITY A language is a set of strings. It is a mathematical way of expressing a problem: given an input, is it in the set L? If a language is decidable, there is a computer program (TM) that can always solve the problem correctly – it terminates and has the right answer. If a language is undecidable, then no matter how smart you are, and no matter how long you give it, you cannot program a computer to always solve the problem correctly.

UNDECIDABLE PROBLEMS D TM = { 〈 M 〉 | M is a TM that does not accept 〈 M 〉 } Theorem. D TM is undecidable. Proof. Suppose machine N decides D TM. Then N accepts 〈 N 〉 ⇔ 〈 N 〉  D TM ⇔ N does not accept 〈 N 〉 A TM = { 〈 M,w 〉 : M is a TM that accepts on input w } Theorem. If A TM is decidable, so is D TM. Proof. If ¬A TM is decided by the program nAccept we can decide D TM by calling nAccept(M, 〈 M 〉 ). Theorem. If HALT TM is decidable, then so is A TM. HALT TM = { 〈 M,w 〉 : M is a TM that halts on input w }

In most cases, we will show that a language is undecidable by showing that if it is decidable, then so is A TM We reduce deciding A TM to deciding the language in question

MAPPING REDUCTIONS ƒ : Σ*  Σ* is a computable function if there is a TM that on input w, halts with ƒ(w) on its tape A  m B if there is a computable ƒ, such that w  A  ƒ(w)  B ƒ is called a reduction from A to B

Theorem: If A ≤ m B and A is undecidable, then B is undecidable Proof: Suppose, for contradiction, that BSolver decides B and let ƒ be a reduction from A to B. Then there is a program ASolver that decides A: ASolver(w): 1. Let s = ƒ(w) 2. Return BSolver(s) Since A is undecidable the program BSolver must not exist. Thus B is undecidable.

0 → 0, R  → , R q accept q reject 0 → 0, R  → , R q0q0 q1q1 0q10q1 q00q00 0q rej q10q10  q rej q0q0 q1q1  q acc 0 0   # # # #q 0 0# # ## q acc  q acc q acc 0q acc q acc q acc  q acc q acc 0 # #q 0 0#0q10q1 q00q00# ## 0 0 q1q1  q acc # # 0 0q acc  q acc # q acc ## # #q acc 0q acc # #

MORE UNDECIDABLE PROBLEMS Many “problems about programs” are undecidable: “Does this applet open a network connection?” “Find all buffer overflows in this program.” “Find all unused methods in this applet.” “Find all memory leaks in this program.” “Do these programs always have the same output?” “Does this function always return the same answer?”

TOOLS package cs4011.tm; public class TuringMachine { public TuringMachine(String TM, String Input); public void run(); public boolean accepted(); … /* turing_machine.h – TM emulator in C */ #define ACCEPT 1 #define REJECT 0 /* runTM – simulate the TM with description m * on input string w. Return ACCEPT or REJECT */ int runTM(char *M, char *w);

NET = { J | J is a java applet that opens a network connection } Theorem. A TM ≤ m NET. Proof. On input 〈 M,w 〉, output the Java applet: import cs4011.tm.TuringMachine; import java.net.*; public class OutputApplet extends Applet { public void start() { TuringMachine TM = new TuringMachine(“M”, “w”); TM.run(); if (TM.accepted()) { // open a network connection URL url = new URL(“ Object o = url.getContent(); }

import cs4011.tm.TuringMachine; import java.net.*; public class OutputApplet extends Applet { public void start() { TuringMachine TM = new TuringMachine(“M”, “w”); TM.run(); if (TM.accepted()) { // open a network connection URL url = new URL(“ Object o = url.getContent(); } If M accepts w: OutputApplet opens url. If M loops on w: OutputApplet never gets to url. If M rejects w: OutputApplet skips if {… } block. In both cases, OutputApplet ∉ NET. Thus OutputApplet ∈ NET.

What’s wrong with this reduction? On input 〈 M,w 〉 : Run M on w. if M accepts, output: public class OutputApplet extends Applet { public void start() { URL url = new URL(“ Object o = url.getContent(); } else output: public class OutputApplet extends Applet { public void start() { return; }

CONST= { J | J is a Java program that prints the same string for every input } Theorem. A TM ≤ m CONST. Proof. On input 〈 M,w 〉, output the Java program: import cs4011.tm.TuringMachine; public class MightBeConstProgram { public static void main(String[] args) { if (args.length == 1 && args[0].equals(“Y”)) { System.out.print(“Y”); return; } TuringMachine TM = new TuringMachine(“M”, “w”); TM.run(); if (TM.accepted()) System.out.print(“Y”); else System.out.print(args[0]); }

ALLUSED = { J | J is a java applet with no unused methods} Theorem. A TM ≤ m ALLUSED. Proof. On input 〈 M,w 〉, output the Java applet: import cs4011.tm.TuringMachine; public class AllMethodsApplet extends Applet { public void unusedMethod() { int x = 0; return; } public void start() { TuringMachine TM = new TuringMachine(“M”, “w”); TM.run(); if (TM.accepted()) { this.unusedMethod(); }

SAME = { 〈 J 1,J 2 〉 | J 1 and J 2 are java programs that have the same output for all inputs.} Theorem. ¬A TM ≤ m SAME. Proof. On input 〈 M,w 〉, output the Java programs: import cs4011.tm.TuringMachine; public class J1 { public static void main(String[] args) { TuringMachine TM = new TuringMachine(“M”, “w”); TM.run(); if (TM.accepted()) System.out.print(“Y”); } import cs4011.tm.TuringMachine; public class J2 { public static void main(String[] args) { TuringMachine TM = new TuringMachine(“M”, “w”); TM.run(); if (TM.accepted()) System.out.print(“N”); }

OFLOW = { P | P is a C program with an exploitable buffer overflow } Theorem. A TM ≤ OFLOW. Proof. On input 〈 M,w 〉, output the C program: #include int main(int argc, char **argv) { int i; char buf[1024]; for(i = 0; i < 2048 && runTM(“M”,“w”); i++) { buf[i] = fgetc(stdin); } return 0; }

MLEAK = { P | P is a C program with a memory leak} Theorem. A TM ≤ MLEAK. Proof. On input 〈 M,w 〉, output the C program: #include int main(int argc, char **argv) { char *buf = NULL; buf = malloc(1<<30); if (runTM(“M”,”w”)) { buf = malloc(512); } if (buf != NULL) free(buf); return 0; }