__________________________________________________________________________
1.5.c
The following language is the complement of a simpler language. Construct a DFA
for the simpler language, then use it to give the state diagram of a DFA for the
language given. Σ = { a, b } . { w | w contains neither the substrings ab nor ba }.
Figure 1: Simpler language: { w | w contain at least one of the substrings ab or ba }.
Figure 2: The complement: { w | w contains neither the substrings ab nor ba }.
__________________________________________________________________________
1.6.b
Give state diagram of DFA recognizing the following language.
The alphabet is { 0, 1 } . { w| w contains at least three 1s }.
__________________________________________________________________________
1.7.e
Give state diagram of NFA with the specified number of states recognizing the
following language. The alphabet is { 0, 1 } . The language 0 * 1 * 0 + with three states.
0 * 1 * 0 + ≈ 00 … 0 11 … 1 0 0 … 0
__________________________________________________________________________
1.16
Use the construction given in Theorem 1.39 to convert the following two
nondeterministic finite automata to equivalent deterministic finite automata.
Let D be the DFA.
Step one: Constructing the D's states, one for each subset of the above NFA's states.
⟹ D's states:{ ∅, { 1 }, { 2 }, { 1, 2 }}
Step two: The Start state is the set of states that are reachable from 1 along 𝜖 arrows,
plus 1 itself.
⟹ Start state: E({ 1 }) = { 1 }
Step three: The new accept states are those containing the NFA's accept states.
⟹ Accept states: {{ 1 }, { 1, 2 }}
Step four: Drawing the transitions from NFA to D. And adding a a, b transition from ∅ to
itself.
a to { 1, 2 }
{1} via
b to {2}
a to ∅
⟹ From {2} via
b to {1}
a to { 1, 2 } ∪ ∅ = { 1, 2 }
{ 1, 2 } via
b to { 2 } ∪ { 1 } = { 1, 2 }
.................................................................................................................................................
Let D be the DFA.
Step one: Constructing the D's states, one for each subset of the above NFA's states.
⟹ D's states:{ ∅, { 1 }, { 2 }, { 3 }, { 1, 2 }, { 1, 3 }, { 2, 3 }, { 1, 2, 3 }}
Step two: The Start state is the set of states that are reachable from 1 along 𝜖 arrows,
plus 1 itself.
⟹ Start state: E({ 1 }) = { 1, 2 }
Step three: The new accept states are those containing the DFA's accept states.
⟹ Accept states: {{ 2 }, { 1, 2 }, { 2, 3 }, { 1, 2, 3 }}
Step four: Drawing the transitions from NFA to D. And adding a a, b transition from ∅ to
itself.
a to {3}
{1} via
b to ∅
a to { 1 } and a + 𝜖 to { 2 } ⟹ { 1, 2 }
{2} via
b to ∅
a to {2}
{3} via
b to { 2, 3 }
a to { 3 } ∪ { 1, 2 } = { 1, 2, 3 }
⟹⟹ From { 1, 2 } via
b to ∅∪∅ = ∅
a to { 3 } ∪ { 2 } = { 2, 3 }
{ 1, 3 } via
b to ∅ ∪ { 3, 2 } = { 2, 3 }
a to { 1, 2 } ∪ { 2 } = { 1, 2 }
{ 2, 3 } via
b to ∅ ∪ { 3, 2 } = { 2, 3 }
a to { 3 } ∪ { 1, 2 } ∪ { 2 } = { 1, 2, 3 }
{ 1, 2, 3 } via
b to ∅ ∪ ∅ ∪ { 2, 3 } = { 2, 3 }
Step five: Removing the states that are not reachable by any other states.
⟹ Remove states: {{ 1 }, { 3 }, { 2 }, { 1, 3 }}
Simplified
⏪⏪⏪⏪
⏫
__________________________________________________________________________
1.32
For languages A and B, let the shuffle of A and B be the language
w| w = a1 b1 … ak bk , where a1 … ak ∈ A and b1 … bk ∈ B, each ai , bi ∈ Σ * .
Show that the class of regular languages is closed under shuffle.
Let A and B be regular languages. We need to show that A shuffle B is regular.
by corollary 1.40 we know that a language is regular if and only if some NFA recognizes it.
So we take N 1 for A and N 2 for B and combine them into one new NFA, N.
Let N 1 = Q 1 , ∑ , 𝛿 1 , q 1 , F 1 recognize A and N 2 = Q 2 , ∑ , 𝛿 2 , q 2 , F 2 recognize B.
Now we Construct N = Q, ∑ , 𝛿, q 0 , F to recognize A shuffle B.
We have to construct N in such a way that first it accepts the 𝜖 since k can be zero and
second it accepts a string that is made from a 1 … a k and b 1 … b k so both a k and b k must
land in an accept state so it must keep track of two strings and then when it reads a new
character it decides (being nondeterministic is useful here) whether to move in the first or
the second string.
1. Q = (Q 1 × Q 2 ) ∪ { q 0 } which is {(q i , q j ) | q i ∈ Q 1 and q j ∈ Q 2 } ∪ { q 0 } .
To have all the possible states and the empty state.
2. Start state = q 0
3. Accept states= (F 1 × F 2 ) ∪ { q 0 } which is {(f i , f j ) | f i ∈ F 1 and f j ∈ F 2 } ∪ { q 0 } .
Accepts if both of the tracked strings are in the accept state and { q 0 } is for accepting
𝜖.
4. Transitions = for any q ∈ Q and any a ∈ Σ:
(q 1 , q 2 ) q = q0 , a = 𝜖
𝛿(q, a) =
{(𝛿1 (p1 , a), p2 ), (p1 , 𝛿2 (p2 , a))} q = (q1 , q2 ), a ≠ 𝜖
__________________________________________________________________________
1.33
Let A be any language. Define DROP - OUT (A) to be the language containing all
strings that can be obtained by removing one symbol from a string in A. Thus,
DROP - OUT (A) = xz| xyz ∈ A where x, z ∈ Σ * , y ∈ Σ .
Show that the class of regular languages is closed under the DROP - OUT
operation. Give both a proof by picture and a more formal proof by construction as
in Theorem 1.47.
Let A be a regular language. We need to show that DROP - OUT (A) is regular.
by corollary 1.40 we know that a language is regular if and only if some NFA recognizes it.
So we take D 1 for A and modify it to recognize a new NFA, N.
First we create to copies of the DFA D 1 .
Let D 1 = Q 1 , ∑ , 𝛿 1 , q 1 , F 1 and D'1 = Q'1 , ∑ , 𝛿'1 , q'1 , F'1 recognize A
Now we Construct N = Q, ∑ , 𝛿, q 0 , F to recognize DROP - OUT (A) .To do so for
each transition in D 1 from some state m to some state n by reading some character other
than 𝜖 (like a ∈ ∑ ), we add a shortcut that takes the state m from D 1 to the state n in D'1
by reading 𝜖, thus we dropped out one character. note that all the final states are in D'1 .
Now any path from the starting state in D 1 to an accept state in D'1 will include exactly
one such dropped out transition which will be chosen nondeterministically.
The formal proof:
N = Q, ∑ , 𝛿, q0 , F
1. Q = Q 1 ∪ Q'1
All the state from both D 1 and D'1 . Relabel each state q 1
2. Start state = q 0 = q 1
The start state in D 1 .
3. Accept states= F'1
Accept states in D'1 .
4. Transitions = for any q ∈ Q and any a ∈ Σ:
𝛿1 (q, a) q ∈ Q1 and a = 𝜖
𝛿(q, a) =
q' q ∈ Q1 and a ≠ 𝜖 and 𝛿1 (q, a) = q' ∈ Q'1
__________________________________________________________________________