SlideShare a Scribd company logo
Nondeterminism and Epsilon Transitions
Mridul Aanjaneya
Stanford University
June 28, 2012
Mridul Aanjaneya Automata Theory 1/ 30
Challenge Problem
Question
Prove that any square with side length a power of 2, and one square
removed, is tileable with L’s.
Mridul Aanjaneya Automata Theory 2/ 30
Something to think about ...
Question
Are such tilings always possible?
Mridul Aanjaneya Automata Theory 3/ 30
Recap: Deterministic Finite Automata
Definition
A DFA is a 5-tuple (Q, Σ, δD, q0, F) consisting of:
• A finite set of states Q,
• A set of input alphabets Σ,
• A transition function δD : Q × Σ → Q,
• A start state q0, and
• A set of accept states F ⊆ Q.
The transition function δD:
• Takes two arguments, a state q and an alphabet a.
• δD(q,a) = the state the DFA goes to when it is in state q and
the alphabet a is received.
Mridul Aanjaneya Automata Theory 4/ 30
Recap: Graph representation of DFA’s
• Nodes correspond to states.
• Arcs represent transition function.
Arc from state p to state q labeled by all those input symbols
that have transitions from p to q.
• Incoming arrow from outside denotes start state.
• Accept states indicated by double circles.
q q1 2
1
0
0
q3
1
0,1
• Accepts all binary strings without two consecutive 1’s.
Mridul Aanjaneya Automata Theory 5/ 30
Recap: Transition table for DFA’s
0 1
→ q∗
1 q1 q2
q∗
2 q1 q3
q3 q3 q3
• A row for each state, a column for each alphabet.
• Accept states are starred.
• Arrow for the start state.
q q1 2
1
0
0
q3
1
0,1
Mridul Aanjaneya Automata Theory 6/ 30
Recap: Regular languages
Definition
A DFA M = (Q, Σ, δD, q0, F) accepts w if there exists a sequence
of states r0, r1, . . . , rn in Q with three conditions:
• r0 = q0
• δD(ri , wi+1) = ri+1 for i = 0, . . . , n − 1, and
• rn ∈ F
• Condition 1 says that M starts in the start state q0.
• Condition 2 says that M follows δD between two states.
• Condition 3 says that last state is an accept state.
• We say that M recognizes L if L = {w | M accepts w}.
Mridul Aanjaneya Automata Theory 7/ 30
Regular Languages: Examples
Example
Let L = {w | w ∈ {0,1}∗ and w, viewed as a binary integer, is
divisible by 5.}
q q0
1
2
0
1
1
0
1
0
1
0
0
q q
q
1 3
4
Mridul Aanjaneya Automata Theory 8/ 30
Regular Languages: Examples
Example
Show that the language of all strings over {0, 1} that do not contain
a pair of 1’s that are separated by an odd number of 0’s is regular.
1
a
0 1
1
0,10 0
e
o b
Mridul Aanjaneya Automata Theory 9/ 30
Regular Languages: Examples
Example
Show that the language of all strings over {0, 1} that contain an
even number of 0’s and 1’s is regular.
0 00 0
1
1
1
1
oo
ee
oe
eo
Mridul Aanjaneya Automata Theory 10/ 30
Nondeterminism
• Deterministic finite automata can only be in one state at any
point in time.
Recall the definition of the transition function δD.
• In contrast, nondeterministic finite automata (NFA’s) can be
in several states at once!
The transition function δN is a one-to-many function.
q1
q q q2 3 4
1
0,1
0,1 0,1
• This NFA recognizes strings in {0,1}∗ containing a 1 in the
third position from the end.
Mridul Aanjaneya Automata Theory 11/ 30
Transition table
0 1
→ q1 q1 q1,q2
q2 q3 q3
q3 q4 q4
q∗
4 q4 q4
• q1 is a nondeterministic state with a one-many transition on 1.
q1
q q q2 3 4
1
0,1
0,1 0,1
• Intuitively, the NFA always guesses right.
Mridul Aanjaneya Automata Theory 12/ 30
Nondeterministic Finite Automata
Example
An NFA that accepts all strings of the form 0k where k is a multiple
of 2 or 3.
q1
q2
q3
q4
q5
q6
0
0 0
0
0
ε
ε
Mridul Aanjaneya Automata Theory 13/ 30
Nondeterministic Finite Automata
Definition
An NFA is a 5-tuple (Q, Σ, δN, q0, F) consisting of:
• A finite set of states Q,
• A set of input alphabets Σ,
• A transition function δN : Q × Σε → P(Q),
• A start state q0, and
• A set of accept states F ⊆ Q.
• Here, Σε denotes the set Σ ∪ {ε}.
• P(Q) denotes the power set of Q.
Mridul Aanjaneya Automata Theory 14/ 30
Transition function of an NFA
• δN(q,a) is a set of states.
• Extend to strings as follows:
Basis: δN (q,ε) = q
Induction: δN (q,wa) = the union over all states of δN (p,a),
where p ∈ δN (q,w).
• A string is accepted by an NFA if δN(q0,w) contains at least
one state p ⊆ F.
• The language of an NFA is the set of strings it accepts.
Mridul Aanjaneya Automata Theory 15/ 30
Equivalence of DFA’s and NFA’s
• Every DFA is also an NFA by definition.
There is simply no nondeterminism.
• Surprisingly, for every NFA, there is also an equivalent DFA!
Two equivalent machines recognize the same language.
Nonintuitive, as we’d expect NFA’s to be more powerful.
Useful, as describing an NFA is much simpler.
• Proof is the subset construction.
• The number of states of the DFA can be exponential in the
number of states of the NFA.
• Thus, NFA’s accept exactly the regular languages.
Mridul Aanjaneya Automata Theory 16/ 30
Equivalence of DFA’s and NFA’s
• DFA for recognizing strings with a 1 in the third last position.
q q q q6 4
1
0
1 1
1
00
1
0 0
11 0
0
1
1 0
q q q1
q
2
35 7
8
Mridul Aanjaneya Automata Theory 17/ 30
Subset construction
• Given an NFA (Q,Σ,δN,q0,F), construct equivalent DFA with:
States P(Q) (set of subsets of Q).
Inputs Σ.
Start state {q0}.
Final states = all those with a member of F.
Note:
• The DFA states have names that are sets of NFA states.
• But as a DFA state, an expression like {p,q} must be read as
a single symbol.
Mridul Aanjaneya Automata Theory 18/ 30
Subset construction
• Example: We’ll construct the DFA for the following NFA
which recognizes strings in {0,1}∗ containing a 1 in the
second position from the end.
1
0,1
0,1
a b c
Mridul Aanjaneya Automata Theory 19/ 30
Subset construction
1
0,1
0,1
a b c
1
a
0
a,b a,b,c
a,c
1
00
0 1
1
Mridul Aanjaneya Automata Theory 20/ 30
Proof of equivalence: subset construction
• Show by induction on length of w that
δN(q0,w) = δD({q0},w)
• Basis: w = ε. δN(q0,ε) = δD({q0},ε) = {q0}.
• Inductive step: Assume IH is true for all strings shorter than
w. Let w = xa, then IH is true for x.
Let δN (q0,x) = δD({q0},x) = S.
Let T = the union over all states p in S of δN (p,a).
Then δN (q0,w) = δD({q0},w) = T (by definition).
Mridul Aanjaneya Automata Theory 21/ 30
NFA’s with ε-transitions
• State-to-state transitions on ε input.
• These transitions are spontaneous, and do not consider the
input string.
0
0
1
1 1
ε
A
DCB
E F
0
ε
ε
Mridul Aanjaneya Automata Theory 22/ 30
Closure of States
• CL(q) = set of states that can be reached from state q
following only arcs labeled ε.
0
0
1
1 1
ε
A
DCB
E F
0
ε
ε
• CL(A) = {A}, CL(E) = {B, C, D, E}.
• Closure of set of states = union of closure of each state.
Mridul Aanjaneya Automata Theory 23/ 30
Extended transition function
• Basis: δE (q,ε) = CL(q).
• Induction: δE (q,xa) is computed as follows:
1 Start with δE (q,x) = S.
2 Take the union of CL(δ(p,a)) for all p in S.
• Intuition: δE (q,w) is the set of states you can reach from q
following a path labeled w with ε’s in between.
Mridul Aanjaneya Automata Theory 24/ 30
Example: Extended transition function
0
0
1
1 1
ε
A
DCB
E F
0
ε
ε
• δE (A,ε) = CL(A) = {A}.
• δE (A,0) = CL(E) = {B, C, D, E}.
• δE (A,01) = CL(C,D) = {C, D}.
Mridul Aanjaneya Automata Theory 25/ 30
Example: Extended transition function
0
0
1
1 1
ε
A
DCB
E F
0
ε
ε
• Language of an ε-NFA is the set of strings w such that
δE (q0,w) contains a final state.
Mridul Aanjaneya Automata Theory 26/ 30
Equivalence of NFA, ε-NFA
• Every NFA is an ε-NFA.
It just has no ε-transitions.
• Converse requires us to take an ε-NFA and construct an NFA
that accepts the same language.
• This is done by combining ε-transitions with the next
transition on a real input.
• Start with an ε-NFA (Q,Σ,q0,F,δE ) and construct an ordinary
NFA (Q,Σ,q0,F’,δN).
Mridul Aanjaneya Automata Theory 27/ 30
Equivalence of NFA, ε-NFA
• Compute δN(q,a) as follows:
Let S = CL(q).
δN (q,a) is the union over all p in S of δE (p,a).
• F’ = set of states q such that CL(q) contains a state of F.
• Intuition: δN incorporates ε-transitions before using a.
• Proof of equivalence is by induction on |w| that
CL(δN(q0,w)) = δE (q0,w).
• Basis: CL(δN(q0,ε)) = CL(q0) = δE (q0,ε).
• Inductive step: Assume IH is true for all x shorter than w.
Let w = xa.
Then CL(δN (q0,xa)) = CL(δE (CL(δN (q0,x)),a)) (by definition).
But from IH, CL(δN (q0,x)) = δE (q0,x).
Hence, CL(δN (q0,w)) = CL(δE (δE (q0,x),a)) = δE (q0,w).
Mridul Aanjaneya Automata Theory 28/ 30
Example
0
0
1
1 1
ε
A
DCB
E F
0
ε
ε
0
0
1
1 1
A
DCB
E F
0
11
1
Mridul Aanjaneya Automata Theory 29/ 30
Summary
• DFA’s, NFA’s and ε-NFA’s all accept exactly the same set of
languages: the regular languages.
• NFA types are easier to design and may have exponentially
fewer states than a DFA.
• But only a DFA can be implemented!
Mridul Aanjaneya Automata Theory 30/ 30

