- Matrix grammar
-
A matrix grammar is a formal grammar in which instead of single productions, productions are grouped together into finite sequences. A production cannot be applied separately, it must be applied in sequence. In the application of such a sequence of productions, the rewriting is done in accordance to the each production in sequence, the first one, second one etc. till the last production has been used for rewriting. The sequences are referred to as matrices.
Matrix grammar is an extension of context-free grammar, and one instance of a Controlled grammar.
Formal definition
A matrix grammar is an ordered quadruple
- G = (VN,VT,X0,M).
where
- VN is a finite set of non-terminals
- VT is a finite set of terminals
- X0 is a special element of VN, viz. the starting symbol
- M is a finite set of non-empty sequences whose elements are ordered pairs
The pairs are called productions, written as
. The sequences are called matrices and can be written asLet F be the set of all productions appearing in the matrices m of a matrix grammar G. Then the matrix grammar G is of type-i,i = 0,1,2,3, length-increasing, linear, λ-free, context-free or context-sensitive if and only if the grammar G1 = (VN,VT,X0,F) has the following property.
For a matrix grammar G, a binary relation
is defined; also represented as
. For any
,
holds if and only if there exists an integer
such that the wordsover V exist and
- αi = P and αr + 1 = Q
- m is one of the matrices of G
- αi = RiPiRi and αi + 1 = RiQiRi.
If the above conditions are satisfied, it is also said that
holds with (m,R1) as the specifications.Let
be the reflexive transitive closure of the relation
. Then, the language generated by the matrix grammar G is given byExample
Consider the matrix grammar
G = ({S,X,Y},{a,b,c},S,M)
where M is a collection containing the following matrices:
![[S \rightarrow XY], \quad [X \rightarrow aXb, Y \rightarrow cY], \quad [X \rightarrow ab, Y \rightarrow c]](e/39ebeeb9c961971a919cc346377a6710.png)
These matrices, which contain only context-free rules generate the context-sensitive language

This example can be found on pages 8 and 9 of [1].
References
Categories:- Formal languages
Wikimedia Foundation. 2010.

![m = [P_1 \to Q_1, \ldots, P_r \to Q_r].](4/32440b2e8794137143d3ebf49248340d.png)

