# Binary Context-Free Grammars

^{1}

^{2}

^{3}

^{4}

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Regulated, Parallel and Relational Grammars

**Control by prescribed sequences of production rules**where the sequence of productions applied in a derivation belong to a regular language associated with the grammar:

- matrix grammars [12]—the set of production rules is divided into matrices and if the application of a matrix is started, a second matrix can be started after finishing the application of the first one, as well as the rules have to been applied in the order given a matrix;
- vector grammars [13]—in which a new matrix can be started before finishing those which have been started earlier;
- regularly controlled grammars [14]—the sequence of production rules applied in a derivation belong to a given regular language associated with the grammar.

**Control by computed sequences of production rules**where a derivation is accompanied by a computation, which selects the allowed derivations:

- programmed grammars [15]—after applying a production rule, the next production rule has to be chosen from its success field, and if the left hand side of the rule does not occur in the sentential form, a rule from its failure field has to be chosen;
- valence grammars [16]—where with each sentential form an element of a monoid is associated, which is computed during the derivation and derivations where the element associated with the terminal word is the neutral element of the monoid are accepted.

**Control by context conditions**where the applicability of a rule depends on the current sentential form and with any rule some restrictions are associated for sentential forms which have to be satisfied in order to apply the rule:

- random context grammars [17]—the restriction is the belonging to a regular language associated with the rule;
- conditional grammars [18]—the restriction to special regular sets;
- semi-conditional grammars [19]—the restriction to words of length one in the permitting and forbidden contexts;
- ordered grammars [18]—a production rule can be applied if there is no greater applicable production rule.

**Control by memory**where with any nonterminal in a sentential form, its derivation is associated:

- indexed grammars [20]—the application of production rules gives sentential forms where the nonterminal symbols are followed by sequences of indexes (stack of special symbols), and indexes can be erased only by rules contained in these indexes but erasing of the indexes is done in reverse order of their appearance.

**Control by external mechanism**where a mechanism used to select derivations does not belong to the grammar:

**total parallelism**, which is used in the broad varieties of (Deterministic Extended Tabled Zero-Sided) Lindenmayer systems [5,25] where all symbols of strings including terminals are in each step rewritten by productions. The second is

**partial parallelism**where all or some nonterminal symbols (not terminal symbols) are written in each step of the derivations:

- absolutely parallel grammars [26]—all nonterminals of the sentential form are rewritten in one derivation step;
- Indian parallel grammars [27]—all occurrences of one letter are replaced (according to one rule);
- Russian parallel grammars [28]—which combines the context-free and Indian parallel feature;
- scattered context grammars [29]—in which only a fixed number of symbols can be replaced in a step but the symbols can be different;
- concurrently controlled grammars [30]—the control over a parallel application of the productions is realized by a Petri net with different parallel firing strategies.

**grammar system**, which is a system of several phrase-structure grammars with own axioms, symbols and rewriting productions that can work simultaneously and generate own strings. One of such grammar systems is a parallel communicating grammar system [31,32], where the grammars start from separate axioms, work parallelly rewriting their own sentential forms, and also communicate with each other by request. The language of one distinguished grammar in the system is considered the language of the system.

## 3. Notions and Notations

**Basic conventions**: the inclusion is denoted by ⊆ and the strict (proper) inclusion is denoted by ⊂. The symbol ∅ denotes the empty set. The powerset of a set X is denoted by $\mathcal{P}\left(X\right)$, while its cardinality is denoted by $\left|X\right|$. An ordered sequence of elements $a,b$ is called a pair and denoted by $(a,b)$. Two pairs $({a}_{1},{a}_{2})$ and $({b}_{1},{b}_{2})$ are equal iff ${a}_{1}={b}_{1}$ and ${a}_{2}={b}_{2}$. Let $X,Y$ be sets. The set of all pairs $(a,b)$, where $a\in X$ and $b\in Y$, is called the Cartesian product of X and Y, and denoted by $X\times Y$. Then, $X\times X={X}^{2}$. A binary relation on sets $X,Y$ is a subset of the Cartesian product $X\times Y$.

#### Strings, Languages and Grammars

**Definition**

**1.**

**Definition**

**2.**

**Definition**

**3.**

