This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CS 341: Foundations of Computer Science II Prof. Marvin Nakayama Homework 8 Solutions 1. Consider the problem of testing whether a DFA and a regular expression are equiv alent. Express this problem as a language and show that it is decidable. Answer: Define the language as C = {( M,R )  M is a DFA and R is a regular expression with L ( M ) = L ( R ) } . Recall that the proof of Theorem 4.5 defines a Turing machine F that decides the language EQ DFA = { ( A,B )  A and B are DFAs and L ( A ) = L ( B ) } . Then the following Turing machine T decides C : T = On input ( M,R ) , where M is a DFA and R is a regular expression: 1. Convert R into a DFA D R using the algorithm in the proof of Kleenes Theorem. 2. Run TM F from Theorem 4.5 on input ( M,D R ) . 3. If F accepts, accept . If F rejects, reject . 2. Let A CFG = {( G )  G is a CFG that generates } . Show that A CFG is decid able. Answer: We need to ensure that we test all derivations, but we also need the derivations not to be infinite, or to loop forever. To do this, we first convert the CFG G into an equivalent CFG G = ( V, ,R,S ) in Chomsky normal form. If S is a rule in G , where S is the start variable, then clearly G generates , so G also generates since L ( G ) = L ( G ) . Since G is in Chomsky normal form, the only possible rule in G is S , so the only way we can have L ( G ) is if G includes the rule S in R . Hence, if G does not include the rule S , then negationslash L ( G ) . Thus, a Turing machine that decides A CFG is as follows: M = On input ( G ) , where G is a CFG: 1. Convert G into an equivalent CFG G = ( V, ,R,S ) in Chomsky normal form.in Chomsky normal form....
View
Full
Document
This note was uploaded on 01/22/2011 for the course CIS 341 taught by Professor Nakayama during the Fall '10 term at NJIT.
 Fall '10
 Nakayama

Click to edit the document details