retagged by
3,306 views
5 votes
5 votes

I'm having problems with identifying CFL languages a lot recently.I understand L1 is not , but how come L2 is ? Understood 1 stack is enough but aren't there two comparisons ? Or that doesn't matter you can do any number of comparisons ? It's just number of stacks which are important ? In this case , 2 comparisons are needed n<k and k<2n. 

Any other fixed formula , to identify class of language which acts as easy guideline ? 

retagged by

4 Answers

Best answer
8 votes
8 votes

@vishal8492

this is one of the worst way to say whether a language is CFL or not only based on number of comparisons...if it was so then why pumping lemma for CFL was introduced?? there are many examples with a hell lot of comparisons but still CFL ,even regular sometimes....dont fall in such traps..

now coming back to question,
for L1....u can push all 1s onto the stack and then when 0s start coming pop them off...so for all 1s,all 0s will be popped off...now when again 1s start coming u dont have anything on the stack...for this we need a queue with some marking facilities so that we can move 2 ways and mark the inputs...this is LBA....thus the language mentioned is CSL not CFL..

for L2...
S-> aabbb / aaTbbb
T-> aTb / aTbb / epsilon..this is a CFG...
or L1 U L2..U Ln ..So , L1 = a^nb^(n+1), L2 = a^n b^(n+2), ....,Ln = a^n b^(2n-1)
NPDA is possible here

L1 is CSL and L2 is CFL(not DCFL)

selected by
2 votes
2 votes

L1 is not CFL, L2 is CFL

In L1 first you push all 1's, then for 0's pop every 1 to ensure #1's = #0's. So now when 1 come you cannot compare it with initial 0's and 1's as they are lost. So it's no CFL.

In L2 language can be written as {a^nb^n} U  {a^nb^n+1}.......{a^nb^2n}. As all these languages are CFL and we know CFL are closed under union. Therefore L2 is CFL. 

1 votes
1 votes

I am not sure about the answers. Please check.

1. L1 is not CFL. L1= {10n 1m 0m, m=n and n>=1}. While parsing, 1n0will be cancelled out. Similarly, 1m0m  will be cancelled out. Now, it can't be checked if m==n. Thus, not CFL.

2. This is CFL. L2= { abU abn+1  U ........ U ab2n }. Each of the grammars are CFL. Since CFL is closed on union, hence it is CFL.

–1 votes
–1 votes
both are CFL

in L1 , on seeing 1 push the 1's onto stack and on seeing 0 again push the 0's now ...at top we have 0's...after that if if we see 1 again the pop 0 from the stack which is mached against the 1^n written at 3rd position...all 0 is over from stack..then if we see 0 then pop all the 1's from the stack..DPDA can be constructed

Related questions

0 votes
0 votes
3 answers
1
vishal8492 asked Dec 4, 2016
611 views
It seemed like , this is textbook example of non-CFL language ; will require 2 comparisons . That means no complement exist was the answer , I was expecting. Why answer g...
1 votes
1 votes
1 answer
2
Himanshu1 asked Nov 2, 2015
1,013 views
Give an example of Unambiguous CFL which is not DCFL .
1 votes
1 votes
1 answer
3
1 votes
1 votes
2 answers
4
ggwon asked Dec 29, 2022
737 views
L = {$a^{n+m}b^{n}a^{m} | n,m \geq 0$}Is the above language DCFL or CFL ?