0% found this document useful (0 votes)
46 views21 pages

Ch-2 Equivalence of FA & NFA With - Transition

1) The document discusses the equivalence of finite automata (FA), specifically deterministic finite automata (DFA) and non-deterministic finite automata (NFA). 2) It proves that for any language L, L can be accepted by a DFA if and only if it can be accepted by an NFA. This is done by showing that any NFA can be converted to an equivalent DFA using subset construction. 3) Subset construction works by creating DFA states that represent subsets of the NFA states, and transitions between these states that simulate the NFA transitions. This ensures the languages accepted are equivalent.

Uploaded by

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

Ch-2 Equivalence of FA & NFA With - Transition

1) The document discusses the equivalence of finite automata (FA), specifically deterministic finite automata (DFA) and non-deterministic finite automata (NFA). 2) It proves that for any language L, L can be accepted by a DFA if and only if it can be accepted by an NFA. This is done by showing that any NFA can be converted to an equivalent DFA using subset construction. 3) Subset construction works by creating DFA states that represent subsets of the NFA states, and transitions between these states that simulate the NFA transitions. This ensures the languages accepted are equivalent.

Uploaded by

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

Department of Computer and Science Engineering (CSE)

UNIVERSITY INSTITUTE OF
ENGINEERING
COMPUTER SCIENCE
ENGINEERING
Bachelor of Engineering
Theory of Computation (CST-353)

Topic: Equivalence of Finite


DISCOVER . LEARN .
Automata
University Institute of Engineering (UIE) EMPOWER
Department of Computer and Science Engineering (CSE)

Learning Objectives & Outcomes


Objective:
• To understand the concept of Finite Automata, and
equivalence of Finite Automata.

Outcome:
• Student will understand the
 Equivalence of DFA and NDFA
 NFA with null transition

University Institute of Engineering (UIE)


Department of Computer and Science Engineering (CSE)

Equivalence of DFA & NFA


• Theorem:
– A language L is accepted by a DFA if and only if it is
Should be accepted by an NFA.
true for
any L • Proof:
1. If part:
• Prove by showing every NFA can be converted to an
equivalent DFA (in the next few slides…)

2. Only-if part is trivial:


• Every DFA is a special case of an NFA where each state has
exactly one transition for every input symbol. Therefore, if L is
accepted by a DFA, it is accepted by a corresponding NFA.

3
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

Proof for the if-part


• If-part: A language L is accepted by a DFA if it is
accepted by an NFA
• rephrasing…
• Given any NFA N, we can construct a DFA D such
that L(N)=L(D)
• How to convert an NFA into a DFA?
– Observation: In an NFA, each transition maps to a subset
of states
– Idea: Represent:
each “subset of NFA_states”  a single “DFA_state”

4
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

NFA to DFA by subset construction


• Let N = {QN,∑,δN,q0,FN}
• Goal: Build D={QD,∑,δD,{q0},FD} s.t. L(D)=L(N)
• Construction:
1. QD= all subsets of QN (i.e., power set)
2. FD=set of subsets S of QN s.t. S∩FN≠Φ
3. δD: for each subset S of QN and for each input symbol a
in ∑:
• δD(S,a) = U δN(p,a)

p in s

5
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

NFA to DFA construction: Example


Idea: To avoid
• L = {w | w ends in 01} enumerating all of
1 0 power set, do “lazy
creation of states”
NFA: DFA: 0 1
0,1 {q0} {q0,q1} {q0,q2}
0
0 1 1
q0 q1 q2

δD 0 1 δD 0 1
δN 0 1
Ø Ø Ø {q0} {q0,q1} {q0}
q0 {q0,q1} {q0}
{q0} {q0,q1} {q0} {q0,q1} {q0,q1} {q0,q2}
q1 Ø {q2}
{q1} Ø {q2} *{q0,q2} {q0,q1} {q0}
*q2 Ø Ø
*{q2} Ø Ø
0. Enumerate all possible subsets
{q0,q1} {q0,q1} {q0,q2}
1. Determine
*{q0,q2} {q0,q1} {q0}
transitions
2. Retain only those states
*{q1,q2} Ø {q2}
reachable from {q0}
*{q0,q1,q2} {q0,q1} {q0,q2}
6
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

NFA to DFA: Repeating the example



using
L = {w | w ends in 01}
LAZY CREATION
1 0
NFA: DFA: 0 1
0,1 {q0} {q0,q1} {q0,q2}
0
0 1 1
q0 q1 q2

δN 0 1 δD 0 1
q0 {q0,q1} {q0} {q0} {q0,q1} {q0}
q1 Ø {q2} {q0,q1} {q0,q1} {q0,q2}
*q2 Ø Ø *{q0,q2} {q0,q1} {q0}
Main Idea: Introduce
states as you go(on a
need basis)

7
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

Correctness of subset construction


Theorem: If D is the DFA constructed from NFA N by subset
construction, then L(D)=L(N)
• Proof:
– Show that δD({q0},w) ≡ δN(q0,w} , for all w
– Using induction on w’s length:
• Let w = xa
• δD({q0},xa) ≡ δD( δN(q0,x}, a ) ≡ δN(q0,w}

