WIPIVERSE All articles

Matrix grammar

In formal language theory, a matrix grammar is a type of regulated context-free grammar where productions are organized into finite sequences called matrices. During a derivation, the productions within a selected matrix must be applied consecutively in the specified order without interruption by productions from other matrices.

Definition

Formally, a matrix grammar is a quintuple $G = (N, T, M, S, F)$ where:

  • $N$ is a finite set of non-terminal symbols.
  • $T$ is a finite set of terminal symbols ($N \cap T = \emptyset$).
  • $S \in N$ is the start symbol.
  • $M$ is a finite set of matrices. Each matrix $m \in M$ is a finite sequence of context-free productions $(A_1 \to w_1, A_2 \to w_2, \dots, A_k \to w_k)$ where $A_i \in N$ and $w_i \in (N \cup T)^*$.
  • $F \subseteq M$ is a set of final matrices (sometimes defined via a set of final non-terminals or terminal strings).

Derivation Process

A derivation step in a matrix grammar consists of selecting a matrix $m = (p_1, p_2, \dots, p_k)$ from $M$ and applying the productions $p_1, p_2, \dots, p_k$ sequentially to the current sentential form.

  • The derivation starts with the start symbol $S$.
  • If a production in a matrix cannot be applied (i.e., its left-hand side non-terminal does not appear in the current sentential form), the entire matrix application fails, and that derivation path is blocked (this is the standard mode; variants exist where skipping is allowed).
  • A terminal string $w \in T^$ is generated if there is a derivation $S \Rightarrow^ w$ ending with the application of a matrix in $F$ (or resulting in a string containing only terminals, depending on the specific definition variant).

Generative Power

The family of languages generated by matrix grammars (denoted $MAT$) is properly included between the context-free languages ($CF$) and the context-sensitive languages ($CS$): $$CF \subset MAT \subset CS$$ Matrix grammars without appearance checking (where a production must be applied if its left-hand side is present) generate the family of matrix languages without appearance checking ($MAT^\lambda$ or $MAT_{ac}$ depending on notation). With appearance checking (allowing a production $A \to x$ to be skipped if $A$ does not appear in the sentential form), matrix grammars become computationally complete (generate exactly the recursively enumerable languages, $RE$).

Variants and Related Concepts

  • Vector Grammars: A generalization where the sequence of productions in a matrix is replaced by a set (vector) of productions that can be applied in any order.
  • Programmed Grammars: Another regulation mechanism where each production has a success field and a failure field determining the next production to apply.
  • Grammars with Regular Control: Matrix grammars can be viewed as context-free grammars whose derivation sequences are constrained by a regular language over the set of production labels.

History

Matrix grammars were introduced in the early 1970s, notably by Gheorghe Păun, as a mechanism to increase the generative capacity of context-free grammars while maintaining structural restrictions stronger than context-sensitive grammars. They are a central topic in the theory of regulated rewriting.

Browse

More topics to explore

    Browse all articles