514 views
0 votes
0 votes
Is the following language context free:
The set of all strings with number of a’s equal to number of b’s and the sum of a’s and b’s to be divisible by 3.

1 Answer

Best answer
3 votes
3 votes

Yeah it will be context free. 

1st part : Set of all strings with equal noof a's and B's is a standard CFL Language accepted by Push Down Automata. 

2nd : sum of a's and B's divisible by 3 is regular language 

And intersection of regular language and  context free language is CONTEXT FREE. 

 

Theorem : If L1 is a CFL and L2 is regular then L1 $\cap$ L2 is CFL.

 

Proof for above : https://www.cs.umd.edu/~gasarch/COURSES/452/F14/cfgreg.pdf

 

selected by

Related questions

0 votes
0 votes
1 answer
1
0 votes
0 votes
1 answer
4
hrcule asked Mar 21, 2018
680 views
Is true..? In an unambiguous grammar every string has exactly one derivation.