Misplaced Pages

Matrix grammar

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.
This article includes a list of general references, but it lacks sufficient corresponding inline citations. Please help to improve this article by introducing more precise citations. (April 2024) (Learn how and when to remove this message)

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 = ( V N , V T , X 0 , M ) {\displaystyle G=(V_{N},V_{T},X_{0},M)} where

  • V N {\displaystyle V_{N}} is a finite set of non-terminals
  • V T {\displaystyle V_{T}} is a finite set of terminals
  • X 0 {\displaystyle X_{0}} is a special element of V N {\displaystyle V_{N}} , viz. the starting symbol
  • M {\displaystyle M} is a finite set of non-empty sequences whose elements are ordered pairs ( P , Q ) {\displaystyle (P,Q)} where

P V V N V , Q V , V = V N V T . {\displaystyle \quad P\in V^{*}V_{N}V^{*},\quad Q\in V^{*},\quad V=V_{N}\cup V_{T}.}


The pairs are called productions, written as P Q {\displaystyle P\to Q} . The sequences are called matrices and can be written as

m = [ P 1 Q 1 , , P r Q r ] . {\displaystyle m=.}

Let F {\displaystyle F} be the set of all productions appearing in the matrices m {\displaystyle m} of a matrix grammar G {\displaystyle G} . Then the matrix grammar G {\displaystyle G} is of type- i , i = 0 , 1 , 2 , 3 {\displaystyle i,i=0,1,2,3} , length-increasing, linear, λ {\displaystyle \lambda } -free, context-free or context-sensitive if and only if the grammar G 1 = ( V N , V T , X 0 , F ) {\displaystyle G_{1}=(V_{N},V_{T},X_{0},F)} has the following property.

For a matrix grammar G {\displaystyle G} , a binary relation G {\displaystyle \Rightarrow _{G}} is defined; also represented as {\displaystyle \Rightarrow } . For any P , Q V {\displaystyle P,Q\in V^{*}} , P Q {\displaystyle P\Rightarrow Q} holds if and only if there exists an integer r 1 {\displaystyle r\geq 1} such that the words

α 1 , , , α r + 1 , P 1 , , P r , Q 1 , , Q r , R 1 , , R r , , R 1 , , R r {\displaystyle \alpha _{1},,\ldots ,\alpha _{r+1},\quad P_{1},\ldots ,P_{r},\quad Q_{1},\ldots ,Q_{r},\quad R_{1},\ldots ,R_{r},\quad ,R^{1},\ldots ,R^{r}}

over V exist and

  • α 1 = P {\displaystyle \alpha _{1}=P} and α r + 1 = Q {\displaystyle \alpha _{r+1}=Q}
  • [ P 1 Q 1 , , P r Q r ] {\displaystyle } is one of the matrices of G {\displaystyle G}
  • α i = R i P i R i {\displaystyle \alpha _{i}=R_{i}P_{i}R^{i}} and α i + 1 = R i Q i R i {\displaystyle \alpha _{i+1}=R_{i}Q_{i}R^{i}} for all i {\displaystyle i} such that 1 i r . {\displaystyle 1\leq i\leq r.}

Let {\displaystyle \Rightarrow ^{*}} be the reflexive transitive closure of the relation {\displaystyle \Rightarrow } . Then, the language generated by the matrix grammar G {\displaystyle G} is given by

L ( G ) = { P V T | X 0 P } . {\displaystyle L(G)=\{P\in {V_{T}}^{*}|X_{0}\Rightarrow ^{*}P\}.}

Examples

Consider the matrix grammar

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

where M {\displaystyle M} is a collection containing the following matrices:

m 0 : [ S X Y ] , m 1 : [ X a X b , Y c Y ] , m 2 : [ X a b , Y c ] {\displaystyle m_{0}:,\quad m_{1}:,\quad m_{2}:}

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

L = { a n b n c n | n 1 } . {\displaystyle L=\{a^{n}b^{n}c^{n}|n\geq 1\}.} The associate word of a n b n c n {\displaystyle a^{n}b^{n}c^{n}} is A w ( a n b n c n ) = m 0 m 1 n 2 m 2 , n 2 {\displaystyle Aw(a^{n}b^{n}c^{n})=m_{0}m_{1}^{n-2}m_{2},\forall n\geq 2} and A w ( a b c ) = m 0 m 2 {\displaystyle Aw(abc)=m_{0}m_{2}} .

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

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

where M {\displaystyle M} is a collection containing the following matrices:

m 0 : [ S a b c ] , m 1 : [ S a X b Y c Z ] , m 2 : [ X a X , Y b Y , Z c Z ] , m 3 : [ X a b , Y b , Z c ] {\displaystyle m_{0}:,\quad m_{1}:,\quad m_{2}:,\quad m_{3}:}

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

L = { a n b n c n | n 1 } . {\displaystyle L=\{a^{n}b^{n}c^{n}|n\geq 1\}.}

The associate word of a n b n c n {\displaystyle a^{n}b^{n}c^{n}} is A w ( a n b n c n ) = m 1 m 2 n 2 m 3 , n 2 {\displaystyle Aw(a^{n}b^{n}c^{n})=m_{1}m_{2}^{n-2}m_{3},\forall n\geq 2} and A w ( a b c ) = m 0 {\displaystyle Aw(abc)=m_{0}} .

Properties

Let MAT λ {\displaystyle {\ce {MAT^{\lambda }}}} be the class of languages produced by matrix grammars, and MAT the class of languages produced by λ {\displaystyle \lambda } -free matrix grammars.

  • Trivially, MAT is included in MAT λ {\displaystyle {\ce {MAT^{\lambda }}}} .
  • All context-free languages are in MAT, and all languages in MAT λ {\displaystyle {\ce {MAT^{\lambda }}}} 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 MAT λ {\displaystyle {\ce {MAT^{\lambda }}}} .
  • 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 MAT λ {\displaystyle {\ce {MAT^{\lambda }}}} which are not in MAT, and it is neither known whether MAT λ {\displaystyle {\ce {MAT^{\lambda }}}} contains languages which are not context-sensitive .

References

  1. Salomaa, Arto (March 1972). "Matrix grammars with a leftmost restriction" (PDF). Information and Control. 20 (2): 143–149. doi:10.1016/S0019-9958(72)90332-4.

Footnotes

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