Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
41 views27 pages

PDA Unit 5

Pda automata

Uploaded by

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

PDA Unit 5

Pda automata

Uploaded by

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

PUSH DOWN AUTOMATA

Definition of DPDA and NPDA with example

• Let M = (Q,∑,Γ,q0, Z,F ,δ) be a PDA. The PDA is


deterministic if and only if
• δ(q, a, Z) has one element.
• In DPDA For every input with the current
state, there is only one move.
• Both conditions should be satisfied for the
PDA to be deterministic. If one of the
conditions fails, the PDA is non-deterministic.
Example: Is the PDA corresponding to the language L = {anbn | n>=1} by the
finite state is deterministic ?

• Solution: The shown transitions defined for this machine are shown
below:
• δ(q0, a, Z0) =δ(q0, aZ0)
δ(q0, a, a) =δ(q0, aa)
δ(q0, b, a) =δ(q1, ∈)
δ(q1, b, a) =δ(q1, ∈)
δ(q1, ∈, Z0) =δ(qf, ∈)
The PDA should satisfy the two conditions. shown in the definition to be
deterministic.
• δ(q0, a, Z0) has only one element. In this case, for each q∈Q, a∈∑ , and
Z∈Γ, there exists only one definition so the first condition is satisfied.
• since both conditions. are satisfied, then the given PDA is deterministic
Difference between NPDA and DPDA

DPDA(Deterministic Pushdown NPDA(Non-deterministic Pushdown


Automata) Automata)
It is less powerful than NPDA. It is more powerful than DPDA.
It is possible to convert every DPDA to a It is not possible to convert every NPDA to
corresponding NPDA. a corresponding DPDA.
The language accepted by DPDA is a The language accepted by NPDA is not a
subset of the language accepted by NDPA. subset of the language accepted by DPDA.
The language accepted by DPDA is called The language accepted by NPDA is called
DCFL(Deterministic Context-free NCFL(Non-deterministic Context-free
Language) which is a subset of NCFL(Non- Language).
deterministic Context-free Language)
accepted by NPDA.
Why NPDA is more powerful than DPDA?

• NDPA is more powerful than DPDA because we can add more


transitions to it. It is possible for every language to add a transition.
For some languages, we can construct DPDA there exist an NPDA
but there are some languages that are accepted by NPDA but are
not by DPDA. This is said to be powerful when it accepts more sets
of languages than other automata.
• In fact, it is more powerful than DFA(Deterministic finite automata)
and NFA(Non-deterministic finite automata) also because, In the
case of DFA and NFA, they are equivalent in power. So for every
language accepted by DFA there exist an NFA and Vice-Versa. There
is not any language for which we construct NFA but not DFA.
Hence, we can’t convert NPDA to DPDA always and we can convert
NFA to equivalent DFA always
CFG to PDA Conversion

• The first symbol on R.H.S. production must be a terminal


symbol. The following steps are used to obtain PDA from CFG is:
• Step 1: Convert the given productions of CFG into GNF.
• Step 2: The PDA will only have one state {q}.
• Step 3: The initial symbol of CFG will be the initial symbol in the
PDA.
• Step 4: For non-terminal symbol, add the following rule:
δ(q, ε, A) = (q, α)
• Where the production rule is A → α
• Step 5: For each terminal symbols, add the following rule:
δ(q, a, a) = (q, ε) for every terminal symbol
• Convert the following grammar to a PDA that
accepts the same language.
• S → 0S1 | A
• A → 1A0 | S | ε
• Solution:
• The CFG can be first simplified by eliminating unit productions:
S → 0S1 | 1S0 | ε
• Now we will convert this CFG to GNF:
• S → 0SX | 1SY | ε
• X→1
• Y→0
• The PDA can be:
• R1: δ(q, ε, S) = {(q, 0SX) | (q, 1SY) | (q, ε)}
R2: δ(q, ε, X) = {(q, 1)}
R3: δ(q, ε, Y) = {(q, 0)}
R4: δ(q, 0, 0) = {(q, ε)}
R5: δ(q, 1, 1) = {(q, ε)}
Example 2:

