Finite automata with output, also known as sequential machines, include Mealy machines and Moore machines. These machines extend the concept of finite automata by associating outputs with transitions between states. The main distinction lies in when the output is produced—whether it depends on the current state alone (Moore machine) or on both the current state and input symbol (Mealy machine).
Let's explore both Mealy and Moore machines:
1. Mealy Machine:
- States (Q): Finite set of states that the machine can be in.
- Alphabet (Σ): Finite set of input symbols.
- Output Alphabet (Γ): Finite set of output symbols.
- Transition Function (δ): Defines transitions between states based on the current state and input symbol.
- Output Function (λ): Associates an output symbol with each transition.
- Initial State (q0): The starting state.
- Output: The output is produced based on both the current state and the input symbol during a transition.
Example:
Let's consider a Mealy machine that recognizes sequences of 0s and 1s and outputs the parity (even or odd) of the number of 1s encountered. For instance:
States: q0, q1 (q0 is the initial state) Alphabet: {0, 1} Output Alphabet: {even, odd} Transition/Output Functions: q0 --(0/even)--> q0 q0 --(1/odd)--> q1 q1 --(0/even)--> q1 q1 --(1/odd)--> q0
2. Moore Machine:
- States (Q): Finite set of states.
- Alphabet (Σ): Finite set of input symbols.
- Output Alphabet (Γ): Finite set of output symbols.
- Transition Function (δ): Defines transitions between states based on the current state and input symbol.
- Output Function (λ): Associates an output symbol with each state (not with transitions).
- Initial State (q0): The starting state.
- Output: The output depends only on the current state, not on the input symbol during a transition.
Example:
Let's consider a Moore machine that recognizes sequences of 0s and 1s and outputs "even" or "odd" based on the parity of the total number of symbols encountered. For instance:
States: q0 (q0 is the initial state) Alphabet: {0, 1}
Output Alphabet: {even, odd} Transition Function: q0 --(0)--> q0 q0 --(1)--> q0 Output Function: q0: even
In summary, Mealy machines and Moore machines introduce output symbols to finite automata, with the key distinction being when the output is produced. Mealy machines produce output during transitions based on both the current state and input symbol, while Moore machines produce output based solely on the current state during transitions.