Language generated by a grammer

  • Thread starter Thread starter Movingon
  • Start date Start date
  • Tags Tags
    Language
AI Thread Summary
The discussion centers on determining the language generated by a given formal grammar without manually applying its rules. It highlights that while one can identify the language's position in the Chomsky hierarchy by inspecting the grammar's structure, obtaining a precise description often requires rule application. The example provided illustrates a specific grammar that generates the language L = {a^n b^{2n+m} | n ≥ 0, m ≥ 0}. Participants suggest that for more complex grammars, simply analyzing the form may not suffice to fully describe the generated language. Ultimately, the conversation emphasizes the challenges in accurately identifying a language from its grammar without extensive rule application.
Movingon
Messages
4
Reaction score
0
Ok I have a simple question. Let us say we have a formal grammar, let us take this simple example:

S → aSb
S → ab

This grammar generates language a^n b^n. My question is, is there a way I can tell what kind of language this generates from the rules? I can of course apply the rules and find out this grammar can generate such a language but sometimes we may have more complex examples containing more rules. So my questions is, how can we then find out exactly the kind of language generated by a given grammar without having to manually apply rules as this may not be always practical? Thanks in advance!
 
Technology news on Phys.org
"exactly the kind of language generated by a given grammar" is perhaps not precise enough to know exactly what kind of answer you want given any arbitrary grammar.

You can, by inspecting the form of the grammar and not manually applying the rules, probably determine which level of the Chomksy heirarchy the language resides in.

A few seconds of searching turns up one reasonable description of the heirarchy.
http://www.answers.com/topic/chomsky-hierarchy
There are many other well written descriptions of this out there.

If, as I suspect, you are looking for a more precise description of the language than this then I suspect the answer may be that you cannot determine this in every case by just inspecting the form of the grammar.
 
Thanks. Yeah what I meant was describing more precisely and formally a language generated by a certain grammar, the Chomsky hierarchy I already know of. For example, you are given a grammar as follows: G = ({S, X}, {a, b}, P, S) with the rules:
P = {S → aaSbb | X | ε, X → Xb | ε}.

where ε here stands for the empty string. You are asked to find out and describe formally the language generated by this grammar. As it turns out, this grammar generates language L = {a^n b^{2n+m} | n \geq 0, m \geq 0}

So my question is, how could I, for example, figure out that this grammar generates this language? Do I have to apply those rules and then from the result find out the kind of language generated? Is this the only way to find out a language L generated by grammar G?
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
What percentage of programmers have learned to touch type? Have you? Do you think it's important, not just for programming, but for more-than-casual computer users generally? ChatGPT didn't have much on it ("Research indicates that less than 20% of people can touch type fluently, with many relying on the hunt-and-peck method for typing ."). 'Hunt-and-peck method' made me smile. It added, "For programmers, touch typing is a valuable skill that can enhance speed, accuracy, and focus. While...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...
Back
Top