Computing Machinery Chapter 4: Finite State Machines
U - Up D - Down L - Left R - Right Introduction to Finite State Machines
Formally, a finite Automaton (FA) is defined as a 5-tuple (Q, , , q 0, F) where, (1) Q is a finite set of states. (2) is a finite set of symbols or the alphabet. (3) : Q x -> Q is the transition function (4) q 0 is an element of Q called the start state, and (5) F is a subset of Q called the set of accept states. Definition of a Finite State Machine
Example: Maze FSM
Moore Machine
Example: Moore Machine input: X Y Z X X Z Y X Z Y Y Z output: B A A B A A A A A A A A
Mealy Machine
Integer String Recognizer Build a finite state machine that can be used to recognize character string representations of integer values. Valid Integers Not Integers Hello There
Integer String Recognizer Design
reject accept 0111 accept reject FSM that accepts strings containing at least three 1's FSM that accepts strings containing at least three consecutive 1's reject accept reject accept Substring Detectors
Building a Bit String Recognizer detect bit string "1101"
Moore Machine: Bit String Recognizer ("1101") Sometimes we need to decide whether overlapping substrings are accepted
Mealy Machine: Bit String Recognizer ("1101")
FSM to Recognize if a Binary Encoded Value is Divisible by Four
Parity Tester counting 0's and counting 1's
Recognizing Binary Strings with the Same Number of 1's and 0's.
A Partial FSM to Recognize Palindromes binary strings
Detecting Binary Encoded Values Divisible by Three Consider the substrings that leave you in the same state regardless of which state you are in when the substring is encountered Such substrings can be removed from the candidate string without affecting the final state. The substrings '11', '00' and '1001' are three such "reducible" substrings. Reduce the following string by removing these substrings yes