Title: Test 1
1Test 1 Computer Science 500 Spring
2000 February 14 This test is closed-book, 75
minutes Please make sure that you understand
what the questions ask for. Do not hesitate to
ask Pete for clarification Please check your
work and be as precise as reasonably possible.
2Problem 1 a) Write down a regular expression
for the language L all binary strings of
hamming weight equal to 1 mod 2 or a strings
with a positive number of 0s b) Draw the
statetransition diagram for an NFA that accepts
L
8 pts
010(1010)
7 pts
0
0
1
Acc
e
1
e
0
0
Acc
1
0,1
1
32a) draw a DFA that accepts L(N) where N is
the following NFA
10pts
0,1
b
1
1
0
1
Acc
acc
1
a,c
a
0, e
c
a,b,c
acc
0
0
1,e
b
b,c
0
acc
0,1
1
4Problem 2b Write a regular expression for L(N)
from problem 2a
15pts
1 (0Ue) 1
5Problem 3a Prove that the following binary
language is not regular L 0a1b0c where a
b - c and a,b,c are non-negative integers
15pts
- If
- ? a value n such that
- ? w ? L such that w gt n, let w 0n12n0n
- ? x,y,z such that w xyz
where y gt 0, yz lt n - ? i gt 0, xyiz ? L let i 2 note xyiz
0ny12n0n ? L then L is not a regular
language
63b. Prove the following variant of the pumping
lemma
15pts
- If L is a regular language, then
- ? a value n such that
- ? w ? L such that w gt n,
- ? x,y,z such that w xyz
where y gt 0, yz lt n - ? i gt 0, xyiz ? L
7Proof
Let n the number of states of a DFA D that
accepts L Let w be any string in L s.t. w gt
n Let w k and let s1, s2, ... sk1 be the
path of states that D traverses while computing
on w. Because k1 - k n gt n, the pigeon-hole
principle implies that (at least) two of the
states sk-n, sk-n1... sk1 must be identical.
Let i,j be such that k-n lt i lt j lt k1 and si
sj. Let w w1w2 ... wk and x w1w2 ... wi and y
wi1 ... wj and z wj1... wk Note that y gt
0, yz lt n and ? i gt 0, xyiz ? L,
8Problem 4 Is the following statement true or
false? Prove your answer. ? regular binary
languages L1 , L2 , L3 is regular where L3
w ?? x ? L1 ,y ? L2 such that x y w
and ? i 1 lt i lt w wi xi xor yi .
10pts
It is true. Given any L1 , L2 , let L1 L(D1),
L2 L(D2) where D1, D2 are DFAs. We define a
DFA D3 and prove L3 L(D3). Let D1 (0,1,
Q1, ?1, s1, A1), D2 (0,1, Q?, ??, s?,
A?). Define NFA N3 (0,1, Q1 x Q?, ?3, (s1,
s?), A1 x A?). ? bits c, states (q1, q2 ) ? Q1 x
Q?, define ?3 (c, (q1, q2 ), (q3, q4) ) iff ?
a,b c a ? b and ?1 (a, q1) q3 and ?2 (b, q2
) q4
9Claim L3 L(N3) i.e. ?w, w ? L3 ? N3 accepts
w Proof (?) If w ? L3 , then ?? x ? L1 ,y ? L2
such that x y w and ? i 1 lt i lt w
wi xi xor yi One can use accepting paths in
D1 and D2 on x and y to generate a path in N3
on w that leads from the start state to an accept
state. (?) If N3 accepts w, then there is an
accepting path in N3 on w. If one uses the bits
a, b for each step in the path, one can construct
x and y where x ? L1 ,y ? L2 such that x y
w and ? i 1 lt i lt w wi xi xor yi
10Problem 5 (True or False) a) Every
recognizable language is decidable False
consider the complement of Lu b) If L is regular
and L L1 ? L2, then L1 must be regular False.
Consider L f, L1 0n1n n in Z, L2 f c)
Every regular language is decidable True. One
can simulate the DFA on its input d) The language
L yy y a binary string is a regular
language. False. Contrapositive of the pumping
lemma applies let w 10n 10n , i 2 e) If a
language L is a regular language, then L is
finite False. Consider 0
3 points each