comp20121 the implementation and power of computer
play

COMP20121 The Implementation and Power of Computer Languages Power - PowerPoint PPT Presentation

COMP20121 The Implementation and Power of Computer Languages Power Part http://www.cs.man.ac.uk/ petera/2121/index.html . Peter Aczel room: CS2.52, tel: 56155 petera@cs.man.ac.uk email: Department of Computer Science, University of


  1. COMP20121 The Implementation and Power of Computer Languages ‘Power’ Part http://www.cs.man.ac.uk/ ∼ petera/2121/index.html . Peter Aczel room: CS2.52, tel: 56155 petera@cs.man.ac.uk email: Department of Computer Science, University of Manchester COMP20121 - Section 0 – p.1/307

  2. COMP20121, ‘power’ part: section 1 lectures 2,3: Finite automata for regular languages LECTURE FOUR - Some properties of Regular Languages - Start of section 2: Context-free Grammars COMP20121 - Section 1 – p.74/307

  3. Properties of regular languages Proposition • Every finite language is regular. COMP20121 - Section 1 – p.75/307

  4. Properties of regular languages Proposition • Every finite language is regular. • If L is a regular language then so are L n (for all n ∈ N ), L ∗ , L and L R . COMP20121 - Section 1 – p.75/307

  5. Properties of regular languages Proposition • Every finite language is regular. • If L is a regular language then so are L n (for all n ∈ N ), L ∗ , L and L R . • If L and L ′ are regular languages then so are L ∪ L ′ , L ∩ L ′ and L · L ′ . COMP20121 - Section 1 – p.75/307

  6. Proofs—I We first show that every finite language is regular: COMP20121 - Section 1 – p.76/307

  7. Proofs—I We first show that every finite language is regular: If { α 1 , α 2 , . . . , α n } is a finite language then α 1 | α 2 | · · · | α n is a pattern for the language. COMP20121 - Section 1 – p.76/307

  8. Proofs—II If L is regular then so are L n and L ∗ : COMP20121 - Section 1 – p.77/307

  9. Proofs—II If L is regular then so is L n : For if p is a pattern for L then ? is a pattern for L n , COMP20121 - Section 1 – p.77/307

  10. Proofs—II If L is regular then so is L n : For if p is a pattern for L then pp · · · p is a � �� � n pattern for L n , and COMP20121 - Section 1 – p.77/307

  11. Proofs—II If L is regular then so is L n : For if p is a pattern for L then pp · · · p is a � �� � n pattern for L n , and ? is one for L ∗ . COMP20121 - Section 1 – p.77/307

  12. Proofs—II If L is regular then so is L n : For if p is a pattern for L then pp · · · p is a � �� � n pattern for L n , and p ∗ is one for L ∗ . COMP20121 - Section 1 – p.77/307

  13. Proofs—II If L is regular then so is its complement, L . This follows from Assessed Exercise 1(b) and Theorem 1.5. COMP20121 - Section 1 – p.77/307

  14. Proofs—II If L is regular then so is L R . This is an exercise. COMP20121 - Section 1 – p.77/307

  15. Proofs—III If L and L ′ are regular languages then so is L ∪ L ′ : COMP20121 - Section 1 – p.78/307

  16. Proofs—III If L and L ′ are regular languages then so is L ∪ L ′ : If p is a pattern for L and p ′ one for L ′ then ? is a pattern for L ∪ L ′ . COMP20121 - Section 1 – p.78/307

  17. Proofs—III If L and L ′ are regular languages then so is L ∪ L ′ : If p is a pattern for L and p ′ one for L ′ then p | p ′ is a pattern for L ∪ L ′ . COMP20121 - Section 1 – p.78/307

  18. Proofs—III If L and L ′ are regular languages then so is L · L ′ : COMP20121 - Section 1 – p.78/307

  19. Proofs—III If L and L ′ are regular languages then so is L · L ′ : If p is a pattern for L and p ′ one for L ′ then ? is a pattern for L · L ′ . COMP20121 - Section 1 – p.78/307

  20. Proofs—III If L and L ′ are regular languages then so is L · L ′ : If p is a pattern for L and p ′ one for L ′ then pp ′ is a pattern for L · L ′ . COMP20121 - Section 1 – p.78/307

  21. Proofs—III If L and L ′ are regular languages then so is L ∩ L ′ . This is again an exercise. COMP20121 - Section 1 – p.78/307

  22. Long words in regular languages Assume that a DFA has n states. Then every word of length at least n will go through (at least) one state twice. COMP20121 - Section 1 – p.79/307

  23. Long words in regular languages Assume that a DFA has n states. Then every word of length at least n will go through (at least) one state twice. Very long word x 1 x n . . . . . . state n + 1 state 1 COMP20121 - Section 1 – p.79/307

  24. Long words in regular languages Assume that a DFA has n states. Then every word of length at least n will go through (at least) one state twice. Length of word ≥ n , where n is the number of states . . . i . . . i . . . COMP20121 - Section 1 – p.79/307

  25. Long words in regular languages Assume that a DFA has n states. Then every word of length at least n will go through (at least) one state twice. Length of word ≥ n , where n is the number of states . . . i . . . . . . . . . COMP20121 - Section 1 – p.79/307

  26. The Pumping Lemma Lemma (The Pumping Lemma) Let L be an infinite regular language. Then there exists a natural number n > 0 such that every word α of L consisting of at least n characters contains a ‘pumping section’ in the following sense. COMP20121 - Section 1 – p.80/307

  27. The Pumping Lemma The word α can be split up into three parts, say λ , µ , and ν such that • α = λµν and µ � = ǫ ; • the length of λµ is at most n and so that all words of the form λµ k ν, for k ∈ N , belong to L . COMP20121 - Section 1 – p.81/307

  28. The Pumping Lemma–II The processing of α begins The processing of α ends COMP20121 - Section 1 – p.82/307

  29. The Pumping Lemma–II The processing of α begins The processing of α ends p COMP20121 - Section 1 – p.82/307

  30. The Pumping Lemma–II The processing of α begins The processing of α ends p λ is processed COMP20121 - Section 1 – p.82/307

  31. The Pumping Lemma–II The processing of α begins The processing of α ends µ is processed p λ is processed COMP20121 - Section 1 – p.82/307

  32. The Pumping Lemma–II The processing of α begins The processing of α ends µ is processed p ν is processed λ is processed COMP20121 - Section 1 – p.82/307

  33. Processing λν The processing of λν begins The processing of α ends µ is processed p ν is processed λ is processed COMP20121 - Section 1 – p.83/307

  34. Processing λν The processing of λν begins The processing of α ends µ is processed p ν is processed λ is processed COMP20121 - Section 1 – p.83/307

  35. Processing λµ 2 ν The processing of λν begins The processing of α ends µ is processed p ν is processed λ is processed COMP20121 - Section 1 – p.84/307

  36. Processing λµ 2 ν The processing of α begins The processing of α ends µ is processed p ν is processed λ is processed COMP20121 - Section 1 – p.84/307

  37. Processing λµ 2 ν The processing of α begins The processing of α ends µ is processed p ν is processed λ is processed COMP20121 - Section 1 – p.84/307

  38. Processing λµ 2 ν The processing of λν begins The processing of α ends µ is processed p ν is processed λ is processed COMP20121 - Section 1 – p.84/307

  39. Pumping Lemma: Example The language L = { 0 i 1 i | i ∈ N } is not regular. • Assume n is as in the Pumping Lemma. COMP20121 - Section 1 – p.85/307

  40. Pumping Lemma: Example The language L = { 0 i 1 i | i ∈ N } is not regular. • Assume n is as in the Pumping Lemma. • Consider 0 n 1 n ; assume λ , µ , ν as in the Pumping Lemma. COMP20121 - Section 1 – p.85/307

  41. Pumping Lemma: Example • Since the length of λµ is at most n and µ � = ǫ , we know that n n � �� � � �� � 00 · · · · · · 1 · · · 1 . 00 � �� � ���� µ λ COMP20121 - Section 1 – p.86/307

  42. Pumping Lemma: Example • Since the length of λµ is at most n and µ � = ǫ , we know that n n � �� � � �� � 00 · · · · · · 1 · · · 1 . 00 � �� � ���� µ λ • But then λν = λµ 0 ν is not in L : <n n � �� � � �� � 00 · · · 1 · · · 1 . 0 � �� � λ COMP20121 - Section 1 – p.86/307

  43. Section 1 summary • Regular languages are describable via patterns (regular expressions). COMP20121 - Section 1 – p.87/307

  44. Section 1 summary • Regular languages are describable via patterns (regular expressions). • Regular languages are precisely the languages accepted by finite deterministic automata and COMP20121 - Section 1 – p.87/307

  45. Section 1 summary • Regular languages are describable via patterns (regular expressions). • Regular languages are precisely the languages accepted by finite deterministic automata and • these are precisely the languages accepted by finite non-deterministic automata. COMP20121 - Section 1 – p.87/307

  46. Section 1 summary • Matching a word to a pattern is a recursive process, while checking acceptance with a deterministic automaton is straightforward. COMP20121 - Section 1 – p.88/307

  47. Section 1 summary • Matching a word to a pattern is a recursive process, while checking acceptance with a deterministic automaton is straightforward. • The Pumping Lemma says that infinite regular languages contain strings where a ‘pumping section’ can be repeated arbitrarily often. COMP20121 - Section 1 – p.88/307

  48. Section 1 summary • Regular languages are not powerful enough for the parsing of programming languages. COMP20121 - Section 1 – p.89/307

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend