Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2006

Tip: Looking for answers? Try searching our database.

Membership for a context sensitive grammar

Thread view: 
Alex - 14 Sep 2006 14:36 GMT
I have to write a java program to test if a word w € L(G) for a context
sensitive grammar G.

Can anybody help me?

Thx in advance!
Oliver Wong - 14 Sep 2006 15:47 GMT
>I have to write a java program to test if a word w € L(G) for a context
>sensitive grammar G.
>
> Can anybody help me?

http://en.wikipedia.org/wiki/Context-sensitive_grammar
<quote>
The decision problem that asks whether a certain string s belongs to the
language of a certain context-sensitive grammar G, is PSPACE-complete.
Indeed, there are even some context-sensitive grammars whose fixed grammar
recognition problem is PSPACE-complete.
[...]
That makes them totally unworkable for practical use, as the general
algorithm would take exponential time. Ongoing research on computational
linguistics has focused on formulating other classes of languages that are
"mildly context-sensitive" whose decision problems are feasible, such as
tree-adjoining grammars, coupled context-free languages, and linear
context-free rewriting systems. The languages generated by these formalisms
properly lie between the context-free and context-sensitive languages.
</quote>

   - Oliver
Alex - 14 Sep 2006 15:57 GMT
I knew that this was a great decidability problem....but isn't there any
algorithm to do it ?
Oliver Wong - 14 Sep 2006 16:19 GMT
>I knew that this was a great decidability problem....but isn't there any
>algorithm to do it ?

   Yes, such an algorithm exists. Tiny at
http://www.gittens.nl/grammar.html is a proof of concept parser generator
for context-sensitive grammars. It generates C++ code. If you can (or won't)
read the source code, you could try reading the articles posted on that
site, or contacting the author directly.

   - Oliver
Patricia Shanahan - 14 Sep 2006 16:03 GMT
>> I have to write a java program to test if a word w € L(G) for a
>> context sensitive grammar G.
[quoted text clipped - 17 lines]
> languages.
> </quote>

Most programming languages, including Java, are really context
sensitive. Whether:

a = b+c;

is a valid Java statement depends on whether a, b, and c have been
declared, and if so, their declared types.

The usual solution is to separate the rules into a very tractable
grammar, always context free, and a set of additional rules about
declarations etc.

Is there any possibility of doing that sort of translation on your
grammar? It is almost essential if this is a real problem, requiring a
practical solution.

If not, if it is e.g. homework, consider treating it in two pieces, and
algorithm question and a Java coding question. First look for an
algorithm, in any language. Once you understand the algorithm, code it
in Java.

Patricia


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.