Computability Theory

Similar documents
Computability Theory

Decidability (intro.)

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Context-Free Languages

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

ACS2: Decidability Decidability

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Intro to Theory of Computation

Decidability. Overview. Preliminaries to Halting Problem. Decidable Problems of Regular Languages. Decidable Problems of Context-Free Languages

Context-Free Languages (Pre Lecture)

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

CSE 105 THEORY OF COMPUTATION

NPDA, CFG equivalence

CSE 105 THEORY OF COMPUTATION

Chap. 4,5 Review. Algorithms created in proofs from prior chapters

Theory of Computation (IX) Yijia Chen Fudan University

Notes for Comp 497 (Comp 454) Week 10 4/5/05

CS:4330 Theory of Computation Spring Regular Languages. Finite Automata and Regular Expressions. Haniel Barbosa

Properties of Context-Free Languages. Closure Properties Decision Properties

Intro to Theory of Computation

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

acs-07: Decidability Decidability Andreas Karwath und Malte Helmert Informatik Theorie II (A) WS2009/10

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Theory of Computation

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition

CSE 105 THEORY OF COMPUTATION

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

CSE 105 THEORY OF COMPUTATION

CSCE 551: Chin-Tser Huang. University of South Carolina

CS481F01 Solutions 8

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

CSE 105 THEORY OF COMPUTATION

Computability and Complexity

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

V Honors Theory of Computation

6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs

Computability and Complexity

Decidable and undecidable languages

Decidability (What, stuff is unsolvable?)

CS20a: Turing Machines (Oct 29, 2002)

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Einführung in die Computerlinguistik

Lecture 12: Mapping Reductions

Context-Free Languages

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

CPS 220 Theory of Computation

Turing Machines Part III

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

CS375: Logic and Theory of Computing

Notes for Comp 497 (454) Week 10

CSE 105 THEORY OF COMPUTATION

Ogden s Lemma for CFLs

CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

CS20a: Turing Machines (Oct 29, 2002)

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

Computational Models - Lecture 4

CSE 105 THEORY OF COMPUTATION

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Foundations of Informatics: a Bridging Course

MA/CSSE 474 Theory of Computation

CPSC 421: Tutorial #1

CS 530: Theory of Computation Based on Sipser (second edition): Notes on regular languages(version 1.1)

Pumping Lemma for CFLs

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

CS481F01 Prelim 2 Solutions

Decidability and Undecidability

DM17. Beregnelighed. Jacob Aae Mikkelsen

Chapter 6. Properties of Regular Languages

Properties of Context-Free Languages

Section 1 (closed-book) Total points 30

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

CP405 Theory of Computation

Lecture 23: Rice Theorem and Turing machine behavior properties 21 April 2009

Final exam study sheet for CS3719 Turing machines and decidability.

CSE 105 Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Introduction to Theory of Computing

CISC4090: Theory of Computation

10. The GNFA method is used to show that

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

CS20a: summary (Oct 24, 2002)

Finite Automata and Regular languages

Theory of Computation Turing Machine and Pushdown Automata

Homework Assignment 6 Answers

UNIT-VIII COMPUTABILITY THEORY

Lecture VII Part 2: Syntactic Analysis Bottom-up Parsing: LR Parsing. Prof. Bodik CS Berkley University 1

Theory of Computation (Classroom Practice Booklet Solutions)

Theory of Computation

Computational Models Lecture 8 1

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Transcription:

CS:4330 Theory of Computation Spring 2018 Computability Theory Decidable Problems of CFLs and beyond Haniel Barbosa

Readings for this lecture Chapter 4 of [Sipser 1996], 3rd edition. Section 4.1.

Decidable Problems of CFLs We now describe algorithms to test whether a CFG generates a particular string whether the language generated by a CFG is empty We consider the language A CFG = { G,w G is a CFG that generates the string w} 1 / 9

Decidability of CFG generation Theorem A CFG is a decidable language Proof ideas: how to check G generates w? Possibly infinitely many derivations in G, therefore no exhaustive check 2 / 9

