Revision -Construction of PDA ... Construct a PDA to accept strings containing equal number of a's and b's. ... V = {S, A, B, Ca, Cb, C1, C2, C3} ... – PowerPoint PPT presentation
1 Finite Automata Formal Languages (FAFL)Push Down Automata Properties of CFG - Revision
Jibi AbrahamAsst. Professor Dept of CSEM S Ramaiah Institute of TechnologyBangalore. Email jibiabraham_at_msrit.edu
2 Set Difference
L1 and L2 are CFLs. L1 - L2 is not necessarily a CFL
Proof
L1 - L
is regular and is also CFL
But - L LC
If CFLs were closed under set difference then - L LC would always be a CFL.
But CFLs are not closed under complementation
3 Inverse homomorphism
To recall If h is a homomorphism and L is any language then h-1(L) called an inverse homomorphism is the set of all strings w such that h(w)L
The CFLs are closed under inverse homomorphism.
Theorem If L is a CFL and h is a homomorphism then h-1(L) is a CFL
4 Inverse homomorphism proof 5 Proof Contd...
After input a is read h(a) is placed in a buffer.
Symbols of h(a) are used one at a time and fed to PDA being simulated.
Only when the buffer is empty does the PDA read another of its input symbol and apply homomorphism to it.
6 Proof Contd...
Suppose h applies to symbols of alphabet S and produces strings in T.
Let PDA P (Q T G d q0 Z0 F) that accept CFL L by final state.
Construct a new PDA P (Q S G d (q0 ) Z0 F X ) to simulate language of h-1(L) where
Q is the set of pairs (q x) such that
q is a state in Q
x is a suffix of some string h(a) for some input string a in S
7 Proof Contd...
d is defined by
d((q ) a X) ((q h(a))aX)
If d(q b X) (p ) where bT or b then d((q bx) X) ((p x) )
The start state of P is (q0 )
The accepting state of P is (q ) where q is an accepting state of P.
(q0h(w)Z0)-P (p) iff ((q0)wZ0) -P ((p ) )
P accepts h(w) if and only if P accepts w because of the way the accepting states of P are defined.
Thus L(P)h-1(L(P))
8 Revision
Based on previous question papers
Construction of PDA
Convert CFG to PDA
Simplification of CFG
Conversion to CNF
Pumping lemma of CFL
Closure properties of CFL
9 Revision -Construction of PDA
To accept the language L aibjck i j k i 0 j 0 (Feb/Mar 2004 model question paper)
Solution PDA M (q0 q1 q2 q3 a b c a b Z0 d q0 Z0 q3) where d is defined by following rules
d(q0 a Z0) (q0 aZ0) d(q0 a a) (q0 aa)
d(q0 b a) (q1 ba) d(q0 b Z0) (q1 bZ0)
d(q0 c a) (q2 ) d(q1 b b) (q1 bb)
d(q1 c b) (q2 ) d(q2 c b) (q2 )
d(q2 c a) (q2 ) d(q2 Z0) (q3 )
d(q0 Z0) (q3 )
d(q x Y) for all other possibilities
10 Revision -Construction of PDA Contd
To accept the language L anb2n a b S n 1 by final State (Jul/Aug 2004 Jan/Feb 2005 new scheme)
Solution PDA M (q0 q1 q2 a b a Z0 d q0 Z0 q2) where d is defined by following rules
d(q0 a Z0) (q0 aaZ0) d(q0 a a) (q0 aaa)
d(q0 b a) (q1 ) d(q1 b a) (q1 )
d(q1 Z0) (q2 )
d(q x Y) for all other possibilities
11 Revision -Construction of PDA Contd
Construct a PDA to accept strings containing equal number of as and bs. (Jan/Feb 2005 old scheme)
Design PDAs to accept by final scheme and by empty stack 0n1n n 1(July/Aug 2005)
12 Revision - Convert CFG to PDA
July/Aug 2004
I a b S aA A aABC bB a B b C c
Solution PDA accepted by empty stack M (q a b c a b c S A B C I d q S) where transition functions d are given below
d(q I) (q a) (q b)
d(q S) (q aA)
d(q A) (q aABC) (q bB) (q a)
d(q B) (q b) d(q C) (q c)
d(q a a) (q ) d(q b b) (q )
d(q c c) (q )
13 Revision - Convert CFG to PDA Contd
Jan/Feb 2005 old scheme
S aBB B bS c
Solution PDA accepted by empty stack M (q a b c a b c S B d q S) where transition functions d are given below
d(q S) (q aBB)
d(q B) (q bS) (q c)
d(q a a) (q ) d(q b b) (q )
d(q c c) (q )
14 Revision simplification of CFG
Eliminate unit production from the grammar below (July/Aug 2004)
S Aa B B A bb A a bc B
Solution
Unit productions are S B B A and A B
A B and S are derivable
Eliminating B in the A production gives A a bc bb.
Eliminating A in the B production gives B a bc bb.
Eliminating B in the S production gives S Aa a bc bb
15 Revisionsimplification of CFG Contd
The final set of productions after eliminating unit productions are given below
S Aa a bc bb
B a bc bb
A a bc bb
16 Revisionsimplification of CFG Contd
Eliminate useless symbols and productions from the following grammar (Jul/Aug 2004 old scheme)
S ABa BC A aC BCC C a B bcc
D E E d F e
Solution
Step 1 Eliminate non-generating symbols All variables are generating
Step 2 Elimination of non-reachable variables Draw the dependency graph
17 Revisionsimplification of CFG Contd
D E and F are non reachable from S
After Removing useless symbols
S ABa BC
A aC BCC
C a
B bcc
18 Revisionsimplification of CFG Contd
Eliminate useless symbols and productions from the following grammar G (V T P S) where V S A B C T ab and productions P given below (July/Aug 2005)
S ab A C A a B ac C aCb
19 Revision Conversion to CNF
Feb / Mar 2004 model question paper
S ASB A aAS a B SbS A bb
Solution
Step 1 Simplify the grammar with productions P
Step 1a Eliminate - productions to obtain P1
P1 S ASB AB A aAS a aA B SbS A bb Sb bS b
Step 1b Eliminate unit productions to obtain P2
P2 S ASB AB A aAS a aA B SbS bb Sb bS b aAS a aA
20 Revision Conversion to CNF Contd
Step 1cEliminate useless symbols to obtain P3
All variables are generating and all are reachable.
Simplified grammar is G (S A B a b S ASB AB A aAS a aA B SbS bb Sb bS b aAS a aA S)
Step 2 Convert G to CNF
Step 2a Add productions of the form A BC A a
P S AB A a B b a
21 Revision Conversion to CNF Contd
Step 2b Eliminate terminals from RHS of the other productions
A aAS to A CaAS and Ca a
A aA to A CaA
B SbS to B SCbS and Cb b
B bb to B CbCb
B bS to B CbS
B Sb to B SCb
B aAS to B CaAS
B aA to B CaA
Add productions in the CNF form to P S AB A a CaA B CbCb CbSSCbCaA b a Ca a Cbb
22 Revision Conversion to CNF Contd
Step 2c Reduce the RHS of the productions with more than 2 variables to the form of A BC
A CaAS to A CaC1 and C1 AS
B SCbS to B SC2 and C2 CbS
B CaAS to B Ca C3 and C3 AS
Adding these productions to P S AB A a CaA CaC1 B CbCb CbS SCb CaA SC2 CaC3 b a Ca a Cb b C1 AS C2 CbS C3 AS
23 Revision Conversion to CNF Contd
The grammar in CNF form G (V a b P S)
V S A B Ca Cb C1 C2 C3
P S AB A a CaA CaC1 B CbCb CbS SCb CaA SC2 CaC3 b a Ca a Cb b C1 AS C2 CbS C3 AS
24 Revision Conversion to CNF Contd
Jul / Aug 2004 old scheme
S abAB A bAB B BAa A
Jan / Feb 2005 old scheme
S S T T R T T a b R R a
Jul / Aug 2005 old scheme
S ABa A aab B AC
Jan / Feb 2005 new scheme
S ASB A aAS a B AbA A bb
25 Revision Pumping Lemma of CFL
State and prove pumping lemma for CFL (Jul / Aug 2004 old scheme and new scheme) (Jan/Feb 2005 old scheme)
Show that L an bn cn n 1 is not a CFL (Jul / Aug 2004 old scheme) (Jan/Feb 2005 old scheme)
26 Revision Closure Properties of CFL
Show that the family of CFL is not closed under intersection and complementation (Jul / Aug 2005)
Show that the family of CFL is closed under union concatenation and star closure (Jul / Aug 2004 old scheme) (Jan/Feb 2005 new scheme) (Jan/Feb 2005 old scheme)
27 Q AContact Email jibiabraham_at_msrit.edu
About PowerShow.com
PowerShow.com is a leading presentation/slideshow sharing website. Whether your application is business, how-to, education, medicine, school, church, sales, marketing, online training or just for fun, PowerShow.com is a great resource. And, best of all, most of its cool features are free and easy to use.
You can use PowerShow.com to find and download example online PowerPoint ppt presentations on just about any topic you can imagine so you can learn how to improve your own slides and presentations for free. Or use it to find and download high-quality how-to PowerPoint ppt presentations with illustrated or animated slides that will teach you how to do something new, also for free. Or use it to upload your own PowerPoint slides so you can share them with your teachers, class, students, bosses, employees, customers, potential investors or the world. Or use it to create really cool photo slideshows - with 2D and 3D transitions, animation, and your choice of music - that you can share with your Facebook friends or Google+ circles. That's all free as well!
For a small fee you can get the industry's best online privacy or publicly promote your presentations and slide shows with top rankings. But aside from that it's free. We'll even convert your presentations and slide shows into the universal Flash format with all their original multimedia glory, including animation, 2D and 3D transition effects, embedded music or other audio, or even video embedded in slides. All for free. Most of the presentations and slideshows on PowerShow.com are free to view, many are even free to download. (You can choose whether to allow people to download your original PowerPoint presentations and photo slideshows for a fee or free or not at all.) Check out PowerShow.com today - for FREE. There is truly something for everyone!