Lecture 4: the Product Construction: Closure Un- Der Intersection and Union

Lecture 4: the Product Construction: Closure Un- Der Intersection and Union

£ CS 373: Theory of Computation £ Madhusudan Parthasarathy Lecture 4: The product construction: Closure un- der intersection and union 28 January 2010 This lecture nishes section 1.1 of Sipser and also covers the start of 1.3. 1 Product Construction 1.1 Product Construction: Example Let Σ = fa; bg and L is the set of strings in Σ∗ that have the form a∗b∗ and have even ∗ ∗ ∗ length. L is the intersection of two regular languages L1 = a b and L2 = (ΣΣ) . We can show they are regular by exhibiting DFAs that recognize them. r0 a b a,b a,b a,b b a q0 q1 drain r1 L1 L2 We can run these two DFAs together, by creating states that remember the states of both machines. (q0,r0) (q1,r0) (drain, r0) b a a a a b b b a,b a,b (q0,r1) (q1,r1) (drain, r1) Notice that the nal states of the new DFA are the states (q; r) where q is nal in the rst DFA and r is nal in the second DFA. To recognize the union of the two languages, rather than the intersection, we mark all the states (q; r) such that either q or r are accepting states in the their respective DFAs. State of a DFA after reading a word w. In the following, given a DFA M = (Q; Σ; δ; q0;F ), we will be interested in the state the DFA M is in, after reading the a string w. Let us denote 1 by δ∗ : Q × Σ∗ ! Q the function such that δ∗(q; w) is the state the DFA will land in, if started from state q and fed the word w. Formally, we dene δ∗ : Q × Σ∗ ! Q using the following inductive denition: • δ∗(q; ) = q for every q 2 Q, • δ∗(q; wa) = δ(δ∗(q; w); a) for each q 2 Q; w 2 Σ∗; a 2 Σ. ∗ ∗ Note that by the above denition of δ , we have that w 2 L(M) i δ (q0; w) 2 F . 2 Product Construction: Formal construction We are given two DFAs and 0 0 0 0 0 both working over M = (Q; Σ; δ; q0;F ) M = (Q ; Σ; δ ; q0;F ) the same alphabet Σ.A product automaton of M and M 0 is an automaton 0 N = Q; Σ; δN ; (q0; q0) ;FN ; 0 0 0 where Q = Q × Q , and δN : Q × Σ !Q. Also, for any q 2 Q, q 2 Q and c 2 Σ, we require 0 0 0 δN ((q; q ) ; c ) = δ(q; c); δ (q ; c) : (1) | {z } state of N The set FN ⊆ Q of accepting states is free to be whatever we need it to be, depending on what we want N to recognize. For example, if we would like N to accept the intersection 0 0 L(M) \ L(M ) then we will set FN = F × F . If we want N to recognize the union language 0 0 0 L(M) [ L(M ) then FN =(F × Q ) [[(Q × F ). Lemma 2.1 For any input word w 2 Σ∗, the product automata N of the DFAs M = and 0 0 0 0 0 , is in state 0 after reading , if and only (Q; Σ; δ; q0;F ) M = (Q ; Σ; δ ; q0;F ) (q; q ) w if (i) M in the state q after reading w, and (ii) M 0 is in the state q0 after reading w. In other words, ∗ 0 ∗ 0∗ 0 . δN ((q0; q0); w) = (δ (q0; w); δ (q0; w)) Proof: The proof is by induction on the length of the word w. If is the empty word, then is initially in the state 0 by construction, where w = N (q0; q0) (resp. 0 ) is the initial state of (resp. 0). As such, the claim holds in this case. q0 q0 M M Formally, ∗ 0 0 ∗ 0∗ 0 (by denition of ∗ , ∗ and 0∗). δN ((q0; q0); ) = (q0; q0) = (δ (q0; ); δ (q0; )) δN δ δ ∗ Otherwise, jwj > 0, and let us hence assume w = w1a (w1 2 Σ ; a 2 Σ), and assume the induction hypothesis that the claim is true for all input words of length strictly smaller than jwj (in particular jw1j). Let 0 be the state that is in after reading the string . By the induction (qk−1; qk−1) N w1 hypothesis, as , we know that is in the state after reading , and 0 is jw1j = k − 1 M qk−1 wb M in the state 0 after reading . qk−1 wb ∗ Let qk = δ(qk−1; a) = δ(δ (q0; w1) ; a) = δ(q0; w) and 0 0 0 0 0 0 0 0 qk = δ (qk−1; a) = δ (δ (q0; w1) ; a) = δ (q0; w) : 2 As such, by denition, (resp. 0) would in the state (resp. 0 ) after reading . M M qk qk w Also, by the denition of its transition function, after reading w the DFA N would be in the state 0 ∗ 0 0 δN ((q0; q0); w) = δN (δN ((q0; q0); w1) ; a) = δN (qk−1; qk−1); a 0 0 = δ(qk−1; a); δ(qk−1; a) =(qk; qk) ; (see Eq. (1)). This establishes the claim. Lemma 2.2 Let and 0 0 0 0 0 be two given DFAs. Let M = (Q; Σ; δ; q0;F ) M = (Q ; Σ; δ ; q0;F ) N be a product automaton with set of accepting states is F × F 0. Then L(N) = L(M) \ L(M 0). Proof: i ∗ 0 0 w 2 L(N) δN ((q0; q0); w) 2 F × F i ∗ 0∗ 0 0 (by Lemma 2.1) (δ (q0; w); δ (q0; w)) 2 F × F i ∗ and 0∗ 0 0 δ (q0; w) 2 F δ (q0; w) 2 F i w 2 L(M) and w 2 L(M 0). More verbosely: If 0 , then let ∗ and 0 0∗ 0 0. By w 2 L(M) \ L(M ) qw = δ (q0; w) 2 F qw = δ (q0; w) 2 F Lemma 2.1, this implies that ∗ 0 0 0. Namely, accepts the δN ((q0; q0); w) = (qw; qw) 2 F × F N word w, implying that w 2 L(N), and as such L(M) \ L(M 0) ⊆ L(N). Similarly, if , then 0 ∗ 0 must be an accepting state of w 2 L(N) (pw; pw) = δN ((q0; q0); w) . But the set of accepting states of is 0. That is 0 0, implying N N F × F (pw; pw) 2 F × F that and 0 0. Now, by Lemma 2.1, we know that ∗ and pw 2 F pw 2 F δ (q0; w) = pw 2 F 0∗ 0 0 0. Thus, and 0 both accept , which implies that and δ (q0; w) = pw 2 F M M w w 2 L(M) w 2 L(M 0). Namely, w 2 L(M) \ L(M 0), implying that L(N) ⊆ L(M) \ L(M 0). Putting the above together proves the lemma. 3.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    3 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us