Design a finite automaton that recognizes a word that begins with $a$ and even number of $b$

108 Views Asked by At

Given the language $$L=\{w\in\{a,b\}^*\mid\text{$w$ starts with $a$ and has a total of even $b$}\}$$ design a finite automaton that recognizes it.


Consider $M=\bigl(\{q_0,q_1\},\{0,1\},\delta,q_0\bigr)$, where $\delta:\{q_0,q_1\}\times\{0,1\}\to\{0,1\}$ defined by

Finite automaton

but then I realized that $a$ appears once, when the statement does not say anything about that.

How could we find it?

Thanks!

1

There are 1 best solutions below

12
On BEST ANSWER

Well, parts of it are excellent, but it needs more work. $q_1$ is the state with an even number of $b'$s so when you get a $b$ you should transition to a third state $q_2.$ Also, you haven't dealt with what happens when you're in state $q_1$ and you get an $a.$ The number of $b'$s doesn't change, so you stay in $q_1.$

Now you ought to be able to figure out the transitions from $q_2$ on your own.

I haven't been able to find free software to make transition diagrams, so I'll have to settle for a table. This is for an NFA:

\begin{array}{|c|c|c|} \hline &a&b\\ \hline A&B& -\\ \hline B&B&C\\ \hline C&C&B\\ \hline \end{array}

Here $A$ is the initial state and $B$ is the final (accepting) state. State $B$ indicates that we have seen an even number of $b\text{'}$s so far, and state $C$ indicates an odd number of $b\text{'}$s.

A DFA is much the same, we just need a fourth state $D,$ for strings that start with $b$:

\begin{array}{|c|c|c|} \hline &a&b\\ \hline A&B&D\\ \hline B&B&C\\ \hline C&C&B\\ \hline D&D&D\\ \hline \end{array}