You are on page 1of 2

Department of Computer Science & Software Engineering

Comp335 Introduction to Theoretical Computer Science


Winter 2024

Assignment 2. Due date: February 23, by midnight

1. Give a regular expression for each of the languages below.

(a) {w ∈ {a, b, c} ∶ na (w) ≥ 1 and nb (w) ≥ 2}


(b) {ak bm cn ∶ k + m + n is odd}.

2. Consider the two regular expressions

R = 0∗ + 1∗
S = 01∗ + 10∗ + 1∗ 0 + (0∗ 1)∗

(a) Find a string in L(R) ∖ L(S).


(b) Find a string in L(S) ∖ L(R).
(c) Find a string in L(R) ∩ L(S).
(d) Find a string in L(R) ∪ L(S).

3. For each of the DFA’s A, B, C below, use the state elimination technique to obtain an equivalent
regular expression.

A a b B a b C a b c
→ q0 q1 q2 → q0 q1 q2 → q1 q6 q2 q4
q1 q1 q2 q1 q0 q2 q2 q3 q6 q6
q2 q3 q4 ⋆q2 q1 q0 q3 q4 q5 q6
⋆q3 q5 q5 q4 q2 q6 q5
⋆q4 q5 q5 ⋆ q5 q6 q6 q6
q5 q5 q5 q6 q6 q6 q6

4. Convert the following regular expressions to -NFA’s.

(a) (000)∗ ( + 011 + 001)(111)∗


(b) (01 + 10)∗ + (00 + 11)∗ + (1 + 10 + 100)∗

1
5. Using the method of Theorem 3.14 to prove of disprove each of the following statements about
regular expressions.

(a) R(S + T ) = RS + RT .
(b) (R + S)∗ = (R∗ S ∗ )∗
(c) (R + S)∗ = R∗ + S ∗ .
(d) (RS + R)∗ RS = (RR∗ S)∗ .

6. For each of the following languages apply the Pumping Lemma to show that the language is
not regular.
In all cases start with the following:
Suppose to the contrary that L is regular
⇒ ∃ DFA A, s.t. L(A) = L. Let p be the number of states in A.
⇒ ∀w ∈ L(A), if ∣w∣ ≥ p, then w = xyz, where ∣xy∣ ≤ p, ∣y∣ = k ≥ 1, and xy i z ∈ L(A) for all i ≥ 0.

(a) The set of all binary strings with an equal number of occurrences of substrings 01 and
10 where overlapping substrings are not allowed. For instance 01010 is not accepted, but
011010001 is accepted.
n
(b) {a2 ∶ n ≥ 0}.
(c) {an bm ak ∶ n = m or m = k}.

7. (a) Construct NFA’s A and B, such that L(A) = L(ab∗ a∗ ), and L(B) = L(a∗ b∗ a).
Then use these NFA’s to construct an NFA C, such that L(C) = L(A) ∩ L(B).
(b) Suppose h is the homomorphism from {0, 1, 2} to {a, b}∗ defined by h(0) = a, h(1) = b, and
h(2) = ba.
i. What is the string h(21120)?
ii. What is the language h(L(0 + 1∗ 2))?
iii. Let L = {ba}. What is the language h−1 (L)?

8. Draw the table of distinguishabilities for the DFA below (i.e., run the TF algorithm), and then
construct the minimum state equivalent DFA.

0 1
→ A B E
B C F
*C D H
D E H
E F I
*F G B
G H B
H I C
*I A E

You might also like