**Definition**

**4.**

**Example**

**1.**

**Definition**

**5.**

**Definition**

**6.**

**Definition**

**7.**

- The string $x\in {(V\cup \Sigma )}^{+}$ directly derives $y\in {(V\cup \Sigma )}^{*}$, written as $x\to y$, if and only if there is a rule $r=A\to \alpha \in R$ such that $x={x}_{1}A{x}_{2}$ and $y={x}_{1}\alpha {x}_{2}$.
- The reflexive and transitive closure of the relation ⇒ is denoted by ${\Rightarrow}^{*}$.
- A derivation using the sequence of rules $\tau ={r}_{1}{r}_{2}\cdots {r}_{n}$ is denoted by $\stackrel{\tau}{\Rightarrow}$ or $\stackrel{{r}_{1}{r}_{2}\cdots {r}_{n}}{\Rightarrow}$.
- The language generated by a grammar G is defined by $L\left(G\right)=\{w\in {\Sigma}^{*}\mid S{\Rightarrow}^{*}w\}$.

**Example**

**2.**

**Definition**

**8.**

**Example**

**3.**

**Definition**

**9.**

**Definition**

**10.**

- (1)
- $(P,T,F,\varphi )$ is a Petri net;
- (2)
- labeling functions $\beta :P\to V$ and $\gamma :T\to R$ are bijections;
- (3)
- there is an arc from place p to transition t if and only if $\gamma \left(t\right)=A\to \alpha $ and $\beta \left(p\right)=A$. The weight of the arc $(p,t)$ is 1;
- (4)
- there is an arc from transition t to place p if and only if $\gamma \left(t\right)=A\to \alpha $ and $\beta \left(p\right)=x$ where $x\in V$ and ${\left|\alpha \right|}_{x}>0$. The weight of the arc $(t,p)$ is ${\left|\alpha \right|}_{x}$;
- (5)
- the initial marking ι is defined by $\iota \left({\beta}^{-1}\left(S\right)\right)=1$ and $\iota \left(p\right)=0$ for all $p\in P-\left\{{\beta}^{-1}\left(S\right)\right\}$.

**Example**

**4.**

**Definition**

**11.**

**Theorem**

**1.**

## 4. Binary Strings, Languages and Grammars

**Definition**

**12.**

**Definition**

**13.**

**Definition**

**14.**

**Definition**

**15.**

- union is defined as ${L}_{1}\cup {L}_{2}=\{w\mid w\in {L}_{1}\phantom{\rule{4.pt}{0ex}}\mathrm{or}\phantom{\rule{4.pt}{0ex}}w\in {L}_{2}\},$
- concatenation is defined as ${L}_{1}{L}_{2}=\{uv\mid u\in {L}_{1}\phantom{\rule{4.pt}{0ex}}\mathrm{and}\phantom{\rule{4.pt}{0ex}}v\in {L}_{2}\}.$

**Definition**

**16.**

**Definition**

**17.**

- (1)
- ${V}_{i}$, $i=1,2$, are sets of nonterminal symbols,
- (2)
- ${\Sigma}_{i}$, with ${V}_{i}\cap {\Sigma}_{i}=\varnothing $, $i=1,2$, are sets of terminal symbols,
- (3)
- $({S}_{1},{S}_{2})\in {V}_{1}\times {V}_{2}$ is the start (initial) pair, and
- (4)
- R is a finite set nonempty set of binary productions (rules).A binary production is a pair $({r}_{1},{r}_{2})$ where ${r}_{i}$, $i=1,2$, is either empty or it is a context-free production, i.e., ${r}_{i}\in {V}_{i}\times {({V}_{i}\cup {\Sigma}_{i})}^{*}$.

**Remark**

**1.**

**Remark**

**2.**

**Remark**

**3.**

**Definition**

**18.**

**Definition**

**19.**

**Definition**

**20.**

**Example**

**5.**

**Example**

**6.**

## 5. Synchronized Forms for Binary Grammars

**Definition**

**21.**

**Lemma**

**1.**

**Proof.**

**Lemma**

**2.**

**Proof.**

**Lemma**

**3.**

## 6. Generative Capacities of Binary Grammars

**Lemma**

**4.**

**Lemma**

