Matrix grammar

From HandWiki

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 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 (P,Q) where

PV*VNV*,QV*,V=VNVT.[1]


The pairs are called productions, written as PQ. The sequences are called matrices and can be written as

m=[P1Q1,,PrQr].

Let 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 G is defined; also represented as . For any P,QV*, PQ holds if and only if there exists an integer r1 such that the words

α1,,,αr+1,P1,,Pr,Q1,,Qr,R1,,Rr,,R1,,Rr

over V exist and

  • α1=P and αr+1=Q
  • [P1Q1,,PrQr] is one of the matrices of G
  • αi=RiPiRi and αi+1=RiQiRi for all i such that 1ir.

Let * be the reflexive transitive closure of the relation . Then, the language generated by the matrix grammar G is given by

L(G)={PVT*|X0*P}.

Examples

Consider the matrix grammar

G=({S,X,Y},{a,b,c},S,M)

where M is a collection containing the following matrices:

m0:[SXY],m1:[XaXb,YcY],m2:[Xab,Yc]

These matrices, which contain only context-free rules, generate the context-sensitive language

L={anbncn|n1}. The associate word of anbncn is Aw(anbncn)=m0m1n2m2,n2 and Aw(abc)=m0m2.

This example can be found on pages 8 and 9 of [1] in the following form: Consider the matrix grammar

G=({S,X,Y,Z},{a,b,c},S,M)

where M is a collection containing the following matrices:

m0:[Sabc],m1:[SaXbYcZ],m2:[XaX,YbY,ZcZ],m3:[Xab,Yb,Zc]

These matrices, which contain only context-regular rules, generate the context-sensitive language

L={anbncn|n1}.

The associate word of anbncn is Aw(anbncn)=m1m2n2m3,n2 and Aw(abc)=m0.

Properties

Let MATAλ be the class of languages produced by matrix grammars, and MAT the class of languages produced by λ-free matrix grammars.

  • Trivially, MAT is included in MATAλ.
  • All context-free languages are in MAT, and all languages in MATAλ are recursively enumerable.
  • MAT is closed under union, concatenation, intersection with regular languages and permutation.
  • All languages in MAT can be produced by a context-sensitive grammar.
  • There exists a context-sensitive language which does not belong to MATAλ [2].
  • Each language produced by a matrix grammar with only one terminal symbol is regular.

Open problems

It is not known whether there exist languages in MATAλ which are not in MAT, and it is neither known whether MATAλ contains languages which are not context-sensitive [3].

References

Footnotes

  • ^ Ábrahám, S. Some questions of language theory. International Conference on Computational Linguistic, 1965. pp 1–11. [4]
  • ^ Gheorghe Păun, Membrane Computing: An Introduction, Springer-Verlag New York, Inc., Secaucus, NJ, USA, 2002. pp 30–32