Modeling Finite State Machines with Python Coroutines
Source: https://arpitbhayani.me/blogs/fsm-python Date: 2020-04-19
Explore Finite State Machines (FSM) with Python coroutines. Learn to model FSMs for regex, divisibility, & SQL validation.
Finite State Machine is a mathematical model of computation that models a sequential logic. FSM consists of a finite number of states, transition functions, input alphabets, a start state and end state(s). In the field of computer science, the FSMs are used in designing Compilers, Linguistics Processing, Step workflows, Game Design, Protocols Procedures (like TCP/IP), Event-driven programming, Conversational AI and many more.
To understand what a finite machine is, we take a look at Traffic Signal. Finite State Machine for a Traffic Signal is designed and rendered below. Green is the start/initial state, which upon receiving a trigger moves to , which, in turn, upon receiving a trigger, transitions to . The then circles back to and the loop continues.



