Range concatenation grammar

Range concatenation grammar (RCG) is a grammar formalism developed by Pierre Boullier in 1998 as an attempt to characterize a number of phenomena of natural language, such as Chinese numbers and German word order scrambling, which are outside the bounds of the mildly context-sensitive languages.

From a theoretical point of view, any language that can be parsed in polynomial time belongs to the subset of RCG called positive range concatenation grammars, and reciprocally.

Though intended as a variant on Groenink's literal movement grammars (LMGs), RCGs treat the grammatical process more as a proof than as a production. Whereas LMGs produce a terminal string from a start predicate, RCGs aim to reduce a start predicate (which predicates of a terminal string) to the empty string, which constitutes a proof of the terminal strings membership in the language.

Formal definition
A Positive Range Concatenation Grammar (PRCG) is a tuple $$ G = (N,~T,~V,~S,~P)$$, where:
 * $$N$$, $$T$$ and $$V$$ are disjoint finite sets of (respectively) predicate names, terminal symbols and variable names. Each predicate name has an associated arity given by the function $$\dim: N \rightarrow \mathbb{N}\setminus\{0\}$$.
 * $$S \in N$$ is the start predicate name and verify $$\dim(S)=1$$.
 * $$P$$ is a finite set of clauses of the form $$\psi_0 \rightarrow \psi_1 \ldots \psi_m$$, where the $$\psi_i$$ are predicates of the form $$A_i(\alpha_1, \ldots, \alpha_{\dim(A_i)})$$ with $$A_i \in N$$ and $$\alpha_i \in (T \cup V)^\star$$.

A Negative Range Concatenation Grammar (NRCG) is defined like a PRCG, but with the addition that some predicates occurring in the right-hand side of a clause can have the form $$\overline{A_i(\alpha_1, \ldots, \alpha_{\dim(A_i)})}$$. Such predicates are called negative predicates.

A Range Concatenation Grammar is a positive or a negative one. Although PRCGs are technically NRCGs, the terms are used to highlight the absence (PRCG) or presence (NRCG) of negative predicates.

A range in a word $$w \in T^\star$$ is a couple $$\langle l, r \rangle_w$$, with $$0 \leq l \leq r \leq n$$, where $$n$$ is the length of $$w$$. Variables bind to ranges, not to arbitrary strings of nonterminals. Two ranges $$\langle l_1, r_1 \rangle_w$$ and $$\langle l_2, r_2 \rangle_w$$ can be concatenated iff $$r_1 = l_2$$, and we then have: $$\langle l_1, r_1 \rangle_w \cdot \langle l_2, r_2 \rangle_w = \langle l_1, r_2 \rangle_w$$. When instantiating a clause, where an argument consists of multiple elements from $$T \cup V$$, their ranges must concatenate.

For a word $$w = w_1w_2\ldots w_n$$, with $$w_i \in T$$, the dotted notation for ranges is: $$\langle l, r \rangle_w = w_1\ldots w_{l-1} \bullet w_l\ldots w_{r-1} \bullet w_r\ldots w_n$$.

Recognition of strings
The strings of predicates being rewritten represent constraints that the string being tested has to satisfy (if positive), or in the case of negative predicates not satisfy. The order of predicates is irrelevant. Rewrite steps amount to replacing one constraint by zero or more simpler constraints.

Like LMGs, RCG clauses have the general schema $$A(x_1, ..., x_n) \to \alpha$$, where in an RCG, $$\alpha$$ is either the empty string or a string of predicates. The arguments $$x_i$$ consist of strings of terminal symbols and/or variable symbols, which pattern match against actual argument values like in LMG. Adjacent variables constitute a family of matches against partitions, so that the argument $$xy$$, with two variables, matches the literal string $$ab$$ in three different ways: $$x = \epsilon,\ y = ab;\ x = a,\ y = b;\ x = ab,\ y = \epsilon$$. These would give rise to three different instantiations of the clause containing that argument $$xy$$.

Predicate terms come in two forms, positive (which produce the empty string on success), and negative (which produce the empty string on failure/if the positive term does not produce the empty string). Negative terms are denoted the same as positive terms, with an overbar, as in $$\overline{A(x_1, ..., x_n)}$$.

