Finite state machine

2.9k Views Asked by At

I am doing discrete math, and we are studying Finite State Machines. But i am a little confuse on how to do this. Here is a question, Write a regular expression for the language, and define a finite state machine that recognizes word in the language(input alphabet, states, start state, state transition table, and accept states). Include a state digraph for the FSM.

L: For alphabet {a,b}, all strings that contain an odd number of a's and exactly one b.

If you could help me understand this more in depth, that would be amazing.

2

There are 2 best solutions below

1
On

You want a regular expression that is any number, $k$, of $a$'s, followed by a $b$, followed by:

  • an even number of $a$'s if $k$ is odd.
  • an odd number of $a$'s if $k$ is even.

So after some guessing...

$L = a (aa)^* b (aa)^* \ | \ (aa)^* b (aa)^* a$.

To do the FSM, you just add nodes as you need them... there's probably algorthms that can automatically output an FSM graph, but this example is small enough to brute-force.

Here's what I got: Jah mann

0
On

The diagram of FSM describes everything! FSM on $\{a, b\} that accept strings with exactly one $b$ and an even number of $a$s.