|Is this a regular grammar? email@example.com (Silvio Mecucci) (1997-11-02)|
|Re: Is this a regular grammar? firstname.lastname@example.org (David L Moore) (1997-11-03)|
|Re: Is this a regular grammar? email@example.com (1997-11-03)|
|From:||David L Moore <firstname.lastname@example.org>|
|Date:||3 Nov 1997 21:00:34 -0500|
Silvio Mecucci wrote:
> Can somebody proof that the language generated by this grammar is NOT a
> regular language ?
> <sentence> ::= <noun phrase><verb phrase>.
> <noun phrase> ::= <determiner><noun>|<determiner><noun><relative clause>
> <verb phrase> ::= <verb>|<verb><noun phrase>
> <relative clause> ::= that <noun phrase><verb phrase>
> <noun> ::= boy | girls | cat | telescope | song | feather
> <determiner> ::= a | the
> <verb> ::= saw | touched | surprised |sang
Lets start by simplifying it to:
<sentence> ::= <noun phrase><verb phrase>
<noun phrase> ::= the cat | the cat <relative clause>
<verb phrase> ::= saw | saw <noun phrase>
<relative clause> ::= that <noun phrase> <verb phrase>
S ::= NV
N ::= b | bR
V ::= c | cN
R ::= dNV
It is clear that the original grammar is regular only if this
grammar is regular.
S = NV
N = b | bdNV
V = c | cb | cbdNV = c | cb | cbdb | cbdbdNVV etc.
And here is the problem. We can pump out N->bdNV as often as
desired and we require that there be as many V's as "bd"s. This
cannot be handled by a finite state automaton (just pump
out one more N than there are states in your automaton),
so the language is not regular.
This is usually stated as "FSAs cannot count". The canonical example
is that the language ab aabb aaabbb, etc, with as many a's as b's,
is not regular.
Return to the
Search the comp.compilers archives again.