Download presentation
Presentation is loading. Please wait.
Published byDavid Evans Modified over 9 years ago
1
CSCI 2670 Introduction to Theory of Computing August 26, 2004
2
Agenda Last class –Defined regular languages –Discussed creating DFA’s This class –Finish Section 1.1 Next week –Section 1.2 (pages 47 – 63) Read pages 47 – 54 this weekend
3
Announcement Tutorials will be in room 524 with Junfeng Qu –Monday 8:00 – 9:00 AM –Thursday 4:00 – 5:00 PM
4
Designing finite automata Select states specifically to reflect some important concept Ensure this meaning is relevant to the language you are trying to define Try to get “in the head” of the automaton
5
Example Design a DFA accepting all strings over {0,1,2,3} such that the sum of the symbols in the string is equivalent to 2 modulo 4 or 3 modulo 4
6
Step 1 What states do we need? –One state for each value modulo 4 q 1 represents 1 modulo 4 q 2 represents 2 modulo 4 q 3 represents 3 modulo 4 q 4 represents 0 modulo 4
7
Step 2 Create the state transition table 0123 q 1 (1 mod 4)q1q1 q2q2 q 2 (2 mod 4)q2q2 q3q3 q 3 (3 mod 4)q3q3 q4q4 q 4 (0 mod 4)q4q4 q1q1
8
Step 3 What do we know? –Q, , and So we still need q 0 and F –q 0 = q 4 –F = {q 2, q 3 }
9
Draw DFA q1q1 q3q3 q4q4 q2q2 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3
10
Combining regular languages We can create a regular language from other regular languages A and B using specific allowable operations called regular operations –Union: A B –Concatenation: A B –Kleene star: A *
11
Union is a regular operation Theorem: The class of regular languages is closed under the union operation Proof approach: Assume A 1 and A 2 are both regular languages with A 1 =L(M 1 ) and A 2 =L(M 2 ) and create a DFA M such that L(M) = A 1 A 2 Method: Proof by construction
12
Idea of construction Each state of the new DFA represents both where the same word would be if it was being processed in M 1 and where it would be if it were processed in M 2 –Keeping track of the progress of the string in both DFA’s simultaneously
13
Example q1q1 q2q2 q3q3 00 0,1 1 1 M1M1 q1,q1’q1,q1’q2,q1’q2,q1’ 0 q3,q2’q3,q2’ 1 1 q1’q1’q2’q2’q3’q3’ 10 0 0 M2M2 1 1 etc. q3,q1’q3,q1’0 q1,q2’q1,q2’ 1 Maximum number of states? 9 product of number of states in M 1 and in M 2
14
Formally defining M M = (Q, , ,q 0,F) –Q = Q 1 × Q 2 Q 1 and Q 2 are the states in machines M 1 and M 2, respectively – = 1 2 1 and 2 are the alphabets for machines M 1 and M 2, respectively – ((r 1,r 2 ),a) = ( 1 (r 1,a), 2 (r 2,a)) 1 and 2 are the state transition functions for machines M 1 and M 2, respectively
15
Formally defining M M = (Q, , ,q 0,F) –q 0 = (r 1, r 2 ) r 1 and r 2 are the starting states in machines M 1 and M 2, respectively –F = {(r 1,r 2 ) | r 1 F 1 or r 2 F 2 } F 1 and F 2 are the accepting states for machines M 1 and M 2, respectively
16
Concatenation is a regular operation Theorem: The class of regular languages is closed under the concatenation operation Proof approach: Assume A 1 and A 2 are both regular languages with A 1 =L(M 1 ) and A 2 =L(M 2 ) and create a DFA M such that L(M) = A 1 A 2 Method: Proof by construction
17
Idea of construction Any accepting state in M 1 has a copy of M 2 “tacked on” –Problem: if we tack a copy of M 2 on at each accepting states, we lose the deterministic property
18
Example q1q1 q2q2 q3q3 00 0,1 1 1 M1M1 1 q1’q1’q2’q2’q3’q3’ 10 0 0 M2M2 1 q1q1 q2q2 q3q3 00 1 1 1 q1’q1’q2’q2’q3’q3’ 10 0 0 1 ε Can jump to q 1 ’ non- deterministically
19
Next week Non-determinism
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.