π Lecture 22 β Applications of complementing and incrementing machines, Equivalent machines, Moore equivalent to Mealy, proof, example, Mealy equivalent to Moore, proof, example
π Overview: This lecture demonstrates practical applications of Mealy machines, specifically how complementing and incrementing machines can be used for binary subtraction. It then formally defines machine equivalence and provides rigorous proofs with examples for converting between Moore and Mealy machine types, establishing their fundamental relationship in automata theory.
ποΈ Topics Covered
The lecture covers applications of complementing and incrementing machines for binary subtraction, followed by the definition of equivalent machines. It then presents the theorem and proof for converting Moore machines to equivalent Mealy machines with a detailed example, and similarly proves the conversion from Mealy to Moore machines with an illustrative example, including state splitting when necessary.
π Lecture Summary
Applications of Incrementing and Complementing machines
1βs complementing and incrementing machines, which are essentially Mealy machines, are highly useful in computing. The incrementing machine helps build a machine that can perform addition of binary numbers. Using the complementing machine together with the incrementing machine, one can build a machine that performs subtraction of binary numbers.
Method to subtract a binary number b from a binary number a:
- Add the 1βs complement of b to a (ignoring the overflow, if any)
- Increase the result, in magnitude, by 1 using the incrementing machine (ignoring the overflow if any)
Note: If there is no overflow in step (1), take 1βs complement once again in step (2) instead. This occurs when b is greater than a in magnitude.
π Example: Subtract binary number 101 from binary number 1110. Let a = 1110 and b = 101 = 0101 (digits of b are equated with that of a)
Step 1: Adding 1βs complement (1010) of b to a: 1110 +1010
11000 β ignoring overflow gives 1000
Step 2: Using the incrementing machine, increase result 1000 by 1: 1000 +1
1001 (same as ordinary subtraction)
π‘ Why this matters: This method can also be applied to decimal subtraction with the change that 9βs complement of b is added to a in step (1).
Equivalent machines
Two machines are said to be equivalent if they print the same output string when the same input string is run on them.
Remark: Two Moore machines may be equivalent. Similarly, two Mealy machines may be equivalent. However, a Moore machine cannot be equivalent to any Mealy machine directly. But ignoring the extra character printed by the Moore machine, there exists a Mealy machine which is equivalent to the Moore machine.
Theorem β Moore equivalent to Mealy
Statement: For every Moore machine there is a Mealy machine that is equivalent to it (ignoring the extra character printed by the Moore machine).
Proof: Let M be a Moore machine. Shifting the output characters corresponding to each state to the labels of corresponding incoming transitions yields a Mealy machine equivalent to M.
Note: While converting a Moore machine into an equivalent Mealy machine, the output character of a state is ignored if there is no incoming transition at that state. A loop at a state is also considered an incoming transition.
π Example: Consider the following Moore machine with states q0/0, q1/1, q2/0, q3/1 and transitions on a and b.
Using the method above, the equivalent Mealy machine is obtained. Running the string abbabbba on both machines:
| Input | a | b | b | a | b | b | b | a |
|---|---|---|---|---|---|---|---|---|
| States | q0 | q1 | q2 | q3 | q3 | q3 | q3 | q3 |
| Moore | 0 | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
| Mealy | 1 | 0 | 1 | 1 | 1 | 1 | 1 |
Theorem β Mealy equivalent to Moore
Statement: For every Mealy machine there is a Moore machine that is equivalent to it (ignoring the extra character printed by the Moore machine).
Proof: Let M be a Mealy machine. At each state, there are two possibilities for incoming transitions:
- Same output character: Shift that character to the corresponding state.
- Different output characters: The state is converted to as many states as the number of different output characters. If at state qi there are transitions with two output characters, then qi is split into qiΒΉ for one character and qiΒ² for the other. These new states should behave like qi as well.
Note: If there is no incoming transition at a state, any output character may be associated with that state. If the initial state is converted into more than one new state, only one of these new states is considered the initial state.
π Example: Consider a Mealy machine with states q0, q1, q2, q3 and transitions labeled with outputs.
The conversion process involves:
- Shifting output character 1 of transition b to q0
- Shifting output character 0 of transition a to q1
- Shifting output character 1 of transition b to q2
- Splitting q3 into q3ΒΉ and q3Β²
Running the string abbabbba on both machines:
| Input | a | b | b | a | b | b | b | a |
|---|---|---|---|---|---|---|---|---|
| States | q0 | q1 | q2 | q3 | q3 | q0 | q3 | q0 |
| Mealy | 0 | 1 | 1 | 1 | 1 | 0 | 1 | |
| Moore | 1 | 0 | 1 | 1 | 1 | 1 | 0 | 1 |
β Key Takeaways
The complementing and incrementing machines provide a practical method for binary subtraction by combining 1's complement addition with an increment operation. Machine equivalence is defined by identical output strings for the same input, but Moore and Mealy machines cannot be directly equivalent due to Moore's extra output character. The conversion from Moore to Mealy involves shifting state outputs to incoming transition labels while ignoring states with no incoming transitions. The reverse conversion from Mealy to Moore requires splitting states when incoming transitions have different output characters, with each new state inheriting the behavior and one output character of the original state. These conversion theorems establish that despite their structural differences, Moore and Mealy machines are equivalent in computational power when the initial extra character is disregarded.
π§ Quick Revision Questions
- How do you subtract binary number b from binary number a using the complementing and incrementing machines, and what special case requires an alternative step?
- What is the formal definition of equivalent machines, and why can't a Moore machine be directly equivalent to a Mealy machine?
- In the Moore-to-Mealy conversion, what happens to the output of a state that has no incoming transitions?
- In the Mealy-to-Moore conversion, what procedure is followed when a state has incoming transitions with different output characters?
- When the initial state of a Mealy machine is split into multiple states during conversion to Moore, how is the new initial state determined?