Equivalence of Pushdown Automata with Context-Free Grammar
Equivalence of Pushdown Automata with Context-Free Grammar – p.1/45
Equivalence of Pushdown Automata with Context-Free Grammar - - PowerPoint PPT Presentation
Equivalence of Pushdown Automata with Context-Free Grammar Equivalence of Pushdown Automata with Context-Free Grammar p.1/45 Motivation CFG and PDA are equivalent in power: a CFG generates a context-free language and a PDA
Equivalence of Pushdown Automata with Context-Free Grammar – p.1/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.2/45
that recognizes it
then there is a CFG
☎ ✂that generates
Equivalence of Pushdown Automata with Context-Free Grammar – p.3/45
, that generates it
into a PDA
✁that accepts strings
✂if
☎generates
✂3.
✁will work by determining a derivation of
✂.
Equivalence of Pushdown Automata with Context-Free Grammar – p.4/45
is a sequence of substitutions
✟ ✠☛✡ ☞ ✌✎✍ ✂✑✏ ✒✑✡ ☞ ✓ ✍✕✔ ✔ ✔ ✖ ✡ ☞ ✗ ✍ ✂,
✟ ✘ ✙ ✏✛✚,
✟ ✚not necessarily distinguished
variables and terminals
will determine whether some series of substitutions using rules in
✥can lead from start variable
✟to
✂Equivalence of Pushdown Automata with Context-Free Grammar – p.5/45
At each step of the derivation one of the rules for a particular variable is selected nondeterministically.
begins by writing the start variable on the stack and then continues working this string.
Equivalence of Pushdown Automata with Context-Free Grammar – p.6/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.7/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.8/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.9/45
$ A 1 A stack
✄Control
☎1 1 1 Input 0 1 A 1 A 0 Intermediate string
✆ ✝ ✞ ✝ ✟ ✠ ✡ ✡ ✡ ✡ ✡ ✡ ✡ ✡ ✡ ☛ ☞✌ ✍✏✎ ✑✓✒ ✔Equivalence of Pushdown Automata with Context-Free Grammar – p.10/45
nondeterministically select a rule
substitute
.
, read the next input symbol and compare it with
✟. If they match pop the stack; if they don’t match reject on this branch of nondeterminism
accept state: if all text has been read accept, otherwise reject.
until accept or reject
Equivalence of Pushdown Automata with Context-Free Grammar – p.11/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.12/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.13/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.14/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.15/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.16/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.17/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.18/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.19/45
for terminal
✌ ☞ ✄ ✝ ✆ ☛for rule
✝ ✆ ☛ ✂ ☞ ✄ ✝ ✆ ☞ ☞ ✌ ✍ ✎ ✁ ✄✏ ✏✑ ✡ ✂Equivalence of Pushdown Automata with Context-Free Grammar – p.20/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.21/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.22/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.23/45
and want to construct a CFG
☎that generates all strings recognized by
✁.
to do somewhat more: For each pair of states
☎ ✚ ✂ ✤will have a variable
that generates all strings that can take
✁from
☎with an empty stack to
✂with an empty stack. Assume that
☎ ✞ ✝ ✂ ✆ ✠. Then
is the start symbol of the grammar
Note: such strings can take
✁from
☎to
✂regardless of stack contents at
☎, leaving the stack at
✂the same as it was at
☎Equivalence of Pushdown Automata with Context-Free Grammar – p.24/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.25/45
add a new state say
✂ ✆to
the set of final states, and add the new tranbsitions:
just add the transitions:
where
✂ ✄is a new reject-state in
Equivalence of Pushdown Automata with Context-Free Grammar – p.26/45
a two transitions sequence that goes through a new state;
with a two transitions sequence that pushes and then pops an arbitrary stack symbol See Figure 5
Equivalence of Pushdown Automata with Context-Free Grammar – p.27/45
by by
Replace
Replace
Equivalence of Pushdown Automata with Context-Free Grammar – p.28/45
1.
✁’s first move on
✍must be a push, because each move is either a push or a pop, and the stack is empty.
’s computation on
✍: (a) symbol popped at the end is the symbol pushed at the beginning; (b) symbol popped at the end is not the symbol pushed at the beginning
Equivalence of Pushdown Automata with Context-Free Grammar – p.29/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.30/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.31/45
,
✟ ✚ ✁ ✤ ✁☎✄, if
✆(i.e.,
☎ ✆✝✆ ✄ ✡ ✟(i.e.,
✄ ✞ ✆ ✟ ✡ ✄) then put
in
✥in
✥in
✥Figures 6 and 7 provide the intuition of this construction
Equivalence of Pushdown Automata with Context-Free Grammar – p.32/45
Input string
(0,0)
✄generated by
✝ ✡ ☎generated by
✝ ☎ ✁Equivalence of Pushdown Automata with Context-Free Grammar – p.33/45
Input string
(0,0)
✄string generated by
✝ ☎Equivalence of Pushdown Automata with Context-Free Grammar – p.34/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.35/45
contains no variables
whose
contain no variables are
takes
✁from
☎with empty stack to
☎with empty stack
Equivalence of Pushdown Automata with Context-Free Grammar – p.36/45
with
☎ ✂ ✄is either
portion of
✍generated by
, i.e.,
✍ ✞ ✟ ✎ ✁.
with
☎steps, induction hypothesis tells us that
✁can go from
with empty stack
, it follows that
✆(
☎ ✆✝✆ ✄ ✡ ✟ ✘(
✄ ✞ ✆ ✟ ✡ ✄ ✘ ✂)
Equivalence of Pushdown Automata with Context-Free Grammar – p.37/45
starts at
☎with empty stack, after reading
✟it can go to
it can go to
✄and leave
✁, because
✆ ✂ ✚ ✁ ✝ ✤ ✆ ✆ ✄ ✚ ✁ ✚ ✁ ✝, after reading
✁can go to state
✂and pop
✁brings
✁from
☎to
✂with an empty stack
Equivalence of Pushdown Automata with Context-Free Grammar – p.38/45
and
✏that are generated by
and
, respectively, i.e.,
✍ ✞ ✎ ✏,
,
.
and
are derivations containing at most
☎steps,
✎and
✏respectively bring
✁from
☎to
respectively, with empty stack
can bring
✁from
☎to
✂with empty stack.
Equivalence of Pushdown Automata with Context-Free Grammar – p.39/45
.
in
has only time to read the empty string, i.e.,
✍ ✞ ✁contains the rule
, hence
Equivalence of Pushdown Automata with Context-Free Grammar – p.41/45
Two cases: Case a:
✁has a computation of length
☎ ✂ ✄wherein
✍brings
✁from
☎to
✂with empty stack.
Case b:
✁has a computation of length
☎ ✂ ✄wherein the stack is empty at the begin and end, and stacks may become empty also during computation
Equivalence of Pushdown Automata with Context-Free Grammar – p.42/45
the symbol popped at the last move. Let it be
✁be the input read in the first move,
✁the input read at the last move,
be the state before the last move
and
✆✄✂ ✚ ✁ ✝ ✤ ✆ ✆ ✄ ✚ ✁ ✚ ✁ ✝, and
be the portion of
✍without
✟and
✁, i.e.,
✍ ✞ ✟ ✎ ✁. Using induction we know that
✎brings
✁from
without touching
✁because we can remove the first and the last step of computation, hence
.
Equivalence of Pushdown Automata with Context-Free Grammar – p.43/45
to
, both contain at most
☎steps
be the input read during the computation from
☎to
be the input read during the computation from
and
.
is result that
Equivalence of Pushdown Automata with Context-Free Grammar – p.44/45
Equivalence of Pushdown Automata with Context-Free Grammar – p.45/45