1 PDAs Accept Context-Free Languages. 2 Context-Free Languages (Grammars) Languages Accepted by PDAs Theorem:

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

Chapter 5 Pushdown Automata
CFGs and PDAs Sipser 2 (pages ). Long long ago…
Pushdown Automata Part II: PDAs and CFG Chapter 12.
PDAs => CFGs Sipser 2.2 (pages ). Last time…
CFGs and PDAs Sipser 2 (pages ). Last time…
PDAs => CFGs Sipser 2.2 (pages ). Last time…
Decidable languages Sipser 4.1 (pages ). CS 311 Mount Holyoke College 2 Hierarchy of languages All languages Turing-recognizable Turing-decidable.
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.
Costas Busch - RPI1 Undecidable problems for Recursively enumerable languages continued…
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
Introduction to the Theory of Computation John Paxton Montana State University Summer 2003.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
1 Converting NPDAs to Context-Free Grammars. 2 For any NPDA we will construct a context-free grammar with.
Fall 2006Costas Busch - RPI1 The Post Correspondence Problem.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
Fall 2004COMP 3351 NPDA’s Accept Context-Free Languages.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2009 with acknowledgement.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
Fall 2006Costas Busch - RPI1 Pushdown Automata PDAs.
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
CS 3240: Languages and Computation Pushdown Automata & CF Grammars NOTE: THESE ARE ONLY PARTIAL SLIDES RELATED TO WEEKS 9 AND 10. PLEASE REFER TO THE TEXTBOOK.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Design contex-free grammars that generate: L 1 = { u v : u ∈ {a,b}*, v ∈ {a, c}*, and |u| ≤ |v| ≤ 3 |u| }. L 2 = { a p b q c p a r b 2r : p, q, r ≥ 0 }
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 Mälardalen University 2010.
Context-free Languages
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 11 Midterm Exam 2 -Context-Free Languages Mälardalen University 2005.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 6 Mälardalen University 2010.
Pushdown Accepters & Context-Free Grammars Sipser, Theorem 2.12 Denning, Chapter 8.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
11 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 7 School of Innovation, Design and Engineering Mälardalen University 2012.
Formal Languages, Automata and Models of Computation
1.Draw a parse tree for the following derivation: S  C A C  C A b b  b b A b b  b b B b b  b b a A a a b b  b b a b a a b b 2. Show on your parse.
Grammar Set of variables Set of terminal symbols Start variable Set of Production rules.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2011.
Costas Busch - LSU1 The Post Correspondence Problem.
Pushdown Automata Chapter 12. Recognizing Context-Free Languages Two notions of recognition: (1) Say yes or no, just like with FSMs (2) Say yes or no,
1 Chapter Pushdown Automata. 2 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations.
1 Section 12.2 Pushdown Automata A pushdown automaton (PDA) is a finite automaton with a stack that has stack operations pop, push, and nop. PDAs always.
CS 154 Formal Languages and Computability March 15 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
About Grammars Hopcroft, Motawi, Ullman, Chap 7.1, 6.3, 5.4.
Costas Busch - LSU1 PDAs Accept Context-Free Languages.
Lecture 11  2004 SDU Lecture7 Pushdown Automaton.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Formal Languages, Automata and Models of Computation
PDAs Accept Context-Free Languages
NPDAs Accept Context-Free Languages
Pushdown Automata PDAs
Pushdown Automata PDAs
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
PDAs Accept Context-Free Languages
Pushdown Automata PDAs
NPDAs Accept Context-Free Languages
Chapter 2 Context-Free Language - 01
… NPDAs continued.
Pushdown automata The Chinese University of Hong Kong Fall 2011
Normal Forms for Context-free Grammars
Presentation transcript:

1 PDAs Accept Context-Free Languages

2 Context-Free Languages (Grammars) Languages Accepted by PDAs Theorem:

3 Context-Free Languages (Grammars) Languages Accepted by PDAs Proof - Step 1: Convert any context-free grammar to a PDA with:

