costas busch - rpi1 npdas accept context-free languages

Download Costas Busch - RPI1 NPDAs Accept Context-Free Languages

Post on 19-Dec-2015

213 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

  • Slide 1
  • Costas Busch - RPI1 NPDAs Accept Context-Free Languages
  • Slide 2
  • Costas Busch - RPI2 Context-Free Languages (Grammars) Languages Accepted by NPDAs Theorem:
  • Slide 3
  • Costas Busch - RPI3 Context-Free Languages (Grammars) Languages Accepted by NPDAs Proof - Step 1: Convert any context-free grammar to a NPDA with:
  • Slide 4
  • Costas Busch - RPI4 Context-Free Languages (Grammars) Languages Accepted by NPDAs Proof - Step 2: Convert any NPDA to a context-free grammar with:
  • Slide 5
  • Costas Busch - RPI5 Converting Context-Free Grammars to NPDAs Proof - step 1
  • Slide 6
  • Costas Busch - RPI6 to an NPDA automaton We will convert any context-free grammar Such that: Simulates leftmost derivations of
  • Slide 7
  • Costas Busch - RPI7 Input processed Stack contents Input Stack leftmost variable Leftmost derivation Simulation of derivation
  • Slide 8
  • Costas Busch - RPI8 Input Stack Leftmost derivation Simulation of derivation string of terminals end of input is reached
  • Slide 9
  • Costas Busch - RPI9 An example grammar: What is the equivalent NPDA?
  • Slide 10
  • Costas Busch - RPI10 Grammar: NPDA:
  • Slide 11
  • Costas Busch - RPI11 Grammar: A leftmost derivation:
  • Slide 12
  • Costas Busch - RPI12 Input Stack Time 0 Derivation:
  • Slide 13
  • Costas Busch - RPI13 Input Stack Time 0 Derivation:
  • Slide 14
  • Costas Busch - RPI14 Input Stack Time 1 Derivation:
  • Slide 15
  • Costas Busch - RPI15 Input Stack Time 2 Derivation:
  • Slide 16
  • Costas Busch - RPI16 Input Stack Time 3 Derivation:
  • Slide 17
  • Costas Busch - RPI17 Input Stack Time 4 Derivation:
  • Slide 18
  • Costas Busch - RPI18 Input Stack Time 5 Derivation:
  • Slide 19
  • Costas Busch - RPI19 Input Stack Time 6 Derivation:
  • Slide 20
  • Costas Busch - RPI20 Input Stack Time 7 Derivation:
  • Slide 21
  • Costas Busch - RPI21 Input Stack Time 8 Derivation:
  • Slide 22
  • Costas Busch - RPI22 Input Stack accept Time 9 Derivation:
  • Slide 23
  • Costas Busch - RPI23 In general: Given any grammar We can construct a NPDA With
  • Slide 24
  • Costas Busch - RPI24 Constructing NPDA from grammar : For any production For any terminal
  • Slide 25
  • Costas Busch - RPI25 Grammar generates string if and only if NPDA accepts
  • Slide 26
  • Costas Busch - RPI26 Therefore: For any context-free language there is a NPDA that accepts the same language Context-Free Languages (Grammars) Languages Accepted by NPDAs
  • Slide 27
  • Costas Busch - RPI27 Converting NPDAs to Context-Free Grammars Proof - step 2
  • Slide 28
  • Costas Busch - RPI28 For any NPDA we will construct a context-free grammar with
  • Slide 29
  • Costas Busch - RPI29 Intuition:The grammar simulates the machine A derivation in Grammar : Current configuration in NPDA Input processedStack contents terminalsvariables
  • Slide 30
  • Costas Busch - RPI30 Some Necessary Modifications Modify (if necessary) the NPDA so that: 1) The stack is never empty 2) It has a single final state and empties the stack when it accepts a string 3) Has transitions in a special form
  • Slide 31
  • Costas Busch - RPI31 1)Modify the NPDA so that the stack is never empty Stack OK NOT OK
  • Slide 32
  • Costas Busch - RPI32 Introduce the new symbol to denote the bottom of the stack
  • Slide 33
  • Costas Busch - RPI33 Original NPDA At the beginning push into the stack original initial state new initial state
  • Slide 34
  • Costas Busch - RPI34 In transitions: replace every instance of with Example:
  • Slide 35
  • Costas Busch - RPI35 if the automaton attempts to pop or replace it will halt Convert all transitions so that:
  • Slide 36
  • Costas Busch - RPI36 $$ , Convert transitions as follows: halting state
  • Slide 37
  • Costas Busch - RPI37 NPDA , Empty the stack 2) Modify the NPDA so that it empties the stack and has a unique final state , , Old final states
  • Slide 38
  • Costas Busch - RPI38 3) modify the NPDA so that transitions have the following forms: OR
  • Slide 39
  • Costas Busch - RPI39 Convert:
  • Slide 40
  • Costas Busch - RPI40 Convert: symbols
  • Slide 41
  • Costas Busch - RPI41 Convert: symbols Convert recursively
  • Slide 42
  • Costas Busch - RPI42 Example of a NPDA in correct form:
  • Slide 43
  • Costas Busch - RPI43 The Grammar Construction In grammar : Terminals: Input symbols of NPDA states Stack symbol Variables:
  • Slide 44
  • Costas Busch - RPI44 For each transition We add production
  • Slide 45
  • Costas Busch - RPI45 For each transition We add productions For all possible states in the automaton
  • Slide 46
  • Costas Busch - RPI46 Start Variable: Stack bottom symbol Start state final state
  • Slide 47
  • Costas Busch - RPI47 Example: Grammar production:
  • Slide 48
  • Costas Busch - RPI48 Example: Grammar productions:
  • Slide 49
  • Costas Busch - RPI49 Example: Grammar production:
  • Slide 50
  • Costas Busch - RPI50 Resulting Grammar:
  • Slide 51
  • Costas Busch - RPI51
  • Slide 52
  • Costas Busch - RPI52 Derivation of string
  • Slide 53
  • Costas Busch - RPI53 In general: if and only if the NPDA goes from to by reading string and the stack doesnt change below and then is removed from stack
  • Slide 54
  • Costas Busch - RPI54 Therefore: if and only if is accepted by the NPDA
  • Slide 55
  • Costas Busch - RPI55 Therefore: For any NPDA there is a context-free grammar that accepts the same language Context-Free Languages (Grammars) Languages Accepted by NPDAs
  • Slide 56
  • Costas Busch - RPI56 Deterministic PDA DPDA
  • Slide 57
  • Costas Busch - RPI57 Deterministic PDA: DPDA Allowed transitions: (deterministic choices)
  • Slide 58
  • Costas Busch - RPI58 Allowed transitions: (deterministic choices)
  • Slide 59
  • Costas Busch - RPI59 Not allowed: (non deterministic choices)
  • Slide 60
  • Costas Busch - RPI60 DPDA example
  • Slide 61
  • Costas Busch - RPI61 The language is deterministic context-free
  • Slide 62
  • Costas Busch - RPI62 Definition: A language is deterministic context-free if there exists some DPDA that accepts it
  • Slide 63
  • Costas Busch - RPI63 Example of Non-DPDA (NPDA)
  • Slide 64
  • Costas Busch - RPI64 Not allowed in DPDAs
  • Slide 65
  • Costas Busch - RPI65 NPDAs Have More Power than DPDAs
  • Slide 66
  • Costas Busch - RPI66 Deterministic Context-Free Languages (DPDA) Context-Free Languages NPDAs Since every DPDA is also a NPDA It holds that:
  • Slide 67
  • Costas Busch - RPI67 We will actually show: We will show that there exists a context-free language which is not accepted by any DPDA Deterministic Context-Free Languages (DPDA) Context-Free Languages (NPDA)
  • Slide 68
  • Costas Busch - RPI68 The language is: We will show: is context-free is not deterministic context-free
  • Slide 69
  • Costas Busch - RPI69 Language is context-free Context-free grammar for :
  • Slide 70
  • Costas Busch - RPI70 is not deterministic context-free Theorem: The language (there is no DPDA that accepts )
  • Slide 71
  • Costas Busch - RPI71 Proof: Assume for contradiction that is deterministic context free Therefore: there is a DPDA that accepts
  • Slide 72
  • Costas Busch - RPI72 DPDA with accepts
  • Slide 73
  • Costas Busch - RPI73 DPDA with Such a path exists because of the determinism
  • Slide 74
  • Costas Busch - RPI74 The language is not context-free (we will prove this at a later class using pumping lemma for context-free languages) Fact 1: Regular languages Context-free languages
  • Slide 75
  • Costas Busch - RPI75 The language is not context-free Fact 2: (we can prove this using pumping lemma for context-free languages)
  • Slide 76
  • Costas Busch - RPI76 We will construct a NPDA that accepts: which is a contradiction!
  • Slide 77
  • Costas Busch - RPI77 Modify Replace with
  • Slide 78
  • Costas Busch - RPI78 The NPDA that accepts Connect final states of w

Recommended

View more >