| Analytic Grammar |
Website Links For Formal |
Information AboutAnalytic Grammar |
| CATEGORIES ABOUT FORMAL GRAMMAR | |
| formal languages | |
| SHOPPER'S DELIGHT | |
|
In ) Alphabet . Formal grammars are so named by analogy to Grammar in human languages. Formal grammars fall into two main categories: ''generative'' and ''analytic''.
In short, an analytic grammar describes how to ''read'' a language, whereas a generative grammar describes how to ''write'' it. GENERATIVE GRAMMARS A generative grammar consists of a set of rules for transforming strings. To generate a string in the language, one begins with a string consisting of only a single "start" symbol, and then successively applies the rules (any number of times, in any order) to rewrite this string. The language consists of all the strings that can be generated in this manner. Any particular sequence of legal choices taken during this rewriting process yields one particular string in the language, and if there are multiple different ways of generating a single string, then the grammar is said to be Ambiguous . For example, assume the alphabet consists of '' and '', the start symbol is '' and we have the following rules: : 1. : 2. then we start with "", and can choose a rule to apply to it. If we choose rule 1, we replace '' with '' and obtain "". If we choose rule 1 again, we replace '' with '' and obtain "". This process is repeated until we only have symbols from the alphabet (i.e., '' and ''). Finishing off our example, if we now choose rule 2, we replace '' with '' and obtain "", and are done. We can write this series of choices more briefly, using symbols: . The language of the grammar is the set of all the strings that can be generated using this process: . Formal definition In the classic formalization of generative grammars first proposed by Noam Chomsky in the 1950s , a grammar ''G'' consists of the following components:
Usually such a formal grammar is simply summarized as the quad-tuple . The ''language'' of a formal grammar , denoted as , is defined as all those strings over that can be generated by starting with the start symbol and then applying the production rules in until no more nonterminal symbols are present. Example ''For these examples, formal languages are specified using Set-builder Notation .'' Consider, for example, the grammar with , , consisting of the following production rules : 1. : 2. : 3. : 4. and the nonterminal symbol as the start symbol. Some examples of the derivation of strings in are: (where the used production rules are indicated in brackets and the replaced part is each time indicated in bold). | ||
|   | In | "http://wwwinformationdelightinfo/encyclopedia/entry/Vrhbosna/context-free_grammar" class="copylinks">Context-free Grammar s, the left hand side of a production rule may only be formed by a single non-terminal symbol The language defined above is not a context-free language, but for example the language <math>\left \{ a^{n}b^{n} n > 0
ight \}</math> (any positive number of 'a's followed by the same number of 'b's) is, as it can be defined by the grammar <math>G2</math> with <math>N=\left \{S
ight \}</math>, <math>\Sigma=\left \{a,b
ight \}</math>, <math>S</math> the start symbol, and the following production rules: |
|   | The Language Defined Above Is Not Regular, But The Language <math>\left \{ A^{n}b^{m} M,n > 0 Ight \}</math> (any Positive Number Of 'a's Followed By Any Positive Number Of 'b's, Where The Numbers May Be Different) Is, As It Can Be Defined By The Grammar <math>G3</math> With <math>N | \left \{S, A,B
ight \}</math>, <math>\Sigma=\left \{a,b
ight \}</math>, <math>S</math> the start symbol, and the following production rules: |