{'fraction_non_alphanumeric': 0.05282748747315676, 'fraction_numerical': 0.011071343354807922, 'mean_word_length': 3.7855674811600823, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Matrix Insertion-Deletion Systems

In this article, we consider for the first time the operations of insertion and deletion working in a matrix controlled manner. We show that, similarly as in the case of context-free productions, the computational power is strictly increased when using a matrix control: computational completeness can be obtained by systems with insertion or deletion rules involving at most two symbols in a contextual or in a context-free manner and using only binary matrices.


Introduction
The operations of insertion and deletion were first considered with a linguistic motivation [15,5,18]. Another inspiration for these operations comes from the fact that the insertion operation and its iterated variants are generalized versions of Kleene's operations of concatenation and closure [11], while the deletion operation generalizes the quotient operation. A study of properties of the corresponding operations may be found in [7,8,9]. Insertion and deletion also have interesting biological motivations, e.g., they correspond to a mismatched annealing of DNA sequences; these operations are also present in the evolution processes in the form of point mutations as well as in RNA editing, see the discussions in [1,2,22] and [20]. These biological motivations of insertion-deletion operations led to their study in the framework of molecular computing, see, for example, [3,10,20,23].
In general, an insertion operation means adding a substring to a given string in a specified (left and right) context, while a deletion operation means removing a substring of a given string from a specified (left and right) context. A finite set of insertion-deletion rules, together with a set of axioms provide a language generating device: starting from the set of initial strings and iterating insertiondeletion operations as defined by the given rules, one obtains a language.
Even in their basic variants, insertion-deletion systems are able to characterize the recursively enumerable languages. Moreover, as it was shown in [16], the context dependency may be replaced by insertion and deletion of strings of sufficient length, in a context-free manner. If the length is not sufficient (less or equal to two) then such systems are not able to generate more than the recursive languages and a characterization of them was shown in [24].
Similar investigations were continued in [17,12,13] on insertion-deletion systems with one-sided contexts, i.e., where the context dependency is present only from the left or only from the right side of all insertion and deletion rules. The papers cited above give several computational completeness results depending on the size of insertion and deletion rules. We recall the interesting fact that some combinations are not leading to computational completeness, i.e., there are recursively enumerable languages that cannot be generated by such devices.
Like in the case of context-free rewriting, it is possible to consider a graphcontrolled variant of insertion-deletion systems. Thus the rules cannot be applied at any time, as their applicability depends on the current "state", changed by a rule application. Such a formalization is rather similar to the definition of insertion-deletion P systems [19], however it is even simpler and more natural. The article [4] focuses on one-sided graph-controlled insertion-deletion systems where at most two symbols may be present in the description of insertion and deletion rules. This correspond to systems of size (1, 1, 0; 1, 1, 0), (1, 1, 0; 1, 0, 1), (1, 1, 0; 2, 0, 0), and (2, 0, 0; 1, 1, 0), where the first three numbers represent the maximal size of the inserted string and the maximal size of the left and right contexts, while the last three numbers represent the same information, but for deletion rules. It is known that such systems are not computationally complete [14], while the corresponding P systems variants and graph-controlled variants are computationally complete.
In this article we introduce a new type of control, similar to the one used in matrix grammars. More precisely, insertion and deletion rules are grouped in sequences, called matrices, and either the whole sequence is applied consecutively, or no rule is applied. We show that in the case of such control the computational power of systems of size (1, 1, 0; 2, 0, 0) and (2, 0, 0; 1, 1, 0 is strictly increasing. Moreover, we show that binary matrices suffice to achieve this result, hence we obtain a similar characterization like in the case of the binary normal form for matrix grammars.

Definitions
We do not present the usual definitions concerning standard concepts of the theory of formal languages and we only refer to textbooks such as [21] for more details.
The empty string is denoted by λ.
In the following, we will use special variants of the Geffert normal form for type-0 grammars (see [6] for more details).
A grammar G = (N, T, P, S) is said to be in Geffert normal form [6] if N = {S, A, B, C, D} and P only contains context-free rules of the forms S → uSv with u ∈ {A, C} * and v ∈ {B, D} * as well as S → x with x ∈ (T ∪{A, B, C, D}) * and two (non-context-free) erasing rules AB → λ and CD → λ.
We remark that we can easily transform the linear rules from the Geffert normal form into a set of left-linear and right-linear rules (by increasing the number of non-terminal symbols, e.g., see [19]). More precisely, we say that a grammar G = (N, T, P, S) with N = N ′ ∪ N ′′ , S, S ′ ∈ N ′ , and N ′′ = {A, B, C, D}, is in the special Geffert normal form if, besides the two erasing rules AB → λ and CD → λ, it only has context-free rules of the following forms: Moreover, we may even assume that, except for the rules of the forms X → Sb and X → S ′ b, for the first two types of rules it holds that the right-hand side is unique, i.e., for any two rules X → w and U → w in P we have U = X.
The computation in a grammar in the special Geffert normal form is done in two stages. During the first stage, only context-free rules are applied. During the second stage, only the erasing rules AB → λ and CD → λ are applied. These two erasing rules are not applicable during the first stage as long as the left and the right part of the current string are still separated by S (or S ′ ) as all the symbols A and C are generated on the left side of these middle symbols and the corresponding symbols B and D are generated on the right side. The transition between stages is done by the rule S ′ → λ. We remark that all these features of a grammar in the special Geffert normal form are immediate consequences of the proofs given in [6].

Insertion-deletion systems
An insertion-deletion system is a construct ID = (V, T, A, I, D), where V is an alphabet; T ⊆ V is the set of terminal symbols (in contrast, those of V − T are called non-terminal symbols); A is a finite language over V , the strings in A are the axioms; I, D are finite sets of triples of the form (u, α, v), where u, α (α = λ), and v are strings over V . The triples in I are insertion rules, and those in D are deletion rules. An insertion rule (u, α, v) ∈ I indicates that the string α can be inserted between u and v, while a deletion rule (u, α, v) ∈ D indicates that α can be removed from between the context u and v. Stated in another way, (u, α, v) ∈ I corresponds to the rewriting rule uv → uαv, and (u, α, v) ∈ D corresponds to the rewriting rule uαv → uv. By ⇒ ins we denote the relation defined by the insertion rules (formally, x ⇒ ins y if and only if x = x 1 uvx 2 , y = x 1 uαvx 2 , for some (u, α, v) ∈ I and x 1 , x 2 ∈ V * ), and by ⇒ del the relation defined by the deletion rules (formally, x ⇒ del y if and only if x = x 1 uαvx 2 , y = x 1 uvx 2 , for some (u, α, v) ∈ D and x 1 , x 2 ∈ V * ). By ⇒ we refer to any of the relations ⇒ ins , ⇒ del , and by ⇒ * we denote the reflexive and transitive closure of ⇒.
The language generated by ID is defined by The complexity of an insertion-deletion system ID = (V, T, A, I, D) is described by the vector (n, m, m ′ ; p, q, q ′ ) called size, where we denote the families of insertion-deletion systems having the size (n, m, m ′ ; p, q, q ′ ).
If one of the parameters n, m, m ′ , p, q, q ′ is not specified, then instead we write the symbol * . In particular, IN S 0,0 * DEL 0,0 * denotes the family of languages generated by context-free insertion-deletion systems. If one of numbers from the pairs m, m ′ and/or q, q ′ is equal to zero (while the other one is not), then we say that the corresponding families have a one-sided context. Finally we remark that the rules from I and D can be put together into one set of rules R by writing (u, α, v) ins for (u, α, v) ∈ I and (u, α, v) del for (u, α, v) ∈ D.

Matrix insertion-deletion systems
Like context-free grammars, insertion-deletion systems may be extended by adding some additional controls. We discuss here the adaptation of the idea of matrix grammars for insertion-deletion systems.
A matrix insertion-deletion system is a construct • A ⊆ V * is a finite set of axioms, • M = r 1 , . . . , r n is a finite set of sequences of rules, called matrices, of the form The sentential form (also called configuration) of γ is a string The language generated by γ is defined by we denote the families of matrix insertiondeletion systems having matrices with at most k rules and insertion and deletion rules of size (n, m, m ′ ; p, q, q ′ ).

Computational completeness
For all the variants of insertion and deletion rules considered in this section, we know that the basic variants without using matrix control cannot achieve computational completeness (see [14], [17]). The computational completeness results from this section are based on simulations of derivations of a grammar in the special Geffert normal form. These simulations associate a group of insertion and deletion rules to each of the right-or left-linear rules X → bY and X → Y b. The same holds for (non-context-free) erasing rules AB → λ and CD → λ. We remark that during the derivation of a grammar in the special Geffert normal form, any sentential form contains at most one non-terminal symbol from N ′ .
We start with the following affirmation: if the size of the matrices is sufficiently large, then corresponding systems are computationally complete. This is quite obvious for matrices of size 3.
The proof is based on a simulation of a type-0 grammar in the Geffert normal form (as presented in Section 2). Let G = (V, T, S, P ) be such a grammar. We construct the system γ = (V, T, {S}, M ) as follows.
A similar result can be obtained in the case of systems having rules of size (1, 1, 0; 1, 1, 0). They simulate AB → λ by introducing in the string a symbol K AB in a context-free manner and after that by deleting one copy of adjacent A and B. The validity follows from the observation that there can be at most only one copy of K AB in the string (because it's insertion and deletion is synchronized with the deletion and insertion of a special symbol $ initially present in only one copy). In order to delete this symbol at the end of the computation the matrix [(λ, $, λ) del , (λ, λ, λ) ins , (λ, λ, λ) ins ] shall be used.
The rule CD → λ is simulated similarly and the rule S ′ → λ by directly erasing S ′ .
By taking deletion rules with a right context in the previous theorem we obtain.
For every rule r : A → Cb ∈ P we add to M the matrices r.1 : For rules AB → λ ∈ P and CD → λ ∈ P we add to M following six matrices: The rule S ′ → λ is simulated by the matrix that introduces symbol $ S ′ : It is clear that L(γ) = L(G). Indeed, any rule A → bC is simulated directly by inserting bC and deleting A in the context of C. The right position for the insertion is insured by the uniqueness of A. Rules r : A → Cb are simulated in a different way. First A is replaced by X A Y A and after that Y A is rewritten by Cb as in the previous case. We remark that by inserting X A Y A we insure that there is no symbol b before Y A . This permits to correctly place Cb. The additional symbol X A remaining in the string is deleted during the second stage (when symbol $ is introduced). As before, in order to delete $ at the end of the computation the matrix [(λ, $, λ) del , (λ, λ, λ) ins , (λ, λ, λ) ins ] shall be used.
Since the matrix control is a particular case of the graph control we obtain

Computational completeness for binary matrices
In this section we show that binary matrices suffice for computational completeness.
Theorem 6. M at 2 IN S 0,0 2 DEL 1,0 1 = RE. Proof. The proof is based on a simulation if type-0 grammar in the Geffert normal form (as presented in Section 2). Let G = (V, T, S, P ) be such a grammar. We construct the system γ = (V ∪ V ′ , T, w, M ) as follows. For every rule r : A → Cb ∈ P we add to M following matrices: For rules AB → λ ∈ P and CD → λ ∈ P we add to M following matrices: The rule S ′ → λ can be simulated by the following matrix: We claim that L(γ) = L(G). First we show that L(γ) ⊇ L(G). Let w 1 Aw 2 be a sequential form in G (initially S) and let w 1 Aw 2 ⇒ r w 1 bCw 2 be a derivation in G. We show that in γ we obtain the same result: We remark that if the sequence bC is not inserted before A, then the second rule from the matrix will not be applicable (we recall that w 1 w 2 does not contain non-terminals from V \ T and that b = λ.
Consider now the following derivation in G: w 1 Aw 2 ⇒ r w 1 Cbw 2 . This derivation is simulated in γ as follows.
So the grammar G is simulated as follows. Firstly the first stage of the generation is simulated by simulating left-linear and after that right-linear productions. After changing to the second stage, rules AB.i and CD.i (1 ≤ i ≤ 3) can be applied, removing symbols A, B, C, D.
Now in order to prove the converse inclusion L(γ) ⊆ L(G) we show that no other words can be obtained in γ.
We start by observing that matrices r.1 − r.4 for a rule r : A → Cb as well as r.1 for a rule r : A → bC have the form [(λ, x, λ) ins , (x, y, λ) del ], x ∈ V ∪V 2 , y ∈ V . It is not difficult to see that if x was not already present in the string then such a matrix correspond to the rewriting rule y → x. Indeed, since x is not present in the string, it should have been inserted before the symbol y, which is deleted afterwards.
The matrices r.5 − r.7 insure that a sequence of symbols # r 3 # r 5 is deleted. This is performed by introducing into the string a new special symbol K r . If it is not introduced before # r 3 , then nothing happens and K r can be replaced by $. Otherwise, it can delete the two symbols in the sequence. The validity of the simulation is ensured by the fact that the symbol $ is always present in at most one copy.
In order to conclude that the simulation of the rule A → Cb does not yield other words we give the following remarks: • Symbol A is replaced by a pair of symbols # r 1 # r 2 , where # r 1 evolves to C and # r 2 evolves to b.
• Symbol b is inserted if and only if # r 3 (and # r 4 ) is present in the string. This insures that this symbol is separated from any non-terminal that can be derived from C and hence the insertion of this symbol cannot interfere with some other insertion that could be operated.
Since no other words can be generated we can reconstruct a derivation in G starting from a derivation in γ. For this it is enough to follow configurations where there is a non-terminal from V \ {A, B, C, D} in order to reconstruct the first stage of the derivation from G. The deletion of AB and CD has a direct correspondence to the second stage of G. So, L(γ) = L(G).
The proof is based on a simulation if type-0 grammar in the Geffert normal form (as presented in Section 2). Let G = (V, T, S, P ) be such a grammar. We construct the system γ = (V ∪ V ′ , T, w, M ) as follows.
For every rule p : A → Cb ∈ P we add to M following matrices: For every rule p : A → bC ∈ P we add to M following matrices: For rules AB → λ ∈ P and CD → λ ∈ P we add to M following matrices: We also add to M the matrices XY : [(λ, X, λ) del , (λ, Y, λ) del ] and S ′ : We claim that L(γ) = L(G). First we show that L(γ) ⊇ L(G). The simulation uses the following idea. Symbol X marks the site where the non-terminal is situated, while symbol Y marks a position in the string (for commodity we mark the end of the string). The sequence of insertions and deletions is synchronized between these two positions: inserting something at position X also inserts or deletes symbols at position Y . Finally, symbols at position Y are checked to form some particular order. So in some sense Y corresponds to a "stack" where some information is stored and after that the "stack" is checked to be in some specific form.
More precisely, let w 1 Aw 2 be a sequential form in G (initially S) and let w 1 Aw 2 ⇒ r w 1 Cbw 2 be a derivation in G. We show that in γ we obtain the same result: Since there are no rules eliminating p ′ by itself (it can be eliminated only if p is following it, which is no more possible), the above string can become terminal if and only if one insertion is done at the second step (i.e. k = 1). Hence we obtain the string w 1 XCbw 2 Y , i.e. we correctly simulated the corresponding production of the grammar.
We remark that the rule p.2 can be used at any time, but this yields again a symbol p ′ after Y which cannot be removed. Now consider the following derivation in G: w 1 Aw 2 ⇒ r w 1 bCw 2 . This derivation is simulated in γ as follows.
The deletion rules AB → λ, CD → λ and S ′ → λ are simulated directly by rules AB and CD and symbols X and Y are eliminated by the rule XY . Hence L(G) ⊆ L(γ). Now in order to prove the inclusion L(γ) ⊆ L(G) we we show that only specific sequences of rule application can lead to a terminal string. The case of the simulation of rules of type A → Cb is discussed above. We shall concentrate now on the simulation of rules of type A → bC. We give below the rules' dependency graph, where by x ← y we indicate that in order to apply y, we should apply at least one time x. a B B B B B B B B Indeed, if rule p.1 is not applied first, then additional symbols are added after Y and it is clear that they cannot be eliminated. If p.3 is applied before p 2 , then the introduced symbol # ′ p can never be deleted (as there is no symbol # p afterwards). Rule p.4 involves symbols introduced by p.2 and p.3, so it cannot be used before. Rule p.5 cannot be applied before p.3, however its application can be interchanged with the application of p.4. Rule p.6 can be applied once after p.2, while in order to apply p.7 we need to apply before rules p.6, p.5 and p.4. The rule p.8 is applicable only after rule r.7.
It is still possible to apply some rules several times. Now we show that each rule must be applied exactly once. Since there is only one copy of A, only one copy of p will be available. Hence rule p.7 will be applied only one time. We can also deduce that only one copy of p 3 shall be produced, hence rule p.4 should be applied only one time. But this implies the uniqueness of symbols # p and # ′ p , hence a single application of rules p.2 and p.3. The last affirmation implies that p 2 is generated only once, hence p.5 can be applied only once. From p. 6 we can deduce that C p 2 is inserted once, hence p.8 is executed only one time. Finally, from the p.2 we can deduce that C r 1 is inserted only once, so after its deletion in p.8 no more copies will remain.
So, we obtain that any terminal derivation in γ needs an application of a specific sequence of rules. Hence, it is enough to look at strings from γ containing a non-terminal from V \ {A, B, C, D} in order to reconstruct the first stage of the derivation from G. The deletion of AB and CD has a direct correspondence to the second stage of G. This implies that L(γ) ⊆ L(G).

Conclusions
In this article we have introduced the mechanism of a matrix control to the operations of insertion and deletion. We investigated the case of systems with insertion and deletion rules of size (1, 1, 0; 1, 1, 0), (1, 1, 0; 1, 0, 1), (1, 1, 0; 2, 0, 0) and (2, 0, 0; 1, 1, 0) and we have shown that the corresponding matrix insertiondeletion systems are computationally complete. In the case of first two systems matrices of size 3 are used, while in the case of the last two systems binary matrices are sufficient. Since a matrix control is a particular case of a graph control (having an input/output node and series of linear paths starting and ending in this node), we obtain [14] that matrix insertion-deletion systems having rules of size (2, 0, 0; 2, 0, 0) are not computationally complete.
We remark that our results for matrix insertion-deletion systems are different from the results on graph-controlled systems obtained in [4] and previous works. In the graph-controlled case, the total number of nodes in the graph is minimized, while in the matrix case the depth of the graph (corresponding to the size of matrices) is minimized.