announcement
play

Announcement Career Fair DFA Minimization Fair: Tuesday, September - PDF document

Announcement Career Fair DFA Minimization Fair: Tuesday, September 26th 10am -- 4pm Gordon Field House Interviews: Wednesday, September 27th http://www.rit.edu/co-op/careers Announcement Homework Were looking for a


  1. Announcement  Career Fair DFA Minimization  Fair: Tuesday, September 26th  10am -- 4pm  Gordon Field House  Interviews: Wednesday, September 27th  http://www.rit.edu/co-op/careers Announcement Homework  We’re looking for a few good programmers!  Discrete Math Quiz returned  ACM Programming Contest  Homework #1 Due today  Teams up to 3 people  Local Tryouts: Sept 22nd at 5pm (ICL4)  Homework #2  Pg 68 -- Exercise 1  Free food will be served  Pg 69 -- Exercise 7  Contact : Paul Tymann (ptt@cs.rit.edu)  Pg 76 -- Exercise 16a,b,d  By Sept 18th (if interested)  Pg 87 -- Exercise 4c,d  http://www.cs.rit.edu/~icpc  Pg 88 -- Exercise 10a,c Before We Start Plan for today  Any questions?  1st half  Minimization of DFAs  2nd half  Regular Expressions  Note: minor change in schedule.  Next time: Kleene Theorem  See Web page for details 1

  2. Languages Regular Languages  Recall.  A language L is a regular language if there is a DFA, M, such that L = L(M).  What is a language?  What is a class of languages?  A language L is a regular language if there is an NFA, N, such that L = L(N). Minimal Finite Automata Minimal Finite Automata  Motivation  Motivation  Consider the question:  Consider the question:  Do two finite automata accept the same  Do two finite automata accept the same language? language?  Answer  To answer, we introduce the Minimal Finite  We can generate the MFA for each DFA, then Automata (MFA) compare the MFAs on a state by state basis.  Given a DFA, create a new DFA with the minimal number of states possible that accepts the same language. Minimal Finite Automata Minimal Finite Automata  Plan  Equivalent States  M = (Q, Σ , q 0 , δ , F)  Equivalent states of a DFA  Two states, p, q ∈ Q are said to be equivalent  Devise an algorithm (based on equivalent (indistinguishable) if states) that creates a minimal DFA from an  For all strings x ∈ Σ *  δ * (p, x) is in an accepting state iff δ * (q, x) is in an DFA accepting state  Some examples  If δ * (p, x) is an accepting state then δ * (q, x) is an accepting state  If δ * (p, x) is not an accepting state then δ * (q, x) is not an accepting state  If two states are not equivalent, they are said to be distinguishable. 2

  3. Minimal Finite Automata Minimal Finite Automata  Equivalent States  In building a MFA, equivalent states can be combined. Minimal Finite Automata Minimal Finite Automata  Example  Example:  States C and G are distinguishable  One is accepting, one is not  States A and G are distinguishable  δ * (A, 01) = C (accepting)  δ * (G, 01) = E (not-accepting) Minimal Finite Automata Minimal Finite Automata  Example:  Example:  States B and H are equivalent  States A and E are equivalent  δ (B, 1) = δ (H, 1) = C  δ (A, 1) = δ (E, 1) = F  δ * (B, 1x) = δ * (H, 1x) for any x  δ * (A, 1x) = δ * (E, 1x) for any x  δ (B, 0) = δ (H, 0) = G  δ (A, 0) = B, δ (E, 0) = H  δ * (B, 0x) = δ * (E, 0x) for any x  B and H are equivalent  So for any x, δ * (B, x) and δ * (H, x) will either  δ * (A, 0x) and δ * (E, 0x) will either both be accepting or both be non-accepting. both be accepting or both not be accepted. 3

  4. Minimal Finite Automata Minimal Finite Automata  Recursive algorithm to find  Recursive algorithm distinguishable states:  Base case:  Consider pairs {p,q}  If p is accepting and q is non-accepting then {p,q} is distinguishable  For each pair we will determine whether p  Induction is distinguishable from q  For some pair {p,q} if  Said another way, for each pair {p,q} we  δ (p,a) = r and δ (q,a) = s and will determine if p is not equivalent to q.  {r,s} is distinguishable then  {p,q} is distinguishable Minimal Finite Automata Minimal Finite Automata  Let’s take a look at this induction step  This algorithm is sometime best  If r = δ (p,a) and s = δ (q,a) are distinguishable, visualized by using a table with each then there is a string x such that δ (r,x) is table cell representing a pair of states. accepting and δ (s,x) is not, or visa-versa A mark in a table cell indicates that the  Then for x, δ (p,ax) is accepting and δ (q,ax) is two states of the pair are not, or visa-versa. distinguishable.  We found a string, ax such that δ (p,ax) is accepting and (q,ax) is not (or visa-versa), thus {p,q} are distinguishable Minimal Finite Automata Minimal Finite Automata  Distinguishable table  Restatement of algorithm  For all pairs {p,q} such that p is accepting and q is B not, mark the equivalent cell in the table. C  Consider each pair {p,q} not yet marked. D  Determine r = δ (p,a) and s = δ (q,a) for each a in Σ . E  If {r,s} is marked, then mark {p,q} F  Repeat until no further cells are marked during an G iteration of the algorithm H A B C D E F G 4

  5. Minimal Finite Automata Minimal Finite Automata  Example  Example δ (A, 0) = B δ (A, 1) = F δ (B, 0) = G δ (B, 1) = C δ (C, 0) = A δ (C, 1) = C δ (D, 0) = C δ (D, 1) = G δ (E, 0) = H δ (E, 1) = F δ (F, 0) = C δ (F, 1) = G δ (G, 0) = G δ (G, 1) = E δ (H, 0) = G δ (H, 1) = C Minimal Finite Automata Minimal Finite Automata  Let’s try on our example  Once our table is complete  All unmarked cells correspond to state x B pairs that are not-distinguishable, I.e. they C x x are equivalent D x x x  Combine equivalent states into one x x x E  Transitions from equivalent states should x x x x F x x x x x x map to equivalent states G x x x x x x H A B C D E F G Minimal Finite Automata Minimal Finite Automata  Combine H and B x E and A are equivalent B C x x D x x x H and B are equivalent x x x E x x x x F D and F are equivalent x x x x x x G x x x x x x H A B C D E F G 5

  6. Minimal Finite Automata Minimal Finite Automata  Combine E and A  Combine D and F Minimal Finite Automata Minimal Finite Automata  What have we done?  Let’s revisit the question:  Defined the notion of equivalent states  Given 2 specifications of regular languages,  Developed a recursive algorithm to do the specifications describe the same determine which states in an FA are language. equivalent  Create a MFA for each language  Combine equivalent states to create FA  Compare the MFAs on a state by state basis. with minimal number of states.  Questions? For the mathematically minded For the mathematically minded  Let’s go back to our Discrete Math  Equivalence relations  Relation  The nice thing about equivalence relations  Defines relationship between objects  It partitions the elements of your set into a  Usually given as an ordered pair, number of distinct and disjoint subsets.  (x, y) where x,y ∈ some Set  Each subset is called an equivalence class  Equivalence relation  Reflective: (a, a)  Symmetric: if (a,b) then (b,a)  Transitive: if (a,b) and (b,c) then (a,c) 6

  7. Minimal Finite Automata For the mathematically minded  MFA and Equivalence Classes  Questions?  State equivalence (indistinguishability) can be shown to be an equivalence relation on a language.  This relation partitions the strings of L into a number of equivalence classes.  Let’s take a break  Each equivalence class corresponds to a state in the MFA.  You’ll show this for homework 7

Recommend


More recommend