0% found this document useful (0 votes)
176 views8 pages

Term-Paper of Formal Languages and Automation Theory: Faisal Hussian Shah

This document summarizes pushdown automata (PDA). It defines a PDA as a finite automaton with a stack-based memory. Each PDA transition pops and/or pushes symbols from the stack based on the current input symbol and top of stack. PDAs can recognize balanced strings over {0,1} by pushing 0s and popping matching 1s. Formally, a PDA is a 7-tuple with states, alphabets, transitions, and an initial/final state. The language of a PDA is the strings it accepts. PDAs and context-free grammars have equivalent power. Deterministic PDAs have at most one transition per state/input/stack combination while nondeterministic PD

Uploaded by

REAL world
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views8 pages

Term-Paper of Formal Languages and Automation Theory: Faisal Hussian Shah

This document summarizes pushdown automata (PDA). It defines a PDA as a finite automaton with a stack-based memory. Each PDA transition pops and/or pushes symbols from the stack based on the current input symbol and top of stack. PDAs can recognize balanced strings over {0,1} by pushing 0s and popping matching 1s. Formally, a PDA is a 7-tuple with states, alphabets, transitions, and an initial/final state. The language of a PDA is the strings it accepts. PDAs and context-free grammars have equivalent power. Deterministic PDAs have at most one transition per state/input/stack combination while nondeterministic PD

Uploaded by

REAL world
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

TERM-PAPER OF FORMAL

LANGUAGES AND AUTOMATION


THEORY

NAME:- Faisal Hussian Shah


SECTION:- D1910
ROLLNO:- 05
REGISTRATION NO:- 11908350
SUBMITTED TO:- PALLAVI
TOPIC:- Pushdown Automata
Pushdown Automata

● A pushdown automaton (PDA) is a finite automaton equipped with a stack-


based memory.
● Each transition
● is based on the current input symbol and the top of the stack,
● optionally pops the top of the stack, and
● optionally pushes new symbols onto the stack.
● Initially, the stack holds a special symbol Z0 that indicates the bottom of the
stack.

Our First PDA

● Consider the language L = { w ∈ Σ* | w is a string of balanced digits } over Σ =


{ 0, 1 }
● We can exploit the stack to our advantage:
● Whenever we see a 0, push it onto the stack.
● Whenever we see a 1, pop the corresponding 0 from the stack (or fail if not
matched)
● When input is consumed, if the stack is empty, accept.
A Simple Pushdown Automaton

A Simple Pushdown Automaton


TUPLES OF Pushdown Automata

● Formally, a pushdown automaton is a nondeterministic machine


defined by the 7-tuple (Q, Σ, Γ, δ, q0 , Z0 , F), where
● Q is a finite set of states,
● Σ is an alphabet,
● Γ is the stack alphabet of symbols that can be pushed on the stack,
● δ : Q × Σε × Γ ε → (Q × Γ*) is the ℘ transition function, where no
tuple is mapped to an infinite set,
● q0 ∈ Q is the start state,
● Z0 ∈ Γ is the stack start symbol, and
● F ⊆ Q is the set of accepting states.
● The automaton accepts if it ends in an accepting state with no
input remaining

The Language of a PDA

● The language of a PDA is the set of strings that the PDA accepts:
ℒ(P) = { w ∈ Σ* | P accepts w }
● If P is a PDA where ( ℒ P) = L, we say that P recognizes L.

A Note on Terminology
● Finite automata are highly standardized.
● There are many equivalent but different definitions of PDAs.
● The one we will use is a slight variant on the one described in
Sipser.
● Sipser does not have a start stack symbol.
● Sipser does not allow transitions to push multiple symbols onto the
stack.
● Feel free to use either this version or Sipser's; the two are
equivalent to one another.

Push-down Automata and Context-Free


