Converting NPDAs to Context-Free Grammars - PowerPoint PPT Presentation

About This Presentation
Title:

Converting NPDAs to Context-Free Grammars

Description:

If and only if. in the NPDA going from to. the stack doesn't change below ... A fact: 38. Another fact: The language. is not context-free. 39 ... – PowerPoint PPT presentation

Number of Views:85
Avg rating:3.0/5.0
Slides: 44
Provided by: costas
Learn more at: http://www.cs.rpi.edu
Category:

less

Transcript and Presenter's Notes

Title: Converting NPDAs to Context-Free Grammars


1
Converting NPDAstoContext-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
A derivation in Grammar
terminals
variables
Input processed
Stack contents
in NPDA
5
Some Necessary Modifications
  • First, we modify the NPDA
  • It has a single final state
  • It empties the stack
  • when it accepts the input

Empty Stack
Original NPDA
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
stack symbol
In grammar variables have form
states
Terminals are input symbols
9
For each transition
We add production
For all states
10
For each transition
We add production
For all states in the NPDA
11
Stack bottom symbol
Start Variable
Start state
final state
12
Example
Grammar production
13
Example
Grammar productions
14
Example
Grammar production
15
Resulting Grammar
16
(No Transcript)
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
doesnt 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 thanDPDAs

31
We will show
There is
(accepted by a NPDA)
a context-free language
which is not
(not accepted by a DPDA)
deterministic context-free
32
The language is
33
The language is context-free
Context-free grammar for
(there is an NPDA that accepts )
34
Theorem
The language
is not deterministic context-free
(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
accepts
37
A fact
The language
is not context-free
(we will prove it at the next class)
38
Another fact
The language
is not context-free
39
We will construct a NPDA that accepts
40
First, we modify
Replace with
Modified
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
Write a Comment
User Comments (0)
About PowerShow.com