1 / 23

CSCI 2670 Introduction to Theory of Computing

CSCI 2670 Introduction to Theory of Computing. September 5, 2007. Agenda. Last class Introduced deterministic finite automata Formally defined DFA’s Informally described DFA’s This class Formal definition of computation Definition of a regular language Designing finite automata.

rtammie
Télécharger la présentation

CSCI 2670 Introduction to Theory of Computing

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSCI 2670Introduction to Theory of Computing September 5, 2007

  2. Agenda • Last class • Introduced deterministic finite automata • Formally defined DFA’s • Informally described DFA’s • This class • Formal definition of computation • Definition of a regular language • Designing finite automata

  3. Formalizing computation • Let M = (Q,,,q0,F) be a finite automaton and let w = w1w2…wn be any string over . Macceptsw if there is a sequence of states r0, r1, …, rn, of Q such that • r0 = q0 • start in the start state • ri=(ri-1, wi) • the transition function determines each step • rn F • the last state is one of the final states

  4. Regular languages • A deterministic finite automaton Mrecognizes the language A if A = { w | M accepts w } • Alternatively, we say the language of M is A L(M) = { w | M accepts w } • Any language recognized by a deterministic finite automaton is called a regular language

  5. Designing finite automata • Select states specifically to reflect some important concept • even number of 0’s • odd number of occurrences of the string 010 • Ensure this meaning is relevant to the language you are trying to define • Try to get “in the head” of the automaton

  6. 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

  7. 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

  8. Step 2 • Create the state transition table

  9. Step 3 • What elements of the 5-tuple do we know? • Q, , and  • So we still need q0 and F • q0 = q4 • F = {q2, q3}

  10. 3 1 0 q1 q2 0 2 2 3 1 1 3 2 2 q4 q3 0 0 1 3 Draw DFA

  11. 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*

  12. 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) = A1A2 Method: Proof by construction

  13. 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

  14. 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.

  15. 0,1 1 q1 q2 q3 0 0 1 M1 0 0 0 q2,q1’ q1,q1’ q3,q1’ q2,q2’ q3,q2’ q1,q2’ Example 0 0 q1’ q2’ q3’ 1 0 1 1 M2 0 0 0 1 1 1 1 1 1

  16. 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

  17. 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) | r1F1orr2F2} • F1 and F2 are the accepting states for machines M1and M2, respectively

  18. 0 q1’ q2’ 1 0,1 M2 Another Example 1 1 1 • Q = • {(q1,q1’), (q1,q2’), (q2,q1’), (q2,q2’), (q3,q1’), (q3,q2’)} • Σ = {0,1} • q0 = • (q1,q1’) • F = • {(q1,q1’), (q1,q2’), (q2,q2’), (q3,q2’)} q1 q2 q3 0 0 0 M1

  19. 0 q1’ q2’ 1 0,1 M2 Another Example 1 1 1 q1 q2 q3 0 0 0 M1 (q2,) (q2,q1’) (q1,) (q1,q2’) (q2,) (q2,q2’) (q1,q2’) (q1,) (q3,q1’) (q3,) (q2,) (q2,q2’) (q3,q2’) (q3,) (q2,q2’) (q2,) (q1,) (q1,q1’) (q3,) (q3,q2’) (q1,) (q1,q2’) (q3,) (q3,q2’)

  20. Another example 0 0 q1’q1’ 0 q2’q1’ q3’q1’ 1 1 1 1 1 0 0 q3’q2’ q1’q2’ q2’q2’ 1 1 0 0

  21. 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) = A1A2 Method: Proof by construction

  22. 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

  23. 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

More Related