The rewrite semantics for RCGs is rather simple, identical to the corresponding semantics of LMGs. Given a predicate string $$A(\alpha_1, ..., \alpha_n)$$, where the symbols $$\alpha_i$$ are terminal strings, if there is a rule $$A(x_1, ..., x_n) \to \beta$$ in the grammar that the predicate string matches, the predicate string is replaced by $$\beta$$, substituting for the matched variables in each $$x_i$$.

For example, given the rule $$A(x, ayb) \to B(axb, y)$$, where $$x$$ and $$y$$ are variable symbols and $$a$$ and $$b$$ are terminal symbols, the predicate string $$A(a, abb)$$ can be rewritten as $$B(aab, b)$$, because $$A(a, abb)$$ matches $$A(x, ayb)$$ when $$x = a,\ y = b$$. Similarly, if there were a rule $$A(x, ayb) \to A(x, x)\ A(y, y)$$, $$A(a, abb)$$ could be rewritten as $$A(a, a)\ A(b, b)$$.

A proof/recognition of a string $$\alpha$$ is done by showing that $$S(\alpha)$$ produces the empty string. For the individual rewrite steps, when multiple alternative variable matches are possible, any rewrite which could lead the whole proof to succeed is considered. Thus, if there is at least one way to produce the empty string from the initial string $$S(\alpha)$$, the proof is considered a success, regardless of how many other ways to fail exist.

Example
RCGs are capable of recognizing the non-linear index language $$\{ www : w \in \{a,b\}^{*} \}$$ as follows:

Letting x, y, and z be variable symbols: $$ \begin{aligned} S(xyz) &\to A(x, y, z) \\ A(ax, ay, az) &\to A(x, y, z) \\ A(bx, by, bz) &\to A(x, y, z) \\ A(\epsilon, \epsilon, \epsilon) &\to \epsilon \end{aligned} $$ The proof for abbabbabb is then

$$S(abbabbabb) \Rightarrow A(abb, abb, abb) \Rightarrow A(bb, bb, bb) \Rightarrow A(b, b, b) \Rightarrow A(\epsilon, \epsilon, \epsilon) \Rightarrow \epsilon$$

Or, using the more correct dotted notation for ranges:

$$S(\bullet{}abbabbabb\bullet{}) \Rightarrow A(\bullet{}abb\bullet{}abbabb, abb\bullet{}abb\bullet{}abb, abbabb\bullet{}abb\bullet{}) \Rightarrow A(a\bullet{}bb\bullet{}abbabb, abba\bullet{}bb\bullet{}abb, abbabba\bullet{}bb\bullet{})$$ $$\Rightarrow A(ab\bullet{}b\bullet{}abbabb, abbab\bullet{}b\bullet{}abb, abbabbab\bullet{}b\bullet{}) \Rightarrow A(\epsilon, \epsilon, \epsilon) \Rightarrow \epsilon$$

For a string of $$3n$$ letters, there are $$\binom{3n+2}{2} = \frac{(3n+2)(3n+1)}{2}$$ different instantiations of that first clause, but only the one which makes $$x,y,z$$ all $$n$$ letters each allows the derivation to reach $$\epsilon$$.

Properties
Every context-free grammar (CFG) can be converted into a range concatenation grammar:
 * For every nonterminal $$A$$ of the CFG, the RCG has an arity $$1$$ predicate $$A(x)$$.
 * For every CFG rule $$A \to BC$$, the RCG has $$A(xy) \to B(x) C(y)$$.
 * For every CFG rule $$A \to a$$ (where $$a$$ terminal), the RCG has $$A(a) \to \epsilon$$.

The intersection and union of two range concatenation languages are trivially range concatenation languages: Possibly negative range concatenation languages are also closed under set complement.
 * For $$S$$ the intersection of $$A$$ and $$B$$, you have $$S(x) \to A(x)B(x)$$.
 * For $$S$$ the union of $$A$$ and $$B$$, you have $$S(x) \to A(x)$$ and $$S(x) \to B(x)$$.

A consequence of the above is that it is undecidable whether a (positive) range concatenation language is nonempty, because it is undecidable whether the intersection of two context-free languages is nonempty. Hence range concatenation grammars are not generative.