190 likes | 213 Views
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.
E N D
CSCI 2670Introduction 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 • q1 represents 1 modulo 4 • q2 represents 2 modulo 4 • q3 represents 3 modulo 4 • q4 represents 0 modulo 4
Step 2 • Create the state transition table
Step 3 • What do we know? • Q, , and • So we still need q0 and F • q0 = q4 • F = {q2, q3}
3 1 0 q1 q2 0 2 2 3 1 1 3 2 2 q4 q3 0 0 1 3 Draw DFA
Combining regular languages • We can create a regular language from other regular languages A and B using specific allowable operations called regular operations • Union: AB • Concatenation: AB • Kleene star: A*
Union is a regular operation Theorem: The class of regular languages is closed under the union operation Proof approach: Assume A1 and A2 are both regular languages with A1=L(M1) and A2=L(M2) and create a DFA M such that L(M) = A1A2 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 M1and where it would be if it were processed in M2 • Keeping track of the progress of the string in both DFA’s simultaneously
0,1 0 0 1 q1’ q2’ q3’ q1 q2 q3 1 0 0 0 1 1 1 M1 M2 0 q3,q1’ q2,q1’ 0 1 q1,q2’ q1,q1’ 1 1 q3,q2’ Example Maximum number of states? 9 product of number of states in M1 and in M2 etc.
Formally defining M • M = (Q,,,q0,F) • Q = Q1 × Q2 • Q1 and Q2 are the states in machines M1and M2, respectively • = 1 2 • 1 and 2 are the alphabets for machines M1and M2, respectively • ((r1,r2),a) = (1(r1,a), 2(r2,a)) • 1 and 2 are the state transition functions for machines M1and M2, respectively
Formally defining M • M = (Q,,,q0,F) • q0= (r1, r2) • r1 and r2 are the starting states in machines M1and M2, respectively • F = {(r1,r2) | r1F1orr2F2} • F1 and F2 are the accepting states for machines M1and M2, respectively
Concatenation is a regular operation Theorem: The class of regular languages is closed under the concatenation operation Proof approach: Assume A1 and A2 are both regular languages with A1=L(M1) and A2=L(M2) and create a DFA M such that L(M) = A1A2 Method: Proof by construction
Idea of construction • Any accepting state in M1 has a copy of M2 “tacked on” • Problem: if we tack a copy of M2 on at each accepting states, we lose the deterministic property
0,1 0 0 0 0 1 q1’ q1’ q2’ q2’ q3’ q3’ q1 q2 q3 1 1 0 0 0 0 1 1 1 1 1 M1 M2 0,1 1 q1 q2 q3 0 0 ε 1 Example Can jump to q1’ non-deterministically
Next week • Non-determinism Have a great weekend!