CS 172: Computability and Complexity - Homework 2 - Prof. S. A. Seshia, Assignments of Computer Science

Information about homework 2 for the cs 172: computability and complexity course, taught by s. A. Seshia and a. Kulkarni, in spring 2008. The homework covers topics such as equivalence of dfas and nfas, regular expressions, and regular languages. Students are required to complete various problems and provide clear and concise solutions.

Typology: Assignments

Pre 2010

Uploaded on 10/01/2009

koofers-user-x8k
koofers-user-x8k 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS 172: Computability and Complexity, Spring 2008 S. A. Seshia & A. Kulkarni
HW 2: Equivalence of DFAs & NFAs; Regular Expressions
Assigned: January 31, 2008 Due in 283 Soda box, 5pm: February 7, 2006
Note: Take time to write clear and concise solutions. Confused and long-winded answers
may be penalized. Consult the course webpage for course policies on collaboration.
1. (8 points)
(a) Give an NFA recognizing all binary strings with a 1 in the third position from
the end and a 0 in the fourth position from the end.
(b) Following the equivalence proof, convert this to a DFA.
(c) Give a regular expression for this language. You are not required to use the
equivalence proof.
(d) Simplify the DFA given in part (b) so that every state is reachable by some
possible computation of the machine.
2. (6 points) If w=w1w2. . . wnis a string, define w1/2to be the first half of w. I.e.
w1/2=w1w2w3. . . wbn
2c. For any language L, define L1/2=w1/2:wL.
Prove that if Lis regular, then L1/2is regular.
Hint: If a DFA recognizing Lhas state space Q, construct an NFA with state space
Q×Qwhere the first coordinate goes forward and the second coordinate goes back-
ward.
3. (4 points)
(a) Prove that every NFA can be converted to an equivalent NFA that has a single
accept state.
(b) Give an example to support the falsity of the following statement: every DFA
can be converted into an equivalent DFA with a single accept state.
(c) (no points, optional) Give an NFA with a single accept state that recognizes
L=. Also, prove formally that the statement in part (b) is false.
1
pf2

Partial preview of the text

Download CS 172: Computability and Complexity - Homework 2 - Prof. S. A. Seshia and more Assignments Computer Science in PDF only on Docsity!

CS 172: Computability and Complexity, Spring 2008 S. A. Seshia & A. Kulkarni

HW 2: Equivalence of DFAs & NFAs; Regular Expressions

Assigned: January 31, 2008 Due in 283 Soda box, 5pm: February 7, 2006

Note: Take time to write clear and concise solutions. Confused and long-winded answers may be penalized. Consult the course webpage for course policies on collaboration.

  1. (8 points)

(a) Give an NFA recognizing all binary strings with a 1 in the third position from the end and a 0 in the fourth position from the end. (b) Following the equivalence proof, convert this to a DFA. (c) Give a regular expression for this language. You are not required to use the equivalence proof. (d) Simplify the DFA given in part (b) so that every state is reachable by some possible computation of the machine.

  1. (6 points) If w = w 1 w 2... wn is a string, define w^1 /^2 to be the first half of w. I.e. w^1 /^2 = w 1 w 2 w 3... wbn 2 c . For any language L, define L^1 /^2 =

w^1 /^2 : w ∈ L

Prove that if L is regular, then L^1 /^2 is regular.

Hint: If a DFA recognizing L has state space Q, construct an NFA with state space Q × Q where the first coordinate goes forward and the second coordinate goes back- ward.

  1. (4 points)

(a) Prove that every NFA can be converted to an equivalent NFA that has a single accept state. (b) Give an example to support the falsity of the following statement: every DFA can be converted into an equivalent DFA with a single accept state. (c) (no points, optional) Give an NFA with a single accept state that recognizes L = ∅. Also, prove formally that the statement in part (b) is false.

  1. (3 points) Explain in words what languages the following regular expressions repre- sent. Let Σ = {a, b}.

(a) (a ∪ ba ∪ bb)Σ∗ (b) Σ∗aΣ∗bΣ∗aΣ∗

  1. (4 points) Let L be a language comprising all strings w over { 0 , 1 } such that w contains either: - an even number of 1 s, no occurrences of the sub-string 1101 , and total length greater than five, OR - a 0 in the third position and odd length.

Write down a regular expression that generates L. Justify your answer.

  1. (5 points)

(a) Let A be a regular expression. Prove that A ◦ ε = A. (b) In the C programming language, comments appear between delimiters such as /∗ and ∗/. Let L denote the language of all valid delimited comment strings. A member of L must begin with /∗ and end with ∗/ but have no intervening ∗/. For simplicity, assume that the comments themselves are written only with the symbols 0 and 1 , so the alphabet Σ is { 0 , 1 , ∗, /}. Give a regular expression that generates L.