1 … NPDAs continued. 2 Pushing Strings Input symbol Pop symbol Push string.

Slides:



Advertisements
Similar presentations
Chapter 5 Pushdown Automata
Advertisements

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…
Costas Busch - RPI1 Pushdown Automata PDAs. Costas Busch - RPI2 Pushdown Automaton -- PDA Input String Stack States.
Courtesy Costas Busch - RPI1 Pushdown Automata PDAs.
Costas Busch - RPI1 NPDAs Accept Context-Free Languages.
1 Turing Machines. 2 The Language Hierarchy Regular Languages 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.
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.
January 14, 2015CS21 Lecture 51 CS21 Decidability and Tractability Lecture 5 January 14, 2015.
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.
January 15, 2014CS21 Lecture 61 CS21 Decidability and Tractability Lecture 6 January 16, 2015.
Fall 2006Costas Busch - RPI1 PDAs Accept Context-Free Languages.
Prof. Busch - LSU1 Pushdown Automata PDAs. Prof. Busch - LSU2 Pushdown Automaton -- PDA Input String Stack States.
Fall 2005Costas Busch - RPI1 Pushdown Automata PDAs.
1 Pushdown Automata PDAs. 2 Pushdown Automaton -- PDA Input String Stack States.
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)
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 8 Mälardalen University 2010.
Pushdown Automata CS 130: Theory of Computation HMU textbook, Chap 6.
Pushdown Automata (PDAs)
Equivalence of Pushdown Automata and Context-Free Grammars (1) Theorem. Given a context-free grammar CG = ( ,NT,R,S), then there is a pushdown automaton.
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.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
Foundations of (Theoretical) Computer Science Chapter 2 Lecture Notes (Section 2.2: Pushdown Automata) Prof. Karen Daniels, Fall 2010 with acknowledgement.
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.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.
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.
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 10 Class Meeting Department of Computer Science San Jose State University Spring 2016 Instructor: Ron Mak.
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
Chapter 7 PUSHDOWN AUTOMATA.
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 … NPDAs continued

2 Pushing Strings Input symbol Pop symbol Push string

3 top input stack Push pushed string Example:

4 Another NPDA example NPDA

5 Time 0 Input current state Stack Execution Example:

6 Time 1 Input Stack

7 Time 3 Input Stack

8 Time 4 Input Stack

9 Time 5 Input Stack

10 Time 6 Input Stack

11 Time 7 Input Stack

12 Time 8 Input Stack accept

13 Formalities for NPDAs

14 Transition function:

15 Transition function:

16 Formal Definition Non-Deterministic Pushdown Automaton NPDA States Input alphabet Stack alphabet Transition function Final states Stack start symbol

17 Instantaneous Description Current state Remaining input Current stack contents

18 Input Stack Time 4: Example:Instantaneous Description

19 Input Stack Time 5: Example:Instantaneous Description

20 We write: Time 4 Time 5

21 A computation:

22 For convenience we write:

23 Formal Definition Language of NPDA : Initial state Final state

24 Example: NPDA :

25 NPDA :

26 NPDA : Therefore:

27 NPDAs Accept Context-Free Languages

28 Context-Free Languages (Grammars) Languages Accepted by NPDAs Theorem:

29 Context-Free Languages (Grammars) Languages Accepted by NPDAs Proof - Step 1: Convert any context-free grammar to a NPDA with:

30 Context-Free Languages (Grammars) Languages Accepted by NPDAs Proof - Step 2: Convert any NPDA to a context-free grammar with:

31 Converting Context-Free Grammars to NPDAs

32 An example grammar: What is the equivalent NPDA?

33 Grammar: NPDA:

34 The NPDA simulates leftmost derivations of the grammar L(Grammar) = L(NPDA)

35 Grammar: A leftmost derivation:

36 NPDA execution: Input Stack Time 0 current state

37 Input Stack Time 1

38 Input Stack Time 2

39 Input Stack Time 3

40 Input Stack Time 4

41 Input Stack Time 5

42 Input Stack Time 6

43 Input Stack Time 7

44 Input Stack Time 8

45 Input Stack Time 9

46 Input Stack Time 10 accept

47 In general: Given any grammar We can construct a NPDA With

48 Constructing NPDA from grammar : For any production For any terminal

49 Grammar generates string if and only if NPDA accepts

50 Therefore: For any context-free language there is an NPDA that accepts the same language

51 Converting NPDAs to Context-Free Grammars

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

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

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

55 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

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

57 Example of a NPDA in correct form:

58 The Grammar Construction In grammar : Terminals: Input symbols of NPDA states Stack symbol Variables:

59 For each transition We add production

60 For each transition We add production For all states

61 Start Variable: Stack bottom symbol Start state final state

62 Example: Grammar production:

63 Example: Grammar productions:

64 Example: Grammar production:

65 Resulting Grammar:

66

67 Derivation of string

68 In general, in Grammar: if and only if is accepted by the NPDA

69 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