4-solutions

4-solutions - CS 360 Introduction to the Theory of...

This preview shows pages 1–3. Sign up to view the full content.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 360 Introduction to the Theory of Computing Spring 2008 Assignment 4 Solutions 1. [4 points] Prove that the following two languages are decidable: INF DFA = {( D ) : D is a DFA for which L ( D ) is infinite } INF CFG = {( G ) : G is a CFG for which L ( G ) is infinite } Solution 1. Let Σ ≥ n denote the language given by Σ ≥ n = { x ∈ Σ ∗ : | x | ≥ n } . The DTMs that decide INF DFA and INF CFG are almost exactly the same. They are both described as follows: Given input ( D ) (or ( G ) ); Compute the pumping length n of L ( D ) (or L ( G ) ); Compute a DFA E such that L ( E ) = L ( D ) ∩ Σ ≥ n ; (or, Compute a CFG H such that L ( H ) = L ( G ) ∩ Σ ≥ n ); Decide whether L ( E ) (or L ( H ) ) is empty; if L ( E ) negationslash = ∅ (or L ( H ) negationslash = ∅ ) then Accept else Reject; Let us argue that these DTMs decide INF DFA and INF CFG . First, we point out that the pumping lengths for both L ( D ) and L ( G ) are easily computed: • According to Section 4.1.1 of our text, the pumping length of L ( D ) for any DFA D is merely the number of states in D . • According to Section 7.2.2 of our text, the pumping length of L ( G ) for any CFG G is equal to 2 m where m is the number of variables in the Chomsky normal form of G . In either case, this pumping length is clearly computable. Next, is clear that Σ ≥ n is regular. We saw in our lecture that regular languages are closed under intersection and that context-free languages are closed under intersection with a regular language. Hence, L ( D ) ∩ Σ ≥ n is regular and L ( G ) ∩ Σ ≥ n is context-free. Moreover, the proofs of these closure properties are constructive. Hence, we may compute the DFA E and CFG H satisfying L ( E ) = L ( D ) ∩ Σ ≥ n and L ( H ) = L ( G ) ∩ Σ ≥ n . We also saw in our lecture that testing regular and context-free languages for emptiness are both decidable problems. In particular, it is possible to decide whether L ( E ) = ∅ and whether L ( H ) = ∅ . Finally, we argue that L ( D ) is infinite ⇔ L ( E ) negationslash = ∅ , and L ( G ) is infinite ⇔ L ( H ) negationslash = ∅ . Clearly, L ( E ) negationslash = ∅ if and only if L ( D ) contains a string of length n . Similarly, L ( H ) negationslash = ∅ if and only if L ( G ) contains a string of length at least n . So it remains only to prove that L ( D ) and L ( G ) are infinite if and only if they contain a string of length at least n . One direction is easy: if L ( D ) is infinite then it surely contains a string of length at least n , as otherwise L ( D ) would be finite. (The same holds for L ( G ) .) For the other direction, suppose that L ( D ) contains a string x of length at least n . By the pumping lemma for regular languages, there exist strings u,v,w with x = uvw such that: 1 • v negationslash = ε , • | uv | ≤ n , • uv i w ∈ L ( D ) for each i ≥ ....
View Full Document

{[ snackBarMessage ]}

Page1 / 7

4-solutions - CS 360 Introduction to the Theory of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online