More Related Content

What's hot

Daa notes 3
Daa notes 3Daa notes 3
Daa notes 3
smruti sarangi
 
Markov Models
Markov ModelsMarkov Models
Markov Models
Vu Pham
 
05 linear transformations
05 linear transformations05 linear transformations
05 linear transformations
Andres Mendez-Vazquez
 
Anomalous Transport
Anomalous TransportAnomalous Transport
Anomalous Transport
Subham Dutta Chowdhury
 
Finite automata intro
Finite automata introFinite automata intro
Finite automata intro
lavishka_anuj
 
Limits of functions
Limits of functionsLimits of functions
Limits of functions
Louie Joy Rosit
 
Vector Spaces
Vector SpacesVector Spaces
Hidden Markov Models with applications to speech recognition
Hidden Markov Models with applications to speech recognitionHidden Markov Models with applications to speech recognition
Hidden Markov Models with applications to speech recognition
butest
 
Viterbi algorithm
Viterbi algorithmViterbi algorithm
Viterbi algorithm
Supongkiba Kichu
 
Seminar on quantum automata and Languages
Seminar on quantum automata and LanguagesSeminar on quantum automata and Languages
Seminar on quantum automata and Languages
ranjanphu
 
sistem non linier Lyapunov Stability
sistem non linier Lyapunov Stabilitysistem non linier Lyapunov Stability
sistem non linier Lyapunov Stability
ardian gundrunk pratama
 
