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

Module 3 - NFA To DFA

NFA to DFA

Uploaded by

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

Module 3 - NFA To DFA

NFA to DFA

Uploaded by

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

NFA to DFA

Lecturer: Jay A. Abaleta


Introduction
to NFA and
DFA
Each state has exactly one
transition for every input
symbol.

Deterministic
Finite No ambiguity in state
Automaton transitions.

(DFA)
Easier to implement in
hardware/software due to
deterministic behavior.
A state can have multiple
transitions for the same input
symbol or no transition.
Nondetermini
stic Finite Epsilon (ε) transitions are allowed,
meaning a transition can occur
Automaton without reading an input symbol.
(NFA)
More flexible but harder to
implement directly.
Why we Convert
NFA to DFA?
 DFA is more practical for implementation,
but NFAs are often easier to design and
conceptualize.
 For practical applications, any NFA can be
converted into an equivalent DFA that
accepts the same language.
 Although DFAs may have more states than
NFAs, they provide clarity and
determinism in processing input.
Formal Definition of DFA
• A DFA is a collection of 5-tuples same as we described in the
definition of FA.
Where:
Q: finite set of states
∑: finite set of the input symbol
q0: initial state
F: final state
δ: Transition function
δ: Q x ∑→Q
Formal definition of NFA

• where:
Q = set of states
 = set of input alphabets
 = transition function
q0 = initial state
F = set of final state
δ: (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
NFA with back tracking
• L = {Set of all strings over(0,1) which every ‘1’ is (eventually) followed by an ‘0’. }

Examples of strings accepted by the automaton:


"10" – There is one '1' and it is immediately followed by an '0', so it is accepted.
"1010" – There are two '1's, and each '1' is followed by an '0', so it is accepted.
"00" – There is no '1', so it is also accepted.

Examples of strings not accepted:


"1" – There is one '1' but it is not followed by an '0', so it is not accepted.
"11" – There are two '1's but neither is followed by an '0', so it is not accepted.
"011" – The last '1' is not followed by an '0', so it is not accepted.
Transition Diagram and Test Input
Steps for converting NFA to DFA
• Step 1: Initially Q' = ϕ
• Step 2: Add q0 of NFA to Q'. Then find the transitions from this start
state.
• Step 3: In Q', find the possible set of states for each input symbol. If
this set of states is not in Q', then add it to Q'.
• Step 4: In DFA, the final state will be all the states which contain
F(final states of NFA)
Convert NFA to DFA
• Example#1:
L = {Set of all strings over(0,1) that starts with 0}
∑ = {0,1}
NFA: Transition Diagram Transition Table:
Convert NFA to DFA
• Transition Diagram Transition Table:
Example #2: NFA
L = {Set of all strings over(0,1) that ends with 1}
∑ = {0,1}
Transition Diagram: Transition Table:
Convert NFA to DFA
Transition Diagram: Transition Table:

Method of Construction: Subset Construction Method


In the NFA to DFA conversion process, the union operation plays a crucial role,
especially when dealing with transitions between states. The union operation helps
combine the results of multiple state transitions into one set.
• During the conversion from an NFA
Union to a DFA, each DFA state
Operation corresponds to a set of NFA states.
When processing an input symbol,
in NFA to we need to find all the possible
DFA NFA states the automaton can
transition to from any of the NFA
Conversio states in the current DFA state.
n
• If the current DFA state is {q0, q1}, and
we process input ‘0', we need to
Example: compute the set of NFA states
reachable from both q0 and q1 on
• Let's take an NFA with the input ‘0'.
following states and • From q0 on input ‘0': {q1, q2}
transitions:
• From q1 on input ‘0': {q2}
• States: {q0, q1, q2}
• Input symbols: {0, 1} • We use the union operation to
• Transitions: combine these results:
• δ(q0, 0) = {q1, q2} {q1,q2}∪{q2}={q1,q2}
• δ(q1, 0) = {q2}
• δ(q2, 1) = {q0} • Formal Definition of Union Operation:
• For two sets A and B, the union of A and B, denoted as
A∪B, is the set of elements that are in A, in B, or in both.
Mathematically:
• A ∪ B = {x∣x ∈ A or x ∈ B}
Example#3: NFA to DFA Formal
Definition
L = {Set of all strings over(0,1) where the string starts with 0 or 1
has at least one ’1’ or consists solely of ’0’s}
M = [{q0,q1,q2},(0,1), δ,q0,{q2}]
Transition Diagram:(NFA) Transition Table:
Convert NFA to DFA
• Explanation:
This automaton accepts:
Strings of '0's of any length (0*).
Strings that have one or more '1's (0*1+0*).
The set of the language accepted by this NFA consists of:
1. Strings of only '0's: Any sequence of '0's (including the empty string
if considered).
2. Strings that contain at least one '1': Can have any number of '0's
before or after '1'.
Strings of '0's of any length (0*).
The strings consisting solely of '0's of any length (0)* mean any number of
consecutive '0's. In the context of this automaton, it accepts strings made up
only of '0's, regardless of their length, and may contain no '1'.
• Explanation: The regular expression 0* means any number of '0', including
the possibility of having no '0' (i.e., the string is empty).
Examples of strings made up only of '0's of any length:
"0" - one '0'
"00" - two '0's
"000" - three '0's
"0000" - four '0's
... and so on.
Strings that have one or more '1's
(0*1+0*)
Strings with one or more '1's (01+0) mean that the string can contain any number of '0's at the
beginning (0*), followed by one or more '1's (1+), and can again end with any number of '0's (0*).
• Explanation:
 0*: Any number of '0's at the beginning, could be none or many '0's.
 1+: One or more '1's. This is the part of the string that must have at least one '1'.
 0*: Any number of '0's after the '1', could be none or many '0's.
• Examples:
 "1" - Just one '1', no '0' at the start or end.
 "01" - One '0' at the beginning, followed by one '1'.
 "001" - Two '0's at the beginning, followed by one '1'.
 "10" - One '1' followed by one '0'.
 "1100" - Two '1's followed by two '0's.
 "000111000" - Three '0's at the beginning, three '1's, and three '0's at the end.

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