Regular grammar

Regular grammar

= Strictly regular grammars =

In computer science, a right regular grammar (also called right linear grammar) is a formal grammar ("N", Σ, "P", "S") such that all the production rules in "P" are of one of the following forms:
# "A" → "a" - where "A" is a non-terminal in "N" and "a" is a terminal in Σ
# "A" → "aB" - where "A" and "B" are in "N" and "a" is in Σ
# "A" → ε - where "A" is in "N" and ε denotes the empty string, i.e. the string of length 0.

In a left regular grammar (also called left linear grammar), all rules obey the forms
# "A" → "a" - where "A" is a non-terminal in "N" and "a" is a terminal in Σ
# "A" → "Ba" - where "A" and "B" are in "N" and "a" is in Σ
# "A" → ε - where "A" is in "N" and ε is the empty string.

An example of a right regular grammar "G" with "N" = {S, A}, Σ = {a, b, c}, "P" consists of the following rules: S → aS: S → bA: A → ε: A → cAand S is the start symbol. This grammar describes the same language as the regular expression a*bc*.

A regular grammar is a left regular or right regular grammar.

Some textbooks and articles disallow empty production rules,and assume that the empty string is not present in languages.

Extended regular grammars

An "extended right regular grammar" is one in which all rules obey one of
# "A" → "a" - where "A" is a non-terminal in "N" and "a" is a terminal in Σ
# "A" → "Bw" - where "A" and "B" are in "N" and "w" is in Σ*
# "A" → ε - where "A" is in "N" and ε is the empty string.Some authors call this type of grammar a "right regular grammar" (or "right linear grammar") and the type above a "strictly right regular grammar" (or "strictly right linear grammar").

An "extended left regular grammar" is one in which all rules obey one of
# "A" → "a" - where "A" is a non-terminal in "N" and "a" is a terminal in Σ
# "A" → "wB" - where "A" and "B" are in "N" and "w" is in Σ*
# "A" → ε - where "A" is in "N" and ε is the empty string.Some authors call this type of grammar a "left regular grammar" and the type above a "strictly left regular grammar".

Expressive power

There is a direct one-to-one correspondence between the rules of a (strictly) left regular grammar and those of a nondeterministic finite state automaton, such that the grammar generates exactly the language the automaton accepts. Hence, the left regular grammars generate exactly all regular languages. The right regular grammars obviously describe the reverses of all such languages, that is, exactly the regular languages as well.

Every strict right regular grammar is extended right regular, while every extended right regular grammar can be made strict by inserting new nonterminals, such that the result generates the same language; hence, extended right regular grammars generate the regular languages as well. Analogously, so do the extended left regular grammars.

If empty productions are disallowed, only all regular languages that do not include the empty string can be generated.

Mixing left and right regular rules

If mixing of left-regular and right-regular rules is allowed, we still have a linear grammar, but not necessarily a regular one.What is more, such a grammar need not generate a regular language: all linear grammars can be easily brought into this form, and hence, such grammars can generate exactly all linear languages, including nonregular ones.

For instance, the grammar "G" with "N" = {S, A}, Σ = {a, b}, "P" with start symbol "S" and rules: S → aA: A → Sb: S → εgenerates { a^ib^i | i >= 0}, the paradigmatic non-regular linear language.

See also

* Linear Grammar
* Prefix grammar
* Chomsky hierarchy


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать курсовую

Look at other dictionaries:

  • Regular language — In theoretical computer science, a regular language is a formal language (i.e., a possibly infinite set of finite sequences of symbols from a finite alphabet) that satisfies the following equivalent properties: * it can be accepted by a… …   Wikipedia

  • regular — ► ADJECTIVE 1) arranged or recurring in a constant or definite pattern, especially with the same space between individual instances. 2) doing the same thing often or at uniform intervals: regular worshippers. 3) done or happening frequently. 4)… …   English terms dictionary

  • Regular Language description for XML — (RELAX) is a specification for describing XML based languages.A description written in RELAX is called a RELAX grammar. RELAX Core has been approved as an ISO/IEC Technical Report 22250 1.RELAX was designed by Murata Makoto. See also *RELAX NG… …   Wikipedia

  • Regular expression — In computing, a regular expression provides a concise and flexible means for matching (specifying and recognizing) strings of text, such as particular characters, words, or patterns of characters. Abbreviations for regular expression include… …   Wikipedia

  • regular — reg|u|lar1 W2S2 [ˈregjulə US ər] adj ▬▬▬▬▬▬▬ 1¦(every hour/day/week etc)¦ 2¦(often)¦ 3¦(usual)¦ 4¦(equal distance)¦ 5¦(ordinary)¦ 6¦(normal size)¦ 7¦(shape)¦ 8¦(grammar)¦ 9¦(emphasizing)¦ 10 regular army/troops/so …   Dictionary of contemporary English

  • Regular tree grammar — In Computer Science, a regular tree grammar is a formal grammar that allows to generate trees.DefinitionA regular tree grammar G is defined by the tuple:G = (N, Sigma, Z, P), where * N is a set of non terminals, * Sigma is a ranked alphabet (i.e …   Wikipedia

  • regular — reg|u|lar1 [ regjələr ] adjective *** ▸ 1 arranged evenly ▸ 2 doing something often ▸ 3 ordinary ▸ 4 with normal grammar ▸ 5 of professional army 1. ) usually before noun arranged so that there is the same amount of time between events, or the… …   Usage of the words and phrases in modern English

  • grammar — I (New American Roget s College Thesaurus) Mode of speaking and writing Nouns 1. grammar; accidence, syntax, analysis, synopsis, praxis, punctuation, syllabi[fi]cation; agreement. See speech, language, writing. 2. a. part of speech; participle;… …   English dictionary for students

  • Grammar of Assent — An Essay in Aid of a Grammar of Assent is John Henry Newman s seminal work. Though completed in 1870, Newman revealed to friends that it took him 20 years to write the book after many fits and starts.The Grammar was an apologia for faith. Newman… …   Wikipedia

  • regular — [[t]re̱gjʊlə(r)[/t]] ♦♦ regulars 1) ADJ GRADED: usu ADJ n Regular events have equal amounts of time between them, so that they happen, for example, at the same time each day or each week. Take regular exercise... Now it s time for our regular… …   English dictionary

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”