Download presentation
Presentation is loading. Please wait.
Published byAbigail Harris Modified over 9 years ago
1
Lecture 3UofH - COSC 3340 - Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 3
2
UofH - COSC 3340 - Dr. Verma 2 Closure properties of Regular Languages Regular languages are closed under: – Union Notation: – Intersection Notation: L 1 L 2 is regular if L 1 and L 2 are regular. L 1 L 2 is regular if L 1 and L 2 are regular.
3
Lecture 3UofH - COSC 3340 - Dr. Verma 3 Examples Let = {a,b}. Let L 1 = { w in * | w has even number of a's}. – Is L 1 regular? L 2 = { w in * | w has odd number of b's}. – Is L 2 regular? L 1 L 2 = ? – Ans: {w in * | w has even a's or odd b's}. L 1 L 2 = ? – Ans: {w in * | w has even a's and odd b's}. By closure properties, both these are regular.
4
Lecture 3UofH - COSC 3340 - Dr. Verma 4 DFA of L 1 = {w in {a,b}* | w has even number of a's}.
5
Lecture 3UofH - COSC 3340 - Dr. Verma 5 DFA of L 2 = { w in {a,b}* | w has odd number of b's}.
6
Lecture 3UofH - COSC 3340 - Dr. Verma 6 DFA of L 1 L 2 = {w in {a,b}* | w has even a's or odd b's}.
7
Lecture 3UofH - COSC 3340 - Dr. Verma 7 DFA of L 1 L 2 = {w in {a,b}* | w has even a's and odd b's}.
8
Lecture 3UofH - COSC 3340 - Dr. Verma 8 DFA of L 1 L 2 = {w in {a,b}* | w has even a's or odd b's}. aba
9
Lecture 3UofH - COSC 3340 - Dr. Verma 9 DFA of L 1 L 2 = {w in {a,b}* | w has even a's or odd b's}. aba
10
Lecture 3UofH - COSC 3340 - Dr. Verma 10 DFA of L 1 L 2 = {w in {a,b}* | w has even a's or odd b's}. abaaba
11
Lecture 3UofH - COSC 3340 - Dr. Verma 11 DFA of L 1 L 2 = {w in {a,b}* | w has even a's or odd b's}. aba
12
Lecture 3UofH - COSC 3340 - Dr. Verma 12 DFA of L 1 L 2 = {w in {a,b}* | w has even a's and odd b's}. aba
13
Lecture 3UofH - COSC 3340 - Dr. Verma 13 DFA of L 1 L 2 = {w in {a,b}* | w has even a's and odd b's}. aba
14
Lecture 3UofH - COSC 3340 - Dr. Verma 14 DFA of L 1 L 2 = {w in {a,b}* | w has even a's and odd b's}. abaaba
15
Lecture 3UofH - COSC 3340 - Dr. Verma 15 DFA of L 1 L 2 = {w in {a,b}* | w has even a's and odd b's}. aba
16
Lecture 3UofH - COSC 3340 - Dr. Verma 16 DFA of A = {w | w contains at least one 1 and an even number of 0s follow the last 1}
17
Lecture 3UofH - COSC 3340 - Dr. Verma 17 General Construction for and Idea: Simulate two DFA's in parallel. Let M 1 = (Q 1, , 1, s 1, F 1 ) and M 2 = (Q 2, , 2, s 2, F 2 ) M = (Q, , , s, F) where: Q = Q 1 X Q 2 s = (s 1, s 2 ) ((q 1, q 2 ), ) = ( 1 (q 1, ), 2 (q 2, )) For Union, F = ? – Ans: (Q 1 X F 2 ) U (F 1 X Q 2 ) For Intersection, F = ? – Ans: F 1 X F 2
18
Lecture 3UofH - COSC 3340 - Dr. Verma 18 Nondeterministic Finite Automaton (NFA) Generalization of DFA. Allows: – 0 or more next states for the same (q, ). Guessing – Transitions labeled by the empty string. Changing state without reading input Motivation: Flexibility. – Easier to prove many closure properties.
19
Lecture 3UofH - COSC 3340 - Dr. Verma 19 How does an NFA work? w is accepted by an NFA provided there is a sequence of guesses that leads to a final state. Language accepted by NFA is the set of all strings accepted by it.
20
Lecture 3UofH - COSC 3340 - Dr. Verma 20 Example: {w in {0,1}* | the second last symbol of w is a 1}
21
Lecture 3UofH - COSC 3340 - Dr. Verma 21 NFA A = {w in {0,1}* | the second last symbol of w is a 1} 110
22
Lecture 3UofH - COSC 3340 - Dr. Verma 22 NFA A = {w in {0,1}* | the second last symbol of w is a 1} 110
23
Lecture 3UofH - COSC 3340 - Dr. Verma 23 NFA A = {w in {0,1}* | the second last symbol of w is a 1} 110110
24
Lecture 3UofH - COSC 3340 - Dr. Verma 24 NFA A = {w in {0,1}* | the second last symbol of w is a 1} 110
25
Lecture 3UofH - COSC 3340 - Dr. Verma 25 Formal definition of NFA Notation: e = U {e}. NFA M = (Q, , , s, F) where: – Q - finite set of states – - input alphabet – s - initial state – F Q - set of final states – is a subset of Q X e X Q. If (p, u, q) in , then NFA in state p can read u and go to q.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.