0% found this document useful (0 votes)
2 views

Module-3

BCS503 Module 3 notes

Uploaded by

vkhiremath18
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Module-3

BCS503 Module 3 notes

Uploaded by

vkhiremath18
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 56

o

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,-.-,

4 c,sD')d fxa-r.,na,-e- "e L! + c*pt* Co+) q,,'d


+^pu-
€=
t 9-L'.-*-
Cv
'T ''' s )
v u 34t % \r?.r^'-atr{
/",* b*;^*J{
s'4 % {<{ "'w"dt
; : 84J-5
€Arh p^ld"{ut,a,^ Lt .,P&"L'no
Bf tl-i ^/\ "( - lr
hs-A.qrr- o{ & q , F{'
b--e, b,,,r
Fu
U,v\ ri-.f^^a. A WftT;.q;T
ojg_o"-
't' rf i
OAJ'4 ; q*a r a.,q
tL"rnr^4-\ {to.
,
^-
o-' .* €br,4
\ A=^r q a(( 7lryr+L --:t'f r-4ff\oe6 c;
w' ),

.A?f
.-ry,ftva 9' ( v, r,, P,S )
=1g/
r(sla):
'
Ir V
S -: or[z IJ;j
S

-*-h* P=lse orlt?


(-lt -s .{ -g+arr
-
t

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
'.

v$+a"n wt M.aj- bo ghnl


^li
.U
bts +t-.a..I .S,l{^: L9 rn,-.11-itcls c}r
-tZ--.: -4

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&'

0ts It-6-(f e& %


A-0
,l &ru'

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,

qagl* al" a+b


tt . It It, ------

,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

Arn rvt-oJ-- [j3


tul'r-*y

-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

r'----- g+g SqSa -e


-0 tf ll<ttt ,j rl .

'l

,^4 rna.Jt

ftn b: rybe-
.31- gaaSb
-

VT
s )asL
V=
A aa9b L
ct

I IC 2r* '3+^,* h{""'Lc4


':'
rnr^AJ\- rn

anb^:

ob, af^bb. aaa*LbL -_- . . 1

=('v.T p. s

=I-f-qb
-- C tg__$g, s+rd -----U---
q"^^t"l .

stq --A- -Wwr"to* b qe-r-nu*-, U-L+etfqt'+

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=

f= - -,"rr----=- t --?_. . _--*_-.___

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 -->

v?l-l r,\l f\,/o


V* ^bW
A- 94'.' o,^\ d
r\4 t\*

A+ ol OA

hld$r* ,_a.^-.t- to Ok ^'r


LE

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

gjil-- -:, SaaA&

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
-==-

S-et \ril g't S-.^tfi'.^J


btl
QXa.araaa{- - Yb
fr\"
rn -. oJ- q F".A
-
S4-^14^ * db rrrrv\eL E
"(-
srdf 6l

T*, -lt t- Obrfl.tt idtid*id a


-+. !
i.Sc..,..}tn t-n- q+9 Qlan,.,9+
'

-+-r 4W
-+r* A ; dgul',.,.Loo S:+<, 11-Ar4*
o^3

d&ei;-h.# 3/n6\^r,)

ql ,r__1 diq*j{gjHg__i d ,_, i dt_E__ id_+ i d,+jrf _


l.

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

.Jt-,- Str" -? id -+ i d nr'i d q bg+a; d {F,c."^ rG> gaLF


al E b.+ O.-broLr.r,ir re A o r*lr,r.L' crr fu
J.1-rfr,rr51p. d'rr:"'*'L''o fu C,ar''\
;, ,. -rug-+Fhf&+-|*+t!Ir
--0
\+e n

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

rr) +l,v- hi tar'vf\- d"A\.AfI t5 S)4*'

+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

potu 4re* o.E*,r\Aa

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

4_or") {+1 ur- ,f,!r4


E, + E:+'6|, n*elid

d4 c,^.m b<0 o-,


_.._,li
E4q-*+ a
;:
;i
ti
4 E+el+€
-) Et E xid
'
ii
it
- iltl
tl
- -J"it
ilIt

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 .

., to_-."*rsrqdnt_ 3l^'-la-+f1i--s*J* - dro


l:
rr4**tji 4t++F=l- da4..'-L'n^ -q++ Sqn-9*lcl
. I lar0.. - t I^rr
-Il
,.^r
-i.
U[-aa btD.G-J

'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

S; 1+.e;--L AJ.'1. 'ft^s0 t -s*'.g;;tf


--v--
dlu'itzllrt h{(' Uf
=

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

Cr4^ L4- vlvl#-q;


drArz.|r o,^" J4 s"rn b .lr,^: " f

i 'S eq (s +ds

La"bbs ( go bl"
+4uB( t-to

J IiJrL oJ\t- +^rO

',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

C5\1ea$ )-& Jt-

tt- .f4-r-t* ,{^t c ts{rrg .lr-< I


a^-^+ ,]'t tT T'r Q.^^bp;i^r"ry,
Module-3

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:

-There is a tape which is divided into cells.


-There is a tape head which can move along the tape, one cell to the right per move.
-There is a stack containing symbols and special symbol $ or Z0
-There is a state control, which can be in any one of a finite number of states.
Definition:
A PDA can be formally defined as a 7-tuple: P = (Q, ∑, Γ, δ, q0, Z0, F)

Γ: A finite set of stack symbols


δ : The transition function: Maps Q x {Σ ∪ ε} x Γ  Q x Γ*
q0 : The start state

Z0 : The stack initial( bottom marker) symbol.

F: The set of Accepting states or final states


Example: A pushdown automata(PDA) for accepting L = { anbn : n ≥ 1 }
Moves of a PDA
Example: Show the moves made by PDA for the string “aaabbb”
Or
Give the sequence of IDs the PDA is in for the string “aaabbb”
Example: Design a Pushdown automata(PDA) for accepting L = { anbn : n ≥ 0 }
& also show the sequence of IDs for the string “aabb” .
Language of PDA
A language can be accepted by PDA using two approaches:

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) =

2. Acceptance by Empty Stack


On reading the input string from the initial configuration, the stack of PDA gets
empty.
Let P =(Q, ∑, Γ, δ, q0, Z0, F) be a PDA. The language acceptable by empty stack 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 }

Moves by PDA: on “ aabbaa”


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.
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

From Grammar to Pushdown Automata

-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 }

2. For each terminal a, define transition:


δ(q, a, a) = {(q, ε)}
Convert the following grammar into Equivalent PDA.

S  aABC
A aB | a
B  bA | b
Ca
Practice Examples
1) For the grammar: 2) Convert the following CFG to PDA

S aABB | aAA | ε S  aSa | bSb |aa | bb


A aBB | a
B bBB | A
Ca
Obtain the corresponding PDA

You might also like