Finite State Machine Representation
Finite state machines have inputs, outputs, and of course, a finite number of states.The states depend on the inputs, and the outputs depend on the states. State machines can be represented in many different ways, including state diagrams, regular expressions, Chomksy hierarchy, state tables, etc…
A regular expression (regex) specifies a set of strings required for a particular purpose..
We can take a look at a light switch as an example of a finite state machine. The light switch has a finite number of states, “Light on” and “Light off”. As a regular expression, the light switch would be represented as: (ab)*.
Whereas a state diagram for the same state machine would look like this:
As shown, (ab)* is a much simpler and shorter way of representing a finite state machine than drawing a diagram of one. This is even further emphasised when creating much more complex finite state machines than just a light switch. In addition, it would also be a lot easier to turn a regular expression into something a compiler can understand than it would be to turn a state diagram into something a compiler could understand.