1 Applications of Regular Closure. 2 The intersection of a context-free language and a regular language is a context-free language context free regular.

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

4.5 Inherently Ambiguous Context-free Language For some context-free languages, such as arithmetic expressions, may have many different CFG’s to generate.
Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
Fall 2004COMP 3351 Simplifications of Context-Free Grammars.
Prof. Busch - LSU1 Simplifications of Context-Free Grammars.
CS 3240: Languages and Computation Properties of Context-Free Languages.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
Prof. Busch - LSU1 Properties of Context-Free languages.
Lecture 15UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 15.
Courtesy Costas Busch - RPI1 More Applications of the Pumping Lemma.
Courtesy Costas Busch - RPI1 Positive Properties of Context-Free languages.
1 Positive Properties of Context-Free languages. 2 Context-free languages are closed under: Union is context free is context-free.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Courtesy Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
Costas Buch - RPI1 Simplifications of Context-Free Grammars.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
Costas Busch - RPI1 Positive Properties of Context-Free languages.
Fall 2003Costas Busch - RPI1 Decidable Problems of Regular Languages.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
1 Simplifications of Context-Free Grammars. 2 A Substitution Rule substitute B equivalent grammar.
Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
1 Simplifications of Context-Free Grammars. 2 A Substitution Rule Substitute Equivalent grammar.
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2003Costas Busch1 More Applications of The Pumping Lemma.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Fall 2006Costas Busch - RPI1 More Applications of the Pumping Lemma.
1 More Applications of The Pumping Lemma. 2 The Pumping Lemma: there exists an integer such that for any string we can write For infinite context-free.
Prof. Busch - LSU1 Pumping Lemma for Context-free Languages.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
Prof. Busch - RPI1 Decidable Problems of Regular Languages.
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
1 Non-regular languages. 2 Regular languages Non-regular languages.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Costas Busch1 More Applications of The Pumping Lemma.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
The Pumping Lemma for Context Free Grammars. Chomsky Normal Form Chomsky Normal Form (CNF) is a simple and useful form of a CFG Every rule of a CNF grammar.
1 L= { w c w R : w  {a, b}* } is accepted by the PDA below. Use a construction like the one for intersection for regular languages to design a PDA that.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Non-CF Languages The language L = { a n b n c n | n  0 } does not appear to be context-free. Informal: A PDA can compare #a’s with #b’s. But by the time.
Costas Busch - LSU1 Properties of Context-Free languages.
Pumping Lemma for CFLs. Theorem 7.17: Let G be a CFG in CNF and w a string in L(G). Suppose we have a parse tree for w. If the length of the longest path.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
Critique this PDA for L= { u u R v v R : u ∈ {0,1}* and v ∈ {0,1}+ } u0εu0 u1εu1 uεεvε v00vε v11vε vεεfε sεεtε t0εt0 t1εt1 t00tε t11tε tεεuε After you.
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
Chapter 8 Properties of Context-free Languages These class notes are based on material from our textbook, An Introduction to Formal Languages and Automata,
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
CS 154 Formal Languages and Computability March 17 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
 2004 SDU Lecture8 NON-Context-free languages.  2004 SDU 2 Are all languages context free? Ans: No. # of PDAs on  < # of languages on  Pumping lemma:
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
7. Properties of Context-Free Languages
Simplifications of Context-Free Grammars
PDAs Accept Context-Free Languages
Deterministic PDAs - DPDAs
Pumping Lemma for Context-free Languages
Closure Properties of Context-Free languages
Elementary Questions about Regular Languages
Non-regular languages
Decidable Problems of Regular Languages
More Applications of the Pumping Lemma
Chapter 2 Context-Free Language - 02
More Applications of The Pumping Lemma
Applications of Regular Closure
Presentation transcript:

1 Applications of Regular Closure

2 The intersection of a context-free language and a regular language is a context-free language context free regular context-free Regular Closure

3 An Application of Regular Closure Prove that: is context-free

4 We know: is context-free

5 is regular We also know:

6 regularcontext-free is context-free context-free (regular closure)

7 Another Application of Regular Closure Prove that: is not context-free

8 context-freeregularcontext-free If is context-free Then Impossible!!! Therefore, is not context free (regular closure)

9 Decidable Properties of Context-Free Languages

10 Membership Question: for context-free grammar find if string Membership Algorithms: Parsers Exhaustive search parser CYK parsing algorithm

11 Empty Language Question: for context-free grammar find if Algorithm: 1.Remove useless variables 2.Check if start variable is useless

12 Infinite Language Question: for context-free grammar find if is infinite Algorithm: 1. Remove useless variables 2. Remove unit and productions 3. Create dependency graph for variables 4. If there is a loop in the dependency graph then the language is infinite

13 Example: Dependency graph Infinite language

14

15 The Pumping Lemma for Context-Free Languages

16 Take an infinite context-free language Example: Generates an infinite number of different strings

17 A derivation:

18 Derivation treestring

19 repeated Derivation treestring

20

21 Repeated Part

22 Another possible derivation

23

24

25

26 Therefore, the string is also generated by the grammar

27 We know: We also know this string is generated:

28 We know: Therefore, this string is also generated:

29 We know: Therefore, this string is also generated:

30 Therefore, this string is also generated: We know:

31 Therefore, knowing that is generated by grammar, we also know that is generated by

32 In general: We are given an infinite context-free grammar Assume has no unit-productions no -productions

33 Take a string with length bigger than Some variable must be repeated in the derivation of (Number of productions) x (Largest right side of a production) > Consequence:

34 Last repeated variable String repeated

35 Possible derivations:

36 We know: This string is also generated:

37 This string is also generated: The original We know:

38 This string is also generated: We know:

39 This string is also generated: We know:

40 This string is also generated: We know:

41 Therefore, any string of the form is generated by the grammar

42 knowing that we also know that Therefore,

43 Observation: Since is the last repeated variable

44 Observation: Since there are no unit or productions

45 The Pumping Lemma: there exists an integer such that for any string we can write For infinite context-free language with lengths and it must be:

46 Applications of The Pumping Lemma

47 Context-free languages Non-context free languages

48 Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages

49 Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma

50 Pumping Lemma gives a magic number such that: Pick any string with length We pick:

51 We can write: with lengths and

52 Pumping Lemma says: for all

53 We examine all the possible locations of string in

54 Case 1: is within

55 Case 1: and consist from only

56 Case 1: Repeating and

57 Case 1: From Pumping Lemma:

58 Case 1: From Pumping Lemma: However: Contradiction!!!

59 Case 2: is within

60 Case 2: Similar analysis with case 1

61 Case 3: is within

62 Case 3: Similar analysis with case 1

63 Case 4: overlaps and

64 Case 4: Possibility 1:contains only

65 Case 4: Possibility 1:contains only

66 Case 4: From Pumping Lemma:

67 Case 4: From Pumping Lemma: However: Contradiction!!!

68 Case 4: Possibility 2:contains and contains only

69 Case 4: Possibility 2:contains and contains only

70 Case 4: From Pumping Lemma:

71 Case 4: From Pumping Lemma: However: Contradiction!!!

72 Case 4: Possibility 3:contains only contains and

73 Case 4: Possibility 3:contains only contains and Similar analysis with Possibility 2

74 Case 5: overlaps and

75 Case 5: Similar analysis with case 4

76 There are no other cases to consider (since, string cannot overlap, and at the same time)

77 In all cases we obtained a contradiction Therefore: The original assumption that is context-free must be wrong Conclusion:is not context-free