• Construct PDA for the given CFG, and test whether


010000 is acceptable by this PDA.
• S → 0BB
• B → 0S | 1S | 0
• Solution:
• The PDA can be given as:
• A = {(q), (0, 1), (S, B, 0, 1), δ, q, S, ?}
• The production rule δ can be:
• R1: δ(q, ε, S) = {(q, 0BB)} R2: δ(q, ε, B) = {(q, 0S) | (q, 1S) |
(q, 0)} R3: δ(q, 0, 0) = {(q, ε)} R4: δ(q, 1, 1) = {(q, ε)}
• δ(q, 010000, S) ⊢ δ(q, 010000, 0BB)
• ⊢ δ(q, 10000, BB) R1
• ⊢ δ(q, 10000,1SB) R3
• ⊢ δ(q, 0000, SB) R2
• ⊢ δ(q, 0000, 0BBB) R1
• ⊢ δ(q, 000, BBB) R3
• ⊢ δ(q, 000, 0BB) R2
• ⊢ δ(q, 00, BB) R3
• ⊢ δ(q, 00, 0B) R2
• ⊢ δ(q, 0, B) R3
• ⊢ δ(q, 0, 0) R2
• ⊢ δ(q, ε) R3
Closure Properties of Context Free Languages

• Context Free Languages (CFLs) are accepted by pushdown automata. Context free languages can be
generated by context free grammars, which have productions (substitution rules) of the form : A -> ρ
(where A ∈ N and ρ ∈ (T ∪ N)* and N is a non-terminal and T is a terminal)
• Properties of Context Free Languages
Union : If L1 and L2 are two context free languages, their union L1 ∪ L2 will also be context free. For
example,
L1 = { anbncm | m >= 0 and n >= 0 } and L2 = { anbmcm | n >= 0 and m >= 0 }
L3 = L1 ∪ L2 = { anbncm ∪ anbmcm | n >= 0, m >= 0 } is also context free.
L1 says number of a’s should be equal to number of b’s and L2 says number of b’s should be equal to
number of c’s. Their union says either of two conditions to be true. So it is also context free language.
• Note: So CFL are closed under Union.

Concatenation : If L1 and If L2 are two context free languages, their concatenation L1.L2 will also be
context free. For example,
L1 = { anbn | n >= 0 } and L2 = { cmdm | m >= 0 }
L3 = L1.L2 = { anbncmdm | m >= 0 and n >= 0} is also context free.
L1 says number of a’s should be equal to number of b’s and L2 says number of c’s should be equal to
number of d’s. Their concatenation says first number of a’s should be equal to number of b’s, then
number of c’s should be equal to number of d’s. So, we can create a PDA which will first push for a’s, pop
for b’s, push for c’s then pop for d’s. So it can be accepted by pushdown automata, hence context free.
• Kleene Closure : If L1 is context free, its Kleene closure L1* will also be context free. For
example,
L1 = { anbn | n >= 0 }
L1* = { anbn | n >= 0 }* is also context free.
• Note :So CFL are closed under Kleen Closure.

Intersection and complementation : If L1 and If L2 are two context free languages,
their intersection L1 ∩ L2 need not be context free. For example,
L1 = { anbncm | n >= 0 and m >= 0 } and L2 = (ambncn | n >= 0 and m >= 0 }
L3 = L1 ∩ L2 = { anbncn | n >= 0 } need not be context free.
L1 says number of a’s should be equal to number of b’s and L2 says number of b’s
should be equal to number of c’s. Their intersection says both conditions need to be
true, but push down automata can compare only two. So it cannot be accepted by
pushdown automata, hence not context free.
Similarly, complementation of context free language L1 which is ∑* – L1, need not be
context free.
• Note : So CFL are not closed under Intersection and Complementation.

You might also like