Re: need help developin better sense for context free languages
- From: Chris F Clark <cfc@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 25 Jan 2007 12:24:26 -0500
I think Torben's post has a bunch of good ideas. In real-life
(i.e. outside of courses and exams), this question is almost never
asked. And, not having been in school since probably before you were
born, I can't tell you what lecturers ask. However, there aren't
really very many patterns, so you can almost memorize all the
cases. ww^R works because you can push w onto the stack and pop it
back off, so palindromes are solvable (and ww doesn't because you need
to push onto a queue rather than a stack). Same thing goes for
a^jb^j, push a's and pop off to match b's. a^jb^jc^j doesn't because
you only have one stack, so you can't both pop when seing b's to match
the a^jb^j part and push at the same time to match the b^jc^j part.
However, there aren't a lot of more known tricks than that, which hold
only for CFG's.
But ask yourself this one, how about a^jb^jb^j? Is that a CFL or not?
Explain why. How about a^jb^kc^j, a^jbc^jc^j, or a^jb^jcb^j? If you
can answer those questions, you are likely to understand the principle
distinction. Note, if you really know your stuff, you should be able
to turn any of the above solvable problems into a grammar that
actually expresses the language "precisely"--the unsolvable ones won't
have a grammar (why not?).
Hope this helps,
-Chris
*****************************************************************************
Chris Clark Internet : compres@xxxxxxxxxxxxx
Compiler Resources, Inc. Web Site : http://world.std.com/~compres
23 Bailey Rd voice : (508) 435-5016
Berlin, MA 01503 USA fax : (978) 838-0263 (24 hours)
------------------------------------------------------------------------------
.
- Follow-Ups:
- Re: need help developin better sense for context free languages
- From: Patricia Shanahan
- Re: need help developin better sense for context free languages
- References:
- need help developin better sense for context free languages
- From: TheGist
- Re: need help developin better sense for context free languages
- From: Mitch
- Re: need help developin better sense for context free languages
- From: Torben Ægidius Mogensen
- need help developin better sense for context free languages
- Prev by Date: Re: Hofman and Diaby talk about P=NP at INFORMS 2007
- Next by Date: Optimal generalization of Montgomery's trick
- Previous by thread: Re: need help developin better sense for context free languages
- Next by thread: Re: need help developin better sense for context free languages
- Index(es):
Relevant Pages
|