1
Recap lecture 17
NFA corresponding to Closure of FA,
2
Moore machine
A Moore machine consists of the
following
1. A finite set of states q0, q1, q2, … where q0 is
the initial state.
2. An alphabet of letters  = {a,b,c,…} from
which the input strings are formed.
3. An alphabet ={x,y,z,…} of output
characters from which output strings are
generated.
3
Moore machine continued …
4. A transition table that shows for each
state and each input letter what state is
entered the next.
5. An output table that shows what
character is printed by each state as it is
entered.
4
Moore machine continued …
Note: It is to be noted that since in Moore machine
no state is designated to be a final state, so there is
no question of accepting any language by Moore
machine. However in some cases the relation
between an input string and the corresponding
output string may be identified by the Moore
machine. Moreover, the state to be initial is not
important as if the machine is used several times
and is restarted after some time, the machine will
be started from the state where it was left off.
Following are the examples
5
Example
Consider the following Moore machine
having the states q0, q1, q2, q3 where q0 is
the start state and
 = {a,b},
={0,1}
the transition table follows as
6
Example continued …
Old
States
New States after
reading
a b
q0- q1 q3
q1 q3 q1
q2 q0 q3
q3 q3 q2
1
0
0
1
Characters
to be
printed
7
Example continued …
the transition diagram corresponding to the
previous transition table may be
a
b
b
a
q0/1
a
b
q1/0
q2/0 q3/1 a
b
8
Example continued …
It is to be noted that the states are labeled
along with the characters to be printed.
Running the string abbabbba over the above
machine, the corresponding output string
will be 100010101, which can be
determined by the following table as well
a
b
b
a
q0/1
a
b
q1/0
q2/0 q3/1 a
b
9
Example continued …
1
0
1
0
1
0
0
0
1
output
q0
q2
q3
q2
q3
q1
q1
q1
q0
State
a
b
b
b
a
b
b
a
Input
It may be noted that the length of output
string is l more than that of input string as
the initial state prints out the extra character
1, before the input string is read.
10
Example
To identify the relation between the input
strings and the corresponding output strings
in the following Moore machine,
q2/0
b
a
a
q1/0 q3/1
b
q0/0
a
b
b
a
11
Example continued …
0
1
0
0
0
0
0
1
0
0
0
0
output
q0
q3
q2
q1
q0
q0
q1
q3
q2
q2
q1
q0
State
a
a
b
b
a
a
b
a
b
b
b
Input
if the string bbbabaabbaa is run, the output
string will be 000010000010, as shown
below
12
Example continued …
It can be observed from the given Moore machine
that q3 is the only state which prints out the
character 1 which shows that the moment the state
q3 is entered, the machine will print out 1. To enter
the state q3, starting from q0 the string must
contain bba. It can also be observed that to enter
the state q3 once more the string must contain
another substirng bba. In general the input string
will visit the state q3 as many times as the number
of substring bba occurs in the input string. Thus
the number of 1’s in an output string will be same
as the number of substring bba occurs in the
corresponding input string.
13
Mealy machine
A Mealy machine consists of the
following
1. A finite set of states q0, q1, q2, … where q0 is
the initial state.
2. An alphabet of letters  = {a,b,c,…} from
which the input strings are formed.
3. An alphabet ={x,y,z,…} of output
characters from which output strings are
generated.
14
Mealy machine continued …
4. A pictorial representation with states
and directed edges labeled by an input
letter along with an output character. The
directed edges also show how to go from
one state to another corresponding to
every possible input letter.
Note: It is not possible to give transition
table in this case.
15
Mealy machine continued …
Note: It is to be noted that since, similar to
Moore machine, in Mealy machine no state is
designated to be a final state, so there is no
question of accepting any language by Mealy
machine. However in some cases the relation
between an input string and the corresponding
output string may be identified by the Mealy
machine. Moreover, the state to be initial is not
important as if the machine is used several
times and is restarted after some time, the
machine will be started from the state where it
was left off. Following are the examples
16
Example
Consider the following Mealy machine
having the states q0, q1, q2, q3 , where q0 is
the start state and
 = {a,b},
