Exercise - 3
Exercise - 3
1. Design a NFA for the following language over the alphabet {0,1}:
“Accepts all strings that contain two 0’s separated by a substring whose
length is a multiple of 3”.
2. Is the class of languages recognized by NFAs closed under complement?
Explain your answer.
3. Show by giving an example that, if M is an NFA that recognizes language C,
swapping the accept and non-accept states in M doesn’t necessarily yield a
new NFA that recognizes C complement.
4. Suppose we define a restricted version of the Java programming language in
which variable names must satisfy all of the following conditions:
• A variable name can only use Roman letters (i.e., a, b, . . . , z,
A, B, . . . , Z) or Arabic numerals (i.e., 0, 1, 2, . . . , 9); i.e.,
underscore and dollar sign are not allowed.
• A variable name must start with a Roman letter: a, b, . . . , z, A,
B, . . . , Z
• The length of a variable name must be no greater than 8.
• A variable name cannot be a keyword (e.g., if). The set of
keywords is finite.
Let L be the set of all valid variable names in our restricted version of Java.
Let L0 be the set of strings satisfying the first 3 conditions above; i.e., we do
not require the last condition. Give a regular expression for L0.
5. Let Σm = {a1, . . . , am} be an alphabet containing m elements, for some
integer m ≥ 1. Let Lm be the following language: “Accepts all strings in
which at least one ai occurs an even number of times (not necessarily
consecutively), where 1 ≤ i ≤ m”. Construct an NFA for the language L2.
6. Prove that, for any NFA N there is a DFA D, such that L(D) = L(N), and
vice versa.
7. Prove that "If L = L(A) for some DFA A, then there is an Regular
Expression R such that L = L(R)."
8. Consider machine D1. Apply the Myhill-Nerode theorem using Table-1 to
minimize D1 and then convert it to a regular expression. Table-1 represents
the marking of all pairs of states (P, Q) where P∈ F and Q∉ F for the given
D1.
A B C D
State 0 1
A B C B 0
B B D C 0 0
C B C
D 0 0 0
D B E
E B C E 1 1 1 1
D-1
Table-1