You are on page 1of 3

Fall 2017 CIS 262

Automata, Computability and Complexity


Jean Gallier
Solutions for Homework 5
October 9, 2017

Problem B1 (40 pts). Let R be any regular language over some alphabet . Prove that
the language
L = {u | v , uv R, |u| = |v|}
is regular.

Assume that R is accepted by the DFA D = (Q, , , q0 , F ). The idea is to simulate


two copies of D in parallel, forward and starting from q0 in the first copy, backward and
nondeterministically starting from some final state in the second copy, and accepting when
the same state is reached in both copies of D. This way, on input u, every transition on
some symbol a in the first copy is matched by a transition along the inverse of some
edge in the second copy, no matter what the input symbol a is. An NFA implementing the
above idea can be constructed as follows. Let

N = ((Q Q) {s0 }, , 2 , s0 , {(p, p) | p Q})

where s0 is a new state not in Q, and the transition function 2 is defined as follows: for
every a and every (p1 , p2 ) Q Q,

(q1 , q2 ) 2 ((p1 , p2 ), a)

iff
(p1 , a) = q1 and (b )((q2 , b) = p2 )
and
(q0 , f ) 2 (s0 , ) iff f F.
Then, we can show by induction on |u| that

(q1 , q2 ) 2 (s0 , u)

iff
(q0 , u) = q1 and (q2 , v) F for some v such that |u| = |v|.

1
The base case w =  is easy. For the induction step, if we write w = ua with a , then we
have [
2 (s0 , ua) = 2 ((s1 , s2 ), a).
(s1 ,s2 ) 2 (s0 ,u)

By the induction hypothesis, (s1 , s2 ) 2 (s0 , u) iff

(q0 , u) = s1

and if there is some v such that |u| = |v| and (s2 , v) F . Also, (q1 , q2 ) 2 ((s1 , s2 ), a)
iff
(s1 , a) = q1
and if there is some b such that

(q2 , b) = s2 .

Then, we get
(q0 , ua) = ( (q0 , u), a) = (s1 , a) = q1
and
(q2 , bv) = ((q2 , b), v) = (s2 , v) F
with |ua| = |bv| since |u| = |v|. Therefore, (q1 , q2 ) 2 (s0 , ua) iff

(q0 , ua) = q1

and there is some bv such that |ua| = |bv| and

(q2 , bv) F

which concludes the induction hypothesis.


Since the final states of N are of the form (q, q) where q Q, we have

(q, q) 2 (s0 , u)

iff
(q0 , u) = q and (q, v) F for some v such that |u| = |v|,
and thus,
(q0 , uv) = ( (q0 , u), v) = (q, v) F,
so that uv L(G). This proves that L(N ) = L.
Another solution consists in first guessing the state, p, in which D will end up on input
u and to run in parallel, Dp = (Q, , , q0 , {p}), with p as only final state, with the copy, Dp0 ,
of D, where Dp0 is the NFA D with start state p, which, from any state, q, makes moves on
all input a if there is some transition from q. Formally, we can define the NFA

N = ((Q Q Q) {s0 }, , 0 , s0 , {(p, f, p) | (p, f ) Q F }),

2
such that, for every a ,
(q1 , q2 , p) 0 ((p1 , p2 , p), a)
iff (p1 , a) = q1 and there is some b such that (p2 , b) = q2 , and

(q0 , p, p) 0 (s0 , ),

for all p Q.

You might also like