csci 3130: formal languages and automata theory tutorial 3

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

Upload: kaden-beach

Post on 04-Jan-2016

36 views

Category:

Documents


0 download

DESCRIPTION

CSCI 3130: Formal languages and automata theory Tutorial 3. Chin. Reminder. Homework 2 is due on next Monday. 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. - PowerPoint PPT Presentation

TRANSCRIPT

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

CSCI 3130: Formal languagesand automata theory

Tutorial 3

Chin

Page 2: CSCI 3130: Formal languages and automata theory Tutorial 3

Reminder

• Homework 2 is due on next Monday.

Page 3: CSCI 3130: Formal languages and automata theory Tutorial 3

Homework 1

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

(d) Some of you accept the strings 02 & 20 in the DFASome of you did not explain how the DFA works

Page 4: CSCI 3130: Formal languages and automata theory Tutorial 3

Homework 1

• Problem 2Be careful of -transitionsMany people (including myself!) missedthe edge from q1 to q0 on input ‘0’

q1 --> q0 -0-> q1 --> q0

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.

Page 5: CSCI 3130: Formal languages and automata theory Tutorial 3

Homework 1

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

Many of you just showed strings in L1 are also in L2, then conclude they are equivalent.What if some strings in L2 are not in L1?

Do NOT do the following…L1 and L2 are the equivalent because L2 clearly represents the language of L1.

Page 6: CSCI 3130: Formal languages and automata theory Tutorial 3

Closure Properties

1. If L is regular, is L’ = {wx: w L; x ∈ ∈ *}also regular?

2. If L1 is not regular and L2 is not regular, is L1∩L2 also not regular?

Page 7: CSCI 3130: Formal languages and automata theory Tutorial 3

Closure Properties

1. Yes. Let R be the regular expression of L. Then R* is also a regular expression. Hence regular.

2. No. L1 = 0n1n, L2 = 1n0n. Then L1 and L2 are both non-regular. But L1∩L2 = {, which is regular

Page 8: CSCI 3130: Formal languages and automata theory Tutorial 3

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.

• z depends on n• u can be empty string• i can be 0 (very useful)• You only have to choose one z

Page 9: CSCI 3130: Formal languages and automata theory Tutorial 3

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 uv2w = 11 1111 is not in L.If uv = 11 and u = 1, then uv2w = 1 11 111 is not in L.If uv = 11 and u = , then uv2w = 1111 1111 is not in L.Therefore, L is not regular.

Page 10: CSCI 3130: Formal languages and automata theory Tutorial 3

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.

Page 11: CSCI 3130: Formal languages and automata theory Tutorial 3

Pumping lemma

• What’s wrong in the proof?L = {x: x = 1k0n1n, k ≥ 0, n ≥ 0} is not regular.

Proof:Suppose the DFA has n states. Then z = 1110n1n is in L.Write z = uvw, where u = 111, v = 0n-3, w = 031n

Then |uv| ≤ n and |v|≥ 1.But uv0w = 111031n is not in L. Therefore, L is not regular.

Page 12: CSCI 3130: Formal languages and automata theory Tutorial 3

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 = 0n-3

• n-3 can be less than 1.• Write z = uvw, where u = 111, v = 0n-3, w = 031n.• You cannot decide what u, v, w are.

Page 13: CSCI 3130: Formal languages and automata theory Tutorial 3

Pumping lemma

TemplateSuppose 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.

Page 14: CSCI 3130: Formal languages and automata theory Tutorial 3

Pumping lemma

• Are the following regular?• = {a, b, c}

L1 = {w: w has the same number of patterns ab and ba}L2 = {ai bj : i < j}

Page 15: CSCI 3130: Formal languages and automata theory Tutorial 3

Pumping lemma

1. Yes. (covered in lecture?)

2. No. Suppose L2 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 uv2w 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.

Page 16: CSCI 3130: Formal languages and automata theory Tutorial 3

Homework 2

• Questions?• Want hints?

Page 17: CSCI 3130: Formal languages and automata theory Tutorial 3

End

• Any questions?