Understanding Non-Regular Languages and the Pumping Lemma

Slide Note
Embed
Share

Dive into the world of regular and non-regular languages, exploring the concept of the pumping lemma. Learn about different types of non-regular languages and why some languages require an infinite number of states to be represented by a finite automaton. Find out why mathematical proofs are essential in determining the regularity of languages.


Uploaded on Jul 29, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Non-regular languages - The pumping lemma

  2. Regular Languages Regular languages are the languages which are accepted by a Finite Automaton. Not all languages are regular

  3. Non-Regular Languages L0= {akbk: k 0} = { } is a regular language q0a q0b

  4. Non-Regular Languages L1 = {akbk: k 1} = { , ab} is regular a q0a q1a b q1b q0b

  5. Non-Regular Languages L2 = {akbk: k 2} = { , ab, aabb} is regular a a q0a q1a q2a b b q2b q1b q0b

  6. Non-Regular Languages L3 = {akbk: k 3} is regular a a a q0a q1a q2a q3a b b b q3b q2b q1b q0b

  7. Non-Regular Languages n 0,Ln = {akbk : k n} is regular a a a a q0a q1a q2a q3a qna b b b b q(n-3)b q(n-1)b q(n-2)b qnb q0b

  8. Non-Regular Languages However L = {anbn: n 0} = Un 0 Lndoesn t seem to be a regular language at all! We need an infinite number of states to build this automaton! a a a a q0a q1a q2a q3a b b b b q(n-3)b q(n-1)b q(n-2)b qnb

  9. Non-Regular Languages However L = {anbn: n 0} = Un 0 Lndoesn t seem to be a regular language at all! We need an infinite number of states to build this automaton! (Observe that you cannot use the fact that regular languages are closed under union because we have an infinite union)

  10. Is this a proof? NO!In fact consider: L = {s : s contains equal number of a and b} L = {s : s contains equal number of ab and ba} L is indeed not regular but L is regular! WE NEED A MATHEMATICAL PROOF!!! A proof that there is no FA that accepts L or L .

  11. Pigeonhole Principle If we have n holes and m pigeons (m>n) then there is a hole with at least two pigeons.

  12. Pigeonhole Principle If we have n holes and m pigeons (m>n) then there is a hole with at least two pigeons.

  13. PP and Finite Automata If an automaton with n states accepts a string with length m (m n) then for every accepting path there should be at least one repeating state. s = aaba

  14. PP and Finite Automata If an automaton with n states accepts a string with length m (m n) then for every accepting path there should be at least one repeating state. b a a a s = aaba

  15. PP and Finite Automata If an automaton with n states accepts a string with length m (m n) then for every accepting path there should be at least one repeating state. b a a a Any string of the form aab*a should be accepted!

  16. PP and FA continued

  17. PP and FA continued x z y

  18. PP and FA continued x z y xyz is accepted

  19. PP and FA continued x z y xyyz is accepted

  20. PP and FA continued x z y xyyyz is accepted

  21. PP and FA continued x z y xz is accepted

  22. PP and FA continued x z y xyiz, for i 0 is accepted

  23. The pumping lemma For every infinite regular language L there exists a pumping length n > 0 such that for any string s in L with length |s| n we can write s = xyz with |xy| n and |y| 1 such that xyiz in L for every i 0.

  24. Proof If L is regular then there exists a DFA M which accepts L. Set n to be M s number of states. L is infinite, there exists a string s with length greater than n. The number of states is n, the accepting path for s is of length at most n. The string is of length at least n, there is a part in the path that is repeated.

  25. Proof Split s into 3 parts x, y, z with y being the first repeated part. Since we have n states the first repetition should take place (|y| 1) in at most n transitions (|xy| n). Since the path under y is a loop we can follow it as many times as we want (maybe none). Thus xyiz for any i 0 should lead us to the same accepting state as xyz.

  26. Prove that L is not regular Given is an infinite language L.

  27. Prove that L is not regular Given is an infinite language L. (What if L is finite?)

  28. Prove that L is not regular Given is an infinite language L If L is regular

  29. Prove that L is not regular Given is an infinite language L If L is regular Pumping lemma holds: There exists a pumping length n such that for all proper strings s in L there is a splitting of s in x,y,z (with the desired properties) such that for all i xyiz is in L.

  30. Prove that L is not regular Given is an infinite language L If L is regular Pumping lemma holds: There exists a pumping length n such that for all proper strings s in L there is a splitting of s in x,y,z (with the desired properties) such that for all i xyiz is in L. |s| n |y| 1 and |xy| n

  31. Prove that L is not regular Given is an infinite language L If L is regular the pumping lemma holds. The negation of the pumping lemma: For all pumping lengths n there exists a proper string s in L such that for every possible splitting of s in x,y,z (with the desired properties) there is an i for which xyiz is not in L.

  32. Prove that L is not regular Given is an infinite language L Assume L is regular (pumping lemma holds) Prove the negation of the pumping lemma: Fix an arbitrary pumping length n. Specify a proper string s in L. Show that for every possible splitting of s in x,y,z (with the desired properties), there is an i for which xyiz is not in L.

  33. Prove that L is not regular Given is an infinite language L Assume L is regular (pumping lemma holds) Prove the negation of the pumping lemma: Fix an arbitrary pumping length n. Specify a proper string s in L. Show that for every possible splitting of s in x,y,z (with the desired properties), there is an i for which xyiz is not in L. Contradiction!!!

  34. Prove that L is not regular Given is an infinite language L Assume L is regular (pumping lemma holds) Prove the negation of the pumping lemma: Fix an arbitrary pumping length n. Specify a proper string s in L. Show that for every possible splitting of s in x,y,z (with the desired properties), there is an i for which xyiz is not in L. Contradiction!!! L is not regular

  35. Example L = {anbn: n 0} is not regular. Proof: Assume that L is regular. The pumping lemma holds!

  36. Example L = {anbn: n 0} is not regular. Proof: Fix an arbitrary pumping length k for L.

  37. Example L = {anbn: n 0} is not regular. Proof: The string s = akbk should be in the language.

  38. Example L = {anbn: n 0} is not regular. Proof: s is proper: |s| = 2k is greater than k

  39. Example L = {anbn: n 0} is not regular. Proof: Consider all possible splittings of akbk in the form xyz with the desired properties: |xy| k and |y| 1

  40. Example L = {anbn: n 0} is not regular. Proof: Consider all possible splittings of akbk in the form xyz with the desired properties: |xy| k and |y| 1 a a a a a a a a a b b b b b b b b b k k

  41. Example L = {anbn: n 0} is not regular. Proof: Consider all possible splittings of akbk in the form xyz with the desired properties: |xy| k and |y| 1 a a a a a a a a a b b b b b b b b b x y k k z

  42. Example L = {anbn: n 0} is not regular. Proof: Consider all possible splittings of akbk in the form xyz with the desired properties y = am, for 1 m k k k a a a a a a a a a b b b b b b b b b x y z

  43. Example L = {anbn: n 0} is not regular. Proof: Consider all possible splittings of akbk in the form xyz with the desired properties y = am, for 1 m k for i =2, xy2z = ak+mbk is not in L! a a a a a a a a a a a a b b b b b b b b b x y y z

  44. Example L = {anbn: n 0} is not regular. Proof: Consider all possible splittings of akbk in the form xyz with the desired properties xy2z is not in L! CONTRADICTION! a a a a a a a a a a a a b b b b b b b b b x y y z

  45. Try it yourself Show that the following language is not a regular language: Lp = {abjcj | j 0} Members: a, abc, abbcc, abbbccc,

  46. Try it yourself Show that the following language is not a regular language: Lp = {abjcj | j 0} Negation of the pumping lemma (reminder): Fix an arbitrary pumping length n. Specify a proper string s in L. Show that for every possible splitting of s in x,y,z (with the desired properties), there is an i for which xyiz is not in L.

  47. How to use the pumping lemma The pumping lemma mentions that if L is a regular language then it can be pumped. The contrapositive is true: If L cannot be pumped then it shouldn t be regular! Show that L cannot be pumped to prove that L is not regular.

  48. How not to use the pumping lemma The pumping lemma mentions that if L is a regular language then it can be pumped. The converse is not true: If a language can be pumped this doesn t mean that it is regular! Do not try to show that L can be pumped in order to prove that L is regular.

  49. Pumping Lemma - Converse For example consider the language Lp = {aibjck : i,j,k 0, if i=1 then j=k}.

  50. Pumping Lemma - Converse For example consider the language Lp = {aibjck : i,j,k 0, if i=1 then j=k}. 1. Lp is not regular.

Related