A Comprehensive, Elite Guide to Finite State Transducers
In the Theory of Computation, a Moore Machine is a finite-state machine whose current output values are determined strictly by its current state. This is in direct contrast to the Mealy Machine, where output depends on both the current state and the current input.
Because the output is tied to the state itself, a Moore machine acts as an unconditional generator—the moment it enters a state, an output character is produced, regardless of what input brought it there.
A Moore Machine is formally defined as a 6-tuple (Q, Σ, Δ, δ, λ, q0) where:
Q × Σ → Q.Q → Δ.q0 ∈ Q.Designing Moore machines requires a slightly different mindset than designing standard DFAs. Master these core principles:
Length of Input String + 1. This is because the machine prints the output of the initial state before any input is even consumed.q0), and the bottom half contains the output symbol (e.g., 1).0 or empty).Below are precisely engineered step-by-step designs of Moore Machines. The diagrams are generated with absolute geometric clarity.
q0: Start state. Output is a neutral placeholder, say 0 (this first bit is extra due to the N+1 rule).q1: Represents "Just read a 0". Must output 1.q2: Represents "Just read a 1". Must output 0.Next_Mod = (Current_Mod * 2 + input) % 3.
q0: Current Remainder 0. Output 0. (Start state).q1: Current Remainder 1. Output 1.q2: Current Remainder 2. Output 2.0 if the number of 'a's read so far is Even, and 1 if Odd.q0: Even number of 'a's. Output 0. (Start state, since 0 'a's is even).q1: Odd number of 'a's. Output 1.1 whenever the sequence "10" is detected in a binary stream. Otherwise output 0.q0: Start state (nothing seen). Output 0.q1: Saw '1'. Output 0.q2: Saw '10' (Sequence matched!). Output 1.1 whenever the string "11" occurs. E.g., for input "111", output "0011".q0: Start state. Output 0.q1: Saw '1'. Output 0.q2: Saw '11'. Output 1.A if the string ends in 'a', B if it ends in 'b', and C otherwise (initially).q0: Initial state (ends in neither). Output C.qa: Last character read was 'a'. Output A.qb: Last character read was 'b'. Output B.1 when the sequence "aba" is completed. Output 0 otherwise. Overlapping allowed.q0: Start (out 0).q1: Saw 'a' (out 0).q2: Saw 'ab' (out 0).q3: Saw 'aba' (out 1).q0: Mod 0. Output 0.q1: Mod 1. Output 1.q2: Mod 2. Output 2.q3: Mod 3. Output 3.1 whenever the last two inputs were identical ("00" or "11"). Output 0 otherwise.q_start: Start. Out 0.q_0: Last was '0' (but not '00'). Out 0.q_1: Last was '1' (but not '11'). Out 0.q_00: Last two were '00'. Out 1.q_11: Last two were '11'. Out 1.1 if the string contains "001" anywhere within it. Once "001" is found, output 1 for all subsequent inputs.q0: Start. Out 0.q1: Saw '0'. Out 0.q2: Saw '00'. Out 0.q3: Saw '001'. Out 1. (Self-loops on both 0 and 1 forever).1 whenever the sequence "010" is detected in the input stream. Overlapping is allowed (e.g., "01010" outputs "000101").q0: Start state. Out 0.q1: Saw '0'. Out 0.q2: Saw '01'. Out 0.q3: Saw '010' (Match!). Out 1.0 if the binary string read so far is divisible by 2 (Even), and 1 if not (Odd). Read from left to right.q0: Start state. Neutral, assume 0 for empty string. Out 0.q1: Last bit was '0' (Even). Out 0.q2: Last bit was '1' (Odd). Out 1.0 and 1 every time a '1' is received. An input of '0' maintains the current output.q0: Current output is 0. Loop on 0, switch to q1 on 1.q1: Current output is 1. Loop on 0, switch to q0 on 1.1 if the string ends in a double character ("aa" or "bb"). Otherwise output 0.q0: Start. Out 0.qa: Last char 'a'. Out 0.qb: Last char 'b'. Out 0.qaa: Ends in 'aa'. Out 1.qbb: Ends in 'bb'. Out 1.q0: Start / Reading initial 0s. Out 0.q1: Just read the first '1'. Out 1.q2: Flip Mode (Read 0). Out 1.q3: Flip Mode (Read 1). Out 0.1 if the binary string has an Even number of '0's AND an Even number of '1's. Output 0 otherwise.qEE: Even 0s, Even 1s (Start state). Out 1.qEO: Even 0s, Odd 1s. Out 0.qOE: Odd 0s, Even 1s. Out 0.qOO: Odd 0s, Odd 1s. Out 0.Y if the total length of the string is a multiple of 3. Otherwise output N. Alphabet is {a, b}.q0: Length Mod 0. Out Y.q1: Length Mod 1. Out N.q2: Length Mod 2. Out N.1 as soon as the string "bb" is encountered, and keep outputting 1 forever regardless of subsequent inputs.q0: Start. Out 0.q1: Saw one 'b'. Out 0.q2: Saw 'bb'. Out 1. This is a sink state.0.qS: Start state. Output 0.q0: Previous input was '0'. Output 0.q1: Previous input was '1'. Output 1.1 every time three consecutive 1's are seen.q0: Start / Reset on 0. Out 0.q1: Saw one '1'. Out 0.q2: Saw two '1's. Out 0.q3: Saw three '1's. Out 1. Loops on '1' to keep matching.