6 votes 6 votes if a is a terminal and S, A, B are three non-terminals, then which of the following are regular grammars? (a) S → ε, A → aS|b (b) A → aB|a, B → bA|b (c) A → Ba|Bab (d) A → abB|aB please explain how u proceed? The answer is given "b" Compiler Design regular-grammar compiler-design regular-language + – VIKRAM KASANA asked Oct 1, 2017 VIKRAM KASANA 3.0k views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
3 votes 3 votes A grammar is either left linear (any non-terminal in production comes at the left end) or right linear (any non-terminal in production comes at the right end) is regular. $S\to Sa \mid a$ is left-linear so it is regular grammar. $S\to aS \mid a$ is right-linear, so it is regular grammar. $S\to SaS \mid a$ is neither left linear nor right linear and hence it is not regular grammar. Now check all options who satisfy the definition of regular grammar. Here both option (A)and (B)are satisfying the definition of regular grammar. LeenSharma answered Oct 1, 2017 • edited Oct 1, 2017 by LeenSharma LeenSharma comment Share Follow See all 7 Comments See all 7 7 Comments reply Show 4 previous comments rajoramanoj commented Oct 1, 2017 reply Follow Share but in type-3 V-> T*V/T*(RLG), V-> VT*/T*(LLG). now all follow this. 0 votes 0 votes Pradatt Sharma commented Oct 1, 2017 reply Follow Share But, It is not T*, it shoud be single terminal or a single terminal followed by a single vertex for (RLG) and accordingly for (LLG). And according to Chomsky, it allowes S--->€(epsilon) only if S doesn't appear on right side of any rule. So A got rejected. But still 1st generate epsilon as only string and we can have FA for that, so it should be regular. Still confused!! 0 votes 0 votes LeenSharma commented Oct 2, 2017 reply Follow Share but regular grammar definition says grammar should be either left-linear or right-linear.and it is satisfying the condition.So (A) is also regular grammar. 0 votes 0 votes Please log in or register to add a comment.
0 votes 0 votes Reason behind not counting A option as regular, as far as I think is that if you consider s start symbol, nothing can be generated from it. Am I correct... Chandan1990 answered Oct 1, 2017 Chandan1990 comment Share Follow See 1 comment See all 1 1 comment reply VIKRAM KASANA commented Oct 7, 2017 reply Follow Share s->ε will create ε and that fall under the regular language 0 votes 0 votes Please log in or register to add a comment.