2.7k views

Consider a grammar with the following productions

• $S \rightarrow a \alpha b \mid b \alpha c \mid aB$
• $S \rightarrow \alpha S\mid b$
• $S \rightarrow \alpha b b\mid ab$
• $S \alpha \rightarrow bd b\mid b$

The above grammar is:

1. Context free
2. Regular
3. Context sensitive
4. $LR(k)$
edited | 2.7k views
+9
Isn't this production violating CSL property of |LHS| <= |RHS| ?

$S\alpha\ \rightarrow b$
0
yes.. I'm having the same doubt.. Plz let me know after your doubt gets cleared. Thanks !
0

Agree @ Tuhin Dutta

• $S\alpha \to$

This violates the condition of context-free grammar that the $\text{LHS}$ must be a single non-terminal symbol.

•  $S\alpha \to b$

This violates even the weaker requirement for CSG that the length of $\text{RHS}$ of a production must be at least same as that of $\text{LHS}$. So, the grammar is not even context-sensitive.

edited by
0
is ∝ a terminal?
+6
∝ is Non terminal, teminal as well.... http://en.m.wikipedia.org/wiki/Chomsky_hierarchy
+8
Yes. alpha is a sequence of terminals and non-terminals.
+7
In CSL by definition, length of LHS of production is less than RHS ? How CSL then ?
+1
@pC sir, why? how ? LR(k) ? It's not even CFG
0
@sudarshna  can u give me hint about how grammers are joined wid  diffrent parsers.
+1
one doubt sir, if if Alpha is sequence of terminals or non terminals then how CSL  as in CSL every production should be , if X--->Y then |x| <= |y| so this also voilates the condition of CSL  as given S aplha --> b  ???
+4
@piya  i know u r correct but other then this we don't have better choice. bcz we always belive to a  take strong answer so due to its violate cfg then we go upward in chomasky hirearchy  then we have only csl  otherwise if option is unrestricted grammer(type 0)  then i will go wid that .
0
Ok sir...  N wht is lr(k)?
+3
plz dont call me sir.  lr(k)  is a bottom up parser and all bottom parser generate  right most derivation and in this  parser  we parse  the string form bottom to up  fashion .in this question its  some how relevant bcz  some where i red it is equvalent to DPDA means accept dcfl but not cfl .
+1
@arjun sir,

By definition it is a CSL because of the case [email protected]>bdb|bd  (@ being alpha)

BUT if try to analyse the grammer, the production [email protected] will never be used,

Since all productions have terminal symbols only except
S->@S
Which will produce @@@@@....S on recursion but never ever [email protected] will be seen in any permutation of the grammer.
Also, the rest of the gammer is right recursive therefore I think it should be Regular.

Although in the book it is given as you explained, but still I have this doubt.
It will be very helpful of you to kindly clear it.
0
@Abbas2131

The grammar is surely not regular

consider S->@bb

now, @ sequence of terminals and nonterminals

eg @=AAB

then S->AABbb surely not regular
0

@VS

@ is given as terminal not non terminal.

What i am saying is that the production [email protected] will never be used in any derivation for the grammar. Therefore its its useless and will never occur during parsing.

If we ignore that .. then the grammar is right recursive and also we can obtain a RegEx for that

@*([email protected] + [email protected] + ab + b + abb)

0

@Abbas2131

∝ is Non terminal, teminal as well.... http://en.m.wikipedia.org/wiki/Chomsky_hierarchy

0
@VS

oh.. yeah :D

I didnt knew that ... my bad :)
0
in  csg  , lhs<= rhs  ,  tis grammar is violating tis condition , how csg   ??
+2
yes.i think none of options are correct as CSG is also not satisfied.

1
2