8
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

A bad case where #states(DFA)>>#states(NFA)


• L = {w | w is a binary string s.t., the kth symbol
from its end is a 1}

– NFA has k+1 states

– But an equivalent DFA needs to have at least 2k states

(Pigeon hole principle)


– m holes and >m pigeons
• => at least one hole has to contain two or more pigeons

9
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

Applications

• Text indexing
– inverted indexing
– For each unique word in the database, store all locations
that contain it using an NFA or a DFA
• Find pattern P in text T
– Example: Google querying
• Extensions of this idea:
– PATRICIA tree, suffix tree

10
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

A few subtle properties of DFAs and NFAs


• The machine never really terminates.
– It is always waiting for the next input symbol or making transitions.
• The machine decides when to consume the next symbol from the
input and when to ignore it.
– (but the machine can never skip a symbol)
• => A transition can happen even without really consuming an input
symbol (think of consuming  as a free token) – if this happens, then
it becomes an -NFA (see next few slides).
• A single transition cannot consume more than one (non-) symbol.

11
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

FA with -Transitions
• We can allow explicit -transitions in finite
automata
– i.e., a transition from one state to another state without
consuming any additional input symbol
– Makes it easier sometimes to construct NFAs

Definition:  -NFAs are those NFAs with at least


one explicit -transition defined.
•  -NFAs have one more column in their transition
table

12
University Institute of Engineering (UIE)
Example of an -NFA

L = {w | w is empty, or if non-empty will end in 01}


0,1

0 1
• -closure of a state q,
q0 q1 q2 ECLOSE(q), is the set of

all states (including
start q’0 itself) that can be
δE 0 1
 reached from q by
*q’0 Ø Ø {q’0,q0} repeatedly making an
q0 {q0,q1} {q0} {q0} arbitrary number of -
q1 Ø {q2} {q1} transitions.
*q2 Ø Ø {q2}

University Institute of Engineering (UIE) 13


Example of an -NFA

To simulate any transition:


Step 1) Go to all immediate destination states.
Step 2) From there go to all their -closure states as well.

L = {w | w is empty, or if non-empty will end in 01}


0,1

0 1
Simulate for w=101:
q0 q1 q2
 q0’
 
start q’0
q0’ q0
1 1

δE 0 1
Ø q0
*q’0 Ø Ø {q’0,q0} x 0
ECLOSE(q’0)
q0 {q0,q1} {q0} {q0} q1
ECLOSE(q0) 1
q1 Ø {q2} {q1}
q2
*q2 Ø Ø {q2}

University Institute of Engineering (UIE) 14


Example of another -NFA
To simulate any transition:
Step 1) Go to all immediate destination states.
Step 2) From there go to all their -closure states as well.

0,1 Simulate for w=101: ?

0 1
q0 q1 q2
  1

start q’0 q3

δE 0 1

*q’0 Ø Ø {q’0,q0,q3}
q0 {q0,q1} {q0} {q0,q3}
q1 Ø {q2} {q1}
*q2 Ø Ø {q2}
q3 Ø {q2} {q3}

15
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

Equivalency of DFA, NFA, -NFA


• Theorem: A language L is accepted by some -NFA if
and only if L is accepted by some DFA

• Implication:
– DFA ≡ NFA ≡ -NFA
– (all accept Regular Languages)

16
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

Eliminating -transitions
Let E = {QE,∑,δE,q0,FE} be an -NFA
Goal: To build DFA D={QD,∑,δD,{qD},FD} s.t. L(D)=L(E)
Construction:
1. QD= all reachable subsets of QE factoring in -closures
2. qD = ECLOSE(q0)
3. FD=subsets S in QD s.t. S∩FE≠Φ
4. δD: for each subset S of QE and for each input symbol a∑:
• Let R= U δE(p,a) // go to destination states

p in s
• δD(S,a) = U ECLOSE(r) // from there, take a union
of all their
-closures r in R

17
University Institute of Engineering (UIE)
Example: -NFA  DFA

L = {w | w is empty, or if non-empty will end in 01}


0,1

0 1
q0 q1 q2

start q’0


δE 0 1
δD 0 1
*q’0 Ø Ø {q’0,q0}
*{q’0,q0}
q0 {q0,q1} {q0} {q0}

q1 Ø {q2} {q1}
*q2 Ø Ø {q2}

University Institute of Engineering (UIE) 18


Department of Computer and Science Engineering (CSE)

Summary
• Equivalency of DFA & NFA
• Removal of redundant states and including dead states
• -transitions in NFA
• Pigeon hole principles
• Text searching applications

19
University Institute of Engineering (UIE)
Department of Computer and Science Engineering (CSE)

References
• Https://en.wikipedia.org/wiki/Finite-state_machine
• https://www.safaribooksonline.com
• http://studentsfocus.com/
• http://www.francisxavier.ac.in/

University Institute of Engineering (UIE)


THANK YOU

University Institute of Engineering (UIE)

You might also like