01.01 vector spaces
01.01 vector spaces01.01 vector spaces
01.01 vector spaces
Andres Mendez-Vazquez
 
3 fol examples v2
3 fol examples v23 fol examples v2
3 fol examples v2
Digvijay Singh
 
Probable
ProbableProbable
Kernel Lower Bounds
Kernel Lower BoundsKernel Lower Bounds
Kernel Lower Bounds
ASPAK2014
 
06 recurrent neural_networks
06 recurrent neural_networks06 recurrent neural_networks
06 recurrent neural_networks
Andres Mendez-Vazquez
 
Lecture7 channel capacity
Lecture7   channel capacityLecture7   channel capacity
Lecture7 channel capacity
Frank Katta
 
Lesson 11: Markov Chains
Lesson 11: Markov ChainsLesson 11: Markov Chains
Lesson 11: Markov Chains
Matthew Leingang
 
Computability - Tractable, Intractable and Non-computable Function
Computability - Tractable, Intractable and Non-computable FunctionComputability - Tractable, Intractable and Non-computable Function
Computability - Tractable, Intractable and Non-computable Function
Reggie Niccolo Santos
 
Formal methods 4 - Z notation
Formal methods   4 - Z notationFormal methods   4 - Z notation
Formal methods 4 - Z notation
Vlad Patryshev
 

