Give a NFA over the alphabet {a ,b , c}

1k Views Asked by At

How do I solve this?

Give a NFA over the alphabet {a, b, c} whose words have a length which is multiple of 4 or are such that the number of a’a plus the number of b’s in the word is even.

Use then the subset construction to build the corresponding DFA.

I am unsure if the NFA will look like this

i am unsure if the NFA will look like this

or like this...

or like this...

and I know it has to be with a,b and c instead but how do I do that?

1

There are 1 best solutions below

8
On

HINT: I think that it’s at least as easy to construct a DFA directly. Since every DFA is in fact an NFA as well, this does not violate the letter of the instructions, though it may violate their spirit.

Let $L_0$ be the set of words over $\Sigma=\{a,b,c\}$ whose lengths are divisible by $4$, and let

$$L_1=\left\{w\in\Sigma^*:|w|_a+|w|_b\text{ is even}\right\}\;;$$

your language is $L=L_0\cup L_1$. Start by building a DFA $M_0$ for $L_0$; this is very easy and can be done with just $4$ states. Then build a DFA $M_1$ for $L_1$; this is also easy and can be done with just $2$ states. Then form the cross-product DFA $M$ of $M_0$ and $M_1$; if $Q_0$ and $Q_1$ are the state sets of $M_0$ and $M_1$, respectively, the state of $M$ is $Q_0\times Q_1$, and the transitions are set up so that

$$\langle p,q\rangle\overset{x}\longrightarrow\langle p',q'\rangle$$

is a transition of $M$ if and only if

$$p\overset{x}\longrightarrow p'$$

is a transition of $M_0$ and

$$q\overset{x}\longrightarrow q'$$

is a transition of $M_1$. This means that $M$ in effect runs $M_0$ on the first coordinate of the states and $M_1$ on the second coordinate. With a proper choice of initial state (for which there really is only one sensible choice, and it’s the right one) and acceptor states $M$ will accept $L$. By the way, by suitably changing the acceptor states you can make accept and of the languages $L_0\cap L_1$, $L_0\setminus L_1$, and $L_1\setminus L_0$ instead, so this is a very useful construction. You may find this PDF helpful