CS 390 Solutions to Test II

revised on July 27, 2000



July 25, 2000



1. Find an NFA without $\Lambda$ that accepts the same language as the following NFA-$\Lambda$: [26]


$q$ $\sigma$ $\delta(q, \sigma)$ $q$ $\sigma$ $\delta(q, \sigma)$
$q_{0}$ $a$ {$q_{1}$} $q_{1}$ $\Lambda$ {$q_{2}$}
$q_{0}$ $b$ {$q_{2}$} $q_{2}$ $\Lambda$ {$q_{0}$}


The initial state is $q_{0}$ and the accepting state is $q_{2}$.
The transitions not given in the table are to the empty set.


Solution


$q$ $\sigma$ $\delta(q, \sigma)$ $q$ $\sigma$ $\delta(q, \sigma)$
$q_{0}$ $a$ { $q_{0}, q_{1}, q_{2}$} $q_{1}$ $b$ {$q_{0}, q_{2}$}
$q_{0}$ $b$ {$q_{0}, q_{2}$} $q_{2}$ $a$ { $q_{0}, q_{1}, q_{2}$}
$q_{1}$ $a$ { $q_{0}, q_{1}, q_{2}$} $q_{2}$ $b$ {$q_{0}, q_{2}$}


The initial state is $q_{0}$ and the accepting state is $q_{2}$.



2. Find an FA that accepts the same language as the following NFA: [26]


$q$ $\sigma$ $\delta(q, \sigma)$ $q$ $\sigma$ $\delta(q, \sigma)$
$q_{0}$ $a$ {$q_{1}$, $q_{2}$} $q_{2}$ $a$ {$q_{3}$}
$q_{0}$ $b$ {$q_{3}$} $q_{2}$ $b$ {$q_{2}$}
$q_{1}$ $a$ $\emptyset$ $q_{3}$ $a$ $\emptyset$
$q_{1}$ $b$ {$q_{3}$} $q_{3}$ $b$ $\emptyset$


The initial state is $q_{0}$ and the accepting state is $q_{3}$.


Solution


$q$ $\sigma$ $\delta(q, \sigma)$ $q$ $\sigma$ $\delta(q, \sigma)$
{$q_{0}$} $a$ {$q_{1}$, $q_{2}$} {$q_{2}, q_{3}$} $a$ {$q_{3}$}
{$q_{0}$} $b$ {$q_{3}$} {$q_{2}, q_{3}$} $b$ {$q_{3}$}
{$q_{1}, q_{2}$} $a$ {$q_{3}$} {$q_{2}$} $a$ {$q_{3}$}
{$q_{1}, q_{2}$} $b$ {$q_{2}, q_{3}$} {$q_{2}$} $a$ {$q_{2}$}
{$q_{3}$} $a$ $\emptyset$ $\emptyset$ $a$ $\emptyset$
{$q_{3}$} $b$ $\emptyset$ $\emptyset$ $b$ $\emptyset$


The initial state is {$q_{0}$} and the accepting states are {$q_{3}$} and {$q_{2}, q_{3}$} .



3. Let $S$ and $T$ be sets of states of an NFA-$\Lambda$.
Prove that $\Lambda(S \cup T) \subseteq \Lambda (S) \cup \Lambda (T)$ by structural induction. [20]



Proof: Proof by induction on $\Lambda(S \cup T)$
Note that here we are trying to prove that all elements of $\Lambda(S \cup T)$ have a certain property. The property here is "being in set $\Lambda (S) \cup \Lambda (T)$".
Basis Step: Since the basis of $\Lambda(S \cup T)$ is $(S \cup T)$, we show $(S \cup T) \subseteq
\Lambda (S) \cup \Lambda (T)$.
By the definition of $\Lambda$-closure, $S \subseteq \Lambda (S)$ and $T \subseteq \Lambda (T)$.
Hence $S \subseteq \Lambda(S) \cup \Lambda(T)$ and $T \subseteq \Lambda(S) \cup \Lambda(T)$.
Hence $(S \cup T) \subseteq
\Lambda (S) \cup \Lambda (T)$.
Inductive Step: Assume that for any arbitrary state $q$ in $\Lambda(S \cup T)$, $q \in \Lambda (S) \cup \Lambda (T)$.
We need to show that $\delta(q, \Lambda) \subseteq \Lambda (S) \cup \Lambda (T)$.
If $q \in \Lambda (S) \cup \Lambda (T)$, then $q \in \Lambda (S)$ or $q \in \Lambda (T)$.
Hence by the definition of $\Lambda$-closure $\delta(q, \Lambda) \subseteq \Lambda (S)$ or $\delta(q, \Lambda) \subseteq \Lambda (T)$.
Hence $\delta(q, \Lambda) \subseteq \Lambda (S) \cup \Lambda (T)$, which is what we needed to show.



4. For the FA given below answer the following questions:
(a) Find $R(1,3,3)$ using the recursive formula given by Kleene's Theorem. [10]
(b) Find the language accepted by this FA. You may answer this by inspection. [18]


$q$ $\sigma$ $\delta(q, \sigma)$ $q$ $\sigma$ $\delta(q, \sigma)$
$q_{0}$ $a$ $q_{1}$ $q_{2}$ $a$ $q_{3}$
$q_{0}$ $b$ $\emptyset$ $q_{2}$ $b$ $q_{0}$
$q_{1}$ $a$ $q_{2}$ $q_{3}$ $a$ $q_{1}$
$q_{1}$ $b$ $\emptyset$ $q_{3}$ $b$ $\emptyset$


The initial state is $q_{0}$ and the accepting state is $q_{3}$ ({, } have been deleted from the original question).



Solutions


Let us use $i$ to denote state $q_{i}$ for simplicity.
(a) $R(1,3,3) = R(1,3,2) + R(1,3,2)R(3,3,2)^{*}R(3,3,2)$
$R(1,3,2) = R(1,3,1) + R(1,2,1)R(2,2,1)^{*}R(2,3,1)$
= $\emptyset + a(baa)^{*}a = a(baa)^{*}a$
$R(3,3,2) = R(3,3,1) + R(3,2,1)R(2,2,1)^{*}R(2,3,1)$
= $\Lambda + aa(baa)^{*}a$
Hence $R(1,3,3) = a(baa)^{*}a + a(baa)^{*}a(\Lambda + aa(baa)^{*}a)^{*}(\Lambda + aa(baa)^{*}a)$
= $a(baa)^{*}a(aa(baa)^{*}a)^{*}(\Lambda + aa(baa)^{*}a) $
= $a(baa)^{*}a(aa(baa)^{*}a)^{*}$
(b) $a(aaa + aba)^{*}aa$ or $aa(aaa + baa)^{*}a$ or any other equivalent one.