What's hot (20)

Daa notes 3
Daa notes 3Daa notes 3
Daa notes 3
 
Markov Models
Markov ModelsMarkov Models
Markov Models
 
05 linear transformations
05 linear transformations05 linear transformations
05 linear transformations
 
Anomalous Transport
Anomalous TransportAnomalous Transport
Anomalous Transport
 
Finite automata intro
Finite automata introFinite automata intro
Finite automata intro
 
Limits of functions
Limits of functionsLimits of functions
Limits of functions
 
Vector Spaces
Vector SpacesVector Spaces
Vector Spaces
 
Hidden Markov Models with applications to speech recognition
Hidden Markov Models with applications to speech recognitionHidden Markov Models with applications to speech recognition
Hidden Markov Models with applications to speech recognition
 
Viterbi algorithm
Viterbi algorithmViterbi algorithm
Viterbi algorithm
 
Seminar on quantum automata and Languages
Seminar on quantum automata and LanguagesSeminar on quantum automata and Languages
Seminar on quantum automata and Languages
 
sistem non linier Lyapunov Stability
sistem non linier Lyapunov Stabilitysistem non linier Lyapunov Stability
sistem non linier Lyapunov Stability
 
01.01 vector spaces
01.01 vector spaces01.01 vector spaces
01.01 vector spaces
 
3 fol examples v2
3 fol examples v23 fol examples v2
3 fol examples v2
 
Probable
ProbableProbable
Probable
 
Kernel Lower Bounds
Kernel Lower BoundsKernel Lower Bounds
Kernel Lower Bounds
 
06 recurrent neural_networks
06 recurrent neural_networks06 recurrent neural_networks
06 recurrent neural_networks
 
Lecture7 channel capacity
Lecture7   channel capacityLecture7   channel capacity
Lecture7 channel capacity
 
Lesson 11: Markov Chains
Lesson 11: Markov ChainsLesson 11: Markov Chains
Lesson 11: Markov Chains
 
Computability - Tractable, Intractable and Non-computable Function
Computability - Tractable, Intractable and Non-computable FunctionComputability - Tractable, Intractable and Non-computable Function
Computability - Tractable, Intractable and Non-computable Function
 
Formal methods 4 - Z notation
Formal methods   4 - Z notationFormal methods   4 - Z notation
Formal methods 4 - Z notation
 

Similar to Graph representation of DFA’s Da

Nfa to-dfa
Nfa to-dfaNfa to-dfa
Nfa to-dfa
rsivashankari
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
Srimatre K
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.ppt
RohitPaul71
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
ssuser47f7f2
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
ankitamakin
 
