CS 4510: Problem Set 1 Solutions - Regular Expressions and Finite Automata, Assignments of Computer Science

Solutions to problem 4 of cs 4510: automata and complexity, which involves giving regular expressions for certain languages. It also includes a proof that an exponential blowup is necessary when converting an nfa to an equivalent dfa in the worst case.

Typology: Assignments

Pre 2010

Uploaded on 08/05/2009

koofers-user-mvl
koofers-user-mvl 🇺🇸

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 4510: Automata and Complexity
Problem Set 1 Solutions
Problem 4 Give a regular expression for each of the following languages.
1. {w: The length of wis a multiple of 3}.
Solution: (ΣΣΣ)
2. {w:weither starts with 01 or ends with 10}.
Solution: (01Σ)10)
3. {w:wdoes not contain the substring 001}.
Solution: (1 01)0
Problem 6
The procedure for converting an NFA to an equivalent DFA given in class yields an exponential
blowup in the number of states. That is, if the original NFA has nstates, then the resulting DFA
has 2nstates. In this problem, you will show that such an exponential blowup is necessary in the
worst case.
Define Ln={w: The nth symbol from the right is 1}.
1. Give an NFA with n+ 1 states that recognizes Ln.
2. Prove that any DFA with fewer than 2nstates cannot recognize Ln. (Hint: Let Mbe any
DFA with fewer than 2nstates. Start by showing that there exist two different strings of
length nthat drive Mto the same state.)
Proof: Let Mbe any DFA with fewer than 2nstates. We will show that Mcannot recognize
Ln. Since there are 2nstrings of length n, by the Pigeonhole Principle, there are two different
strings x=x1x2· · · xnand y=y1y2· · · ynthat drive Mto the same state. Since x6=y, there
is some isuch that xi6=yi. Without loss of generality, say that xi= 1 and yi= 0. Let
x0=x0i1and y0=y0i1. It is easy to see that x0Lnand y06∈ Ln. However, since xand
ydrive Mto the same state, it is clear that x0=x0i1and y0=y0i1also drive Mto the
same state, yet x0Lnand y06∈ Ln. Therefore Mcannot recognize Ln.
1

Partial preview of the text

Download CS 4510: Problem Set 1 Solutions - Regular Expressions and Finite Automata and more Assignments Computer Science in PDF only on Docsity!

CS 4510: Automata and Complexity

Problem Set 1 Solutions

Problem 4 Give a regular expression for each of the following languages.

  1. {w : The length of w is a multiple of 3}. Solution: (ΣΣΣ)∗
  2. {w : w either starts with 01 or ends with 10}. Solution: (01Σ∗) ∪ (Σ∗10)
  3. {w : w does not contain the substring 001}. Solution: (1 ∪ 01)∗ 0 ∗

Problem 6

The procedure for converting an NFA to an equivalent DFA given in class yields an exponential blowup in the number of states. That is, if the original NFA has n states, then the resulting DFA has 2n^ states. In this problem, you will show that such an exponential blowup is necessary in the worst case.

Define Ln = {w : The nth symbol from the right is 1}.

  1. Give an NFA with n + 1 states that recognizes Ln.
  2. Prove that any DFA with fewer than 2n^ states cannot recognize Ln. (Hint: Let M be any DFA with fewer than 2n^ states. Start by showing that there exist two different strings of length n that drive M to the same state.) Proof: Let M be any DFA with fewer than 2n^ states. We will show that M cannot recognize Ln. Since there are 2n^ strings of length n, by the Pigeonhole Principle, there are two different strings x = x 1 x 2 · · · xn and y = y 1 y 2 · · · yn that drive M to the same state. Since x 6 = y, there is some i such that xi 6 = yi. Without loss of generality, say that xi = 1 and yi = 0. Let x′^ = x 0 i−^1 and y′^ = y 0 i−^1. It is easy to see that x′^ ∈ Ln and y′^6 ∈ Ln. However, since x and y drive M to the same state, it is clear that x′^ = x 0 i−^1 and y′^ = y 0 i−^1 also drive M to the same state, yet x′^ ∈ Ln and y′^6 ∈ Ln. Therefore M cannot recognize Ln.