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

TC Module 4

The document discusses various concepts related to context-free languages (CFL) and their properties, including Chomsky Normal Form (CNF) and Greibach Normal Form (GNF). It outlines methods for eliminating nullable variables, simplifying grammars, and converting grammars to CNF and GNF. Additionally, it addresses closure properties of CFLs under operations such as union, concatenation, and complementation.

Uploaded by

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

TC Module 4

The document discusses various concepts related to context-free languages (CFL) and their properties, including Chomsky Normal Form (CNF) and Greibach Normal Form (GNF). It outlines methods for eliminating nullable variables, simplifying grammars, and converting grammars to CNF and GNF. Additionally, it addresses closure properties of CFLs under operations such as union, concatenation, and complementation.

Uploaded by

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

Module- 4 Propuhes CFL

Elminabin4 Usels Symbola


Synkoa
qrammar
deivabiom. 9 the

Sß wET*

Othewise, the symbol A a callad wseles. symel.


and nea chabe
X
X a eachablu there n
or Bonme
erminal stahy

Eummating ¬- podluehors:
langag LL has CFG, Aen L- {ey has a
CF wrthout e-produehbrs.

() Discovermg nullate' van atiles:


A. vanable A ionullatle y A é DA ia
nulable,. os oherrever A
A ajpan ih prooli t
boy Amight derive e.
Making Two vesstons production:
Consi de a prodeehn B CAD ut A e we
make huo
a the prrlutiom,
One oitho A th body (B-), which
Corouponds to the ohere A uould hae been
tud to denve e
One
)H tannot be alloused fo dne E.
() Eum nabn E-produchbra
step s,B, toto
tohel step
The yhe! elinnat all produtbog
van'able
oith ¬ bodis, tius

Uoit
tss Produehrs.
Eumnabng
A wnit produ etion e a, prod ctbbn e
uhere bott A and B e variabus.
A’B

Steps:
Consider qramnay:
’ FT* F

T Cah be in poduchon
erpand1d in produchn ETi
doo pogsib k wy
Repleeeng it by
This hong shu does notelnnat nt pnducbvw

Hat Dd not preb usly part q me gramma.


" Fsther ponding E F byby too prodluebon. for
F E’ a<b] TEF
Smpliy tollougqrammars
1.
AaAA/e
8 6B]bbC
c’B
Sol": Spls Bimati nit productm ic
SoaA/a BB
AaAAle
B bB/bbC
C’ 68/bbl
Skp-2! Elumihate A-¬

A’atAaAla
B’ B|hbC
C’ be/bbc.
na B an d C produs Same' bodes, and C-g.
se can wi
B b8/bbB.
: The ampufed qramma ia
SSaAlaB8|a
AaAALaAla
B b8]b8.
A’ a as/a
B sbs| P{bb.
Sol?: Step-l: Ebminate S-e

S’ ASB AB
A’ aAsla laA
8’ Sbs/njbb /sb]bs| b.
Bp-2: Eminat BA.
B’ SbslaAs |a lak|bb) sb| bs< b.
The rammar
S’ Ae[AB
A ’ aAS alaA
B SbS) abga [a Al bbJsb|s|b
Chomsky Noxmal Fm (CNf)
CFG uin wich al pradnd

(i) A 8c, wte' A, &and C au lach vauay


i) Aa, wre A' ia a vanabu

Furth G has no wseles symtola, dueh a qrammar


to be n CNf.

Pro blems:
Covet he tolboing CFG t cNF:
S’QACa
A ’Bla
B->cles

emove trerm
we must st
8 Remonng CE
B’
fele S’ aACaaAa
AB.

Panong we gut.
B
A
-ela
Rermong
A> a
we get

RauecttaThe qramar
S’.aACalata
Aa
Bc
C’cclc
Podutns hat are CNF arei
ando
Aa, B>c
Prouchu not in NP:
S’ aACala Aa Congider a= Ao(Ao
C’cl. nd c G

Producon Achion Reslt,


S’aACa la Aa
C’ cc
C-’Ce n aloo h o
CNE.
Now, tonsiden AA B and CA D, (a%, D,¬ )
The oducbtne at are' now not

S’AACA, and
AaAslaa
|AB ASB S’
S-E Remonhg
E-praubbu
the in
wni ore There
BSbs)A}
bb.
aAs)ai A
Symbol Ss,Staat
Cecle
Aa
P{
T:{a,
CNE innow abo a
DoC=
A%
SAAGA./AAA,
Result.
Aetion
Naw, the modijd CPG ia
A’ aAs|a laA

Produetons in cNE
S ASB
A aAS/aA

Consld a: Ao wtere Ao, Bo E V.

Produebbn Aebon

S’ AsB
A’a AS]aA
a= Ao
b

Produebbry that
Poduchy thot ae now

S-’ ASB

B8sl Ao As
Corutcer As=
AS A, ohele A, B, ev
SBo B)

hen Psodductn Action Res lt


As A) S’ A, B
A’ A AS AS= A|

B8,s|Ao A
sB B
Now

G- (v, T, , )
V:{S A, B, Ao, Bo, A), Bg
P

B’ alb| Ao tlB,8, 1se. B,s B,S|Ao Ay

S
StatSynol
8Ao
S.
rei CNE yous
h are hoduesong
Hhat
'B'BB8]
AoJ.
BAoAAB AonA|is
BB A
Ao S
Aebon
etbs Produ ymen
Result
V. ¬B,Ao, whre bA Consid
B|BBloS.
A0AA1s
SOA|]B A
Produetos
not CNF Products
E-productay.
contain not doA CGqiren The dol"
2’|Belolo.
A>oAA
1s
OA|18. S3.
Peoduchry Not ih cUF aei
B BoB8.