Finite automata
Finite automataFinite automata
Finite automata
Rajesh Yaramadi
 
Automata
AutomataAutomata
Dfa
DfaDfa
Nfa egs
Nfa egsNfa egs
Nfa egs
ankitamakin
 
Fsa
FsaFsa
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
ranjan317165
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
amara jyothi
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
Rajendran
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
ssuser47f7f2
 
Automata
AutomataAutomata
Automata
Gaditek
 
Automata
AutomataAutomata
Automata
Gaditek
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's Classification
PrafullMisra
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introduction
NAMRATA BORKAR
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata
parmeet834
 

Similar to Graph representation of DFA’s Da (20)

Nfa to-dfa
Nfa to-dfaNfa to-dfa
Nfa to-dfa
 
Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1Formal Languages and Automata Theory Unit 1
Formal Languages and Automata Theory Unit 1
 
FiniteAutomata.ppt
FiniteAutomata.pptFiniteAutomata.ppt
FiniteAutomata.ppt
 
FiniteAutomata (1).ppt
FiniteAutomata (1).pptFiniteAutomata (1).ppt
FiniteAutomata (1).ppt
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Finite automata examples
Finite automata examplesFinite automata examples
Finite automata examples
 
Finite automata
Finite automataFinite automata
Finite automata
 
Automata
AutomataAutomata
Automata
 
Dfa
DfaDfa
Dfa
 
Nfa egs
Nfa egsNfa egs
Nfa egs
 
Fsa
FsaFsa
Fsa
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
FiniteAutomata_anim.pptx
FiniteAutomata_anim.pptxFiniteAutomata_anim.pptx
FiniteAutomata_anim.pptx
 
Turing Machine
Turing MachineTuring Machine
Turing Machine
 
03-FiniteAutomata.pptx
03-FiniteAutomata.pptx03-FiniteAutomata.pptx
03-FiniteAutomata.pptx
 
Automata
AutomataAutomata
Automata
 
Automata
AutomataAutomata
Automata
 
Thoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's ClassificationThoery of Computaion and Chomsky's Classification
Thoery of Computaion and Chomsky's Classification
 
Automata theory introduction
Automata theory introductionAutomata theory introduction
Automata theory introduction
 
Nondeterministic Finite Automata
Nondeterministic Finite Automata Nondeterministic Finite Automata
Nondeterministic Finite Automata
 

More from parmeet834

DFA
DFA DFA
Problemes chap1 toc
Problemes chap1 tocProblemes chap1 toc
Problemes chap1 toc
parmeet834
 
Hwsoln03 toc
Hwsoln03 tocHwsoln03 toc
Hwsoln03 toc
parmeet834
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
parmeet834
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
parmeet834
 
Pushdown Automata
Pushdown AutomataPushdown Automata
Pushdown Automata
parmeet834
 
Assignment Theory of computation TOC
Assignment Theory of computation TOCAssignment Theory of computation TOC
Assignment Theory of computation TOC
parmeet834
 
5 decidability theory of computation
5 decidability theory of computation 5 decidability theory of computation
5 decidability theory of computation
parmeet834
 
Turing Machines (TM)
Turing Machines (TM)Turing Machines (TM)
Turing Machines (TM)
parmeet834
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
parmeet834
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
parmeet834
 
1 introduction
1 introduction1 introduction
1 introduction
parmeet834
 

More from parmeet834 (12)

DFA
DFA DFA
DFA
 
Problemes chap1 toc
Problemes chap1 tocProblemes chap1 toc
Problemes chap1 toc
 
Hwsoln03 toc
Hwsoln03 tocHwsoln03 toc
Hwsoln03 toc
 
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
CS 162 Fall 2015 Homework 1 Problems September 29, 2015 Timothy Johnson 1. Ex...
 
Pushdown automata
Pushdown automataPushdown automata
Pushdown automata
 
Pushdown Automata
Pushdown AutomataPushdown Automata
Pushdown Automata
 