Decidability of CFG generation Theorem A CFG is a decidable language Proof ideas: how to check G generates w? Possibly infinitely many derivations in G, therefore no exhaustive check However, if G is in Chomsky normal form then for any w L (G), with w = n, n > 0, exactly 2n 1 steps are required for any derivation of w. 2 / 9

Decidability of CFG generation Theorem A CFG is a decidable language Proof ideas: how to check G generates w? Possibly infinitely many derivations in G, therefore no exhaustive check However, if G is in Chomsky normal form then for any w L (G), with w = n, n > 0, exactly 2n 1 steps are required for any derivation of w. We can then build a TM S that first converts G into Chomsky Normal Form and then checks every possible derivation of 2n 1 steps 2 / 9

Decidability of CFG generation Theorem A CFG is a decidable language Proof ideas: how to check G generates w? Possibly infinitely many derivations in G, therefore no exhaustive check However, if G is in Chomsky normal form then for any w L (G), with w = n, n > 0, exactly 2n 1 steps are required for any derivation of w. We can then build a TM S that first converts G into Chomsky Normal Form and then checks every possible derivation of 2n 1 steps S = On input string G,w, where G is a CFG and w is a string: 1. Convert G to an equivalent grammar in Chomsky Normal Form 2. List all derivations with 2n 1 steps, for w = n, if n > 0, otherwise list all derivations of 1 step 3. If any of these derivations generates w, accept, otherwise reject. 2 / 9

Decidability of emptiness testing for CFGs Theorem E CFG = { G G is a CFG and L (G) = } is a decidable language. 3 / 9

Decidability of emptiness testing for CFGs Theorem E CFG = { G G is a CFG and L (G) = } is a decidable language. Proof ideas: check whether string of terminals derivable from start We proceed by solving a more general problem: whether from a nonterminal a string of terminals is derivable. Algorithm proceeds bottom up by marking terminals, then all nonterminals with rules whose rhs consists only of marked symbols 3 / 9

Decidability of emptiness testing for CFGs Theorem E CFG = { G G is a CFG and L (G) = } is a decidable language. Proof ideas: check whether string of terminals derivable from start We proceed by solving a more general problem: whether from a nonterminal a string of terminals is derivable. Algorithm proceeds bottom up by marking terminals, then all nonterminals with rules whose rhs consists only of marked symbols R = On input string G, where G is a CFG: 1. Mark all terminal symbols in G 2. Repeat until no new nonterminal gets marked: 3. Mark any nonterminal A s.t. G contains a rule A u 1,..., u n and each symbol u i has already been marked 4. If the start nonterminal of G is marked, accept, otherwise reject. 3 / 9

Decidability of equality problem for CFGs Consider the language EQ CFG = { G,H G and H are CFGs and L (G) = L (H)} Could we proceed to prove its decidability as we did with EQ DFA? 4 / 9

Decidability of equality problem for CFGs Consider the language EQ CFG = { G,H G and H are CFGs and L (G) = L (H)} Could we proceed to prove its decidability as we did with EQ DFA? NO! CFGs are not closed under intersection or complement, therefore we cannot use symmetric difference. And as we will see later on, EQ CFG is indeed undecidable. 4 / 9

Decidability of context-free languages Theorem Every CFL is decidable. 5 / 9

Decidability of context-free languages Theorem Every CFL is decidable. Proof idea: simulate generation of string by respective CFG Let G be a CFG and let L (G) = A. Design a TM M G that decides A by building a copy of G into M G : 5 / 9

Decidability of context-free languages Theorem Every CFL is decidable. Proof idea: simulate generation of string by respective CFG Let G be a CFG and let L (G) = A. Design a TM M G that decides A by building a copy of G into M G : M G = On input string w, where G is a CFG: 1. Run TM S on input G,w 2. If this machine accepts, accept, otherwise reject. 5 / 9

