0% found this document useful (0 votes)
20 views

Module 1

The document discusses deterministic finite automata (DFA) and non-deterministic finite automata (NDFA). It defines them as finite state machines that can accept strings of symbols. A DFA has a single deterministic transition between states for each symbol, while an NDFA can transition to multiple states non-deterministically. Both can be represented as 5-tuples and as state diagrams, with DFAs having a single transition arrow between states and NDFAs having multiple potential transition arrows. Examples of DFAs and NDFAs are provided to illustrate their definitions and representations.

Uploaded by

vidhya_bineesh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views

Module 1

The document discusses deterministic finite automata (DFA) and non-deterministic finite automata (NDFA). It defines them as finite state machines that can accept strings of symbols. A DFA has a single deterministic transition between states for each symbol, while an NDFA can transition to multiple states non-deterministically. Both can be represented as 5-tuples and as state diagrams, with DFAs having a single transition arrow between states and NDFAs having multiple potential transition arrows. Examples of DFAs and NDFAs are provided to illustrate their definitions and representations.

Uploaded by

vidhya_bineesh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 38

Finite Automata:Deterministic And

Non- deterministic Finite Automaton


(DFA)
Automata
The term "Automata" is derived from the Greek word "αὐτόματα" which means
"self-acting". An automaton (Automata in plural) is an abstract self-propelled
computing device which follows a predetermined sequence of operations
automatically.
Finite
Automata
An automaton with a finite number of states is called a Finite Automaton (FA) or Finite
State Machine (FSM).
A finite automata can be represented by a 5-tuple (Q, Σ, δ, q0, F), where:
• Q is a finite set of states.
• Σ is a finite set of symbols, called the alphabet of the automaton.
• δ is the transition function.
• q0 is the initial state from where any input is processed (q0 ∈ Q).
• F is a set of final state/states of Q (F ⊆ Q).
Deterministic Finite Automaton (DFA)
In DFA, for each input symbol, one can determine the state to which the machine
will move. Hence, it is called Deterministic Automaton. As it has a finite number
of states, the machine is called Deterministic Finite Machine or Deterministic
Finite Automaton.
A DFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:

• Q is a finite set of states.

• Σ is a finite set of symbols called the alphabet.

• δ is the transition function where δ: Q × Σ → Q

• q0 is the initial state from where any input is processed (q0 ∈ Q).

• F is a set of final state/states of Q (F ⊆ Q).


Graphical Representation of a
DFA by digraphs called state diagram.
A DFA is represented

• The vertices/circles represent the states.

• The arcs labeled with an input alphabet show the transitions.

• The initial state is denoted by an empty single incoming arc.

• The final state is indicated by double circles.


Example
Let a deterministic finite automaton be

• Q = {a, b, c},

• Σ = {0, 1},

• q0={a},

• F={c}, and

• Transition function δ as shown by the following table:


C
A Sample Deterministic Finite Accepter
• Example shows a dfa to accept the set of all strings
on { a, b } that start with the prefix ab.
Build a DFA
accepts the set of all strings over {0,1} that end with 00
D FA
• Construct a DFA that accept all strings over the alphabets {a, b}
where the string length is at least 2.
– and

a, b

a,b a,b
A B C

– Up to this is a DFA of string length 2. This is not the required DFA.


– Now this is required DFA.
11
D FA
• Construct a DFA that accept all strings over the alphabets {a, b}
where the string length is at most two.
– and

a, b

a,b a,b a, b
A B C D
– To accept null string () the only way to make initial state to both initial
state and final state.
12
Minimum number of states

|𝝎|=𝟐 |𝝎|≥𝟐 |𝝎|≤𝟐


n+2 n+1 n+2
13
DFA vs NDFA
DFA NDFA
The transition from a state is to a single The transition from a state can be to multiple
particular next state for each input symbol. next states for each input symbol. Hence it is
Hence it is called deterministic. called non-deterministic.
Empty string transitions are not seen in DFA. NDFA permits empty string transitions.

Backtracking is allowed in DFA In NDFA, backtracking is not always


possible.
Requires more space. Requires less space.
A string is accepted by a DFA, if it A string is accepted by a NDFA, if at least
transits to a final state. one of all possible transitions ends in a
final state.
Transition diagram and
Transition diagramsTransition tables tables

Each state is a node Tabular representation of a function


The rows correspond to the states and
For each state q ∈ Q and each symbol the columns to the inputs
a ∈ , let δ(q, a) = p The entry for the row corresponding
to state q and the column
Then the transition diagram has
corresponding to input a is the state
an arc from q to p, labeled a δ(q, a)

There is an arrow to the start state The initial and final states are
q0 denoted by → and * respectively.
Nodes corresponding to final states
are marked with doubled circle

1
Non-deterministic Finite Automaton
In NDFA, for a particular input symbol, the machine can move to any combination
of the states in the machine. In other words, the exact state to which the
machine moves cannot be determined. Hence, it is called Non-deterministic
Automaton. As it has finite number of states, the machine is called Non-
deterministic Finite Machine or Nondeterministic Finite Automaton.
An NDFA can be represented by a 5-tuple (Q, Σ, δ, q0, F) where:

• Q is a finite set of states.

• Σ is a finite set of symbols called the alphabets.

• δ is the transition function where δ: Q × Σ → 2𝑄

(Here the power set of Q (2𝑄) has been taken because in case of NDFA, from a

state, transition can occur to any combination of Q states)


• q0 is the initial state from where any input is processed (q0 ∈ Q).

• F is a set of final state/states of Q (F ⊆ Q).


Graphical Representation of an
NDFA
Graphical Representation of an NDFA: (same as DFA)

An NDFA is represented by digraphs called state diagram.

• The vertices/Circles represent the states.

• The arcs labeled with an input alphabet show the transitions.

• The initial state is denoted by an empty single incoming arc.

• The final state is indicated by double circles.


Example
Let a non-deterministic finite automaton be

• Q = {a, b, c}

• Σ = {0, 1}

• q0 = {a}

• F={c} and

• Transition function δ as shown by the following table:


Representation of DFA
M1 = (Q, Σ, δ, q1, F )
where Q = {q1, q2, q3}, Σ =
{0, 1},

0 1
q1 q1 q2
the transition function δ is q2 q3 q2
q3 q2 q2
Final state F = {q2}.
q1 is the start state, and F = {q2}.
Example: Testing Membership
01011
Next
symbol
0 0,1

1 1
A B C

Start 0

Current
state

2
2
Example: Testing Membership
01011
Next
symbol
0 0,1

1 1
A B C

Start 0

Current
state

2
3
Example: Testing Membership
01011
Next
symbol
0 0,1

1 1
A B C

Start 0

Current
state

2
4
Example: Testing Membership
01011
Next
symbol
0 0,1

1 1
A B C

Start 0

Current
state

2
5
Example: Testing Membership
01011
Next
symbol
0 0,1

1 1
A B C

Start 0

Current
state

2
6
Example: Testing Membership
01011
Next
symbol
0 0,1

1 1
A B C

Start 0

Current
state

2
7
Example

• M3= (Q, Σ, δ , q1, F) or M3 = ({q1, q2,q3}, {0,1}, 6, q1, {q2})


• Accepted Strings or Words (w):
– 1, 01, 11, 100, 011, 0101, 0100, 110000, …
 If A is the set of all strings that machine M accepts, we say:
• A is the language of machine M1 and write L(M3) = A
• M3 recognizes A or that M3 accepts A
• A = {1, 01, 11, 100, 011, 0101, 0100, 110000, …} or
• A = {w| w contains at least one 1 and an even number of 0s follow the last 1}
28
Transition and extended transition
function for DFA
Transition function δ: (Q x Σ)Q,

δ is defined for any q in Q and a in Σ, and δ(q , a) = q’ is equal to some state q’ in


Q, could be q’=q

Intuitively, δ(q, a) is the state entered by ε after reading symbol a while in state q.

If δ is our transition function, then the extended transition function is denoted by δˆ

The extended transition function is a function that takes a state q and a string
w and returns a state p (the state that the automaton reaches when starting in
state q and processing the sequence of inputs w )

δ^(q , w) – The state entered after reading string w having started in state q

Extended transition function δ ^ : (Q x Σ*)  Q

Describes what happens when we start in any state and follow any sequence of inputs

23
Cont …
Formally:

1)δ^(q, ) = q, If we are in a state q and read no inputs, then we are still in state q

and

2) For all w in Σ* and a in Σ: δ^(q , wa) = δ (δ^(q , w), a) i.e. Recursive


definition

Suppose w is a string of the form xa; that is a is the last symbol of w, and x is the
string consisting of all but the last symbol Then: δˆ(q, w) =δ(δˆ(q, x), a)

To compute δˆ(q, w), first compute(q, x), the state that the automaton is in after
processing all but the last symbol of w

Suppose this state is p, i.e. δˆ(q, x) =p

Then δˆ(q, w )is what we get by making a transition from state P on input a – the last
symbol of w.
Extension of δ to Strings
Example #1: 1
0
q0 q1 1
0
What is δ^(q0, 011)? Informally, it is the state entered by ε after
processing 011 having started in state q0.
Formally:
δ^(q0, 011) = δ (δ^(q0,01), 1)
= δ (δ (δ ^(q0,0), 1), 1)
= δ (δ (δ (δ ^(q0, ), 0), 1), 1)
= δ (δ (δ(q0,0), 1), 1)
= δ (δ (q1, 1), 1)
= δ (q1, 1)
= q1
Is 011 accepted? No, since δ^(q0, 011) = q1 is not a final state.
Conti
Example #2: 1
0
1
0
… 1

q2
q0 q1
0
What is δ(q0, 011)? Informally, it is the state entered by ε after processing 011
having started in state q0.
Formally:
δ(q0, 011) = δ (δ(q0,01), 1)
= δ (δ (δ (q0,0), 1), 1)
= δ (δ (q1, 1), 1)
= δ (q1, 1)
= q1
Is 011 accepted? No, since δ(q0, 011) = q1 is not a final state.
Language?
NDFA to DFA
Conversion
Problem Statement

Let X = (Qx, Σ, δx, q0, Fx) be an NDFA which accepts the language L(X). We have
to design an equivalent DFA Y = (Qy, Σ, δy, q0, Fy) such that L(Y) = L(X). The
following procedure converts the NDFA to its equivalent DFA:
Algorithm
Input: An NDFA

Output: An equivalent DFA

Step 1 Create state table from the given NDFA.

Step 2 Create a blank state table under possible input alphabets for the equivalent DFA.

Step 3 Mark the start state of the DFA by q0 (Same as the NDFA).

Step 4 Find out the combination of States {Q0, Q1,... , Qn} for each possible input
alphabet.

Step 5 Each time we generate a new DFA state under the input alphabet columns, we have to apply step 4 again,
otherwise go to step 6.

Step 6 The states which contain any of the final states of the NDFA are the final states of the equivalent DFA.
Example
Let us consider the NDFA shown in the figure below.
Using the above algorithm, we find its equivalent DFA. The state table of the DFA
is shown in below.
The state diagram of the DFA is as follows:

You might also like