Assignment Theory of computation TOC
Assignment Theory of computation TOCAssignment Theory of computation TOC
Assignment Theory of computation TOC
 
5 decidability theory of computation
5 decidability theory of computation 5 decidability theory of computation
5 decidability theory of computation
 
Turing Machines (TM)
Turing Machines (TM)Turing Machines (TM)
Turing Machines (TM)
 
Regular Languages
Regular LanguagesRegular Languages
Regular Languages
 
Finite Automata
Finite AutomataFinite Automata
Finite Automata
 
1 introduction
1 introduction1 introduction
1 introduction
 

Recently uploaded

How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
Celine George
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
IreneSebastianRueco1
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
adhitya5119
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
Academy of Science of South Africa
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 

Recently uploaded (20)

How to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold MethodHow to Build a Module in Odoo 17 Using the Scaffold Method
How to Build a Module in Odoo 17 Using the Scaffold Method
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
RPMS TEMPLATE FOR SCHOOL YEAR 2023-2024 FOR TEACHER 1 TO TEACHER 3
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Advanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docxAdvanced Java[Extra Concepts, Not Difficult].docx
Advanced Java[Extra Concepts, Not Difficult].docx
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)South African Journal of Science: Writing with integrity workshop (2024)
South African Journal of Science: Writing with integrity workshop (2024)
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 

Graph representation of DFA’s Da

  • 1. Nondeterminism and Epsilon Transitions Mridul Aanjaneya Stanford University June 28, 2012 Mridul Aanjaneya Automata Theory 1/ 30
  • 2. Challenge Problem Question Prove that any square with side length a power of 2, and one square removed, is tileable with L’s. Mridul Aanjaneya Automata Theory 2/ 30
  • 3. Something to think about ... Question Are such tilings always possible? Mridul Aanjaneya Automata Theory 3/ 30
  • 4. Recap: Deterministic Finite Automata Definition A DFA is a 5-tuple (Q, Σ, δD, q0, F) consisting of: • A finite set of states Q, • A set of input alphabets Σ, • A transition function δD : Q × Σ → Q, • A start state q0, and • A set of accept states F ⊆ Q. The transition function δD: • Takes two arguments, a state q and an alphabet a. • δD(q,a) = the state the DFA goes to when it is in state q and the alphabet a is received. Mridul Aanjaneya Automata Theory 4/ 30
  • 5. Recap: Graph representation of DFA’s • Nodes correspond to states. • Arcs represent transition function. Arc from state p to state q labeled by all those input symbols that have transitions from p to q. • Incoming arrow from outside denotes start state. • Accept states indicated by double circles. q q1 2 1 0 0 q3 1 0,1 • Accepts all binary strings without two consecutive 1’s. Mridul Aanjaneya Automata Theory 5/ 30
  • 6. Recap: Transition table for DFA’s 0 1 → q∗ 1 q1 q2 q∗ 2 q1 q3 q3 q3 q3 • A row for each state, a column for each alphabet. • Accept states are starred. • Arrow for the start state. q q1 2 1 0 0 q3 1 0,1 Mridul Aanjaneya Automata Theory 6/ 30
  • 7. Recap: Regular languages Definition A DFA M = (Q, Σ, δD, q0, F) accepts w if there exists a sequence of states r0, r1, . . . , rn in Q with three conditions: • r0 = q0 • δD(ri , wi+1) = ri+1 for i = 0, . . . , n − 1, and • rn ∈ F • Condition 1 says that M starts in the start state q0. • Condition 2 says that M follows δD between two states. • Condition 3 says that last state is an accept state. • We say that M recognizes L if L = {w | M accepts w}. Mridul Aanjaneya Automata Theory 7/ 30
  • 8. Regular Languages: Examples Example Let L = {w | w ∈ {0,1}∗ and w, viewed as a binary integer, is divisible by 5.} q q0 1 2 0 1 1 0 1 0 1 0 0 q q q 1 3 4 Mridul Aanjaneya Automata Theory 8/ 30
  • 9. Regular Languages: Examples Example Show that the language of all strings over {0, 1} that do not contain a pair of 1’s that are separated by an odd number of 0’s is regular. 1 a 0 1 1 0,10 0 e o b Mridul Aanjaneya Automata Theory 9/ 30
  • 10. Regular Languages: Examples Example Show that the language of all strings over {0, 1} that contain an even number of 0’s and 1’s is regular. 0 00 0 1 1 1 1 oo ee oe eo Mridul Aanjaneya Automata Theory 10/ 30
  • 11. Nondeterminism • Deterministic finite automata can only be in one state at any point in time. Recall the definition of the transition function δD. • In contrast, nondeterministic finite automata (NFA’s) can be in several states at once! The transition function δN is a one-to-many function. q1 q q q2 3 4 1 0,1 0,1 0,1 • This NFA recognizes strings in {0,1}∗ containing a 1 in the third position from the end. Mridul Aanjaneya Automata Theory 11/ 30
  • 12. Transition table 0 1 → q1 q1 q1,q2 q2 q3 q3 q3 q4 q4 q∗ 4 q4 q4 • q1 is a nondeterministic state with a one-many transition on 1. q1 q q q2 3 4 1 0,1 0,1 0,1 • Intuitively, the NFA always guesses right. Mridul Aanjaneya Automata Theory 12/ 30
  • 13. Nondeterministic Finite Automata Example An NFA that accepts all strings of the form 0k where k is a multiple of 2 or 3. q1 q2 q3 q4 q5 q6 0 0 0 0 0 ε ε Mridul Aanjaneya Automata Theory 13/ 30
  • 14. Nondeterministic Finite Automata Definition An NFA is a 5-tuple (Q, Σ, δN, q0, F) consisting of: • A finite set of states Q, • A set of input alphabets Σ, • A transition function δN : Q × Σε → P(Q), • A start state q0, and • A set of accept states F ⊆ Q. • Here, Σε denotes the set Σ ∪ {ε}. • P(Q) denotes the power set of Q. Mridul Aanjaneya Automata Theory 14/ 30
  • 15. Transition function of an NFA • δN(q,a) is a set of states. • Extend to strings as follows: Basis: δN (q,ε) = q Induction: δN (q,wa) = the union over all states of δN (p,a), where p ∈ δN (q,w). • A string is accepted by an NFA if δN(q0,w) contains at least one state p ⊆ F. • The language of an NFA is the set of strings it accepts. Mridul Aanjaneya Automata Theory 15/ 30
  • 16. Equivalence of DFA’s and NFA’s • Every DFA is also an NFA by definition. There is simply no nondeterminism. • Surprisingly, for every NFA, there is also an equivalent DFA! Two equivalent machines recognize the same language. Nonintuitive, as we’d expect NFA’s to be more powerful. Useful, as describing an NFA is much simpler. • Proof is the subset construction. • The number of states of the DFA can be exponential in the number of states of the NFA. • Thus, NFA’s accept exactly the regular languages. Mridul Aanjaneya Automata Theory 16/ 30
  • 17. Equivalence of DFA’s and NFA’s • DFA for recognizing strings with a 1 in the third last position. q q q q6 4 1 0 1 1 1 00 1 0 0 11 0 0 1 1 0 q q q1 q 2 35 7 8 Mridul Aanjaneya Automata Theory 17/ 30
  • 18. Subset construction • Given an NFA (Q,Σ,δN,q0,F), construct equivalent DFA with: States P(Q) (set of subsets of Q). Inputs Σ. Start state {q0}. Final states = all those with a member of F. Note: • The DFA states have names that are sets of NFA states. • But as a DFA state, an expression like {p,q} must be read as a single symbol. Mridul Aanjaneya Automata Theory 18/ 30
  • 19. Subset construction • Example: We’ll construct the DFA for the following NFA which recognizes strings in {0,1}∗ containing a 1 in the second position from the end. 1 0,1 0,1 a b c Mridul Aanjaneya Automata Theory 19/ 30
  • 20. Subset construction 1 0,1 0,1 a b c 1 a 0 a,b a,b,c a,c 1 00 0 1 1 Mridul Aanjaneya Automata Theory 20/ 30
  • 21. Proof of equivalence: subset construction • Show by induction on length of w that δN(q0,w) = δD({q0},w) • Basis: w = ε. δN(q0,ε) = δD({q0},ε) = {q0}. • Inductive step: Assume IH is true for all strings shorter than w. Let w = xa, then IH is true for x. Let δN (q0,x) = δD({q0},x) = S. Let T = the union over all states p in S of δN (p,a). Then δN (q0,w) = δD({q0},w) = T (by definition). Mridul Aanjaneya Automata Theory 21/ 30
  • 22. NFA’s with ε-transitions • State-to-state transitions on ε input. • These transitions are spontaneous, and do not consider the input string. 0 0 1 1 1 ε A DCB E F 0 ε ε Mridul Aanjaneya Automata Theory 22/ 30
  • 23. Closure of States • CL(q) = set of states that can be reached from state q following only arcs labeled ε. 0 0 1 1 1 ε A DCB E F 0 ε ε • CL(A) = {A}, CL(E) = {B, C, D, E}. • Closure of set of states = union of closure of each state. Mridul Aanjaneya Automata Theory 23/ 30
  • 24. Extended transition function • Basis: δE (q,ε) = CL(q). • Induction: δE (q,xa) is computed as follows: 1 Start with δE (q,x) = S. 2 Take the union of CL(δ(p,a)) for all p in S. • Intuition: δE (q,w) is the set of states you can reach from q following a path labeled w with ε’s in between. Mridul Aanjaneya Automata Theory 24/ 30
  • 25. Example: Extended transition function 0 0 1 1 1 ε A DCB E F 0 ε ε • δE (A,ε) = CL(A) = {A}. • δE (A,0) = CL(E) = {B, C, D, E}. • δE (A,01) = CL(C,D) = {C, D}. Mridul Aanjaneya Automata Theory 25/ 30
  • 26. Example: Extended transition function 0 0 1 1 1 ε A DCB E F 0 ε ε • Language of an ε-NFA is the set of strings w such that δE (q0,w) contains a final state. Mridul Aanjaneya Automata Theory 26/ 30
  • 27. Equivalence of NFA, ε-NFA • Every NFA is an ε-NFA. It just has no ε-transitions. • Converse requires us to take an ε-NFA and construct an NFA that accepts the same language. • This is done by combining ε-transitions with the next transition on a real input. • Start with an ε-NFA (Q,Σ,q0,F,δE ) and construct an ordinary NFA (Q,Σ,q0,F’,δN). Mridul Aanjaneya Automata Theory 27/ 30
  • 28. Equivalence of NFA, ε-NFA • Compute δN(q,a) as follows: Let S = CL(q). δN (q,a) is the union over all p in S of δE (p,a). • F’ = set of states q such that CL(q) contains a state of F. • Intuition: δN incorporates ε-transitions before using a. • Proof of equivalence is by induction on |w| that CL(δN(q0,w)) = δE (q0,w). • Basis: CL(δN(q0,ε)) = CL(q0) = δE (q0,ε). • Inductive step: Assume IH is true for all x shorter than w. Let w = xa. Then CL(δN (q0,xa)) = CL(δE (CL(δN (q0,x)),a)) (by definition). But from IH, CL(δN (q0,x)) = δE (q0,x). Hence, CL(δN (q0,w)) = CL(δE (δE (q0,x),a)) = δE (q0,w). Mridul Aanjaneya Automata Theory 28/ 30
  • 29. Example 0 0 1 1 1 ε A DCB E F 0 ε ε 0 0 1 1 1 A DCB E F 0 11 1 Mridul Aanjaneya Automata Theory 29/ 30
  • 30. Summary • DFA’s, NFA’s and ε-NFA’s all accept exactly the same set of languages: the regular languages. • NFA types are easier to design and may have exponentially fewer states than a DFA. • But only a DFA can be implemented! Mridul Aanjaneya Automata Theory 30/ 30