4 Context-Free Languages (Grammars) Languages Accepted by PDAs Proof - Step 2: Convert any PDA to a context-free grammar with:

5 Converting Context-Free Grammars to PDAs Proof - step 1

6 Context-Free Languages (Grammars) Languages Accepted by PDAs Convert any context-free grammar to a PDA with:

7 to a PDA such that: We will convert grammar simulates leftmost derivations of

8 Production in Terminal in Convert grammar to PDA

9 Grammar leftmost derivation PDA computation Simulates grammar leftmost derivations Leftmost variable

10 Grammar PDA Example

11 Grammar derivation PDA computation

12 Input Stack Time 0 Derivation:

13 Input Stack Time 0 Derivation:

14 Input Stack Time 1 Derivation:

15 Input Stack Time 2 Derivation:

16 Input Stack Time 3 Derivation:

17 Input Stack Time 4 Derivation:

18 Input Stack Time 5 Derivation:

19 Input Stack Time 6 Derivation:

20 Input Stack Time 7 Derivation:

21 Input Stack Time 8 Derivation:

22 Input Stack accept Time 9 Derivation:

23 Grammar generates string PDA accepts In general, it can be shown that: If and Only if Therefore

24 Therefore: For any context-free language there is a PDA that accepts Context-Free Languages (Grammars) Languages Accepted by PDAs

25 Converting PDAs to Context-Free Grammars Proof - step 2

26 Context-Free Languages (Grammars) Languages Accepted by PDAs Convert any PDA to a context-free grammar with:

27 We will convert PDA to a context-free grammar such that: simulates computations of with leftmost derivations

28 Some Necessary Modifications If necessary, modify the PDA so that: 1. The stack is never empty during computation 2. It has a single accept state and empties the stack when it accepts a string 3. Has transitions without popping

29 1. Modify the PDA so that the stack is never empty during computation Stack OK NOT OK

30 Introduce the new symbol to mark the bottom of the stack

31 Original PDA At the beginning insert into the stack original initial state new initial state

32 # # , halting state Convert all transitions so that after popping the automaton halts pop

33 PDA , Empty stack 2. Modify the PDA so that at end it empties stack and has a unique accept state , , Old accept states New accept state

34 3. Modify the PDA so that it has no transitions popping :

35 Example of a PDA in correct form: (modifications are not necessary)

36 Grammar Construction In grammar : Terminals: PDA stack symbolsVariables: PDA input symbols Start Variable:Stack bottom symbol

37 PDA transition Grammar production

38 PDA transition Grammar production

39 Grammar leftmost derivation PDA computation Leftmost variable

40 Example PDA: Grammar:

41 Grammar Leftmost derivation: PDA Computation:

42 Derivation: Time 0

43 Derivation: Time 1 Stack

44 Derivation: Time 2 Stack

45 Derivation: Time 3 Stack

46 Derivation: Time 4 Stack

47 Derivation: Time 5 Stack empty

48 However, this grammar conversion does not work for all PDAs:

49 Grammar:

50 Grammar: Bad Derivation:

51 The Correct Grammar Construction In grammar : Terminals: Input symbols of PDA PDA states PDA stack symbol Variables:

52 PDA transition Grammar production

53 PDA transition Grammar production For all possible states in PDA

54 Start Variable: Stack bottom symbol Start state accept state

55 Example: Grammar production:

56 Example: Grammar productions:

57 Example: Grammar production:

58 Resulting Grammar:

59

60 Grammar Leftmost derivation PDA computation

61 Derivation: Time 0

62 Derivation: Time 1 Stack

63 Derivation: Time 2 Stack

64 Derivation: Time 3 Stack

65 Derivation: Time 4 Stack

66 Derivation: Time 5 Stack empty

67 In general: If and Only if Grammar PDA

68 Thus: If and Only if Grammar generates PDA accepts

69 Therefore: For any PDA there is a context-free grammar that accepts the same language Context-Free Languages (Grammars) Languages Accepted by PDAs