Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Jeremy Corren [jdc2189] COMS W3261: HW2 2/4/2017

COMS W3261: HW2

Jeremy Corren [jdc2189]

1a What is L1 L2 ? Provide two strings in this language and two strings not
in this language.

L1 L2 = {xy | x has at most two 0s and y has at an odd number of 0s}.


001 10 and 101 000 give two strings 00110, 101000 2 L1 L2 .
000 1 and 0000 100 give two strings 0001, 0000100 2/ L1 L2 .

1b Construct DFAs for L1 and L3 , and use the intersection construction to


derive a DFA for L1 \ L3 .

DFA accepting L1 , where L1 = {w | w has at most two 0s}

qw 0 qx 0 qy 0 qz
start

1 1 1 1,0

DFA accepting L3 , where L3 = {w | w has at least two 1s}

qa 1 qb 1 qc
start

0 0 1,0

DFA accepting L1 \L3 , where L1 \L3 = {w | w has at most two 0s and at least two 1s}

1 1
start {w, a} {w, b} {w, c} 1

0 0 0

1 1
{x, a} {x, b} {x, c} 1

0 0 0

1 1
{y, a} {y, b} {y, c} 1

0 0 0

1 1
{z, a} {z, b} {z, c} 1

0 0 0

1
Jeremy Corren [jdc2189] COMS W3261: HW2 2/4/2017

2 Let L1 , L2 be arbitrary languages.


Prove that L1 L1 L2 if and only if " 2 L2 or L1 = ;.

First, we will show that if L1 L1 L2 , then " 2 L2 or L1 = ;.

Suppose L1 L1 L2 , where L1 L2 = {xy | x 2 L1 , y 2 L2 }. Note that for any


string w, w " = w. Then, if the string x 2 L1 and x 2 L1 L2 , it must be the
case that for some y, where y 2 L2 and xy 2 L1 L2 , y = ". We have shown
that if L1 L1 L2 , then " 2 L2 .

Next, we will show that if " 2 L2 or L1 = ;, then L1 L1 L2 .

Suppose " 2 L2 . Then, for all a such that a 2 L1 , L1 L2 will include ev-
ery a ". Note that for any string w, w " = w. Then, for all a, it follows
that a 2 L1 L2 . Since all elements belonging to L1 also belong to L1 L2 ,
L1 L1 L2 .

Or suppose L1 = ;. For any language L, L ; = ;. Then, L1 L2 = ;. As a


result, L1 = ; and L1 L2 = ;. Since ; ;, it follows that L1 L1 L2 .

3 Let Li = {ai bi |, i 0}. Define


S1 languages Li for i = 0, 1, 2, ... and show that
(1) Li is regular and (2) L = i=0 Li .

Using the definition of L, we can define:


L0 = {"}
L1 = {ab}
L2 = {aabb}
..
.
where each Li is a finite string of length 2i. Then, for all i, we can construct
an NFA Ni accepting Li , where Ni = (Qi , , i , qj , Fi ). For each Ni , Qi would
have 2i + 1 states to process the given string of length 2i, a single start state
qj and a single accept state qj+(2i+1) 2 F . i (q, a) would move from qj through
the intermediary states, given correct input characters, to qj+(2i+1) . Since we
can construct an NFA for each Li , we have shown that each Li is regular.

Now consider the union of all Li for i = 0, 1, 2, ... Let us attempt to construct
an NFA for which the union L0 [ L1 [ ... is accepted, in order to show that L
is regular. We begin by creating a new start state q0 and drawing "-transitions
from q0 to each of the initial states for all Li . However, since i goes from
0...1, there are necessarily
S1 infinitely many states needed to process L, since,
by definition, L = i=0 Li . Since we cannot create an NFA with an infinite
number of states, there exists no NFA that accepts L. Therefore, L cannot be
regular.

2
Jeremy Corren [jdc2189] COMS W3261: HW2 2/4/2017

4 Given a DFA A that recognizes L, where L {a, b} , construct an NFA B


recognizing wrap(L), where wrap(L) = {abxba | x 2 L}.

Let A = (Q, , , q1 , F ) recognize L


B = (Q0 , , 0 , qv , F 0 ) recognize wrap(L), where

Q0 = {Q [ qv [ qw [ qx [ qy [ qz }
qv is the new start state.
F 0 = {qz }
Define 0 so that for any q 2 Q0 and any a 2 " ,
8
>
> {qw } q = qv and a = a
>
>
>
> {q1 } q = qw and a = b
>
>
>
>
< (q, a)
> q 2 Q and q 2 F
0
(q, a) = (q, a) q 2 F and a 6= "
>
>
>
> (q, a) [ {qx } q 2 F and a = "
>
>
>
>
>
> {qy } q = qx and a = b
>
:
{qz } q = qy and a = b

If B reads a and then b, the computation passes from the new start state qv
through qw to arrive at q1 , the former start state of A. If the string x 2 L, the
computation will reach at least one state q 2 F , where F is the set of former
accepting states in A. B will take "-transitions from any of these states to qx . If
B reads b and then a, the computation passes from qx through qy to the single
accept state in F 0 , qz .

Since we have defined the NFA B that accepts wrap(L), then wrap(L) must be
regular.

You might also like