comp3630 6360 theory of computation semester 1 2020 the
play

COMP3630/6360: Theory of Computation Semester 1, 2020 The - PowerPoint PPT Presentation

COMP3630/6360: Theory of Computation Semester 1, 2020 The Australian National University Properties of Regular Expressions 1 / 17 This Lecture Covers Chapter 4 of HMU: Properties of Regular Languages Pumping Lemma for regular languages


  1. COMP3630/6360: Theory of Computation Semester 1, 2020 The Australian National University Properties of Regular Expressions 1 / 17

  2. This Lecture Covers Chapter 4 of HMU: Properties of Regular Languages � Pumping Lemma for regular languages � Some more properties of regular languages � Decision properties of regular languages � Equivalence and minimization of automata Additional Reading: Chapter 4 of HMU.

  3. Pumping Lemma for Regular Languages Pumping Lemma ∠ We know: If a language is given by a regular expression, or a DFA, it is regular. ∠ What can we say if a language is defined by enumeration or by a predicate? ∠ Is L = { w ∈ { 0 , 1 } ∗ : w does not contain 10 } regular? ∠ Is L = { 0 n 1 n : n ≥ 0 } regular? ∠ How do we answer such questions without delving into each ∠ Is there an inherent structure to the strings belonging to a regular language? Lemma 4.1.1 (Pumping Lemma for Regular Languages) Let L be a regular language. There there exists an n ∈ N (depending on L) such that for any string w ∈ L with | w | ≥ n, there exist strings x , y , z such that: (1) w = xyz (2) | xy | ≤ n (3) | y | > 0 (4) xy i z ∈ L for i ∈ N ∪ { 0 } 3 / 17

  4. Pumping Lemma for Regular Languages Proof of the Pumping Lemma ∠ Let DFA A = ( Q , Σ , δ, q 0 , F ) accept L , and let n := | Q | . ∠ The claim is vacuously true if L contains only strings of length n − 1 or less. ∠ Suppose L contains a string w = s 1 · · · s k ∈ L with | w | = k ≥ n . ∠ Then, there must be a sequence of transitions that move A from q 0 to some final state upon reading w . q 0 = q i 0 − → q i 1 − → q i 2 − → · · · − → q i n − → · · · − → q i k ∈ F � �� � n symbols and n + 1 states ∠ SOME state must be visited (at least) twice. Let q i a = q i b for i 0 ≤ i a < i b ≤ i n . y is read z is read x is read � �� � � �� � � �� � s ia + 1 s ib s ib + 1 s in + 1 s ik s ia s in s 1 q 0 = q i 0 − → · · · − → q i a − → · · · − → q i b − → · · · − → q i n − → · · · − → q i k ∈ F ∠ (4) holds since the path for xy i z is derived from the above either by deleting the subpath between q i a and q i b or by repeating it. All such paths end in q i k ∈ F . 4 / 17

  5. Pumping Lemma for Regular Languages Applications of the Pumping Lemma Using the Pumping Lemma, we can show ∠ L = { 0 n 1 n : n ≥ 0 } is not regular. ∠ Suppose it is. Let DFA A = ( Q , Σ , δ, q 0 , F ) accept L , and let ℓ := | Q | ∠ Consider 0 ℓ 1 ℓ . ∠ By the Pumping Lemma, there must exist x , y , z s.t. xyz = 0 ℓ 1 ℓ and | y | > 0 y = 0 j y = 0 j 1 k y = 1 k ( j > 0 ) ( j , k > 0 ) ( k > 0 ) ⇓ ⇓ ⇓ 0 ℓ + j 1 ℓ ∈ L 0 ℓ 1 k 0 j 1 ℓ ∈ L 0 ℓ 1 ℓ + k ∈ L ∠ A contradiction in each case. ∠ L = { w ∈ { 0 , 1 } ∗ : | w | is a prime } is not regular. ∠ L = { ww R : w ∈ { 0 , 1 } ∗ } is not regular. [ w R = w read from right to left]. 5 / 17

  6. Some More Properties Additional Properties of Regular Languages ∠ We already know regular languages are closed under: ∠ union, intersection, concatenation, Kleene- ∗ closure, and difference. ∠ We’ll see three more operations under which regular languages are closed. ∠ Let L R be the language obtained by reversing each string ( ( 01 ) R = 10) Theorem 4.2.1 Let L be regular. Then L R := { w R : w ∈ L } is also regular. Proof of Theorem 4.2.1 ∠ Let langauge L be accepted by DFA A . A A 0 › . . . . . . › ∠ Let A ′ be the DFA obtained by: (a) Reversing each arrow in A ; (b) swapping final and initial states; and (c) introduce ǫ -transitions to make initial state (of A ′ ) unique. ∠ Then L R is accepted by A ′ . 6 / 17

  7. Some More Properties Closure under Homomorphisms ∠ A homomorphism is a map h : Σ 1 → Σ ∗ 2 . h ∠ The map can be extended to strings by defining s 1 · · · s k �→ h ( s 1 ) · · · h ( s k ) . Theorem 4.2.2 Let L be regular. Then h ( L ) := { h ( w ) : w ∈ L } is also regular. Proof of Theorem 4.2.2 ∠ Let E be the regular expression corresponding to L ∠ Let h ( E ) be the expression obtained by replacing symbols s ∈ Σ 1 by h ( s ) . ∠ Then h ( E ) is a regular expression over Σ 2 ∠ By a straightforward induction argument, we can show that L ( h ( E )) = h ( L ( E )) Expressions Languages (language over Σ 1 ) E L ( E ) h h h ( E ) h ( L ( E )) = L ( h ( E )) (language over Σ 2 ) 7 / 17

  8. Some More Properties Closure under Inverse Homomorphisms Theorem 4.2.3 Let L be regular. Then h − 1 ( L ) := { w : h ( w ) ∈ L } is also regular. Proof of Theorem 4.2.3 ∠ Let DFA A = ( Q , Σ 2 , δ, q 0 , F ) accept L ∠ Let DFA B = ( Q , Σ 1 , γ, q 0 , F ) where γ ( q , s ) = ˆ δ ( q , h ( s )) [Depending on the input B mimics none, one, or many transitions of A ] ∠ By definition, ǫ ∈ L ( A ) iff q 0 ∈ F iff ǫ ∈ L ( B ) ∠ By induction, we can show that s 1 · · · s k ∈ L ( B ) ⇔ h ( s 1 ) · · · h ( s k ) ∈ L ( A ) = L ∠ Hence, B accepts h − 1 ( L ) . 8 / 17

  9. Decision Properties of Regular Languages Decision Properties ∠ DFAs and regular expressions are finite representations of regular languages ∠ How do we ascertain if a particular property is satisfied by a language? ∠ Is the language accepted by a DFA is non-empty? ∠ Does the language accepted by a DFA contain a given string w ? ∠ Is the language accepted by a DFA infinite? ∠ Do two given DFAs accept the same language? ∠ Given two DFAs A and B , is L ( A ) ⊆ L ( B ) ? ∠ We will look at the above 5 questions assuming that regular languages are defined by DFAs. (If the language is specified by an expression, we can convert it to a DFA!) 9 / 17

  10. Decision Properties of Regular Languages Decision Properties ∠ Emptiness: If one is given a DFA with n states that accepts L , we can find all the states reachable from the initial state in O ( n 2 ) time. If no final state is reachable, L must be empty. ∠ Membership: If one is given a DFA with n states that accepts L , given string w , we can simply identify the transitions corresponding to w one symbol at a time. If the last state is an accepting state, then w must be in the language. This takes no more than O ( | w | ) time steps. ∠ Infiniteness: We can reduce the problem of infiniteness to finding a cycle in the directed graph (a.k.a. transition diagram) of the DFA. ∠ First, delete any node unreachable from the initial node ( O ( n 2 ) complexity). ∠ Next, delete nodes that cannot reach any final node ( O ( n 3 ) complexity). ∠ Use depth-first search (DFS) to find a cycle in the remaining graph ( O ( n 2 ) complexity). 10 / 17

  11. Decision Properties of Regular Languages Decision Properties (Cont’d) ∠ Equivalence: Given A = ( Q A , Σ , δ A , q A 0 , F A ) and A = ( Q B , Σ , δ B , q B 0 , F B ) , how do we ascertain if L ( A ) = L ( B ) ? L ( A ) ∩ L ( B ) c = ∅ L ( A ) = L ( B ) ⇔ L ( A ) c ∩ L ( B ) = ∅ Run A and B in parallel. ∠ L ( A ) ∩ L ( B ) c : Accept if resp. paths ends in F A and F c B . ∠ L ( A ) c ∩ L ( B ) : Accept if resp. paths ends in F c A and F B . ∠ Use product DFA: Construct C = ( Q C , Σ , δ C , q C 0 , F C ) defined by Q C = Q A × Q B [ Cartesian Product ] q C 0 = ( q A 0 , q B 0 ) δ C (( q , q ′ ) , s ) = ( δ A ( q , s ) , δ B ( q ′ , s )) [ Both DFAs are simulated in parallel ] F C = ( F A × F c B ) ∪ ( F c A × F c ) [ accept strings in exactly one of L ( A ) or L ( B )] L ( A ) = L ( B ) ⇔ L ( C ) = ∅ 11 / 17

  12. Decision Properties of Regular Languages Decision Properties (Cont’d) ∠ Inclusion: Given A = ( Q A , Σ , δ A , q A 0 , F A ) and A = ( Q B , Σ , δ B , q B 0 , F B ) , how do we ascertain if L ( A ) ⊆ L ( B ) ? L ( A ) ∩ L ( B ) c = ∅ L ( A ) ⊆ L ( B ) ⇔ Run A and B in parallel. ∠ L ( A ) ∩ L ( B ) c : Accept if resp. paths ends in F A and F c B . ∠ Use product DFA: Construct C = ( Q C , Σ , δ C , q C 0 , F C ) defined by Q C = Q A × Q B [ Cartesian Product ] q C 0 = ( q A 0 , q B 0 ) δ C (( q , q ′ ) , s ) = ( δ A ( q , s ) , δ B ( q ′ , s )) [ Both DFAs are simulated in parallel ] F C = ( F A × F c B ) [ accept strings in exactly one of L ( A ) or L ( B )] L ( A ) ⊆ L ( B ) ⇔ L ( C ) = ∅ 12 / 17

  13. Minimizing the Number of States DFA State Minmimization ∠ Given two DFAs, we know how to test if they accept the same language. ∠ Is there a unique minimal DFA for a given regular language? ∠ Given a DFA, can we reduce the number of states without altering the language it accepts? 0 0 1 C 1 1 1 A B 0 1 A B 0 0 Clearly, the two DFAs accept the same language and state C is unnecessary. ∠ How do we remove ‘unnecessary’ states without altering the underlying language? 13 / 17

  14. Minimizing the Number of States DFA State Minmimization ∠ State minimization requires a notion of equivalence or distinguishability of states. ∠ Clearly, distinguishability of two states must be based on finality ˆ δ ( p , w ) ∈ F whenever ˆ states p and q are equivalent ⇔ δ ( q , w ) ∈ F for every w ∈ Σ ∗ . or indistinguishable exactly one of ˆ δ ( p , w ) or ˆ states p and q are distinguishable ⇔ δ ( q , w ) is in F for some w ∈ Σ . ∠ Table Filling Algorithm identifies equivalent and distinguishable pairs of states. ∠ Any final state is distinguishable from a non-final state (and vice versa) ∠ If (a) p and q are distinguishable; (b) ˆ δ ( p ′ , s ) = p and (c) ˆ δ ( q ′ , s ) = q , then p ′ and q ′ are also distinguishable s p 0 − ! p s q 0 − ! q 14 / 17

Recommend


More recommend