CSCI 2670 Introduction to Theory of Computing August 26, 2004
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
Announcement Tutorials will be in room 524 with Junfeng Qu –Monday 8:00 – 9:00 AM –Thursday 4:00 – 5:00 PM
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
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
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
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
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 }
Draw DFA q1q1 q3q3 q4q4 q2q
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 *
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
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
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’ 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
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
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
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
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
Example q1q1 q2q2 q3q3 00 0,1 1 1 M1M1 1 q1’q1’q2’q2’q3’q3’ M2M2 1 q1q1 q2q2 q3q q1’q1’q2’q2’q3’q3’ ε Can jump to q 1 ’ non- deterministically
Next week Non-determinism