Languages
Lemma 1.1 (3.4.1) L The class of languages recognized by push-down
automata is the same as the class of context-free languages. This result is
interesting because sometimes it is easier to see how to construct a push-
down automaton than a context-free language. Also, pda are helpful for
parsing cfl.
Given a context-free grammar G = (V, Σ, R, S), one can construct a pushdown
automaton M such that L(M) = L(G) as follows:
M = ({p, q}, Σ, V, ∆, p, {q}) where ∆ has the rules
(1) ((p, ǫ, ǫ),(q, S))
(2) ((q, ǫ, A),(q, x)) if A → x is in R (do leftmost derivation on the stack)
(3) ((q, a, a),(q, ǫ)) for each a ∈ Σ (remove matched symbols)
Here is an example of this construction. Consider the grammar G given by the
following rules:
S → aSb
S→ǫ
Then the push-down automaton M has the following transitions:
(1) ((p, ǫ, ǫ),(q, S))
(2) ((q, ǫ, S),(q, aSb)) from S → aSb
((q, ǫ, S),(q, ǫ)) from S → ǫ
(3) ((q, a, a),(q, ǫ)) because a ∈ Σ
((q, b, b),(q, ǫ)) because b ∈ Σ
We note that aabb ∈L(G) by the derivation
S ⇒ aSb ⇒ aaSbb ⇒ aabb
Corresponding to this there is the following accepting computation of the
push-down automaton M:
(p, aabb, ǫ) ⊢ (q, aabb, S) ⊢ (q, aabb, aSb) ⊢ (q, abb, Sb) ⊢ (q, abb, aSbb) ⊢ (q,
bb, Sbb) ⊢ (q, bb, bb) ⊢ (q, b, b) ⊢ (q, ǫ, ǫ)
For this derivation, for all configurations in the state q,
• the part of the input already read,
• followed by the stack,
• is always derivable from the start symbol,
so that one can always recover a cfg derivation from a pda computation. In this
case we obtain the following sequence from the pda computation:
S, aSb, a : Sb, a : aSbb, aa : Sbb, aa : bb, aab : b, aabb : ǫ
where the colon separates the part already read from the stack. In general,
• it is possible to convert any context-free derivation in G into a computation
on the pda M in this way, and back,
• so that L(M) = L(G)
The same construction works for any context-free grammar G, showing that
every context-free language can be recognized by some push-down automaton
The reverse direction of the proof, going from a push-down automaton to a
context-free grammar, is much harder, and the main part of the argument is
given in Lemma 3.4.2 of the text.
Lemma 1.2 (3.4.2) If a language is recognized by a push-down automaton, then
it is a context-free language. The basic idea of the proof is to construct a
context-free grammar G from a push-down automaton M, satisfying L(G) =
L(M).
• The nonterminals of G are triples of the form hq, A, pi where q and p are
states of M and A is a stack symbol or ǫ. • Then G has productions
guaranteeing that hq, A, pi ⇒∗ x if and only if (q, x, A) ⊢ ∗ M (p, e, e) where (q,
x, A) and (p, e, e) are configurations of M and ⊢ is the “yields” relation.
• Intuitively, the nonterminal hq, A, pi derives x if the push-down automata
can remove A from the stack while reading x and going from state q to state p.
The context-free grammar G has
• productions of the form hq, B, pi → ahr, C, pi for all states p ∈ K and for each
transition of M of the form ((q, a, B),(r, C)), and
• productions of the form hq, B, pi → ahr, C1, p′ ihp ′ , C2, pi for all p, p′ ∈ K
and for each transition of M of the form ((q, a, B),(r, C1C2)).
Intuitively, to remove B from the stack, one can first put C1C2 on the stack,
then remove C1, then remove C2, or one can put C on the stack and then
remove it.
This proof is more complicated than lemma 3.4.1 because context-free
grammars are simple but push-down automata are complex. It is easier to
simulate something simple by something complex, as in lemma 3.4.1, but
harder to simulate something complex by something simple, as in lemma 3.4.2

Deterministic Pushdown Automata and


non-deterministic Pushdown Automata

● With finite automata, we considered both deterministic (DFAs) and


nondeterministic (NFAs) automata.
● So far, we've only seen nondeterministic PDAs (or NPDAs).
● What about deterministic PDAs (DPDAs)?
Deterministic Pushdown Automaton

● A deterministic pushdown automaton is a PDA with the extra property that


For each state in the PDA, and for any combination of a current input symbol
and a current stack symbol, there is at most one transition defined.
● In other words, there is at most one legal sequence of transitions that can be
followed for any input.
● This does not preclude ε-transitions, as long as there is never a conflict
between following the ε-transition or some other transition.
● However, there can be at most one ε-transition that could be followed at any
one time.
● This does not preclude the automaton “dying” from having no transitions
defined; DPDAs can have undefined transitions.

The Power of Nondeterminism


● When dealing with finite automata, there is no difference in the power of
NFAs and DFAs.
● However, when dealing with PDAs, there are CFLs that can be recognized by
NPDAs that cannot be recognized by DPDAs.
● Simple example: The language of palindromes.
● How do you know when you've read half the string?
● NPDAs are more powerful than DPDAs.

You might also like