Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.

Slides:



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

Lecture 3 Universal TM. Code of a DTM Consider a one-tape DTM M = (Q, Σ, Γ, δ, s). It can be encoded as follows: First, encode each state, each direction,
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 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
The diagonalization method The halting problem is undecidable Decidability.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
The Halting Problem Sipser 4.2 (pages ). CS 311 Mount Holyoke College 2 Taking stock All languages Turing-recognizable Turing-decidable Context-free.
The Halting Problem Sipser 4.2 (pages ).
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
Fall 2004COMP 3351 Recursively Enumerable and Recursive Languages.
Lecture 8 Recursively enumerable (r.e.) languages
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.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Decidability. Why study un-solvability? When a problem is algorithmically unsolvable, we realize that the problem must be simplified or altered before.
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.
CHAPTER 4 Decidability Contents Decidable Languages
CS 310 – Fall 2006 Pacific University CS310 Decidability Section 4.1/4.2 November 10, 2006.
Fall 2004COMP 3351 Reducibility. Fall 2004COMP 3352 Problem is reduced to problem If we can solve problem then we can solve problem.
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.1: Decidable Languages) David Martin With modifications.
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
Courtesy Costas Busch - RPI1 Reducibility. Courtesy Costas Busch - RPI2 Problem is reduced to problem If we can solve problem then we can solve problem.
January 23, 2015CS21 Lecture 81 CS21 Decidability and Tractability Lecture 8 January 23, 2015.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
January 28, 2015CS21 Lecture 101 CS21 Decidability and Tractability Lecture 10 January 28, 2015.
CS21 Decidability and Tractability
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)
Decidability A decision problem is a problem with a YES/NO answer. We have seen decision problems for - regular languages: - context free languages: [Sections.
February 18, 2015CS21 Lecture 181 CS21 Decidability and Tractability Lecture 18 February 18, 2015.
The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.
1 Undecidability Reading: Chapter 8 & 9. 2 Decidability vs. Undecidability There are two types of TMs (based on halting): (Recursive) TMs that always.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
Computer Language Theory
A Universal Turing Machine
Context-Free and Noncontext-Free Languages Chapter 13 1.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
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.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
D E C I D A B I L I T Y 1. 2 Objectives To investigate the power of algorithms to solve problems. To explore the limits of algorithmic solvability. To.
Computability Universal Turing Machine. Countability. Halting Problem. Homework: Show that the integers have the same cardinality (size) as the natural.
CS 461 – Nov. 7 Decidability concepts –Countable = can number the elements  –Uncountable = numbering scheme impossible  –A TM undecidable –Language classes.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
Recursively Enumerable and Recursive Languages
Donghyun (David) Kim Department of Mathematics and Computer Science North Carolina Central University 1 Chapter 4 Decidability Some slides are in courtesy.
1 Chapter 9 Undecidability  Turing Machines Coded as Binary Strings  Universal Turing machine  Diagonalizing over Turing Machines  Problems as Languages.
 2005 SDU Lecture11 Decidability.  2005 SDU 2 Topics Discuss the power of algorithms to solve problems. Demonstrate that some problems can be solved.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY * Read chapter 4 of the book for next time * Lecture9x.ppt.
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.
The Acceptance Problem for TMs
CIS Automata and Formal Languages – Pei Wang
Recursively Enumerable and Recursive Languages
CSCI 2670 Introduction to Theory of Computing
Lecture12 The Halting Problem
CSCI 2670 Introduction to Theory of Computing
BCS 2143 Theory of Computer Science
MCC 2093 Advanced Theoretical Computer Science
Decidable Languages Costas Busch - LSU.
CS21 Decidability and Tractability
CS21 Decidability and Tractability
CS21 Decidability and Tractability
Formal Languages, Automata and Models of Computation
Intro to Theory of Computation
CS21 Decidability and Tractability
Cpt S 317: Spring 2009 Reading: Chapter 8 & 9
Intro to Theory of Computation
CIS Automata and Formal Languages – Pei Wang
Presentation transcript:

Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems

Deciding CFLs Useful to have an efficient algorithm to decide whether string x is in given CFL –e.g. programming language often described by CFG. Determine if string is valid program. Can simulate NPDA, but this takes exponential time in the worst case.

Deciding CFLs Convert CFG into Chomsky Normal form. parse tree for string x generated by nonterminal A: A BC x If A  k x (k > 1) then there must be a way to split x: x = yz A → BC is a production and B  i y and C  j z for i, j < k yz

Deciding CFLs An algorithm: IsGenerated(x, A) if |x| = 1, then return YES if A → x is a production, else return NO for all n-1 ways of splitting x = yz for all ≤ m productions of form A → BC if IsGenerated(y, B) and IsGenerated(z, C) return YES return NO worst case running time?

Deciding CFLs worst case running time exp(n) Idea: avoid recursive calls –build table of YES/NO answers to calls to IsGenerated, in order of length of substring –example of general algorithmic strategy called dynamic programming –notation: x[i,j] = substring of x from i to j –table: T(i, j) contains {A: A nonterminal such that A * x[i,j]}

Deciding CFLs IsGenerated(x = x 1 x 2 x 3 …x n, G) for i = 1 to n T[i, i] = {A: “A → x i ” is a production in G} for k = 1 to n - 1 for i = 1 to n - k for k splittings x[i, i+k] = x[i,i+j]x[i+j+1, i+k] T[i, i+k] = {A: “A → BC” is a production in G and B  T[i,i+j] and C  T[i+j+1,i+k] } output “YES” if S  T[1, n] else output “NO”

Emptiness problem for CFL’s L = { | L(G) is empty } We can show that L is decidable using the following algorithm: Input: A CFG G. Output: ‘yes’ if L(G) is empty, ‘no’ else. N1 = { }; N2 = { A | A -> w is a rule in G for some w in * } While (N1 != N2) { N1 = N2; N2 = { A | A -> for some in (  U N1)* } } if (S is included in N1) output yes else output no;

Problems related to CFG Equivalence problem for CFG Given two CFG’s G1 and G2, determine if L(G1) = L(G2). It turns out that this problem is undecidable. This means, it is impossible to design an algorithm to solve this problem.

13 Countable and Uncountable Sets Nthe natural numbers N = {1,2,3,…} are countable Definition: a set S is countable if it is finite, or it is infinite and there is a bijection N f: N → S

14 Countable and Uncountable Sets Theorem: the positive rational numbers N Q = {m/n : m, n  N } are countable. Proof: 1/1 1/2 1/3 1/4 1/5 1/6 … 2/1 2/2 2/3 2/4 2/5 2/6 … 3/1 3/2 3/3 3/4 3/5 3/6 … 4/1 4/2 4/3 4/4 4/5 4/6 … 5/1 … …

Countable and Uncountable Sets R Theorem: the real numbers R are NOT countable (they are “uncountable”). How do you prove such a statement? –assume countable (so there exists bijection f) –derive contradiction (some element not mapped to by f) –technique is called diagonalization (Cantor)

16 Countable and Uncountable Sets Proof: R –suppose R is countable R –list R according to the bijection f: nf(n) _ … … … … …

17 Countable and Uncountable Sets Proof: R –suppose R is countable R –list R according to the bijection f: nf(n) _ … … … … … set x = 0.a 1 a 2 a 3 a 4 … where digit a i ≠ i th digit after decimal point of f(i) (not 0, 9) e.g. x = … x cannot be in the list!

18 non-RE languages Theorem: there exist languages that are not Recursively Enumerable. Proof outline: –the set of all TMs is countable –the set of all languages is uncountable –the function L:{TMs} →{languages} cannot be onto

19 non-RE languages Lemma: the set of all TMs is countable. Proof: –each TM M can be described by a finite-length string N –can enumerate these strings, and give the natural bijection with N

20 non-RE languages Lemma: the set of all languages is uncountable Proof: –fix an enumeration of all strings s 1, s 2, s 3, … (for example, lexicographic order) –a language L is described by its characteristic vector  L whose i th element is 0 if s i is not in L and 1 if s i is in L

21 non-RE languages –suppose the set of all languages is countable –list characteristic vectors of all languages according to the bijection f: nf(n) _ … … … … …

22 non-RE languages –suppose the set of all languages is countable –list characteristic vectors of all languages according to the bijection f: nf(n) _ … … … … … set x = 1101… where i th digit ≠ i th digit of f(i) x cannot be in the list! therefore, the language with characteristic vector x is not in the list

23 The Halting Problem Definition of the “Halting Problem”: HALT = { : TM M halts on input x } HALT is recursively enumerable. – proof? Is HALT decidable?

24 The Halting Problem Theorem: HALT is not decidable (undecidable). Proof: –Suppose TM H decides HALT –Define new TM H’: on input if H accepts > then loop if H rejects > then halt

25 The Halting Problem Proof: –define new TM H’: on input if H accepts > then loop if H rejects > then halt –consider H’ on input : if it halts, then H rejects >, which implies it cannot halt if it loops, then H accepts > which implies it must halt –contradiction.

26 The Halting Problem Turing Machines inputs Y n Y n n Y n YnYYnnY H’ : box (M, x): does M halt on x? The existence of H which tells us yes/no for each box allows us to construct a TM H’ that cannot be in the table.

27 So far… Can we exhibit a natural language that is non-RE? regular languages context free languages all languages decidable RE {a n b n : n ≥ 0 } {a n b n c n : n ≥ 0 } some language HALT

28 RE and co-RE The complement of a RE language is called a co-RE language regular languages context free languages all languages decidable RE {a n b n : n ≥ 0 } {a n b n c n : n ≥ 0 } some language HALT co-RE

29 RE and co-RE Theorem: a language L is decidable if and only if L is RE and L is co-RE. Proof: () we already know decidable implies RE –if L is decidable, then complement of L is decidable by flipping accept/reject. –so L is in co-RE.

30 RE and co-RE Theorem: a language L is decidable if and only if L is RE and L is co-RE. Proof: () we have TM M that recognizes L, and TM M’ recognizes complement of L. –on input x, simulate M, M’ in parallel –if M accepts, accept; if M’ accepts, reject.

31 A natural non-RE language Theorem: The complement of HALT is not recursively enumerable. Proof: –we know that HALT is RE –suppose complement of HALT is RE –then HALT is co-RE –implies HALT is decidable. Contradiction.

Summary Main point: some problems have no algorithms, HALT in particular. regular languages context free languages all languages decidable RE {a n b n : n ≥ 0 } {a n b n c n : n ≥ 0 } some language HALT co-RE co-HALT