Sei sulla pagina 1di 25

TWO-WAY DETERMINISTIC FINITE AUTOMATA

(2DFA)
Presented By: Raushan kumar

DFA

Input is processed once from left to right. After an input has been read, the DFA decides whether the input is accepted or rejected.

2DFA
Can read the input back and forth with no limit on how many times an input symbol can be read. As in the case of DFA, the 2DFA decides whether a given input is accepted or rejected.

WHAT IS 2DFA?

The concept of 2DFA was originated by Rabin and Scott in 1997


2DFA is a generalized version of the DFA which can revisit characters already processed.

HOW 2DFA WORKS?

Two-way Finite Automata have a read head, which can move left or right over the input string. Consists of the symbols of the input string as occupying cells of a nite tape, one symbol per cell.

The input string is enclosed in left and right endmarkers and , which are not elements of the input alphabet . The read head may not move outside of the endmarkers.

STRUCTURE OF 2DFA

FORMAL DEFINITION OF 2DFA


Is a quintuple M = ( Q, , , q0 , F)

Function takes a state and a symbol as arguments and returns a new state and a direction to move the head. If (p, b) = (q, L/R), then whenever the machine is in state p and scanning a tape cell containing symbol b, it moves its head one cell in the direction d and enters state q.

EXAMPLE:
2DFAs can be seen as read-only Turing machines with no work tape, only a read-only input tape

TURING MACHINE
Move back and forth in the working tape while reading and/or writing. Has no limit to the amount of memory that it can use.

HOW DOES DFA COMPARE TO 2DFA?

2DFA can solve any problems that are solvable by DFA. Next, are there problems that can be solved by 2DFA but cannot be solved by DFA

WHY NOT 2DFA?

Consumes less memory and time than DFA.


Problems that can be solved by DFA can be solved by 2DFA Easy to implement/ much more powerful than DFA.

FINITE AUTOMATA WITH OUTPUT

MOORE AND MEALY MACHINES


Both these machine types follow the basic characteristics of state machines, but differ in the way that outputs are produced. Moore Machine: Outputs are independent of the inputs, ie outputs are effectively produced from within the state of the state machine. Mealy Machine: Outputs can be determined by the present state and the present inputs, ie outputs are produced as the machine makes a transition from one state to another.

MATHEMATICAL REPRESENTATION
= (Q , , , , qo , ) Q = A nonempty finite set of state in M. = A nonempty finite set of input symbols. (delta.upp) = A nonempty finite set of outputs. (delta.low) = It is a transition function which takes two arguments input state and input symbol. qo = Initial state of M belongs to Q. (lambda) = It is a mapping function which maps Q to giving output associated with each state.
M

MOORE MACHINE DIAGRAMS


The Moore State Machine output is shown inside the state bubble, because the output remains the same as long as the state machine remains in that state. The output can be arbitrarily complex but must be the same every time the machine enters that state.
Output condition that results from being in a particular present state

State 1 q,r

a,b
Input condition that must exist in order to execute these transitions from State 1

i,j

State 2 x,y

MOORE MACHINE

Describe Outputs as Concurrent Statements Depending on State Only


transition condition 1
state 1 / output 1 state 2 / output 2 transition condition 2

EXAMPLE OF MOORE MACHINE


TRANSITION TABLE

Present state q0 q1 q2 q3

input output a=0 a=1 q3 q1 0 q1 q2 q3 q2 q3 q0 1 0 0

TRANSITION DIAGRAM

1
1 0

q0
1 1

q1
1
0 0

q2
0

q3
0

MEALY MACHINE DIAGRAMS


The Mealy State Machine generates outputs based on: The Present State, and The Inputs to the M/c. So, it is capable of generating many different patterns of output signals for the same state, depending on the inputs present on the clock cycle. Outputs are shown on transitions since they are determined in the same way as is the next state.
Output condition that results from being in a particular present state

State 1

a,b q,r
Input condition that must exist in order to execute these transitions from State 1

i,j x,y

State 2

MEALY MACHINE

Describe Outputs as Concurrent Statements Depending on State and Inputs

transition condition 1 / output 1 state 2 transition condition 2 / output 2

state 1

EXAMPLE OF MEALY MACHINE


TRANSITION TABLE

Present state q1 q2 q3 q4

Input State q3 q1 q2 q4

a=0 output 0 1 1 1

Input State output q2 q4 q1 q3

a=1

0 1 0 0

TRANSITION DIAGRAM
0/1

q1
1/0
1/0 0/0

q2
1/1 0/1

q3

1/0

q4

0/1

TRANSFORMING A MOORE MACHINE INTO A MEALY MACHINE

a P b

a/P c

MOORE MACHINE

b/P

q1
c/P

MEALY MACHINE

EXAMPLE
1

q1
a 0 a 1

q0

q3

a/b

b q2 0

a MOORE MACHINE

CONVERT INTO MEALY MACHINE

q1
a/1 a/1 a/1 , b/1

q0

b/0

q3

b/1 b/0 q2

a/0 MEALY MACHINE

TRANSFORMING A MEALY MACHINE INTO A MOORE MACHINE b/0 a/0 a/1 b/1 q1 b/1 MEALY MACHINE

b 0 a/1 b 1 a/1

q11
a b/1

q12
b/1

MOORE MACHINE

THANK YOU

Potrebbero piacerti anche