The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
0 votes

S -> AaB

A -> aC | $\epsilon$

B -> aB | bB | $\epsilon$

C -> aCb | $\epsilon$

Is the regular expression for the above is this:

a(a + b)* a ( a* + b* )*  ?

asked in Theory of Computation by Loyal (9.1k points) | 171 views
it will be, $a(a+b)^*$
I think answer will be a(a^nb^n)a(a+b)*/n>=1

your's expression is generating minimum length string as 'aaba' (i.e 4), but above grammar is generating smallest string as 'a'
You are right. it should be a(a+b)*

I think it is (a(anbn)+ epsilon) a(a+b)* for n>=0

The given grammar is not a regular grammar because S and C does not follow the rule of right linear grammar. Instead the grammar is Context Free Grammar. So Regular Expression in not possible for the language generated by given grammar.
@Pratik Gawali

even non regular grammar can generate regular language

and the above grammar generate regular language whose corresponding regular expression is $a(a+b)^∗$

@joshi_nitish Yes, you are right.

Regular Grammar always generate Regular Language. However, Non-Regular Language may or may not generate Regular Language. In this case a non-regular grammar is generating a regular language.

From the grammar, it is clear that the expression that can be generated is of the form (a(anbn)+ ϵ)a(a+b)* . But I am not able to understand how is it equivalent to a(a+b)*?

yes can be a(a+b)*

first element of the string always be a

and then u can generate any string

1 Answer

0 votes
It should be (a(a+b)*)+a(a^nb^n)

because here minimum one "a" is must and by the production B we will get all string of "a and b"

But at the same time by the production C we will get string in a and b will be equal.
answered by (163 points)
(a+b)*can also generate strings having equal number of a's and b's

Related questions

+1 vote
1 answer
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,814 questions
54,522 answers
75,388 users