CSCI 3130 Formal languages and automata theory Tutorial

  • Slides: 17
Download presentation
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin

CSCI 3130: Formal languages and automata theory Tutorial 3 Chin

Reminder • Homework 2 is due on next Monday.

Reminder • Homework 2 is due on next Monday.

Homework 1 • Problem 1 (c) Should state clearly what each state represents (d)

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

Homework 1 • Problem 2 Be careful of e-transitions Many people (including myself!) missed

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

Homework 1 • Problem 3 Most of you need to explain more clearly. Many

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.

Closure Properties 1. If L is regular, is L’ = {wx: w ∈ L;

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

Closure Properties 1. Yes. Let R be the regular expression of L. Then RS*

Closure Properties 1. Yes. Let R be the regular expression of L. Then RS* 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 = {e}, which is regular.

Non regularity • For every n, choose one z of length ≥ n in

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 vi w is not in L for some i ≥ 0. 1. 2. 3. 4. z depends on n u can be empty string i can be 0 (very useful) You only have to choose one z

Pumping lemma • What’s wrong in the proof? L = {11111} is not regular.

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 = e, then uv 2 w = 1111 is not in L. Therefore, L is not regular.

Pumping lemma • For every n there exists z of length ≥ n in

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.

Pumping lemma • What’s wrong in the proof? L = {x: x = 1

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 = 031 n Then |uv| ≤ n and |v|≥ 1. But uv 0 w = 111031 n is not in L. Therefore, L is not regular.

Pumping lemma • For every n there exists z of length ≥ n in

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 vi w is not in L for some i ≥ 0. • • v = 0 n-3 can be less than 1. Write z = uvw, where u = 111, v = 0 n-3, w = 031 n. You cannot decide what u, v, w are.

Pumping lemma Template Suppose L is regular and its DFA has n states. Then

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.

Pumping lemma • Are the following regular? • S = {a, b, c} L

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

Pumping lemma 1. Yes. (covered in lecture? ) 2. No. Suppose L 2 is

Pumping lemma 1. Yes. (covered in lecture? ) 2. No. Suppose L 2 is regular and its DFA has n states. Then z = anbn+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.

Homework 2 • Questions? • Want hints?

Homework 2 • Questions? • Want hints?

End • Any questions?

End • Any questions?