**5.**

**Lemma**

**6.**

**Proof.**

**Lemma**

**7.**

**Proof.**

**Corollary**

**1.**

**Lemma**

**8.**

**Proof.**

**Lemma**

**9.**

**Proof.**

- (1)
- the start production: $({S}_{1}\to X,{S}_{2}\to S),$
- (2)
- the matrix entry productions: $(X\to {Y}_{i},\varnothing ),1\le i\le n,$
- (3)
- the matrix processing productions:$$\left({Y}_{i}\to {Z}_{i,1},{r}_{i,1}\right),({Z}_{i,1}\to {Z}_{i,2},{r}_{i,2}),\dots ,({Z}_{i,k\left(i\right)-1}\to {Z}_{i,k\left(i\right)},{r}_{i,k\left(i\right)})$$
- (4)
- the matrix exit productions: $({Z}_{i,k\left(i\right)}\to X,\varnothing ),1\le i\le n.$
- (5)
- the terminating production: $(X\to \lambda ,\varnothing ).$

**Lemma**

**10.**

**Proof.**

- $(P,T,F,\varphi )$ is a Petri net;
- the labeling functions $\beta :P\to {V}_{1}$ and $\gamma :T\to R$ are bijections;
- there is an arc from place p to transition t if and only if $\gamma \left(t\right)=({r}_{1},{r}_{2})$ and $\beta \left(p\right)=\mathsf{lhs}\left({r}_{1}\right)$. The weight of the arc $(p,t)$ is 1;
- there is an arc from transition t to place p if and only if $\gamma \left(t\right)=({r}_{1},{r}_{2})$ and $\beta \left(p\right)=X$ where $X\in {V}_{1}$ and $|\mathsf{rhs}\left({r}_{1}\right){|}_{X}>0$. The weight of the arc $(t,p)$ is $|\mathsf{rhs}\left({r}_{1}\right){|}_{X}$;
- the initial marking $\iota $ is defined by $\iota \left({\beta}^{-1}\left({S}_{1}\right)\right)=1$ and $\iota \left(p\right)=0$ for all $p\in P-\left\{{\beta}^{-1}\left({S}_{1}\right)\right\}$.

**Theorem**

**2.**

## 7. Conclusions

## Author Contributions

## Funding

## Acknowledgments

## Conflicts of Interest

## Abbreviations

CF | context-free |

REG | regular |

LIN | linear |

MAT | matrix |

## References

