Regular grammar

related topics
{math, number, function}
{language, word, form}
{company, market, business}

In theoretical computer science, a regular grammar is a formal grammar that describes a regular language.


Strictly regular grammars

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:

In a left regular grammar (also called left linear grammar), all rules obey the forms

An example of a right regular grammar G with N = {S, A}, Σ = {a, b, c}, P consists of the following rules

and S is the start symbol. This grammar describes the same language as the regular expression a*bc*.

A regular grammar is a left 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

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

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 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

generates \{ a^ib^i : i \geq 0\}, the paradigmatic non-regular linear language.

Full article ▸

related documents
Tree structure
Characteristic subgroup
Mutual recursion
Complete category
Category of sets
Hamiltonian path problem
Baire category theorem
Sophie Germain prime
Elias delta coding
Axiom of union
Abelian category
Product of rings
Brun's constant
Column vector
Normal morphism
Sum rule in differentiation
Up to
AVL tree
Double precision
Blum Blum Shub
Contraction mapping
Complete measure
Multiple inheritance
LALR parser
Babylonian numerals
Nearest neighbour algorithm
Inverse functions and differentiation