0

$S \rightarrow AB$

$A \rightarrow aA \mid bA \mid \epsilon$

$B \rightarrow aBb \mid \epsilon$

Does this grammar generate regular language?

According to me this grammar generates language of the form $$ L = \{ (a+b)^* a^nb^n \mid n\ge 1\} $$

I think it's a DCFL. If the condition would have been $n\ge0$ then it's regular according to me. But my book says it's regular language.

Am I correct ?

Raphael
  • 72,336
  • 29
  • 179
  • 389
Sagar P
  • 319
  • 3
  • 13
  • 2
    Why do you think $n\ge 1$? – Rick Decker Oct 24 '17 at 20:28
  • @RickDecker if n≥0 then all words, no matter how you pump them, are contained inside (a + b)* and belong to the language – rotia Oct 24 '17 at 23:58
  • 2
    @rotia Correct. However, the OP said "According to me this grammar generates ... $n\ge 1". I wondered why. – Rick Decker Oct 25 '17 at 00:05
  • @RickDecker true, I didn't look at the grammar, you are right – rotia Oct 25 '17 at 00:10
  • The language of $B$ is not regular. What's your regular grammar for it? – Thumbnail Oct 25 '17 at 01:23
  • 1
    We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. – D.W. Oct 25 '17 at 02:40
  • 1
    Why don't you try to prove your answer correct? Then you'll know whether you are correct. You might start with https://cs.stackexchange.com/q/11315/755, then try to find a DFA or regular grammar for your language -- see https://cs.stackexchange.com/q/1331/755 -- then try to find a deterministic PDA for it. – D.W. Oct 25 '17 at 02:41
  • @Rick Decker, Is it n>=0 because S (start symbol) is able to generate epsilon ? if it would have been n>=1 then it would be DCFL right ? – Sagar P Oct 27 '17 at 16:03
  • 1
    It is $n\ge 0$ since that's what $B$ can generate. If it had been the production $B\rightarrow aBa\mid ab$, then it would have generated $a^nb^n$ for $n\ge 1$ – Rick Decker Oct 27 '17 at 19:20
  • So for $n>=1$, it would be CFL and not DCFL right ? It would not be regular as we no longer have $epsilon$ in $a^n b^n$ which can help us to generate $(a+b)^*$ . Am I correct ? @Rick Decker. – Sagar P Oct 27 '17 at 19:45
  • How will it be regular ? Language also contains strings like aabb aabb which do not end with ab. I think epsilon matters. – Sagar P Oct 29 '17 at 21:12
  • @Rick Decker. !! – Sagar P Oct 30 '17 at 20:20
  • @RickDecker OP is right, set $w=a^pb^p$ then xy contains only a's, then set i=0, since y is bigger or equal than 1, we have less a's than b's – rotia Nov 01 '17 at 00:13
  • I neglected the $n$s when I wrote "ending in $ab$". My bad. – Rick Decker Nov 01 '17 at 17:10
  • @rotia So it would be CFL right ? – Sagar P Nov 02 '17 at 01:51

0 Answers0