Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.

Similar presentations


Presentation on theme: "CSCI 3130: Formal languages and automata theory Tutorial 3 Chin."— Presentation transcript:

1 CSCI 3130: Formal languages and automata theory Tutorial 3 Chin

2 Reminder Homework 2 is due on next Monday.

3 Homework 1 Problem 1 (c) Should state clearly what each state represents (d) Some of you accept the strings 02 & 20 in the DFA Some of you did not explain how the DFA works

4 Homework 1 Problem 2 Be careful of  -transitions Many people (including myself!) missed the edge from q 1 to q 0 on input ‘0’ q 1 -  -> q 0 -0-> q 1 -  -> q 0 A few of you did not draw a transition table or a NFA without  -transitions, but the converted DFA is wrong. Do draw them to get partial credits.

5 Homework 1 Problem 3 Most of you need to explain more clearly. Many of you just showed strings in L 1 are also in L 2, then conclude they are equivalent. What if some strings in L 2 are not in L 1 ? Do NOT do the following… L 1 and L 2 are the equivalent because L 2 clearly represents the language of L 1.

6 Closure Properties 1. If L is regular, is L’ = {wx: w ∈ L; x ∈  *}also regular? 2. If L 1 is not regular and L 2 is not regular, is L 1 ∩L 2 also not regular?

7 Closure Properties 1. Yes. Let R be the regular expression of L. Then R  * is also a regular expression. Hence regular. 2. No. L 1 = 0 n 1 n, L 2 = 1 n 0 n. Then L 1 and L 2 are both non-regular. But L 1 ∩L 2 = { , which is regular 

8 Non regularity For every n, choose one z of length ≥ n in L, such that for every way of writing z = u v w where  |uv| ≤ n and  |v| ≥ 1, the string u v i w is not in L for some i ≥ 0. 1. z depends on n 2. u can be empty string 3. i can be 0 (very useful) 4.You only have to choose one z

9 Pumping lemma What’s wrong in the proof? L = {11111} is not regular. Proof: Suppose n = 2 and z = 11111, which is in L. Write z = uvw, where |uv| ≤ 2 and |v|≥ 1. Then uv = 1 or uv = 11. If uv = 1, then uv 2 w = 11 1111 is not in L. If uv = 11 and u = 1, then uv 2 w = 1 11 111 is not in L. If uv = 11 and u = , then uv 2 w = 1111 1111 is not in L. Therefore, L is not regular.

10 Pumping lemma For every n there exists z of length ≥ n in L, such that for every way of writing z = u v w where n is not fixed.

11 Pumping lemma What’s wrong in the proof? L = {x: x = 1 k 0 n 1 n, k ≥ 0, n ≥ 0} is not regular. Proof: Suppose the DFA has n states. Then z = 1110 n 1 n is in L. Write z = uvw, where u = 111, v = 0 n-3, w = 0 3 1 n Then |uv| ≤ n and |v|≥ 1. But uv 0 w = 1110 3 1 n is not in L. Therefore, L is not regular.

12 Pumping lemma For every n there exists z of length ≥ n in L, such that for every way of writing z = u v w where  |uv| ≤ n and  |v| ≥ 1, the string u v i w is not in L for some i ≥ 0. v = 0 n-3 n-3 can be less than 1. Write z = uvw, where u = 111, v = 0 n-3, w = 0 3 1 n. You cannot decide what u, v, w are.

13 Pumping lemma Template Suppose L is regular and its DFA has n states. Then z = _______ (z should contain n somewhere) is in L. Write z = uvw, where |uv| ≤ n and |v|≥ 1. Argue no matter how we write z = uvw, the string uv _ w is not in L (choose i in _, i can be 0) Therefore L is not regular.

14 Pumping lemma Are the following regular?  = {a, b, c} L 1 = {w: w has the same number of patterns ab and ba} L 2 = {a i b j : i < j}

15 Pumping lemma 1. Yes. (covered in lecture?) 2. No. Suppose L 2 is regular and its DFA has n states. Then z = a n b n+1 is in L. Write z = uvw, where |uv| ≤ n and |v|≥ 1. Since|uv| ≤ n, uv contains ‘a’s only, meaning v contains ‘a’s only. Since |v|≥ 1, v must contain at least 1 a. Then the number of ‘a’s in uv 2 w is n + |v| ≥ n + 1, which is the number of b in the string. Therefore it is not in L and so L is not regular.

16 Homework 2 Questions? Want hints?

17 End Any questions?


Download ppt "CSCI 3130: Formal languages and automata theory Tutorial 3 Chin."

Similar presentations


Ads by Google