Unrestricted Grammar

2 min read Last updated Sat Jun 27 2026 08:46:52 GMT+0000 (Coordinated Universal Time)

Aka. phrase-structure grammar. A 4-tuple G=(V,Σ,S,P)G = (V, \Sigma, S, P) where:

  • VV — non-terminals
  • Σ\Sigma — terminals
    VV and Σ\Sigma are disjoint.
  • SS — start symbol
  • PP — productions
    αβ\alpha \to \beta where α,β(VΣ)\alpha, \beta \in (V \cup \Sigma)^* and α\alpha contains 1\geq 1 non-terminal

Productions αβ\alpha \to \beta impose no length constraint. Both the LHS and RHS can contain any mix of terminals and non-terminals.

LHS must contain 1\ge 1 non-terminal. This is the only restriction.

Equivalence to Turing Machines

  • For any recursively-enumerable language LL, there exists an unrestricted grammar GG generating LL.
  • For any unrestricted grammar GG, there exists a Turing machine TT accepting the same language.

Unrestricted grammars generate exactly the recursively-enumerable languages.

Example

The language L={anbncnn1}L = \{a^n b^n c^n \mid n \ge 1\} is not context-free but is generated by an unrestricted grammar. The grammar uses non-terminals to enforce equal counts across 3 symbol types by rewriting across the string.

A simpler example: L={www{a,b}+}L = \{ww \mid w \in \{a,b\}^+\} (strings that are the concatenation of a word with itself).

Productions (sketch):

  • SABS \to AB — separate the 2 halves
  • AaAbAλA \to aA \mid bA \mid \lambda — generate first half
  • BaBbBλB \to aB \mid bB \mid \lambda — generate second half
  • Synchronization rules force AA and BB to produce the same string

Full grammars for such languages use auxiliary non-terminals and cross-symbol rewriting that no CFG production AαA \to \alpha can simulate.

Was this helpful?