Download presentation
Presentation is loading. Please wait.
Published byLucinda Curtis Modified over 9 years ago
1
Lecture 4UofH - COSC 3340 - Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 4
2
UofH - COSC 3340 - Dr. Verma 2 Define *(q, w) as a set of states: p ε *(q, w) if there is a directed path from q to p labeled w – Example: consider NFA of Lecture 3 *(q 0, 1) = ? – Ans: {q 0, q 1 } *(q 0, 11) = ? – Ans: {q 0, q 1, q 2 } Formal definition of NFA acceptance
3
Lecture 4UofH - COSC 3340 - Dr. Verma 3 NFA acceptance (contd.) w is accepted by NFA M iff *(q 0, w) F is nonempty. L(M) = {w in * | w is accepted by M}.
4
Lecture 4UofH - COSC 3340 - Dr. Verma 4 NFA vs. DFA Is NFA more powerful than DFA? – Ans: No. Theorem: – For every NFA M there is an equivalent DFA M' Proof Idea: – NFA is in a set of states at any point during reading a string. – DFA will use a lot of states to keep track of this. Important Assumption: – No transition labeled by epsilon. (Will get rid of this assumption later.)
5
Lecture 4UofH - COSC 3340 - Dr. Verma 5 Equivalent DFA construction. NFA M = (Q, , , s, F) DFA M' = (Q', , , s', F') where: – Q' = 2 Q – s' = {s} – F' = {P | P F is nonempty} – ({p 1, p 2, p m }, ) = *(p 1, ) *(p 2, ) ... *(p m, ) i.e. find all the states that can be reached on from all the NFA states in a DFA state.
6
Lecture 4UofH - COSC 3340 - Dr. Verma 6 Example: Equivalent DFA construction NFA
7
Lecture 4UofH - COSC 3340 - Dr. Verma 7 Equivalent DFA construction (contd.)
8
Lecture 4UofH - COSC 3340 - Dr. Verma 8 How to handle epsilon transitions? Define e-closure of state q as *(q, ). – notation: e-closure(q). Example:
9
Lecture 4UofH - COSC 3340 - Dr. Verma 9 Handling epsilon transitions (contd.) Extend e-closure to sets of states by: – e-closure({s 1,..., s m }) = e-closure(s 1 ) ... e-closure(s m ) Now let s' = e-closure({s}). and, ({p 1,..., p m }, ) = e-closure( *(p 1, )) ... e-closure( *(p m, )) to complete construction of DFA.
10
Lecture 4UofH - COSC 3340 - Dr. Verma 10 Example: Handling epsilon transitions.
11
Lecture 4UofH - COSC 3340 - Dr. Verma 11 DFA = ?
12
Lecture 4UofH - COSC 3340 - Dr. Verma 12 Language Operations 1. Concatenation. Notation: L L' or just LL' – L L' = {uv | u in L, v in L'}. 2. Kleene Star. Notation: L* – L* = { w in * | w = w 1...w k for some k >= 0 and each w i in L}. Examples : if L = {a (2n+1) | n >= 0}. L' = {b (2n) | n > = 0}. LL' = ? – Ans: LL' = { a (2n+1) b (2m) | n, m > = 0} L* = ? – Ans: {a n | n >= 0} U,., * are called regular operations.
13
Lecture 4UofH - COSC 3340 - Dr. Verma 13 Closure properties of regular languages. Previously we saw closure under and . New: Regular languages are closed under – Concatenation – Kleene star – Complement.
14
Lecture 4UofH - COSC 3340 - Dr. Verma 14 Examples L = {w in {a,b}* | w has even a’s }
15
Lecture 4UofH - COSC 3340 - Dr. Verma 15 Examples L' = {w in {a,b}* | w has at least one b}
16
Lecture 4UofH - COSC 3340 - Dr. Verma 16 Construction for L L' L’’ = (K, , ,s,F) K = K 1 K 2 s = s 1 F = F 2 = 1 2 F 1 X {e} X {s 2 }
17
Lecture 4UofH - COSC 3340 - Dr. Verma 17 L * and L' * L* L’* M = (K, , , s, F) K = {s} K 1 F = {s} F 1 = 1 F 1 X {e} X {s 1 } {(s, e, s 1 )} Given M 1 = (K 1, , 1, s 1, F 1 )
18
Lecture 4UofH - COSC 3340 - Dr. Verma 18 Complement of L and L' Complement of L Complement of L’
19
Lecture 4UofH - COSC 3340 - Dr. Verma 19 General Construction for Complement DFA M = (K, , δ, s, F) K = K 1 s = s 1 F = K - F 1 δ = δ 1 L(M) = Complement of L(M 1 ) DFA M 1 = (K 1, , δ 1, s 1, F 1 ) Exercise: Will this construction work for NFAs? Explain your answer.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.