Docsity

Understanding Moore & Mealy Machines: Finite Automaton with Output, Study notes of Nuclear Physics

Partial preview of the text

Download Understanding Moore & Mealy Machines: Finite Automaton with Output and more Study notes Nuclear Physics in PDF only on Docsity!

PIR AMAD ALI SHAH

COMSATS I.I.T, SAHIWAL

In today’s Lecture

Finite Automaton with Output… Chapter 8

Moore and Mealy Machines… Chapter 8

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1 2

Moore machine

A Moore machine consists of the following

  1. A finite set of states q 0 , q 1 , q 2 , … where q 0 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.

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

Moore machine continued …

  1. A transition table that shows for each state and each input letter what state is entered the next.
  2. An output table that shows what character is printed by each state as it is entered.

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

Example

Consider the following Moore machine having the states q 0 , q 1 , q 2 , q 3 where q 0 is the start state and

 = {a,b},

Г={0,1}

the transition table follows as

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

Example continued …

Old States

New States after reading a b

q 0 - q 1 q 3

q 1 q 3 q 1

q 2 q 0 q 3

Characters to be printed

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

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

q^ a 0 /

a

b

q 1 /

q 2 /0 q 3 /1^ a

b

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

Example continued …

output 1 0 0 0 1 0 1 0 1

State^ q 0 q 1 q 1 q 1 q 3 q 2 q 3 q 2 q 0

Input a b b a b b b a

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. Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

Example continued …

output 0 0 0 0 1 0 0 0 0 0 1 0

State^ q 0 q 1 q 2 q 2 q 3 q 1 q 0 q 0 q 1 q 2 q 3 q 0

Input b b b a b a a b b a a

if the string bbbabaabbaa is run, the output string will be 000010000010, as shown below

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

14

Example continued …

It can be observed from the given Moore machine that q 3 is the only state which prints out the character 1 which shows that the moment the state q 3 is entered, the machine will print out 1. To enter the state q 3 , starting from q 0 the string must contain bba. It can also be observed that to enter the state q 3 once more the string must contain another substirng bba. In general the input string will visit the state q 3 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. (^) Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

Mealy machine continued …

  1. 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.

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

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

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

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/

b/

a/

q 1

a/

q 2

q 0^ b/0 q 3 a/

b/

b/

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1

Example continued …

output 0 1 1 1 1 0 1 0

States^ q 0 q 1 q 2 q 3 q 3 q 0 q 3 q 0 q 1

Input a b b a b b b a

  • (^) It may be noted that in Mealy machine, the length of output string is equal to that of input string.

Theory of Automata & Formal Languages (CSC-307) - Week 8, Lecture 1