l06 fawih output

28
FA with output

Upload: gautam-khanna

Post on 28-Oct-2014

42 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: L06 FAwih Output

FA with output

Page 2: L06 FAwih 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

Page 3: L06 FAwih 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

Page 4: L06 FAwih Output

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

Page 5: L06 FAwih Output

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

Page 6: L06 FAwih Output

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

Page 7: L06 FAwih Output

Mealy machine

q1q3

b/1

b/0a/0

q0

a/0

b/0q2

a/0

b/0

a/0

Page 8: L06 FAwih Output

Mealy machine

baaba

q0

q1

q2

a/0

q3

b/1

a/1

a/1

a/0b/0

b/1 b/1

Example

01110

Page 9: L06 FAwih Output

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

Page 10: L06 FAwih Output

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

Page 11: L06 FAwih Output

Mealy machine

• Parity checker using mealy machine

Page 12: L06 FAwih Output

Moore M/c For 1’s Complement

Page 13: L06 FAwih Output

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.

Page 14: L06 FAwih Output

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.

Page 15: L06 FAwih Output

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

Page 16: L06 FAwih Output

• 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

Page 17: L06 FAwih Output

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

Page 18: L06 FAwih Output

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

Page 19: L06 FAwih Output

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

Page 20: L06 FAwih Output

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 .

Page 21: L06 FAwih Output

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

Page 22: L06 FAwih Output

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

Page 23: L06 FAwih Output

Another Method Mealy to Moore Conversion

Page 24: L06 FAwih Output

Mealy to Moore conversion Example

Page 25: L06 FAwih Output

Solution

Page 26: L06 FAwih Output

A Good Book

Theory Of Computation

  By A.A.Puntambekar

Available on Google Books

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

Page 27: L06 FAwih Output

Moore M/c Mealy M/c

Moore M/c

Mealy M/c

Page 28: L06 FAwih Output

Mealy Moore

Moore M/c

Mealy M/c