problems from formal language theory computability and
play

Problems from Formal Language Theory Computability and Complexity - PDF document

Problems from Formal Language Theory Computability and Complexity Decision Problems Acceptance: does a given string belong to a given language? Emptiness: is a given language empty? Lecture 3 Equality: are given two languages equal? Decidable


  1. Problems from Formal Language Theory Computability and Complexity Decision Problems Acceptance: does a given string belong to a given language? Emptiness: is a given language empty? Lecture 3 Equality: are given two languages equal? Decidable and undecidable problems from formal languages Closure properties of decidable languages Closure properties of recognizable languages These problems make sense only if we specify how the given languages are described (they must have a finite description e.g. given by Jiri Srba via finite automata, context-free grammars or Turing machines). Lecture 3 Computability and Complexity 1/16 Lecture 3 Computability and Complexity 2/16 Acceptance Problem for DFA Acceptance Problem for NFA Problem: ”Given a DFA B and a string w , does B accept w ? Problem: ”Given a NFA B and a string w , does B accept w ? Language Formulation (Acceptance Problem for DFA) Language Formulation (Acceptance Problem for NFA) def = {� B , w � | B is a DFA, w a string and B accepts w } A DFA def A NFA = {� B , w � | B is an NFA, w a string and B accepts w } Theorem Theorem The language A DFA is decidable. The language A NFA is decidable. Proof: Construct a decider M for A DFA : Proof: Construct a decider M for A NFA : M = ” On input x : M = ” On input x : 1. Check if x is of the form � B , w � where 1. Check if x is of the form � B , w � where B is an DFA and w is a string, if not then M rejects. B is an NFA and w is a string, if not then M rejects. 2. Simulate B on w (states of B are stored on a tape). 2. Convert B to an equivalent DFA B ′ . 3. If the simulation accepted then M accepts. 3. Run the algorithm for A DFA on B ′ and w .” If it rejected then M rejects.” Lecture 3 Computability and Complexity 3/16 Lecture 3 Computability and Complexity 4/16 Emptiness Problem for NFA (and DFA) Equality Problem for NFA (and DFA) Problem: ”Given two NFA A and B is L ( A ) equal to L ( B )”? Problem: ”Given a NFA A is the language L ( A ) empty? Language Formulation (Equality Problem for NFA) Language Formulation (Emptiness Problem for NFA) def def = {� A , B � | A and B are NFA and L ( A ) = L ( B ) } EQ NFA E NFA = {� A � | A is an NFA and L ( A ) = ∅ } Theorem Theorem The language EQ NFA (as well as EQ DFA ) is decidable. The language E NFA (as well as E DFA ) is decidable. Proof: Construct a decider M for EQ NFA : Proof: Construct a decider M for E NFA : M = ” 1. On input x , check if x = � A , B � , if not M rejects. On input x , check if x is of the form � A � , if not M rejects. M = ” 2. Construct DFA C for the language 2. Mark all accept states of A . � � � � L ( A ) ∩ L ( B ) ∪ L ( A ) ∩ L ( B ) 3. Repeat until no new states are marked: . 4. Check if L ( C ) = ∅ , if yes then M accepts, else rejects.” Mark any state which has a transition to an already marked state. We reduced the equivalence problem to the emptiness problem! 4. If the start state is marked, then M rejects, else accepts.” Lecture 3 Computability and Complexity 5/16 Lecture 3 Computability and Complexity 6/16

  2. Facts about Context-Free Grammars (CFG) Acceptance Problem for CFG Problem: ”Given a CFG G and a string w , does G generate w ? Chomsky Normal Form A CFG is in Chomsky normal form if Language Formulation (Acceptance Problem for CFG) the rules are of the form A → BC or A → a , def A CFG = {� G , w � | G is a CFG, w a string and w ∈ L ( G ) } the rule S → ǫ is allowed, and no rule has S on the right-hand side. Theorem The language A CFG is decidable. Fact: every grammar can be converted to Chomsky normal form. Proof: Construct a decider M for A CFG : 1. On input x check if x = � G , w � where M = ” Lemma G is an CFG and w is a string, if not then M rejects. If G is a context-free grammar in Chomsky normal form then any 2. Convert G into Chomsky normal form. w ∈ L ( G ) such that w � = ǫ can be derived from S in exactly 3. List all derivations in G of length exactly 2 | w | − 1, 2 | w | − 1 steps. if w = ǫ then check if there is the rule S → ǫ . 4. If w is ever generated then M accepts, else M rejects.” Lecture 3 Computability and Complexity 7/16 Lecture 3 Computability and Complexity 8/16 Emptiness Problem for CFG Summary of Decidable (Undecidable) Problems Problem: ”Given a CFG G , is L ( G ) empty? Language Formulation (Emptiness Problem for CFG) def E CFG = {� G � | G is a CFG and L ( G ) = ∅} Acceptance Emptiness Equality DFA yes yes yes Theorem NFA yes yes yes The language E CFG is decidable. CFG yes yes no TM no no no Proof: Construct a decider M for E CFG : M = ” 1. On input x check if x = � G � where G is an CFG 2. Convert G into Chomsky normal form. 3. Mark all nonterminals A which have some rule A → a . 4. Repeat until no new nonterminals are marked: Mark the nonterminal A if there is a rule A → BC such that B and C are already marked. 5. If S is marked ( L ( G ) � = ∅ ) then M rejects, else accepts. Lecture 3 Computability and Complexity 9/16 Lecture 3 Computability and Complexity 10/16 Closure Properties of Decidable Languages Proof: Closure of Decidable Languages under Intersection Let L 1 and L 2 be decidable. We show that L 1 ∩ L 2 is decidable too. Let M 1 be a decider for L 1 and M 2 be a decider for L 2 . Theorem (Closure Properties of Decidable Languages) Consider a 2-tape TM M : The class of decidable languages is closed under intersection, union, complement, concatenation and Kleene star. ”On input x : 1. copy x on the second tape Q: What does closed under mean? 2. on the first tape run M 1 on x M = 3. if M 1 accepted then goto 4. else M rejects 4. on the second tape run M 2 on x A: If L 1 and L 2 are decidable languages, then L 1 ∩ L 2 , L 1 ∪ L 2 , L 1 , 5. if M 2 accepted then M accepts else M rejects.” L 1 . L 2 and L ∗ 1 are decidable too. The machine M is a decider and it accepts a string x iff both M 1 and M 2 accept x . Two-tape TM is as expressive as the single tape TM. Lecture 3 Computability and Complexity 11/16 Lecture 3 Computability and Complexity 12/16

  3. Proof: Closure of Decidable Languages under Complement Closure Properties of Recognizable Languages Let L 1 be a decidable language. We show that L 1 is decidable too. Let M 1 be a decider for L 1 . Theorem (Closure Properties of Recognizable Languages) Consider a TM M : The class of recognizable languages is closed under intersection, union, concatenation and Kleene star. ”On input x : 1. run M 1 on x M = 2. if M 1 accepted then M rejects else M accepts.” BUT Recognizable languages are not closed under complement! The machine M is a decider, and it accepts a string x iff M 1 rejects x . Hence M decides L 1 . Lecture 3 Computability and Complexity 13/16 Lecture 3 Computability and Complexity 14/16 Proof: Closure of Recognizable Languages under ∪ Exam Questions Let L 1 and L 2 be recognizable languages with the corresponding recognizers M 1 and M 2 . We construct a recognizer M for L 1 ∪ L 2 . Decidable problems on DFA and NFA (acceptance, emptiness, Strategy I: run M 1 and M 2 in parallel on a 2-tape TM M equality). M = ”On input x : 1. Copy x on the second tape. Decidable problems on CFG (acceptance, emptiness). 2. Do one step of M 1 on tape 1 and one step of M 2 on tape 2. Closure properties of decidable languages. 3. If either M 1 or M 2 accepted, then M accepts, else goto 2.” Closure properties of recognizable languages. Strategy II: nondeterministically choose to run M 1 or M 2 Next time TEST from Lectures 1 to 3. M = ”On input x : 1. Nondeterministically choose i ∈ { 1 , 2 } . 2. Run machine M i on the input x . 3. If M i accepted, then M accepts. If M i rejected, then M rejects.” Lecture 3 Computability and Complexity 15/16 Lecture 3 Computability and Complexity 16/16

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend