0% found this document useful (0 votes)
15 views35 pages

03 TOC

The document discusses various aspects of finite state automata (FSA), including deterministic finite automata (DFA) and nondeterministic finite automata (NFA), along with examples and definitions. It covers the construction of DFAs and NFAs for specific languages, the conversion from NFA to DFA, and the concept of epsilon transitions in epsilon-NFA. Additionally, it highlights the limitations and applications of finite state automata.

Uploaded by

sinhaaaryankumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views35 pages

03 TOC

The document discusses various aspects of finite state automata (FSA), including deterministic finite automata (DFA) and nondeterministic finite automata (NFA), along with examples and definitions. It covers the construction of DFAs and NFAs for specific languages, the conversion from NFA to DFA, and the concept of epsilon transitions in epsilon-NFA. Additionally, it highlights the limitations and applications of finite state automata.

Uploaded by

sinhaaaryankumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

Problems on DFA

Σ={a,b}
• Every string contains a substring “abb”
• Every string does not contains a substring “ab”
• Every string where every “a” is followed by 3 “b’s”
• String does not contain 3 consecutive “a’s”
Finite automata

Diagram Table Set


x x 𝛿= x y

y
∗ 𝑞1 𝑞1 𝑞2
𝑞1 𝑞2

∗ 𝑞2 𝑞2 𝑞1
y

M=({q1,q2},{x,y}, 𝛿, q1,{q1, q2}).

𝛿 = { q1, 𝑥 , q1 ,
q1, 𝑦 , q2 , q2, 𝑥 , q2 , q2, 𝑦 , q1 }
• Let Σ = {0, 1}. Give DFAs for {}, {ε}, Σ*, and Σ+.

For {}: For {ε}:


0/1
0/1
0/1
q0 q0 q1

For Σ*: For Σ+: 0/1


0/1
0/1
q0 q0 q1

4
Nondeterministic Finite State Automata (NFA)

• An NFA is a five-tuple:

M = (Q, Σ, δ, q0, F)

Q A finite set of states


Σ A finite input alphabet
q0 The initial/starting state, q0 is in Q
F A set of final/accepting states, which is a subset of Q
δ A transition function, which is a total function from Q x Σ to 2Q

δ: (Q x Σ) –> 2Q :2Q is the power set of Q, the set of all subsets of Q


δ(q,s) :The set of all states p such that there is a transition
labeled s from q to p

δ(q,s) is a function from Q x S to 2Q (but not only to Q)


5
• Example #1: one or more 0’s followed by one or more 1’s

0 1 0/1
Q = {q0, q1, q2}
0 1
Σ = {0, 1} q0 q1 q2
Start state is q0
F = {q2}

δ: 0 1
q0
{q0, q1} {}

q1 {} {q1, q2}

{q2} {q2}
q2

6
• Example #2: pair of 0’s or pair of 1’s as substring

0/1 0/1
Q = {q0, q1, q2 , q3 , q4}
Σ = {0, 1} 0 0
q0 q3 q4
Start state is q0
F = {q2, q4} 1 0/1

1
δ: 0 1 q1 q2
q0 {q0, q3} {q0, q1}

q1 {} {q2}

{q2} {q2}
q2
{q4} {}
q3
{q4} {q4}
q4
7
• Design the min DFA and Min NFA for the Language L={ε}, Σ = {a, b}

a,b
𝑞1
a,b 𝑞2
𝑞1
• Design the min DFA and Min NFA for the Language L=(𝑎 + 𝑏)+ , Σ = {a, b}

a,b

a,b 𝑞2
𝑞1

a,b a,b a,b

a,b 𝑞2 a,b
𝑞1 𝑞1 𝑞2
Points to remember
• For every regular set, there is infinite no of DFAs
• For every regular set, there is infinite no of NFAs
• For every regular set, only one min DFA (unique)
• For every regular language, min DFA and min NFA need not be equal.
• For every regular language, there exist 1 or more min NFAs.
• How many paths are there for “bbb”
b
b
b 𝑞2
𝑞1

•2
•3
•4
•5
• What is the min NFA and min DFA for the below language
Min DFA Min NFA
1. L= 𝑎𝑎(𝑎 + 𝑏)∗ 4 3
2. L= (𝑎 + 𝑏)∗ 𝑎 2 2
3. L= (𝑎 + 𝑏)∗ a (𝑎 + 𝑏)∗ 2 2

a,b a,b

a a a a
𝑞1 𝑞2 𝑞3 𝑞1 𝑞2 𝑞3

b b

𝑞4
a,b
L= (𝑎 + 𝑏)∗ 𝑎

b a

a
𝒒𝟏 𝒒𝟐

b a,b

a
𝒒𝟏 𝒒𝟐
Construct the min NFA and min DFA, Σ = {a, b}
• L= (𝑎 + 𝑏)∗ 𝑎𝑎𝑎(𝑎 + 𝑏)∗ ,
• L= 𝑎𝑏 ∗
• L=(𝑎𝑏)∗
• L=𝑎∗ 𝑏 ∗
• L={w|w ϵ {𝑎, 𝑏}∗ , 𝑤 } is divisible by 3} , No. of states in min DFA is ______.
• L={w|w ϵ {𝑎, 𝑏}∗ , 𝑤 } is even} , No. of states in min DFA is ______.
Difference between DFA and NDFA/NFA
DFA NDFA/NFA
Dead Configuration is not allowed Dead Configuration is allowed
Multiple choices are not available corresponding to an Multiple choices are available corresponding to an
input input
ε move is not allowed Ε move is allowed
Digital computer are deterministic Non deterministic feature is not associated with
computers
Designing and understanding is difficult Designing and understanding is easier
Number of states are more or equal to NFA Number of states are lesser or equal to DFA

Only one min DFA (unique) There exist 1 or more min NFAs
NFA to DFA conversion
Example 1 NFA to DFA Conversion
NFA DFA

State / Alphabet a b State / Alphabet a b


→q0 q0 q0, q1 →q0 q0 {q0, q1}
q1 – *q2 {q0, q1} q0 *{q0, q1, q2}
*q2 – – *{q0, q1, q2} q0 *{q0, q1, q2}
Example 2 NFA to DFA conversion
NFA DFA

State / Alphabet 0 1 State / Alphabet 0 1


→q0 q0 q1, *q2 →q0 q0 *{q1, q2}
q1 q1, *q2 *q2 *{q1, q2} *{q0, q1, q2} *{q1, q2}
*q2 q0, q1 q1 *{q0, q1, q2} *{q0, q1, q2} *{q1, q2}
• NFA of all binary string in which 2nd last bit is 1

0,1
1 0,1
𝑞1 𝑞3 𝑞4

IF n is the number of states in NFA then maximum 2𝑛 states are possible for the converted DFA
ε-NFA (Epsilon NFA)
• Epsilon NFA (ε-NFA) is similar to the NFA but with a little difference
in that it has an epsilon (ε) transition that NFA doesn’t have.
• A Transition that does not consume any input symbol is called an
ε-transitions.
• Due to ε-transitions, the first string of language may be empty.
Formal Definition of Epsilon-NFA

The formal definition of ε-NFA is represented through 5-tuple (Q, ∑, δ, q0, F)


where,

• Q is a finite set of all states (𝑞0 , 𝑞1 ,𝑞2 , …, 𝑞𝑛 ) where n is a finite number.


• ∑ is a finite set of symbols called the alphabet. i.e. {0, 1}.
• δ : Q x (∑ U ε) → 2𝑄 is a total function called as transition function.
• 𝑞0 is the initial state from where any input is processed (𝑞0 ∈ Q).
• F is a set of final states where F will be a subset ( ⊆ ) of Q.
Examples of Epsilon NFA
Elimination of Epsilon (ε) From NFA
Suppose there are two vertices V1 and V3; the epsilon between them is below

• Step 01: Find all edges starting from V2


• Step 02: Remove the epsilon. All Finding edges from V2 are Duplicated to V1
without changing edge labels.
• Step 03: if V1 is initial state, make V2 initial
• Step 04: if V2 is final state, make V1 final
• Step 05: Remove all dead states
0
Eliminate Epsilon (ε) from the given NFA
ε ε 0 1 0 1
𝑞0 𝑞1 𝑞4 𝑞5 𝑞6 𝑞0 𝑞1 𝑞4 𝑞5 𝑞6

0 1 0 0 0 1 0 0
0
0
𝑞2 𝑞3 𝑞2 𝑞3
0

1
𝑞0 𝑞1 𝑞5 𝑞6

0 1 0 0
0
0
𝑞2 𝑞3
Limitations of Finite State Automata (FSA)
• Limited Memory
• Strings without comparison
• Linear Power

Application of FSA

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy