Download presentation
Presentation is loading. Please wait.
1
CS 310 – Fall 2006 Pacific University CS310 Converting NFA to DFA Sections:1.2 Page 54 September 13, 2006
2
CS 310 – Fall 2006 Pacific University Quick Review 5 tuple ( Q, Σ, δ, q 0,F) Σ ε = Σ U {ε} δ : Q x Σ ε -> P(Q) (DFA: δ : Q x Σ -> Q) P(Q) is the power set of Q. 0 1, ε 10 q1q2q3 q4 0,1
3
CS 310 – Fall 2006 Pacific University Convert NFA to DFA Two machines are equivalent if they recognize the same language Every NFA has an equivalent DFA (Th 1.39) δ nfa : Q x Σ ε -> P(Q) The DFA will need to represent all subsets in P(Q) (how many?) –let’s assume no ε-transitions initially
4
CS 310 – Fall 2006 Pacific University Convert NFA to DFA NFA is N =(Q, ∑,δ,q 0,F) DFA is M=(Q`, ∑`,δ`,q 0 `,F`) Q` = P(Q) q 0 ` = {q 0 } F` = {R є Q` | R contains an accept state of NFA} δ`: Q`x ∑` -> Q` (P(Q) x ∑ -> Q)
5
CS 310 – Fall 2006 Pacific University Example (without δ) NFA DFA Q`={Ø, ∑`={a,b} Q 0 `= F` = { δ ab q0{q0,q1}{q1} q1Ø{q0} a a,b b q0 q1 Q={q0,q1} ∑={a,b} Q 0 = q0 F = {q0}
6
CS 310 – Fall 2006 Pacific University Let’s define the δ` δ : Q x ∑ -> P(Q) in NFA δ` : Q` x ∑ -> Q` in DFA R є Q`, a є ∑ δ`(R, a) = { q є Q| q є δ(r, a) some r є R } Union of all sets that can be reached from a state in set R using the δ with input a δ`(R, a) = U r є R δ(r, a)
7
CS 310 – Fall 2006 Pacific University Converting NFA to DFA - ε Transitions Define start state and δ` to include all states that can be reached from a given state by 0 or more ε transitions E(R) = { q | q can be reached from R by using 0 or more ε transitions } δ`(R,a) = { q є Q | q є E(δ(r, a)) for some r є R} δ`(R, a) = { q є Q| q є δ(r, a) some r є R }
8
CS 310 – Fall 2006 Pacific University Conversion Example (with δ) NFA DFA Q`={Ø, ∑`={a,b} Q 0 `= F` = { a ε b 1 2 Q={1,2,3} ∑={a,b} Q 0 = 1 F = {1} 3 a,b a
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.