Methodology for deciding languages relationships To solve decidability problems concerning relations between languages ones should proceed as follows: Understand the relationship Transform the relationship into an expression using closure operators on decidable languages Designing a TM that constructs the language thus expressed Run a TM that decides the language represented by the expression 6 / 9

Example Consider checking the equivalence of DFAs and Regular Expressions. We express this problem as the language EQ DFA,REX = { A,R A is a DFA, R is a regex, and L (A) = L (R)} Since regexs can de reduced into DFAs and DFAs are closed under symmetric difference, we can proceed similarly as we did for proving the decidability of EQ DFA 7 / 9

Example Consider checking the equivalence of DFAs and Regular Expressions. We express this problem as the language EQ DFA,REX = { A,R A is a DFA, R is a regex, and L (A) = L (R)} Since regexs can de reduced into DFAs and DFAs are closed under symmetric difference, we can proceed similarly as we did for proving the decidability of EQ DFA E = On input string A,R, where A is a DFA and R is a regex: 1. Convert R to an equivalent DFA B 2. Use the TM C, for deciding EQ DFA, on input A,B 3. If C accepts, accept, otherwise reject. 7 / 9

Another example Is the problem of testing whether a CFG generates some string 1 decidable? 8 / 9

Another example Is the problem of testing whether a CFG generates some string 1 decidable? We can formulate this problem as showing the decidability of A = { G G is a CFG over {0,1} and L (1 ) L (G) } 8 / 9

Another example Is the problem of testing whether a CFG generates some string 1 decidable? We can formulate this problem as showing the decidability of A = { G G is a CFG over {0,1} and L (1 ) L (G) } We know that 1 defines a regular language, that L (G) is a CFL, and that L (1 ) L (G) is a CFL. We know how to check emptiness of CFLs! 8 / 9

Another example Is the problem of testing whether a CFG generates some string 1 decidable? We can formulate this problem as showing the decidability of A = { G G is a CFG over {0,1} and L (1 ) L (G) } We know that 1 defines a regular language, that L (G) is a CFL, and that L (1 ) L (G) is a CFL. We know how to check emptiness of CFLs! X = On input string G, where G is a CFG: 1. Construct CFG H such that L (H) = L (1 ) L (G) 2. Run the TM R, which decides the language E CFG, on input H 3. If R accepts, reject, otherwise accept. 8 / 9

Yet another example Is the language generated by particular regular expressions decidable? For example, is the language of regular expressions that contain at least one string that has the pattern 111 as a substring decidable? 9 / 9

Yet another example Is the language generated by particular regular expressions decidable? For example, is the language of regular expressions that contain at least one string that has the pattern 111 as a substring decidable? We can formulate this problem as showing the decidability of A = { R R is a regex for a language with at leas one string w = x111y} To decide A we need to be able determine whether for any regex R it is the case that L (R) contains some string x111y. 9 / 9

Yet another example Is the language generated by particular regular expressions decidable? For example, is the language of regular expressions that contain at least one string that has the pattern 111 as a substring decidable? We can formulate this problem as showing the decidability of A = { R R is a regex for a language with at leas one string w = x111y} To decide A we need to be able determine whether for any regex R it is the case that L (R) contains some string x111y. I.e. whether L (Σ 111Σ ) L (R). 9 / 9

Yet another example Is the language generated by particular regular expressions decidable? For example, is the language of regular expressions that contain at least one string that has the pattern 111 as a substring decidable? We can formulate this problem as showing the decidability of A = { R R is a regex for a language with at leas one string w = x111y} To decide A we need to be able determine whether for any regex R it is the case that L (R) contains some string x111y. I.e. whether L (Σ 111Σ ) L (R). Z = On input string R, where R is a regex: 1. Construct the DFA E that accepts L (Σ 111Σ ) 2. Construct the DFA B that accepts L (E) L (R) 2. Run the TM T, which decides E DFA, on input B 3. If T accepts, reject, otherwise accept. 9 / 9