L06 FAwih Output

Post on 28-Oct-2014

35 views 1 download

Transcript of L06 FAwih Output

FA with output

Finite Automata with Output

Finite automata as mathematical models of computers

letters of words input

transitions execution of instructions (a program)

state contents of memory

? output

Moore machine

• A Moore machine is a collection of 6 things:

1. a finite set of states q0,q1,q2,…, where q0 is designated the start state

2. an alphabet of input letters

3. an alphabet Γ of output characters

4. a transition table that shows for each state and each input letter what state to go to next.

5. an output table that shows what character is output (or printed) when entering a state.

6. q0 – the starting state

(state, letter from ) statetransition

Moore machine

Example: states = {q0,q1,q2,q3} ={a,b} ={0,1}

Old state Output by the New state

old state After input a After input b

–q0 1 q1 q3

q1 0 q3 q1

q2 0 q0 q3

q3 1 q3 q2

q0/1q1/0

b

b

q3/1

q2/0

a b

a

baa

abab

10010

Moore machine

Printing 1 final state words that end in aab

q1/0 q3/1b

ba

q0/0

a

bq2/0

a

b

a

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

State q0 q1 q2 q2 q3 q1 q0 q0 q1 q2 q3 q0

Output 0 0 0 0 1 0 0 0 0 0 1 0

Example: A machine that counts ‘aab’s

Mealy machine

• A Mealy machine is:

1. a finite set of states q0,q1,q2,…, where q0 is designated the start state

2. an alphabet of input letters

3. an alphabet of output characters

4. a finite set of transitions that indicate, for each state and letter of the input alphabet, the state to go to next and the character that is output (printed).

input/outputstate state

Mealy machine

q1q3

b/1

b/0a/0

q0

a/0

b/0q2

a/0

b/0

a/0

Mealy machine

baaba

q0

q1

q2

a/0

q3

b/1

a/1

a/1

a/0b/0

b/1 b/1

Example

01110

Mealy machine

Example: binary complement

={0,1} ={0,1}

Abbreviation:

q4 q7

a/x

b/yq4 q7

a/x, b/y

q0

0/1,1/0 101 001010

010 110101

Mealy machine

decimal: 11binary : 1011reverse: 1101

start

carry1/0

0/1

1/0

0/0,1/1

0/1

Example: an Increment Machine

1111

0000

(overflow) 00 11

reverse: 1100decimal: 12

Mealy machine

• Parity checker using mealy machine

Moore M/c For 1’s Complement

Mealy Machine for 2’s Complement

Read input from LSB to MSB. Keep all Zero’s until we read first 1. Keep that 1 as it is then change remaining 1’s by 0’s and 0’s by 1’s.

Equivalence

Let Mo be a Moore machine that prints x in the start state. Let Me be a Mealy machine.

The two machines are equivalent if for every input, whenever the output from Me is w, the output from Mo is xw.

Moore to Mealy M/C

Theorem:

For every Moore machine, there exists a Mealy machine that is equivalent to it.

Proof: By constructive algorithm

q4/t

c

b

a

q4

c/t

b/t

a/t

• For Example, Convert the given Moore m/c to Mealy m/c

q0/0

a

b

a,ba

b

q3/1

q2/0

q1/1

a

b

Moore to Mealy M/C

Moore to Mealy M/C

Solution :

q0

a/1

b/1

a/1,b/1a/1

b/0

q3

q2

q1

a/0

b/0

Mealy to Moore M/C

Theorem:

For every Mealy machine, there exists a Moore machine that is equivalent to it.

Proof: By constructive algorithm

q14/0

a

b/1

a/1

b

q4

a/0

b/1

a/1

b/0

b/1

q24/1

b/1

a/1

b

Mealy to Moore M/C

We must consider

1. incoming edges

2. outgoing edges

3. loops

q3

q6

b/1

a/0a/0

q23/1

q6

a/0

b

b

q13/0

a/0

a

Mealy to Moore M/C

q3

b/1

a/0q1

3/0

b/1

a/0

If there is no entering arrow, choose any letter from output character set .

Mealy to Moore M/C

For example:

q0

a/1

a/0

a/0

b/1

q2

q3

q1

a/1

b/0

b/0

b/1

Mealy to Moore M/C

Solution :

q10/0

aa

q12/0

q22/1

q1/1

a

b

b

q20/1

bq3/0

ab

a

bb

a

Another Method Mealy to Moore Conversion

Mealy to Moore conversion Example

Solution

A Good Book

Theory Of Computation

  By A.A.Puntambekar

Available on Google Books

http://booklens.com/dexter-kozen/automata-and- computability?ref=related

Moore M/c Mealy M/c

Moore M/c

Mealy M/c

Mealy Moore

Moore M/c

Mealy M/c