={0,1}
a/0
b/1
a/1
q1
a/0
q2
q0
q3 a/1
b/0
b/1
b/1
17
Example continued …
Running the string abbabbba over the above
machine, the corresponding output string
will be 11011010, which can be determined
by the following table as well
a/0
b/1
a/1
q1
a/0
q2
q0
q3 a/1
b/0
b/1
b/1
18
Example continued …
0
1
0
1
1
1
1
0
output
q1
q0
q3
q0
q3
q3
q2
q1
q0
States
a
b
b
b
a
b
b
a
Input
It may be noted that in Mealy machine, the
length of output string is equal to that of
input string.
19
Example
Consider the following Mealy machine
having the states q0, q1, q2 , where q0 is the
start state and
 = {a,b},
={0,1}
a/0
q1
q2
q0
b/1
b/0
b/0
a/1
a/0
20
Example continued …
It is observed that in the above Mealy
machine, if in the output string the nth
character is 1, it shows that the nth letter in
the input string is the second in the pair of
double letter.
For babaababba as input string the machine
will print 0000100010.
21
Example
Consider the following Mealy machine having
the only state q0 as the start state and
 = {0,1},
= {0,1}
If 0011010 is run on this machine then the
corresponding output string will be 1100101.
This machine is also called Complementing
machine.
q0
0/1, 1/0
22
Constructing the incrementing
machine
In the previous example of complementing
machine, it has been observed that the input
string and the corresponding output string are
1’s complement of each other. There is a
question whether the Mealy machine can be
constructed, so that the output string is
increased, in magnitude, by 1 than the
corresponding input string ? The answer is yes.
This machine is called the incrementing
machine. Following is how to construct the
incrementing machine
23
Constructing the incrementing
machine continued …
Before the incrementing machine is
constructed, consider how 1 is added to a
binary number.
Since, if two numbers are added, the addition
is performed from right to left, so while
increasing the binary number by 1, the string
(binary number) must be read by the
corresponding Mealy machine from right to
left, and hence the output string (binary
number) will also be generated from right to
left.
24
Constructing the incrementing
machine continued …
Consider the following additions
a) 100101110 b) 1001100111
+ 1 + 1
100101111 1001101000
It may be observed from the above that
a) If the right most bit of binary number, to
be incremented, is 0, the output binary
number can be obtained by converting the
right most bit to 1 and remaining bits
unchanged.
25
Constructing the incrementing
machine continued …
b) If the right most bit of binary number
is 1 then the output can be obtained,
converting that 1 along with all its
concatenated 1’s to 0’s, then converting
the next 0 to 1 and remaining bits
unchanged.
The observations (a) and (b) help to
construct the following Incrementing
(Mealy) machine.
26
Constructing the incrementing
machine continued …
The Mealy machine have the states
q0, q1, q2 , where q0 is the start state and
 = {0,1},
={0,1}
0/1
q1
q2
q0
1/0
0/1
1/0
0/0, 1/1
27
Constructing the incrementing
machine continued …
It may be observed that, in the incrementing
machine, if 0 is read at initial state q0, that 0 is
converted to 1 and a no change state q1 (no carry
state) is entered where all 0’s and all 1’s remain
unchanged. If 1 is read at initial state, that 1 is
converted to 0 and the state q2(owe carry state) is
entered, where all 1’s are converted to 0’s and at
that state if 0 is read that 0 is converted to 1 and
the machine goes to no change state.
If the strings 100101110 and 1001100111 are run
over this machine, the corresponding output
strings will be 100101111 and 1001101000
respectively.
28
Note
It is to be noted that if the string 111111 is run
over the incrementing machine, the machine will
print out 000000, which is not increased in
magnitude by 1. Such a situation is called an
overflow situation, as the length of output string
will be same as that of input string.
It may also be noted that there exists another
incrementing machine with two states.
29
Summing Up
Example of Moore machine, Mealy
machine, Examples, complementing
machine, Incrementing machine.

