Memory Required To Recognize A Language: 20 and The 20th Letter From The Right Is 1, - 2 - 1 2,097,151
Memory Required To Recognize A Language: 20 and The 20th Letter From The Right Is 1, - 2 - 1 2,097,151
Lecture Objective
• Moore Machines
• Mealy Machines
• Moore = Mealy
3
Lecture 14: Theory of Automata:2013
1. A finite set of states q0, q1, q2, ..., where q0 is designated as the
start state.
4. A transition table that shows for each state and each input letter what
state is reached next.
4
Lecture 14: Theory of Automata:2013
Notes
• We did not assume that the input alphabet is the same as the
output alphabet Γ.
5
Lecture 14: Theory of Automata:2013
Notes Contd.
• A Moore machine does not define a language of
accepted words, because there is no such thing
as a final state.
6
Lecture 14: Theory of Automata:2013
7
Lecture 14: Theory of Automata:2013
Pictorial Representation
• Moore machines have pictorial representations
similar to FAs.
8
Lecture 14: Theory of Automata:2013
Example
• Note that the length of the output string is one longer than the length
of the input string.
9
Lecture 14: Theory of Automata:2013
Example
• Suppose we are interested in knowing exactly
how many times the substring aab occurs in a
long input string. The following Moore machine
will count this for us:
10
Lecture 14: Theory of Automata:2013
Example contd.
• To get to q3, we must have come from q2 and have just read a b. To
get to q2, we must have read at least two a’s in a row.
• After finding the subtring aab and tallying a 1 for it, the machine
looks for the next aab. Hence, the number of 1’s in the output string
is exactly the number of substrings aab in the input string.
11
Lecture 14: Theory of Automata:2013
1. A finite set of states q0, q1, q2, ..., where q0 is designated as the start state.
– Each edge is labeled with a compound symbol of the form i/o where i is an input
letter and o is an output character.
– Every state must have exactly one outgoing edge for each possible input letter.
– The edge we travel is determined by the input letter i. While traveling on the
edge, we must print the output character o.
12
Lecture 14: Theory of Automata:2013
Example
14
Lecture 14: Theory of Automata:2013
Example
• The following Mealy machine prints out the 1’s
complement of an input bit string.
• This means that it will produce a bit string that
has a 1 whenever the input string has a 0, and a
0 whenever the input has a 1.
Example
• Let consider a Mealy machine, called increment
machine, which reads a binary number and prints out
the binary number that is one larger.
Example contd.
• From the start state, if we read a 0, we print a 1
(incrementing process), and we go to the no-carry state.
If we read a 1, we print a 0 (incrementing) and we go to
the owe-carry state.
17
Lecture 14: Theory of Automata:2013
Example contd.
• The output will be 0011, which when reversed is 1100 and is the binary
representation of 12.
• In Mealy machine, output length = input length. Hence, if input were 1111,
then output would be 0000 (overflow situation).
18
Lecture 14: Theory of Automata:2013
Example
• Although a Mealy machine does not accept or reject an
input string, it can recognize a language by making its
output string answer some question about the input.
19
Lecture 14: Theory of Automata:2013
• Note that the triple letter word aaa produces the output 011 since
the second and third letters are both the back end of a pair of double
a’s.
20
Lecture 14: Theory of Automata:2013
Moore = Melay
• So far, we have define that two machines are equivalent
if they accept the same language.
• In this sense, we cannot compare a Mealy machine and
a Moore machine because they are not language
definers.
Definition:
• Given the Mealy machine Me and the Moore machine
Mo (which prints the automatic start state character x),
we say that these two machines are equivalent if for
every input string, the output string from Mo is exactly x
concatenated with the output string from Me.
21
Lecture 14: Theory of Automata:2013
Theorem 8
If Mo is a Moore machine, then there is a Mealy
machine Me that is equivalent to Mo.
Proof by constructive algorithm:
• Consider a particular state in Mo, say state q4, which
prints a certain character, say t.
• Let us re-label these edges as a/t, b/t, c/t, ... and let us
erase the t from inside the state q4. This means that we
shall be printing a t on the incoming edges before we
enter q4.
22
Lecture 14: Theory of Automata:2013
becomes
23
Lecture 14: Theory of Automata:2013
Example
• Following the above algorithm, we convert a
Moore machine into a Mealy machine as follows:
24