1 Converting NPDAs to Context-Free Grammars. 2 For any NPDA we will construct a context-free grammar with.

Slides:



Advertisements
Similar presentations
PDAs Accept Context-Free Languages
Advertisements

Fall 2004COMP 3351 Simplifications of Context-Free Grammars.
February 6, 2015CS21 Lecture 141 CS21 Decidability and Tractability Lecture 14 February 6, 2015.
PDAs => CFGs Sipser 2.2 (pages ). Last time…
PDAs => CFGs Sipser 2.2 (pages ). Last time…
Prof. Busch - LSU1 Properties of Context-Free languages.
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.
1 Positive Properties of Context-Free languages. 2 Context-free languages are closed under: Union is context free is context-free.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
Courtesy Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
Costas Buch - RPI1 Simplifications of Context-Free Grammars.
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.
Fall 2004COMP 3351 Pushdown Automata PDAs. Fall 2004COMP 3352 Pushdown Automaton -- PDA Input String Stack States.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Linear Bounded Automata LBAs
1 Normal Forms for Context-free Grammars. 2 Chomsky Normal Form All productions have form: variable and terminal.
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
January 15, 2014CS21 Lecture 61 CS21 Decidability and Tractability Lecture 6 January 16, 2015.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
1 Reducibility. 2 Problem is reduced to problem If we can solve problem then we can solve problem.
1 PDAs Accept Context-Free Languages. 2 Context-Free Languages (Grammars) Languages Accepted by PDAs Theorem:
1 Context-Free Languages. 2 Regular Languages 3 Context-Free Languages.
1 A Non Context-Free Language (We will prove it at the next class)
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 8 Mälardalen University 2010.
Pushdown Automata (PDA) Part 2 While I am distributing graded exams: Design a PDA to accept L = { a m b n : m  n; m, n > 0} MA/CSSE 474 Theory of Computation.
Chapter 7 PDA and CFLs.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Cs3102: Theory of Computation Class 6: Pushdown Automata Spring 2010 University of Virginia David Evans TexPoint fonts used in EMF. Read the TexPoint manual.
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 Automata Chapters Generators vs. Recognizers For Regular Languages: –regular expressions are generators –FAs are recognizers For Context-free.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
Costas Busch - LSU1 Properties of Context-Free languages.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
1 Pushdown Automata There are context-free languages that are not regular. Finite automata cannot recognize all context-free languages.
Formal Languages, Automata and Models of Computation
1 Chapter 6 Pushdown automata Sagrada Familia ( 聖家 堂 ), Barcelona, Spain.
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.
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.
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.
6. Pushdown Automata CIS Automata and Formal Languages – Pei Wang.
Formal Languages, Automata and Models of Computation
PDAs Accept Context-Free Languages
Linear Bounded Automata LBAs
NPDAs Accept Context-Free Languages
Pushdown Automata PDAs
Pushdown Automata PDAs
PDAs Accept Context-Free Languages
PDAs Accept Context-Free Languages
Chapter 7 PUSHDOWN AUTOMATA.
NPDAs Accept Context-Free Languages
DPDA Deterministic PDA
Deterministic PDAs - DPDAs
Closure Properties of Context-Free languages
Properties of Context-Free languages
DPDA Deterministic PDA
Principles of Computing – UFCFA3-30-1
… NPDAs continued.
Decidability continued….
Normal Forms for Context-free Grammars
Presentation transcript:

1 Converting NPDAs to Context-Free Grammars

2 For any NPDA we will construct a context-free grammar with

3 Intuition:The grammar simulates the machine A derivation in Grammar : Current configuration in NPDA

4 in NPDA A derivation in Grammar : Input processedStack contents terminalsvariables

5 Some Necessary Modifications First, we modify the NPDA: It has a single final state It empties the stack when it accepts the input Original NPDA Empty Stack

6 Second, we modify the NPDA transitions: all transitions will have form or

7 Example of a NPDA in correct form:

8 The Grammar Construction In grammar variables have form Terminals are input symbols states stack symbol

9 For each transition We add production For all states

10 For each transition We add production For all states in the NPDA

11 Start Variable: Stack bottom symbol Start state final state

12 Example: Grammar production:

13 Example: Grammar productions:

14 Example: Grammar production:

15 Resulting Grammar:

16

17 Derivation of string

18 In general, in grammar if and only if is accepted by the NPDA

19 Explanation: By construction of grammar: If and only if in the NPDA going from to the stack doesn’t change below and is removed from stack

20 Deterministic PDAs (DPDAs)

21 DPDAs Allowed Transitions:

22 Not allowed: Not allowed even when is

23 Allowed:

24 Not allowed: Not allowed even when is

25 DPDA example

26 The language is deterministic context-free

27 In general: A language is deterministic context-free if there is some NPDA that accepts it

28 Example of Non-DPDA

29 Not allowed transitions for DPDAs

30 NPDAs have more power than DPDAs

31 We will show: There is which is not a context-free language deterministic context-free (accepted by a NPDA) (not accepted by a DPDA)

32 The language is:

33 The language is context-free Context-free grammar for : (there is an NPDA that accepts )

34 is not deterministic context-free Theorem: The language (there is no DPDA that accepts )

35 Proof: Assume for contradiction that is deterministic context free Therefore: There exists a DPDA that accepts

36 The DPDA with accepts

37 The language is not context-free (we will prove it at the next class) A fact:

38 Another fact: The language is not context-free

39 We will construct a NPDA that accepts

40 First, we modify : Modified Replace with

41 The NPDA that accepts Modified Original

42 is accepted by a NPDA Therefore: is context-free Contradiction! ( is not context-free)

43 Therefore: There is no DPDA that accepts End of Proof