Lesson 18 Automata .ppt

  • 1.
    1 Recap lecture 17 NFAcorresponding to Closure of FA,
  • 2.
    2 Moore machine A Mooremachine consists of the following 1. A finite set of states q0, q1, q2, … where q0 is the initial state. 2. An alphabet of letters  = {a,b,c,…} from which the input strings are formed. 3. An alphabet ={x,y,z,…} of output characters from which output strings are generated.
  • 3.
    3 Moore machine continued… 4. A transition table that shows for each state and each input letter what state is entered the next. 5. An output table that shows what character is printed by each state as it is entered.
  • 4.
    4 Moore machine continued… Note: It is to be noted that since in Moore machine no state is designated to be a final state, so there is no question of accepting any language by Moore machine. However in some cases the relation between an input string and the corresponding output string may be identified by the Moore machine. Moreover, the state to be initial is not important as if the machine is used several times and is restarted after some time, the machine will be started from the state where it was left off. Following are the examples
  • 5.
    5 Example Consider the followingMoore machine having the states q0, q1, q2, q3 where q0 is the start state and  = {a,b}, ={0,1} the transition table follows as
  • 6.
    6 Example continued … Old States NewStates after reading a b q0- q1 q3 q1 q3 q1 q2 q0 q3 q3 q3 q2 1 0 0 1 Characters to be printed
  • 7.
    7 Example continued … thetransition diagram corresponding to the previous transition table may be a b b a q0/1 a b q1/0 q2/0 q3/1 a b
  • 8.
    8 Example continued … Itis to be noted that the states are labeled along with the characters to be printed. Running the string abbabbba over the above machine, the corresponding output string will be 100010101, which can be determined by the following table as well a b b a q0/1 a b q1/0 q2/0 q3/1 a b
  • 9.
    9 Example continued … 1 0 1 0 1 0 0 0 1 output q0 q2 q3 q2 q3 q1 q1 q1 q0 State a b b b a b b a Input Itmay be noted that the length of output string is l more than that of input string as the initial state prints out the extra character 1, before the input string is read.
  • 10.
    10 Example To identify therelation between the input strings and the corresponding output strings in the following Moore machine, q2/0 b a a q1/0 q3/1 b q0/0 a b b a
  • 11.
    11 Example continued … 0 1 0 0 0 0 0 1 0 0 0 0 output q0 q3 q2 q1 q0 q0 q1 q3 q2 q2 q1 q0 State a a b b a a b a b b b Input ifthe string bbbabaabbaa is run, the output string will be 000010000010, as shown below
  • 12.
    12 Example continued … Itcan be observed from the given Moore machine that q3 is the only state which prints out the character 1 which shows that the moment the state q3 is entered, the machine will print out 1. To enter the state q3, starting from q0 the string must contain bba. It can also be observed that to enter the state q3 once more the string must contain another substirng bba. In general the input string will visit the state q3 as many times as the number of substring bba occurs in the input string. Thus the number of 1’s in an output string will be same as the number of substring bba occurs in the corresponding input string.
  • 13.
    13 Mealy machine A Mealymachine consists of the following 1. A finite set of states q0, q1, q2, … where q0 is the initial state. 2. An alphabet of letters  = {a,b,c,…} from which the input strings are formed. 3. An alphabet ={x,y,z,…} of output characters from which output strings are generated.
  • 14.
    14 Mealy machine continued… 4. A pictorial representation with states and directed edges labeled by an input letter along with an output character. The directed edges also show how to go from one state to another corresponding to every possible input letter. Note: It is not possible to give transition table in this case.
  • 15.
    15 Mealy machine continued… Note: It is to be noted that since, similar to Moore machine, in Mealy machine no state is designated to be a final state, so there is no question of accepting any language by Mealy machine. However in some cases the relation between an input string and the corresponding output string may be identified by the Mealy machine. Moreover, the state to be initial is not important as if the machine is used several times and is restarted after some time, the machine will be started from the state where it was left off. Following are the examples
  • 16.
    16 Example Consider the followingMealy machine having the states q0, q1, q2, q3 , where q0 is the start state and  = {a,b}, ={0,1} a/0 b/1 a/1 q1 a/0 q2 q0 q3 a/1 b/0 b/1 b/1
  • 17.
    17 Example continued … Runningthe string abbabbba over the above machine, the corresponding output string will be 11011010, which can be determined by the following table as well a/0 b/1 a/1 q1 a/0 q2 q0 q3 a/1 b/0 b/1 b/1
  • 18.
    18 Example continued … 0 1 0 1 1 1 1 0 output q1 q0 q3 q0 q3 q3 q2 q1 q0 States a b b b a b b a Input Itmay be noted that in Mealy machine, the length of output string is equal to that of input string.
  • 19.
    19 Example Consider the followingMealy machine having the states q0, q1, q2 , where q0 is the start state and  = {a,b}, ={0,1} a/0 q1 q2 q0 b/1 b/0 b/0 a/1 a/0
  • 20.
    20 Example continued … Itis observed that in the above Mealy machine, if in the output string the nth character is 1, it shows that the nth letter in the input string is the second in the pair of double letter. For babaababba as input string the machine will print 0000100010.
  • 21.
    21 Example Consider the followingMealy machine having the only state q0 as the start state and  = {0,1}, = {0,1} If 0011010 is run on this machine then the corresponding output string will be 1100101. This machine is also called Complementing machine. q0 0/1, 1/0
  • 22.
    22 Constructing the incrementing machine Inthe previous example of complementing machine, it has been observed that the input string and the corresponding output string are 1’s complement of each other. There is a question whether the Mealy machine can be constructed, so that the output string is increased, in magnitude, by 1 than the corresponding input string ? The answer is yes. This machine is called the incrementing machine. Following is how to construct the incrementing machine
  • 23.
    23 Constructing the incrementing machinecontinued … Before the incrementing machine is constructed, consider how 1 is added to a binary number. Since, if two numbers are added, the addition is performed from right to left, so while increasing the binary number by 1, the string (binary number) must be read by the corresponding Mealy machine from right to left, and hence the output string (binary number) will also be generated from right to left.
  • 24.
    24 Constructing the incrementing machinecontinued … Consider the following additions a) 100101110 b) 1001100111 + 1 + 1 100101111 1001101000 It may be observed from the above that a) If the right most bit of binary number, to be incremented, is 0, the output binary number can be obtained by converting the right most bit to 1 and remaining bits unchanged.
  • 25.
    25 Constructing the incrementing machinecontinued … b) If the right most bit of binary number is 1 then the output can be obtained, converting that 1 along with all its concatenated 1’s to 0’s, then converting the next 0 to 1 and remaining bits unchanged. The observations (a) and (b) help to construct the following Incrementing (Mealy) machine.
  • 26.
    26 Constructing the incrementing machinecontinued … The Mealy machine have the states q0, q1, q2 , where q0 is the start state and  = {0,1}, ={0,1} 0/1 q1 q2 q0 1/0 0/1 1/0 0/0, 1/1
  • 27.
    27 Constructing the incrementing machinecontinued … It may be observed that, in the incrementing machine, if 0 is read at initial state q0, that 0 is converted to 1 and a no change state q1 (no carry state) is entered where all 0’s and all 1’s remain unchanged. If 1 is read at initial state, that 1 is converted to 0 and the state q2(owe carry state) is entered, where all 1’s are converted to 0’s and at that state if 0 is read that 0 is converted to 1 and the machine goes to no change state. If the strings 100101110 and 1001100111 are run over this machine, the corresponding output strings will be 100101111 and 1001101000 respectively.
  • 28.
    28 Note It is tobe noted that if the string 111111 is run over the incrementing machine, the machine will print out 000000, which is not increased in magnitude by 1. Such a situation is called an overflow situation, as the length of output string will be same as that of input string. It may also be noted that there exists another incrementing machine with two states.
  • 29.
    29 Summing Up Example ofMoore machine, Mealy machine, Examples, complementing machine, Incrementing machine.