cse 105
play

CSE 105 THEORY OF COMPUTATION Fall 2016 - PowerPoint PPT Presentation

CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/ T oday's learning goals Sipser Ch 1.11.4 Are there non-regular languages? Pumping Lemma for Regular Languages Identify some nonregular sets


  1. CSE 105 THEORY OF COMPUTATION Fall 2016 http://cseweb.ucsd.edu/classes/fa16/cse105-abc/

  2. T oday's learning goals Sipser Ch 1.1–1.4 • Are there non-regular languages? • Pumping Lemma for Regular Languages • Identify some nonregular sets

  3. DFAs and Counting ● Which of the following languages is regular? L1 = {0 n 1 n | n < 10} – L2 = {0 n 1 n | n > 10} – A) L1 B) L2 C) Both L1 and L2 D) Neither L1 nor L2 E) I don’t know

  4. DFAs and Counting ● Which of the following languages is regular? L1 = {0 n 1 n | n < 10} – L2 = {0 n 1 n | n > 10} – ● Correct answer is (A): Only L1 ● Why is L1 regular? Easy: because it is a fjnite language (of size 10) – ● But why is L2 not regular? Defjnitions look so similar!

  5. A DFA for L1 ● Give a DFA for L1 = {0 n 1 n | n < 10} – ● How many states do you need? A) 10 (or fewer) B) 20 (or fewer) C) 100 (or fewer) D) Exaclty 2048 E) I don’t know

  6. Let’s solve it in JFLAP (n<5)

  7. One more question ● Which of the following languages are regular? L1 = {0 n 1 n | n >= 0 } – L2 = {0 n 1 n | (5<n) and (n<10)} – A) All four L3 = Complement of L2 – B) L2, L3 L4 = {0 n 1 n | not(5<n) or not(n<10)} – C) L2, L3, L4 D) None E) I don’t know

  8. Intuition ● DFAs can count up to 10 ● DFAs can count up to any fjxed bounded number k, given enough states. ● But they cannot count indefjnitely: Given a long enough string 0000000000...0, they will loose – count when they “run out” of states ● How can we formalize this into a proof?

  9. Bounds on DFA • in DFA, memory = states • Automata can only "remember"… • …fjnitely far in the past • …fjnitely much information • If a computation path visits the same state more than once, the machine can't tell the difgerence between the fjrst time and future times it visited that state.

  10. A non-regular language • Proof that L={0 n 1 n | n≥0} is not regular • Proof: assume L is regular (for contradiction) – L=L(M) is the language of a DFA = (Q,…) with a fjnite number of states p=|Q| – Consider computation on input 0 p 1 p – Computation has length 2p+1>|Q| – Must visit the same state twice – This gives many other accepting computations

  11. Proof details ● Assume L(M)={0 n 1 n | n≥0} ● M has p=|Q| states and accepts 0 p 1 p ● M must visit the same state twice while reading 0 p ● Break the computation/input in three parts Accepts not only 000000111111 – 00 But also 00111111, 000000000111111 – 01111 00(000) k 01111111 – 11 000 ● Contradicts the defjnition of L(M)

  12. Pumping Lemma: What and Why ● Pumping lemma abstracts this pattern of reasoning to prove that a language is not regular ● Pumping Lemma: asserts a property satisfjed by all regular languages ● Using the pumping lemma Assume (for contradition) that L is regular – Therefore it satisfjes pumping property – Derive a contradiction. –

  13. Pumping Lemma: informal • All suffjciently long strings accepted by a DFA can be pumped

  14. Pumping • Focus on computation path through DFA Idea: if one long string xyz is accepted, x then many other strings have to be accepted too: xz, xyz, xyyz, xyyyz, ... z y

  15. Pumping Lemma Sipser p. 78 Theorem 1.70

  16. Pumping Lemma Sipser p. 78 Theorem 1.70 # states in # states in DFA DFA recognizing A recognizing A Transition labels T ransition labels along loop along loop

  17. Question ● Which of the following sentences best describes the pumping lemma: A) It is a property of every regular language B) It is a property of every non-regular language C) It is a closure property of regular languages D) It is a closure property of non-regular languages E) I don’t know

  18. Answer ● The pumping lemma asserts a property satisfjed by every regular language ● But we use it to prove nonregular languages Assume L is regular (for contradiction) – Apply pumping property – Get a contradiction – Therefore L is not regular –

  19. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular.

  20. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular. Proof: Assume, towards a contradiction , that L is regular. Pumping Lemma gives property of Pumping Lemma gives property of all regular sets. Can we get a all regular sets. Can we get a contradiction by assuming that contradiction by assuming that the Pumping Lemma applies to the Pumping Lemma applies to this set? this set?

  21. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular. Proof: Assume, towards a contradiction , that L is regular. Therefore, the Pumping Lemma applies to L and gives us some number p, the pumping length of L . In particular, this means that every string in L that is of length p or more can be "pumped". …Idea: can we fjnd some long string in L that can't be?

  22. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular. Proof: …In particular, this means that every string in L that is of length p or more can be "pumped". Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xy i z not in L So we have a contradiction, and L is not regular.

  23. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular. Proof: … Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xy i z not in L Choose s = 0 p 1 p . Consider any s=xyz with |y|>0, |xy|≤p.

  24. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular. Proof: … Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xy i z not in L Choose s = 0 p 1 p . Consider any s = xyz with |y|>0, |xy|≤p. Since |xy|≤p, x=0 m , y = 0 n , z = 0 r 1 p with m+n+r =p, j>0.

  25. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular. Proof: … Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xy i z not in L Choose s = 0 p 1 p . Consider any s = xyz with |y|>0, |xy|≤p. Since |xy|≤p, x=0 m , y = 0 n , z = 0 r 1 p with m+n+r =p, j>0. Picking i=0: xy i z = xz = 0 m 0 r 1 p = 0 m+r 1 p , not in L!

  26. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular. Proof: … Goal: pick a string s in L of length greater than or equal to p such that any division of s as s =xyz with |y|>0 and |xy|≤ p gives some value i≥0 with xy i z not in L Choose s = 0 p 1 p . Consider any s = xyz with |y|>0, |xy|≤p. Since |xy|≤p, x=0 m , y = 0 n , z = 0 r 1 p with m+n+r =p, j>0. Picking i=0: xy i z = xz = 0 m 0 r 1 p = 0 m+r 1 p , not in L! This is a contradiction with the Pumping Lemma applied to L, so L must not be regular.

  27. Key ingredients in proof Claim : Language L is not regular. Proof: Assume, towards a contradiction, that L is regular. By the Pumping Lemma, there is a pumping length p for L. Consider the string s = …… You must pick s carefully: we want |s|≥p and s in L. *Confjrm these facts as part of your proof* Now we will prove a contradiction with the statement "s can be pumped" Consider an arbitrary choice of x,y,z such that s = xyz, |y|>0, | xy|≤p. This means that... What properties are guaranteed about x,y,z? Consider i=… In this case, xy i z = …, which is not in L, a contradiction with the Pumping Lemma applying to L and so L is not regular.

  28. Using the Pumping Lemma Claim: The set L = {0 n 1 n | n ≥ 0} is not regular. In proof, we used s = 0 p 1 p and i=0 Claim: The set {a n b m a n | m,n≥ 0} is not regular. In proof, we used s = a p ba p and i=3

  29. And another Claim: The set {w w R | w is a string over {0,1} } is not regular. Proof : … Consider the string s = …… You must pick s carefully: we want |s|≥p and s in L. Now we will prove a contradiction with the statement "s can be pumped" Consider i=… Which s and i let us complete the proof? A. s = 0 p 0 p , i=2 B. s = 0110, i=0 C. s = 0 p 110 p , i=1 D. s = 1 p 001 p , i=3 E. I don't know

Recommend


More recommend