CS 390 Test
March 6, 2004
1. Find a regular expression for each of the following languages over the alphabet {0, 1}:
(a) The language of all strings of odd length.
(00 + 01 + 10 + 11)*(0 + 1)
(b) The language of all strings each of which contains an odd number of 0's. [10 each]
(1 + 01*0)*
2. Prove that
(ax)r = xra
by structural (general) induction,
where a is an arbitrary symbol in the alphabet {0, 1}, x is an arbitrary string
over the alphabet. [20]
Note that wr for a string w is defined recursively as follows:
Basis Clause: r = .
Inductive Clause: (xa)r = axr for any string x and any symbol a.
Also the set of strings over the alphabet {0, 1} is defined recursively as:
Basis Clause: is in {0, 1}*.
Inductive Clause: If x is in {0, 1}*, then x0 and x1 are in {0, 1}*.
Extremal Clause: Nothing is in {0, 1}* unless it is obtained from the Basis and Inductive
Clauses.
Proof:
Basis Step: (a)r = ar = a.
Also ra = a = a.
Hence (ax)r = xra.
Inductive Step: Assume that (ax)r = xra for an arbitrary string x.
We need to prove that (axb)r = (xb)ra for an arbitrary symbol b in the alphabet.
(axb)r = b(ax)r by the definition of the reversal.
= b(xra) by the induction hypothesis.
= (bxr)a by the associativity of the concatenation operation.
= (xb)ra by the definition of the reversal.
end of proof
3 (a) Find an NFA
that recognizes the same language as the following NFA-
and list the accepting states of the NFA.
Note that { } below denotes the empty set. [15]
State
|
a
|
b
|
|
State
|
a
|
b
|
|
1
|
{ 3 }
|
{ }
|
{ 2 }
|
5
|
{ }
|
{ 8 }
|
{ }
|
2
|
{ 4 }
|
{ }
|
{ 6 }
|
6
|
{ 7, 8 }
|
{ 4 }
|
{ }
|
3
|
{ }
|
{ 4, 5 }
|
{ }
|
7
|
{ }
|
{ 7 }
|
{ }
|
4
|
{ }
|
{ }
|
{ 5 }
|
8
|
{ }
|
{ }
|
{ }
|
The initial state is state 1 and the accepting state is state 8.
(a)
State
|
a
|
b
|
State
|
a
|
b
|
1
|
{ 3, 4, 5, 7, 8 }
|
{ 4, 5 }
|
5
|
{ }
|
{ 8 }
|
2
|
{ 4, 5, 7, 8 }
|
{ 4, 5 }
|
6
|
{ 7, 8 }
|
{ 4, 5 }
|
3
|
{ }
|
{ 4, 5 }
|
7
|
{ }
|
{ 7 }
|
4
|
{ }
|
{ 8 }
|
8
|
{ }
|
{ }
|
(b) Find *(1, ab), where is the transition function
of the NFA-. [5]
{ 4, 5, 7, 8 }
(c) Find ({1, 4}) [5]
{ 1, 2, 4, 5, 6 }
4.
Find a DFA
that recognizes the same language as the following NFA
and list the accepting states of the DFA.
Note that { } below denotes the empty set. [15]
State
|
a
|
b
|
State
|
a
|
b
|
1
|
{ 2, 3, 4, 5, 6 }
|
{ 3 }
|
4
|
{ }
|
{ 4 }
|
2
|
{ }
|
{ 3, 6 }
|
5
|
{ }
|
{ }
|
3
|
{ }
|
{ 5 }
|
6
|
{ }
|
{ 5 }
|
The initial state is state 1 and the accepting state is state 5.
State
|
a
|
b
|
State
|
a
|
b
|
( 1 )
|
( 2, 3, 4, 5, 6 )
|
( 3 )
|
( 3, 4, 5, 6 )
|
( )
|
( 4, 5 )
|
( 2, 3, 4, 5, 6 )
|
( )
|
( 3, 4, 5, 6 )
|
( 4, 5 )
|
( )
|
( 4 )
|
( 3 )
|
( )
|
( 5 )
|
( 4 )
|
( )
|
( 4 )
|
( 5 )
|
( )
|
( )
|
( )
|
( )
|
( )
|
5. Which of the following statements are true and which are false ? [20]
(a) ( (S) ) = (S), where S is
a set of states of an NFA-.
True
(b) (a + b )* = (a*b*)*.
True
(c) *(q, w) for an NFA is
one of its states, where q is a state and w is a string.
False
(d) *(q, xy) = *(*(q,x), y) for a DFA, where q is a state, and x and y are strings.
True
(e) For a function f and subsets S and T of its domain, f(S U T) = f(S) U f(T).
True
(f) (L+)* = L+ for a language L.
False
(g) 1(01)* = (10)*1.
True
(h) If L* = L+ for a language L, then is in L.
True
(i) If a language L1 is a subset of a language L2,
then L1k is
a subset of L2k for any natural number k.
True
(j) For strings x and y, (xy)r = xryr, where wr denotes
the reversal of string w.
False