Module-3
Module-3
t"lOd^r.l-t _ a
-J; .. i
C'o.ntrrd-- F-tr-u Q ta q)
^M\/\^-l-( C Ce
A crnk'2ut-
rn Ln5+*'cA
t-"- Wrn-.a+Cut ffi,!ft\o+ 1) tn be a-
cFq)
e4cA A/,.r,- vradt :
J- lto"^' o' l'+t-k4^d
$'d4 ft\6,J r{ a* sr..r?(. *i,-1
E ^,crr*er
Jg h rr.c- o-
hff*- l'4*d U.a* w L
O-\t eL o{- t-'QJ-'"; 4, M r-',, lar,."^r,-.-,
.A?f
.-ry,ftva 9' ( v, r,, P,S )
=1g/
r(sla):
'
Ir V
S -: or[z IJ;j
S
fo^"t"|
&1z,; cL b nz^tt-h tj|^y &rn-? n ot| t
o&re*gr r,-fl-hDn^4-(
u,, €= C {,T, | ,s)
^
V=fr,Aj
t(r, q.) :A r=fa)
, ', etaA P =f ( a o'=,-
A1 a;.f L
ECA,q)= I
A + a..* S t.r S"}a*
ry^b*ol ,
F_4 L
O6ldr^ q.
Wff)nloutv
S e,,rr' a's
w ^8 "fr
q= Cu,r, p,s)
6(s,o.)=A v= f s,&
S+a* r=
{q?
S-;t P=f s.arylz
tCe,a):f
A +af s
6L.lz 'n a qMqrv-.A,9.-
U
bo -aJ&. * ,tr c"$^$i tL,-6^ t
t^a,^^rlpul 0+ t^
-D v.1 A',s
B1
@ 9 a ora4g
'6.
v= f j
r= l^T
CV.L p, s)
g
P=? s cq *slt-?
( v s4ur-F $a^+u'. ,i
4,b
S4g
5+ a,s
S+bS
StLlas
li -E-'i'--4fu*|-grL
-
I:-+ q,-&.
a-A
r_____-__
I
"_._\-z___\Z_ -V. ,, _A_:, q_&
Sl a,*
Ara a.B
(t-{rf F,6.,^L Dt
(
no r.^.lll* b LgN
Q-r*-rr. f','l^n-bll- -
g+t.
9+a-A
A-, qS
w
b
V= s*
{a
O\ft
A-+ as
S el St&" .JA,
^elrv^
A-
tL+A"-t mrrvJ- W
V\r\riltibl4-l/
e, *> gl oto.aS
qwa
'.
LiA+a.lsl **AS
u.
'J+P*t)-
9+ t, I hAAj
A+ o,lh? __
W &JrAf 8t 'Ao-l .
9+ bs
344t
_ __& ?_9 1 o'* | U*
.Lvr:r rP-, S )*
y2? s-,!T
-a: La,o7--
+: L_ -9-_a*_f us_
g t__ -lt*_Jt
:"4
t, 8J&'
9a bS
,::
-..-'
t'.*
Su -tl-t {'}d"*
--&:1
avne,s- @--4 T Lti
,L
>O L^gk4ro_ aele+
{-o.f ). 5.ffi
\': l
S+ a-A
V:
9-+ a-Pts
+KL t'h.Lr
li
r,l
Vtr,
,l
.*---
ii ^e
-1i---'F+ffi
ri \
ti
'ii S
-
t-l {Jalf-Afoleo{ '
ge+ft--*as--l
a+D^M
. er(v,r,p s,)
b3__
9;7 hnb
t" qur-s-uJi
---o_
tfr# d+-gir h-o:t
(.b ( q+b)
r/_ J,
-
,i -S-*sbN
T;f a +l
U"t I+^tq
-vce$4;,i:l
f
r/
rt-
6;r. ,."b" '"6.
a
,t.
Lrl
E saJ
^
S -t Sa9aI
9a S 4 J
ev f
'l
,^4 rna.Jt
ftn b: rybe-
.31- gaaSb
-
VT
s )asL
V=
A aa9b L
ct
anb^:
=('v.T p. s
=I-f-qb
-- C tg__$g, s+rd -----U---
q"^^t"l .
LJ-ol1bn, t >,"1--
9+ a9b
a(v,r; ?,s)
LtS a,^b^o\ j A,.iL
aSb
t:: v.1.
V:
S d glatr
\tt b^ *?n>.o
4"oo j&
,na nl4X,
Sabb asb
aJb
9;
o-La,, mrt:\a& fu
a0 b\n
S--: e aS*
;.-
r
s+ L o stb
3U
/=
o& r.-d
J-rslr.
Seg bs5
l.' r"
/*'l;' ,.". ..,..,
q=
S -J a"s
q___+ ^lbsL
il
a gt-|ar-rl a
l/\/sY] .-
-t
i
:i
S --Ws -Wrf'
A
tr
r . a - D
€-,6,-,H,
a t
t-
Le om lYr)
s -->
A+ ol OA
3-+ a
h, fI
(h-tt-
vb+a"t
,,,u) =n *r]
.b a* ^b
JJ
I U^l
^''ts-A
l.
l.I
ili
!;
i>o E ?
- -f-:+Ltlli+,*ao^p:
Tt-\, sl
-A
- oJ o-a
L)
V-$-Sto, 7--+,-'i- =-$ -o ;bI P=fT=#fu
-C ., W)t et"^g"J &abelel 'n
vL+a*t ,f; r.rag.Jl- tb
\2.O r4r24
H),
Y1
=A t1 ?>
q> 1M7.9
L^mbb-t
n>o lO,tt<A
at lzatt b
1bB
!E-C_y.\P, r )_
I:Ls= 3
&pa; rf)
^r\4-q- b'5 9a
b"-
S l oJ,a}
+'.J o++l s 3
De{nmJL'6r,
Af4 -
3cr^^r-
6r A
ry ,{4o oq u,t-etu
FroJq{
o(pt
l ar I a
_4.1+ A--}sL.tL'c
-
-r'fi' - w A F>.
q,*
va -+14 l-ll"A
, .qi*,_ ^Ll
ll
,<dn 4 h.r4-
"c li tz
il
-@n -t..
E -_e-+e
E -+ e-e
L
l, g+ Ex6
gdli;t
- --?:'-' ;- -- - E e-te
:i
'
=> id+€
ii
i:
+
,l
, _....i1r!
ll
ti
=>idtid:-8,
E)idtiAxid
-==-
-+-r 4W
-+r* A ; dgul',.,.Loo S:+<, 11-Ar4*
o^3
d&ei;-h.# 3/n6\^r,)
q,i
_,9 +..^.i^-^trr I
i
ti
_..--:*----.- '-'l
__-_ "._______.t
-l!
-l
ig: -Fhs &-U..^o.l,l*r Frou.rS if a.
1H.-l^'a.^b tr
&-^-i nnrt.' arr L8
q+a; Ui &,tl'-L
E -+ E+E
e+e-e
c .r
4rd+e
-d--i-di-E-t E
a_ j a:ri_d_r_e
id + id + ]d
E 2i d+id *iA .
olo*a,.n Ui ,^{r{} &r^rral.ar> lot -t^* S]L,-C.
:
qbb abbba" r. .
^-
-
E d qBlun
slb 4.
92 bsl.r b
S:+ S-fqA
o
2ao,,g )a
a
=* aa".bb A
b'sarLs ( a4a,
bbo.b g ga b
A-oua. Ab ab bs glbs
:)__ag4Lh_
rulaa$A '.. (+_r g
t*'
Dd
&r"l.ral-'ot, A___Li$f rna_O-e -
Cv<t 3,tiD +l^a/r +"t^<,
--
&fiql^.uo & !..aJd ,tb
+i d* i d t-r.jv}
t bstro,c^f _g&a-*^-l--
6 *E+
e ) Ey€
E+E-E
€+E
E-rid
E+8,*E
=) E + Ex id
9---el4sU
-+ il+la*tJ .
-
L--._--
I'
I
---- - --l!t -:
--tl!*_*oe^ 6k a.
-__ J-tg h"\h_ _{s4rJ_- _s*4. q4JkJ_ d.de;l;"fd;_
ll]4-!
'I
.-_-_.; .__
#li:d'. rr.4'G-a=tnr,p-o
E
/\\
€+ e
/t''.-
ild / \ >-
E- r _€_
t
id
W,*y l:d+id'e-_i/
"."+i._---.
rt_-yiu&=q5
ll
\Ii--*.:u'L
J_r._ _st"? ,S_
--
8^'-
gBJ---D-^ar-f
-c-tr-1*- -Vk aY'. u
l-oJ.-q S
;; \'M h4eh's-"o [turt)L)
!.'.!ra tT Cv-vtr 0 z)
ft q'4 l,rrllrl3-- -xh
ii
1- hl/wlh Ad;.ra.i.'6la'*l-r-
-+|^-tr
^*^I 4d,j@
L.t
cslf^ At drr,:J.,rrl
1€
e r- e
sr-U+
h p r^-e Le tfl!- -
slt
,. t
j! ' I
_-'#
# t'
++q qLs.,a&"
A.
5 hS,^rft bil s\^)
il
------T--
'
__iL -
il
t: -.---
e4e+e
-
T-a e-8.
E4 exg
4 EIE
e4 te
fa id
-*----'rl-r\r-l
'i 4\d+idxtd ?)\44ta*!-q
,,tj'tl
-i+- --
t!.-
---.--T- l. tt -rr I .
'iil_
,,e
_
t'
ju!-4_-8^*-&*tw.
ii id tl4"i4
fu^^*.rl6,\^f,Af -
\'{hW htt^ndt ArLi"&'$t'ftA Y-*.-J
/
yg tKL lO -]na "nff,O-\-
C-anHdr,l- +{+---+^fq
Sh"' Otaar4,
o,g
a,.a g_
)a94=9
d aCI.qq
ll So-,e- L e-.Jl^t^
| *a--.s^r L.e( Ut J- Ii
(8.A na rgge{ t{
c&e*r.Lt 9 a*A' L' t- tJo
v- Cbg*-W@_
liL- {.qtlq u u ------
C rAdJ&- ut
-*: S*-=l ag
- -a 44sB _- -CR AaoB)
-)-aesa-
-\ VbbgL__
- ( enu)
C..\
-g
6.
,[f^.;' il a-'Jt6ur',.-l 4.
i,/
il V
s
B
i 'S eq (s +ds
La"bbs ( go bl"
+4uB( t-to
',J
f^n^^r{ a^,rLt6,,^n-a .
--------:=#=
::-:-::=-=-
I, r tt slt"
H,*I-1,,tv161 Jr'{- ta.na*
I lgrvt vt-
+F-
+t-e-
h 4+* 9ory er+\;
l"-<)6w" te o :6Yl b"^{- b
ol
q rnt]
9o1.t}
.-) G.Bltq
Aa as I b nn-19
ts- bs\+sA! St{-
V!'{- t- |...r-.,,L'q'^,
+A{- ^ ^bb_as!
sAa
A a-a
) agq
rb 4b)
g4b
0'l,,0,-bba;Bg ba
g4b
bb o.bb
T'A^^uA"aUt abt
-S qn".bbqbbb+ S-rbj
w3 *o4
.rn r-r- t g,"--e-
,^ -O{ }- ctJl- - -l Shn-
b a.bbb o. b ^l d.fw3
o^FD b{, N :
g:)6.g s 4 qg
o- bS gn
"----2
r.a.bbA -> b*)
b
bbabE 4b
il
ll
=) a^a bba
,-
',}\Aa '
d^
ii
rt J otqr-b-sbbba
J CF'+a)
9a ic+ s ict se,S
t*' 6v
i b+i b+" zo l,'-'
ob+ti ed
g slr.
_;*V" ar@
IctS
Or L.t
br)__
(,
1
--;
tu,tt[to..q--:oo -g-iX
g^'
9a- i9lgs-S
= iut tctge-)
Dibljbtaz-0-
-llr-e* -+h.{ ,{ 9-}, c,^s'o b<f cr".l
['i t
t.
ct S
-Jte a rrrbi
Na '=i;' i tc
A )b
---A-ir^J
tr4rL Lo; ,\^^t'f + dQJu, *r*- lhri Ooh
Orn
/-,
.-.- \
Sd+g -
:=) k a-
P_sg&
A 4oLb
Pushdown Automata(PDA)
Content
-An introduction to PDA, Languages of the PDA
-Designing PDA
-Deterministic and Non-deterministic PDAs
-Alternative equivalent definitions of a PDA
Introduction: An informal description of a pushdown automaton is shown in
the diagram below. Such an automaton consists of the following:
1. Acceptance by Final State: The PDA is said to accept its input by the
final state if it enters any final state in zero or more moves after reading
the entire input.
Let P =(Q, ∑, Γ, δ, q0, Z0, F) be a PDA. The language acceptable by the final state
can be defined as:
L(P) =
Since set of accepting states are irrelevant, We shall sometimes leave off , seventh
component from P.
What does each of the following transitions represent?
1. δ(p, a, Z) = ( q , aZ)
2. δ(p, a, Z) = ( q , ε )
3. δ(p, a, Z) = ( q , B)
4. δ(p, ε , Z) = ( q , B)
5. δ(p, ε, ε) = ( q , Z)
6. δ(p, ε, Z) = ( q , ε )
Designing PDA
Design a Pushdown automata(PDA) for L = { anb2n : n ≥ 1 }
Design a Pushdown automata(PDA) for L = { a2nbn : n ≥ 1 }
Construct a PDA to accept the language L = { wcwR | w ∈ {a,b} * and wR is reverse of
w } by a final state
Design a PDA to accept the language L = { wwR | w ∈ {a,b} * and wR is reverse of w }
2. Obtain a PDA to accept the language L = { w ∈ {a,b}* : Na(w) > Nb(w) } by final state.
3. Obtain a PDA to accept the language L = { w ∈ {a,b}* : Na(w) < Nb(w) } by final state.
4. Design a PDA to accept all the strings of 0’s and 1’s having substring 001.
5. Construct a PDA to accept strings of a’s and b’s ending with ab or ba.
Practice Problems
1. Obtain a PDA to accept the language L = { w ∈ {a,b}* | Na(w) = Nb(w) }
2. Obtain a PDA to accept the language L = { w ∈ {a,b}* : Na(w) > Nb(w) } by final state.
3. Obtain a PDA to accept the language L = { w ∈ {a,b}* : Na(w) < Nb(w) } by final state.
4. Design a PDA to accept all the strings of 0’s and 1’s having substring 001.
5. Construct a PDA to accept strings of a’s and b’s ending with ab or ba.
Equivalence of PDA and CFG
-Given a CFG G, we Can construct a PDA that simulates the leftmost derivations of G.
Let G= (V, T, P, S) be a CFG. Construct the PDA P that accepts L(G) by empty stack
such that L(G) = L(P), where P= ( { q }, T, V∪T, δ, q, S)
Method:
1. For each variable A, define transitions:
δ(q, ε, A) = { (q, β) | A→β is a production of P }
S aABC
A aB | a
B bA | b
Ca
Practice Examples
1) For the grammar: 2) Convert the following CFG to PDA