- Chomsky, N. Three models for the description of languages. IRE Trans. Inf. Theory
**1956**, 2, 113–124. [Google Scholar] [CrossRef] [Green Version] - Chomsky, N. Syntactic Structure; Mouton: Gravenhage, The Netherland, 1957. [Google Scholar]
- Chomsky, N. On certain formal properties of grammars. Inf. Control
**1959**, 2, 137–167. [Google Scholar] [CrossRef] [Green Version] - Hopcroft, J.; Motwani, R.; Ullman, J. Introduction to Automata Theory, Languages, and Computation; Pearson: London, UK, 2007. [Google Scholar]
- Rozenberg, G.; Salomaa, A. (Eds.) Handbook of Formal Languages; Springer: Berlin/Heidelberg, Germany, 1997; Volume 1–3. [Google Scholar]
- Dassow, J.; Păun, G. Regulated Rewriting in Formal Language Theory; Springer: Berlin/Heidelberg, Germany, 1989. [Google Scholar]
- Pǎun, G.; Rozenberg, G.; Salomaa, A. DNA Computing. New Computing Paradigms; Springer: Berlin/Heidelberg, Germany, 1998. [Google Scholar]
- Meduna, A.; Soukup, O. Modern Language Models and Computation. Theory with Applications; Springer: Berlin/Heidelberg, Germany, 2017. [Google Scholar]
- Sipser, M. Introduction to the Theory of Computation; Cengage Learning: Boston, MA, USA, 2013. [Google Scholar]
- Meduna, A.; Zemek, P. Regulated Grammars and Automata; Springer: Berlin/Heidelberg, Germany, 2014. [Google Scholar]
- Meduna, A.; Kopeček, T. Simple-Semi-Conditional Versions of Matrix Grammars with a Reduced Regulated Mechanism. Comput. Inform.
**2004**, 23, 287–302. [Google Scholar] - Abraham, A. Some questions of phrase-structure grammars. Comput. Linguist.
**1965**, 4, 61–70. [Google Scholar] [CrossRef] - Cremers, A.; Mayer, O. On vector languages. J. Comp. Syst. Sci.
**1974**, 8, 158–166. [Google Scholar] [CrossRef] [Green Version] - Ginsburg, S.; Spanier, E. Control sets on grammars. Math. Syst. Theory
**1968**, 2, 159–177. [Google Scholar] [CrossRef] - Rozenkrantz, D. Programmed grammars and classes of formal languages. J. ACM
**1969**, 16, 107–131. [Google Scholar] [CrossRef] - Pǎun, G. A new generative device: Valence grammars. Rev. Roum. Math. Pures Appl.
**1980**, 25, 911–924. [Google Scholar] - Cremers, A.; Maurer, H.; Mayer, O. A note on leftmost restricted random context grammars. Inform. Proc. Lett.
**1973**, 2, 31–33. [Google Scholar] [CrossRef] - Fris, I. Grammars with partial ordering of the rules. Inform. Control
**1968**, 12, 415–425. [Google Scholar] [CrossRef] [Green Version] - Kelemen, J. Conditional grammars: Motivations, definitions and some properties. In Proc. Conf. Automata, Languages and Mathematical Sciences; Peak, I., Szep, J., Eds.; Salgótarján, Hungary, 1984; pp. 110–123. [Google Scholar]
- Aho, A. Indexed grammars. An extension of context-free grammars. J. ACM
**1968**, 15, 647–671. [Google Scholar] [CrossRef] - Wood, D. Bicolored Digraph Grammar Systems. RAIRO Inform. Thérique et Appl./Theor. Inform. Appl.
**1973**, 1, 145–150. [Google Scholar] [CrossRef] [Green Version] - Wood, D. A Note on Bicolored Digraph Grammar Systems. IJCM
**1973**, 3, 301–308. [Google Scholar] - Dassow, J.; Turaev, S. Petri net controlled grammars: The power of labeling and final markings. Rom. J. Inf. Sci. Technol.
**2009**, 12, 191–207. [Google Scholar] - Dassow, J.; Turaev, S. Petri net controlled grammars: The case of special Petri nets. J. Univers. Comput. Sci.
**2009**, 15, 2808–2835. [Google Scholar] - Prusinkiewicz, P.; Hanan, J. Lindenmayer Systems, Fractals, and Plants; Lecture Notes in Biomathematics; Springer: Berlin, Germany, 1980; Volume 79. [Google Scholar]
- Rajlich, V. Absolutely parallel grammars and two-way deterministic finite state transducers. J. Comput. Syst. Sci.
**1972**, 6, 324–342. [Google Scholar] [CrossRef] [Green Version] - Siromoney, R.; Krithivasan, K. Parallel context-free languages. Inform. Control
**1974**, 24, 155–162. [Google Scholar] [CrossRef] [Green Version] - Levitina, M. On some grammars with global productions. NTI Ser.
**1972**, 2, 32–36. [Google Scholar] - Greibach, S.; Hopcroft, J. Scattered context grammars. J. Comput. Syst. Sci.
**1969**, 3, 232–247. [Google Scholar] [CrossRef] [Green Version] - Mavlankulov, G.; Othman, M.; Turaev, S.; Selamat, M.; Zhumabayeva, L.; Zhukabayeva, T. Concurrently Controlled Grammars. Kybernetika
**2018**, 54, 748–764. [Google Scholar] [CrossRef] - Păun, G.; Santean, L. Parallel communicating grammar systems: The regular case. Ann. Univ. Buc. Ser. Mat.-Inform.
**1989**, 37, 55–63. [Google Scholar] - Csuhaj-Varjú, E.; Dassow, J.; Kelemen, J.; Păun, G. Grammar Systems: A Grammatical Approach to Distribution and Cooperation; Gordon and Beach Science Publishers: New York, NY, USA, 1994. [Google Scholar]
- Král, J. On Multiple Grammars. Kybernetika
**1969**, 5, 60–85. [Google Scholar] - Čulík II, K. n-ary Grammars and the Description of Mapping of Languages. Kybernetika
**1970**, 6, 99–117. [Google Scholar] - Bellert, I. Relational Phrase Structure Grammar and Its Tentative Applications. Inf. Control
**1965**, 8, 503–530. [Google Scholar] [CrossRef] - Bellert, I. Relational Phrase Structure Grammar Applied to Mohawk Constructions. Kybernetika
**1966**, 3, 264–273. [Google Scholar] - Crimi, C.; Guercio, A.; Nota, G.; Pacini, G.; Tortora, G.; Tucci, M. Relation Grammars and their Application to Multidimensional Languages. J. Vis. Lang. Comput.
**1991**, 4, 333–346. [Google Scholar] [CrossRef] - Wittenburg, K. Earley-Style Parsing for Relational Grammars. In Proceedings of the IEEE Workshop on Visual Languages, Seattle, WA, USA, 15–18 September 1992; pp. 192–199. [Google Scholar]
- Wittenburg, K.; Weitzman, L. Relational Grammars: Theory and Practice in a Visual Language Interface for Process Modeling. In Visual Language Theory; Marriott, K., Meyer, B., Eds.; Springer Science & Business Media: New York, NY, USA, 1998; pp. 193–217. [Google Scholar]
- Johnson, D. On Relational Constraints on Grammars. In Grammatical Relations; Cole, P., Sadock, J., Eds.; BRILL: Leiden, The Netherlands, 2020; pp. 151–178. [Google Scholar]
- Martín-Vide, C.; Mitrana, V.; Păun, G. (Eds.) Formal Languages and Applications; Springer: Berlin/Heidelberg, Germany, 2004. [Google Scholar]
- Baumgarten, B. Petri-Netze. Grundlagen und Anwendungen; Wissensschaftverlag: Mannheim, Germany, 1990. [Google Scholar]
- Reisig, W.; Rozenberg, G. (Eds.) Lectures on Petri Nets I: Basic Models; Springer: Berlin, Germany, 1997; Volume 1441. [Google Scholar]
- Dassow, J.; Turaev, S. Petri net controlled grammars with a bounded number of additional places. Acta Cybernetica
**2009**, 19, 609–634. [Google Scholar] - Novák, V.; Novotný, M. Binary and Ternary Relations. Math. Bohem.
**1992**, 117, 283–292. [Google Scholar] - Novák, V.; Novotný, M. Pseudodimension of Relational Structures. Czechoslov. Math. J.
**1999**, 49, 541–560. [Google Scholar] - Cristea, I.; Ştefănescu, M. Hypergroups and n-ary Relations. Eur. J. Comb.
**2010**, 31, 780–789. [Google Scholar] [CrossRef] [Green Version] - Chaisansuk, N.; Leeratanavalee, S. Some Properties on the Powers of n-ary Relational Systems. Novi Sad J. Math.
**2013**, 43, 191–199. [Google Scholar]

**Figure 1.**A cf Petri net N associated with the grammar ${G}_{1}$, where the places are labeled with the nonterminals and the transitions are labeled with the productions in one-to-one manner. Moreover, the input place of each transition corresponds to the left-hand side of the associated production and its output places correspond to the nonterminals in the right-hand side of the production. If a transition does not have output places, then the associated production is terminal.

© 2020 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).

## Share and Cite

**MDPI and ACS Style**

Turaev, S.; Abdulghafor, R.; Amer Alwan, A.; Abd Almisreb, A.; Gulzar, Y.
Binary Context-Free Grammars. *Symmetry* **2020**, *12*, 1209.
https://doi.org/10.3390/sym12081209

**AMA Style**

Turaev S, Abdulghafor R, Amer Alwan A, Abd Almisreb A, Gulzar Y.
Binary Context-Free Grammars. *Symmetry*. 2020; 12(8):1209.
https://doi.org/10.3390/sym12081209

**Chicago/Turabian Style**

Turaev, Sherzod, Rawad Abdulghafor, Ali Amer Alwan, Ali Abd Almisreb, and Yonis Gulzar.
2020. "Binary Context-Free Grammars" *Symmetry* 12, no. 8: 1209.
https://doi.org/10.3390/sym12081209