You are on page 1of 9

By-Abhishek Kumar

A grammar G is denoted by { ∑, V, R, S} where :-


# ∑ is a finite set of symbols called Terminals .
# V is a set of symbols disjoint from symbols called Variables (or
non-terminals).
# R is a finite set of production rules of the form xy, where x,y
∈ (∑ ∪ V)*
# S ∈ V is a special symbol called Start Symbol (or Axiom).
Ex.- For any alphabet ∑, the set of all strings over ∑ is denoted by
∑*, and a language over ∑ is therefore a subset of ∑*. For ∑={a, b}
we have
∑*={λ, a, aa, aaa, ab…} where λ= null string
∑* = {all strings that could be generated using a & b}

A language L(G) is defined as all those sentences that can be derived


in a finite no. of steps from the start symbol S; i.e. the set L(G)= {w
∈ ∑*| S=>G*w}
FINITE
AUTOMATA

DFA NFA

Deterministic Finite Automata (DFA)


M = {Q, ∑, ∂, q0, F} Where:
Q = finite set of all states
∑ = finite set of terminals
∂ = transition function
q0 = initial state
F = set of final states

F = {q1}
∂(q0, 1) = q1
Or ∂(Qx∑)  Q
Example :-
For language anb we may have aa, aab, aaab, aaaab etc.

q0 b q1

Q = {q0, q1}
∂(q0, b) = q1 -------Transition function
F = {q1}
∑= {a, b}
Example:-

M = ({q0, q1, q2, q3},{a, b},∂, q0,{q3})


As per the DFA diagram we conclude the following transition
functions:-
∂(q0 ,a) = q1
∂(q0 ,b) = q2
∂(q1 ,a) = q2 ∂:Qx∑Q general
∂(q1 ,b) = q3 expression for ∂
∂(q2 ,a) = q2 ∂* denotes extended transition
function (for multiple inputs)
∂(q2 ,b) = q2
∂(q3 ,a) = q3
∂(q3 ,b) = q2
Ex :- ∂*(q0, ab) = q3 from previous example
∂*(q0, w) = qi is the general expression.
Where w denotes a string
INPUTS
STATES a b
q0 q1 q2
q1 q2 q3
q2 q2 q2
q3 q3 q2

Non-deterministic Finite Automata (NFA)


In this case there may be different states possible for same input.
Back-tracking possible.
M = {∑, ∂, q0, Q, F}
Here the difference arises in ∂ of DFA
∂(Qx∑) = Q*

Conversion of NFA to DFA


Example 1:- Lets consider the following NFA:
M = ({q0, q1}, {0, 1}, ∂, q0, {q1})

(0, 1)
0
1

q0 q1
1
INITIAL STATE FINAL STATE

Fig: NFA

State Transition Table:


INPUTS
STATE 0 1
{q0} {q0} {q1}
{q1} {q1} {q0, q1}
{q0, q1} {q0, q1} {q0, q1}
0
0

1
{q0} {q1}

INITIAL STATE
1

Fig: DFA
{q0, q1} (0, 1)

FINAL STATE
Example 2:- Construct DFA equivalent to
M = ({q0, q1, q2},{a, b}, ∂, q0, {q2 })
Given state table :-
INPUTS
STATE a b
{q0} {q0, q1} {q2}
{q1} {q0} {q1}
{q2} - {q0, q1}

a a a

a
{q0,}
{q1}
b
b
b Fig: NFA
{q2}

Final state

Solution:-
State table for drawing the DFA:-
Inputs
State a b
{q0} {q0, q1} {q0}
{q0, q1} {q0, q1} {q0, q1}
{q0} Ø {q0, q1}
{q0, q1} {q0} {q0, q1}
Ø Ø Ø
{q1, q2}
a
a
{q0, q1}
a
{q0}
(a, b)
b
a Ø
fig DFA {q2}

Example:
Construct a DFA equivalent to
M = ({q0, q1, q2, q3}, {0, 1}, ∂, q0, {q3})
With the NFA state table as:-
INPUTS
States 0 1
{q0} {q0, q1} {q0}
{q1} {q2} {q0}
{q2} {q3} {q3}
{q3} - {q2}
(0, 1) 1

0 {q1}
{q0,}
0 {q3}

Fig : NFA {q2}

Solution:-
State table for DFA:-
STATES 0 1
{q0} {q0, q1} {q0}
{q0, q1} {q0, q1, q2} {q0, q1}
{q0, q1, q2} {q0, q1, q2, q3} {q0, q1, q3}
{q0, q1, q2, q3} {q0, q1, q2, q3} {q0, q1, q2, q3}
{q0, q1, q3} {q0, q1, q2} {q0, q1, q2}

1
1

0 {q0, q1}
{q0} {q0, q1,q3}

{q0, q1, q2}


0

{q0, q1, q2, q3}


Fig:- DFA

You might also like