A, B, f V

Producbn tchon Result


A ’AAA AA A AAoA,
R8- B,

Now al produchong

S’ A, A|B, B
A’1Bo s] AbAy
B’ oAo S|Bo Bi

S: Start symbol
Pracbie

(a|Ac D-G
2. salaf|6 AaBele B’ Aalb.
Grecbach Normal Fom (GNe)
nnon tmpty languag
CFG whgte prducbr and
termal
A ad whue
p mole Sueh a
zeuo mde vaabls.
Btnhg Grebach Nmal Fim.
Normal oum tallhd qinitbach
Problems
Convest t e to lomg CFG to 6NF.
AS/b.
n te . above
SI. There ae no wit 7 E-produtmas
grammar,
to GNE, Fst, we
To convest gn gramay
CNC
it to
Aeed to Con vet

The above qrammar vs already


Congiden

A,= A
Ao A, A
!

A, b.
wotn a
4 (6) tan be

Aj aAo
can be wotn ay
Ao ’ bA

Now, both

Ai bA a
A>aAo lb

S: Stat Ab (stast)

A’ OAA1s
B’ )Be |os D
So(?.
topic ta.coneihrg he above
9rammar to NF
Considen
A Do , D3 : Ao Dy B
D A DuDy : Bo
De B
Now, roie e moduehbrs wth modiNd vatake
Do >

Ds = DDI

(t D-Dy Dy
Da ’0D, (:3o), Do |D( Dy=)
D Dy D,
D, ’0D D|De
D
D ’I D,
Do 0D,1D

Dg D, D
Ds
Ds 6To|1D.) D
o D, D iD,D,
The Grammar GNF.

6: T, P. s)
V:Do D, Da

D,’ oD, |1D,

Du|
Ds ’ DDED1D, D
D 0D, D ! 1D, D
Practia:
I. A BC
C’ CAla
A’A8|b
f
emma foe lomtt Free Langia:
Statement:
Let 1 be a CfL Hhen hire ekizb
eKIsts a constant n
Bueh that 2 any sinng L Hen wt ca)
wote
2: uvo
Provided that the joloohg Cond'tors
onditors ave
are isabued:
) Ivwzl n (mtddle portin kong)

This s becauny Vand X ar thu plees to bey


pemped. This condh'on saus that atfeast onu
te thnhg muut not b
üi) For all 20, uv'oz'y is in L. 'ey he.two
stnas v and 2 may be pumped ay no. g tnes
and th wrl shU be
mcluding 0,
a mmber of L.

Proef
grammar h CNE ach
that

m yaablus Jntesmal
nodes

nody C
Any parSe tree
tre whose longut path q Lengs m
(us dos no 2 ecar Z b to long

: Any pase free utich glds Z has a path o


atteast
ngt Ao

/A k- ng q longut pat,
Ak

This the longs path ih the tree, uhae


the mnimun enagth o k w m (. k2 m) ad
the pah io lngth KtI.

Sne k2 m, hee are atleast n+| occuen us on the


path.

duppose to vanabus are Bame,

Then Aplt 2 rwy

uAy when î 0
uwy
suty when i>o

uvALxy >uvway
N

For any Lompornt i) uw'r'y


wuth belongs to languay

Thus, fhere Qre pase drees n à

languag io sarl fo be c CFL:


:The
Contert- Free languag:
(how that cFL8 uosed ndr followhg
|. Uniom:
ho mkxb.jree langag.
hen heir wn°¡n Lj UL, will elo be cntrt-ree.

iet Ly< fa?bm20 and n2o4. bea cFL


l| bays rat na ef a spuld be egual t no.

not q bo, should bse. lqual to no.fics.


Now

to no. 1
bs and no. bs ohould Se
Prerous iondit

closed undur unibn


. Contatenaton:

Qe 2 CELs' then thei toncatenatn


Li, Lg wiu lp b a
CEL.
v a CFL whth a's should de
tqual to no. of b's.

L, b aoo a CfL tohich bays hat he. f c' shoull


no. o d4.
e eaual to no.

Nouw,
L3(: L L

t, no, o a shoutd be eyual


L3 sauys that
cgal to
cu should be aqial
bo then no.
no. d's
This languag arcefud by PDA.

conattratb
CEL ae closed wndir
3. kleen Closre (star):
Context el,

Nous fab"n2o* b albo a CFL


CFL 8ae losd wndu Klaen Cloge
(how that CFL ae not dosed under
lo8td wnder jollang

Hon er nesse cblon Li nLe need not to be


Con trt

L: fa"8 c"]n2o, n204


Ly: fan b"c" |n2 o, m2oy
Both ase CFLS
Ly say that no. q as shouto be equal o no. f bd
that by dhowld be egual to no.3.

Now

3 says hat bot ha above Condbbns o L, and


Ly muust be tne
But t PDA Corgae ony
Can ymbola.
Ths stanguoge s not aacegted by PDA
not a
CFL.
not clore un der terse chlon,
9. Complementabn:
and L are CFL's

1oKT CFLs ae closed nder


.: L,vL, à alo a cFL.
'. L ULL aleo a CfL

fhuony , we haue

= LnL2 Ctntuse cbioo)


wnor
But CFLB ae not led ty nesechon
that (Fli ae not
contraocbon, we can s y
sed
closed und lomplemntabn.

You might also like