Keywords

1 Introduction

In theoretical computer science, formal language theory is one of the fundamental areas. This study has its origin in Chomskian grammars. Contextual grammars which are different from Chomskian grammars, have been studied in [3, 13] by formal language theorists, as they provide novel insight into a number of issues central to formal language theory. In a total contextual grammar, a context is adjoined depending on the whole current string. Two special cases of total contextual grammars, namely internal and external are very natural and have been extensively investigated. (External) Contextual grammars are introduced by S. Marcus in 1969 [13] with a linguistic motivation in mind. An external contextual grammar generates a language starting from a finite set of strings (the base) and iteratively adjoining to its contexts outside the current string. In other families of contextual grammars, such as internal contextual grammars [13], the contexts are adjoined inside the current string.

There has been a great interest in adapting the techniques of formal string language theory for developing methods to study the problem of picture generation and description, where pictures are considered as connected, digitized finite arrays in the two-dimensional plane [15]. Recently, extensions of string contextual grammars to array structures and hyper graphs have been made in [1, 2, 6,7,8, 11, 12, 14, 16].

On the other hand, Grammatical Inference refers to the method of inferring a grammar (and possibly a target language) from data. Data can be text or informant. The difference between text and informant is that a text gives only positive examples (all strings do belong to the same language) where informant is both positive and negative examples. A learning procedure is an algorithm which is executed on a never-ending stream of inputs. The inputs are grammatical strings/arrays, taken from a target language which is in a known class of languages. The task is to identify a grammar that generates the target language. At each point in the process, any string is given as an input to the algorithm. After each input the algorithm produces a guess at the grammar which is eventually correct and could be unaltered when additional inputs are given. This model of learning is Gold’s model of identification in the limit from positive data [5]. It is proved that no super finite language(it contains all finite languages and at least one infinite language) can be learn-able in the limit from positive examples. Hence, regular, context free, context sensitive grammars are not learn-able in the limit from positive examples only.

In this paper, we have introduced two subclasses of parallel internal column contextual array grammar, called, strictly parallel internal column contextual array grammar (SPICCAG), k-uniform parallel internal column contextual array grammar (k-UPICCAG) in order to find out identification algorithms. Our learning strategy is based on Gold’s model.

2 Definition and Examples

If V is a finite alphabet, then \(V^{*}\) is the set of all strings including the empty string \(\lambda \). An image or a picture over V is a rectangular \(m \times n\) array of elements of V or in short \([a_{ij}]_{m\times n}\), the set of all images including the empty array \(\varLambda \) is denoted by \(V ^{**}\). A picture language or two dimensional language over V is a subset of \(V ^{**}\). In this paper \(\varLambda \) denotes any empty array. The notion of column concatenation is as follows: if X and Y are two arrays where

$$\begin{aligned} X=\left[ {\begin{matrix} a_{1,j} &{} \ldots &{} a_{1,k}\\ a_{2,j} &{} \ldots &{} a_{2,k}\\ \ldots &{} \ldots &{} \ldots \\ a_{l,j} &{} \ldots &{} a_{l,k} \end{matrix}}\right] ,Y=\left[ {\begin{matrix} b_{1,m} &{} \ldots &{} b_{1,n}\\ b_{2,m} &{} \ldots &{} b_{2,n}\\ \ldots &{} \ldots &{} \ldots \\ b_{l,m} &{} \ldots &{} b_{l,n} \end{matrix}}\right] then, X\varPhi Y=\left[ {\begin{matrix} a_{1,j} &{} \ldots &{} a_{1,k} &{} b_{1,m} &{} \ldots &{} b_{1,n}\\ a_{2,j} &{} \ldots &{} a_{2,k} &{} b_{2,m} &{} \ldots &{} b_{2,n}\\ \ldots &{} \ldots &{} \ldots &{} \ldots &{} \ldots &{} \ldots \\ a_{l,j} &{} \ldots &{} a_{l,k} &{} b_{l,m} &{} \ldots &{} b_{l,n} \end{matrix}}\right] \end{aligned}$$

If \(L_{1}, L_{2}\) are two picture languages over an alphabet \(\varSigma \), the column concatenation \(L_1\varPhi L_2\) of \(L_1, L_2\) is defined by \(L_1\varPhi L_2=\{X\varPhi Y \mid X \in L_1, Y \in L_2\}\). If X is an array, the set of all subarrays of X is denoted by sub(X). We now recall the notion of column array context [2, 16].

Definition 1

Let V be an alphabet. A column array context c over V is of the form

$$\begin{aligned} c=\left[ {\begin{matrix} u_1\\ u_2 \end{matrix}}\right] \psi \left[ {\begin{matrix} v_1\\ v_2 \end{matrix}}\right] \end{aligned}$$

\(\in V^{**} \psi V^{**} \text {where } u_1, u_2 \text { are arrays of sizes } 1\times p, \text { and } v_1, v_2 \text { are arrays of sizes } 1\times q, \text { for some } p, q \ge 1 \text { and }\psi \text { is a special symbol not in } V\).

The next definition deals with parallel internal column contextual operation.

Definition 2

Let V be an alphabet, C be a finite subset of \(V^{**} \psi V^{**}\) whose elements are the column array contexts and \(\varphi : V^{**}\rightarrow 2^C\) be mapping, called choice mapping.

$$\begin{aligned} \text { For an array } X=\left[ {\begin{matrix} a_{1,j} &{} \ldots &{} a_{1,k}\\ a_{2,j} &{} \ldots &{} a_{2,k}\\ \ldots &{} \ldots &{} \ldots \\ a_{l,j} &{} \ldots &{} a_{l,k} \end{matrix}}\right] , \end{aligned}$$

\(j\le k, a_{ij} \in V\), we define \(\hat{\varphi }: V^{**}\rightarrow 2^{V^{**}\psi V^{**}}\) such that \(L\psi R \in \hat{\varphi }[X]\), where

$$\begin{aligned} L=\left[ {\begin{matrix} u_1\\ u_2\\ \vdots \\ u_l \end{matrix}}\right] , R = \left[ {\begin{matrix} v_1\\ v_2\\ \vdots \\ v_l \end{matrix}}\right] , \end{aligned}$$

and

$$\begin{aligned} c_{i}= \left[ {\begin{matrix} u_i\\ u_{i+1} \end{matrix}}\right] \psi \left[ {\begin{matrix} v_i\\ v_{i+1} \end{matrix}}\right] \in \varphi \left[ {\begin{matrix} a_{i,j} &{} \ldots a_{i,k}\\ a_{i+1,j} &{} \ldots a_{i+1,k} \end{matrix}}\right] , \end{aligned}$$

with \(c_{i} \in C, (1\le i \le l-1)\), not all need to be distinct.

Given an array \(X=[a_{ij}]\) of size \(m\times n\), \(a_{ij} \in V, X=X_1 \varPhi X_2 \varPhi X_3\) where

$$ X_1= \left[ {\begin{matrix} a_{1,1} &{} \ldots &{} a_{1,p-1}\\ a_{2,1} &{} \ldots &{} a_{2,p-1}\\ \vdots &{} \vdots &{} \vdots \\ a_{m1} &{} \ldots &{} a_{m,p-1} \end{matrix}}\right] , X_{2} = \left[ {\begin{matrix} a_{1,p} &{} \ldots &{} a_{1,q}\\ a_{2,p} &{} \ldots &{} a_{2,q}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,p} &{} \ldots &{} a_{m,q} \end{matrix}}\right] , X_{3} = \left[ {\begin{matrix} a_{1,q+1} &{} \ldots &{} a_{1,n}\\ a_{2,q+1} &{} \ldots &{} a_{2,n}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,q+1} &{} \ldots &{} a_{m,n} \end{matrix}}\right] $$

and \(1\le p\le q \le n\), we write \(X\Rightarrow Y\) if \(Y=X_1\varPhi L\varPhi X_2 \varPhi R \varPhi X_3\) such that \(L\psi R \in \hat{\varphi }[X_2]\). Here L and R are called left and right contexts respectively. We say that Y is obtained from X by parallel internal column contextual operation \((\Rightarrow _{in})\).

Now we consider the notion of parallel internal column contextual array grammar [2, 16].

Definition 3

A parallel internal column contextual array grammar is an ordered system \(G=(V,A,C,\varphi )\) where V is an alphabet, A is a finite subset of \(V^{**}\) called the axiom set, C is a finite subset of \(V^{**} \psi V^{**}\) called column array contexts, \(\varphi :V^{**}\rightarrow 2^{C}\) is the choice mapping which performs the parallel internal column contextual operation. When \(\varphi \) is omitted we call G as a parallel internal contextual array grammar without choice.

For any \(X, Y \in V^{**}, X\Rightarrow Y\) if and only if \(X=X_1 \varPhi X_2 \varPhi X_3, Y = X_1\varPhi L\varPhi X_2 \varPhi R \varPhi X_3\) with \(L\psi R \in \hat{\varphi }[X_2]\). We denote by \(\Rightarrow ^*\) the reflexive transitive closure of \(\Rightarrow _{in}\). Then the parallel internal column contextual array language generated by the parallel internal column contextual array grammar G is defined as the set \(L_{in}(G)=\{Y\in V^{**}/\exists X\in A\) such that \(X\Rightarrow ^*Y\}\).

3 Subclasses of Parallel Internal Column Contextual Array Grammars

In this paper our main focus is on designing an identification algorithm to infer parallel internal column contextual array grammar. According to Gold model [5], no superfinite class of languages is inferable from positive data only. A class of languages that consists of all finite languages and atleast one infinite language, is called a super finite class of languages.

Proposition 1

The class of parallel internal column contextual array languages (PICCAL), is not inferable from positive data only.

Proof

In the case of string languages, the class of internal contextual languages, is not inferable from positive data only [4]. From this fact, we can conclude Theorem 1.

As we know that the class (PICCAL) is not inferable from positive data only, it is natural to look for subclasses of these languages which can be identified in the limit from positive data only. We now define strictly parallel internal column contextual array grammar (SPICCAG) and k-uniform parallel internal column contextual array grammar \((k-UPICCAG)\).

Definition 4

A strictly parallel internal column contextual array grammar (SPICCAG) is a 6 tuple \(G=(V,X,C,\varphi ,P,A)\) where

  • V is the alphabet.

  • X is a finite subset of \(V^{**}\), called selector set and C is a finite subset of \(V^{**} \psi V^{**}\), called context set.

  • \(\varphi : V^{**}\rightarrow 2^C\) is a choice mapping.

  • P is a finite set of parallel internal column contextual rules of the form, \(\varphi [x_i]=L_i\psi R_i\) where \(L_i, R_i\in C\) are the ith left and right context of ith selector \(x_i\in X\), \(L_i, R_i\) have same number of rows.

  • \(first[L_i]\ne first[R_i]\) where first[W] denotes the first column of W and \(L_i\) is not a subarray of \(R_i\) and vice versa.

  • A is a finite subset of \(V^{**}\), called the axiom set.

  • for each selector, there is exactly one rule.

The language generated by strictly parallel internal column contextual array grammar (SPICCAG) is called a strictly parallel internal column contextual array language (SPICCAL) which is \(L_{sin}(G)=\{Y\in V^{**}\mid Q\Rightarrow ^* Y, Q\in A\}\).

3.1 Example

Let \(G =(V,X,C,\varphi ,P,A)\) be a strictly parallel internal column contextual array grammar (SPICCAG) where \(V=\{a,b\}\),

$$\begin{aligned} X=\left\{ \left[ {\begin{matrix} a &{} b\\ b &{} a \end{matrix}}\right] ,\left[ {\begin{matrix} a &{} b\\ a &{} b \end{matrix}}\right] ,\left[ {\begin{matrix} b &{} a\\ b &{} a \end{matrix}}\right] \right\} , C=\left\{ \left[ {\begin{matrix} a\\ b \end{matrix}}\right] \psi \left[ {\begin{matrix} b\\ a \end{matrix}}\right] ,\left[ {\begin{matrix} a\\ a \end{matrix}}\right] \psi \left[ {\begin{matrix} b\\ b \end{matrix}}\right] , \left[ {\begin{matrix} b\\ b \end{matrix}}\right] \psi \left[ {\begin{matrix} a\\ a \end{matrix}}\right] \right\} \end{aligned}$$

\(\varphi \) is a choice mapping

$$\begin{aligned} P=\left\{ \varphi \left[ {\begin{matrix} a &{} b\\ b &{} a \end{matrix}}\right] =\left[ {\begin{matrix} a\\ b \end{matrix}}\right] \psi \left[ {\begin{matrix} b\\ a \end{matrix}}\right] , \varphi \left[ {\begin{matrix} a &{} b\\ a &{} b \end{matrix}}\right] =\left[ {\begin{matrix} a\\ a \end{matrix}}\right] \psi \left[ {\begin{matrix} b\\ b \end{matrix}}\right] , \varphi \left[ {\begin{matrix} b &{} a\\ b &{} a \end{matrix}}\right] =\left[ {\begin{matrix} b\\ b \end{matrix}}\right] \psi \left[ {\begin{matrix} a\\ a \end{matrix}}\right] \right\} , \end{aligned}$$
$$\begin{aligned} A=\left\{ Q=\left[ {\begin{matrix} a &{} a &{} b &{} b\\ a &{} a &{} b &{} b\\ b &{} b &{} a &{} a\\ b &{} b &{} a &{} a \end{matrix}}\right] \right\} \end{aligned}$$

Here for each rule \(\varphi [x_i]=L_i\psi R_i\), \(first(L_i)\ne first(R_i), i \ge 1\), so it does satisfy Definition 4. Clearly, \(L_{sin}(G)=\left\{ \left[ {\begin{matrix} (a^n &{} b^n)_m\\ (b^n &{} a^n)_m \end{matrix}}\right] \mid n \ge 2, m=2 \right\} \) Here \(a^n=aaa...a\) (n times) and \(a_m={\begin{matrix} a\\ \vdots \\ a \end{matrix}}\), m rows are there. A simple derivation of a member of \(L_{sin}(G)\) is as follows,

$$\begin{aligned} Q=\left[ {\begin{matrix} a &{} a &{} b &{} b\\ a &{} a &{} b &{} b\\ b &{} b &{} a &{} a\\ b &{} b &{} a &{} a \end{matrix}}\right] \Rightarrow \left[ {\begin{matrix} a &{} a &{} a &{} b &{} b &{} b\\ a &{} a &{} a &{} b &{} b &{} b\\ b &{} b &{} b &{} a &{} a &{} a\\ b &{} b &{} b &{} a &{} a &{} a \end{matrix}}\right] = \left[ {\begin{matrix} (a^3 &{} b^3)_2\\ (b^3 &{} a^3)_2 \end{matrix}}\right] \in L_{sin}(G). \end{aligned}$$

Definition 5

A k-uniform parallel internal column contextual array grammar is a 6-tuple \((k-UPICCAG)\), \(k \ge 1, G=(V,X,C,\varphi ,P,A)\) where

  • V is the alphabet.

  • X is a finite subset of \(V^{**}\), called selector set and C is a subset of \(V^{**} \psi V^{**}\), called context set.

  • \(\varphi : V^{**}\rightarrow 2^C\) is a choice mapping.

  • P is a finite set of parallel internal column contextual array rules of the following form, \(\varphi [x_i]=L_i\psi R_i\) where \(L_i, R_i\in C\) are the ith left and right context of ith selector \(x_i\in X\), \(L_i, R_i\) have same number of rows.

  • A is the finite subset of \(V^{**}\), called axiom set. Each member of A is an axiom which contains mk number of columns, for some \(m \ge 1\) and we put the following restrictions.

If the rule is \(\varphi [x]=L\psi R\) then,

  • \(|x|= |L|=|R|=k\), where |W| denotes the number of columns in an array W.

  • for each selector, there is exactly one rule.

The language generated by \(k-UPICCAG\) is called a k-uniform parallel internal column contextual array language(k-UPICCAL) which is \(L_{k-uin}(G)=\{Y\in V^{**}\mid Q\Rightarrow ^* Y, Q\in A\}\).

3.2 Example of 2-UPICCAG

\(G=(V,X,C, \varphi , P,A)\) is a 2-UPICCAG where \(V = \{a,b\}\),

$$\begin{aligned} X=\left\{ \left[ {\begin{matrix} a &{} b\\ b &{} b \end{matrix}}\right] , \left[ {\begin{matrix} b &{} b\\ a &{} b \end{matrix}}\right] \right\} , C=\left\{ \left[ {\begin{matrix} a &{} b\\ b &{} a \end{matrix}}\right] \psi \left[ {\begin{matrix} a &{} b\\ b &{} a \end{matrix}}\right] ,\left[ {\begin{matrix} b &{} a\\ a &{} b \end{matrix}}\right] \psi \left[ {\begin{matrix} b &{} a\\ a &{} b \end{matrix}}\right] \right\} , \end{aligned}$$

\(\varphi \) is a choice mapping,

$$\begin{aligned} P=\left\{ \varphi \left[ {\begin{matrix} a &{} b\\ b &{} b \end{matrix}}\right] =\left[ {\begin{matrix} a &{} b \\ b &{} a \end{matrix}}\right] \psi \left[ {\begin{matrix} a &{} b \\ b &{} a \end{matrix}}\right] ,\varphi \left[ {\begin{matrix} b &{} b\\ a &{} b \end{matrix}}\right] =\left[ {\begin{matrix} b &{} a\\ a &{} b \end{matrix}}\right] \psi \left[ {\begin{matrix} b &{} a\\ a &{} b \end{matrix}}\right] \right\} , \end{aligned}$$

\(A=\left\{ Q=\left[ {\begin{matrix} a &{} b &{} a &{} b\\ b &{} b &{} b &{} b\\ a &{} b &{} a &{} b \end{matrix}}\right] \right\} \). Here, \(|x|=|L|=|R|=2, m=2\), number of columns in \(A=mk=4\). So it satisfies Definition 5. Clearly

$$\begin{aligned} L_{k-uin}(G)=\left\{ A, \left[ {\begin{matrix} (ab)^{n-1} &{} ab &{} (ab)^{n-1} &{} ab \\ (ba)^{n-1} &{} bb &{} (ba)^{n-1} &{} bb \\ (ab)^{n-1} &{} ab &{} (ab)^{n-1} &{} ab \end{matrix}}\right] \mid n \ge 2 \right\} \end{aligned}$$
$$\begin{aligned} \text{ For } \text{ instance }, \, \left[ {\begin{matrix} a &{} b &{} a &{} b\\ b &{} b &{} b &{} b\\ a &{} b &{} a &{} b \end{matrix}}\right] \Rightarrow \left[ {\begin{matrix} a &{} b &{} a &{} b &{} a &{} b &{} a &{} b\\ b &{} a &{} b &{} b &{} b &{} a &{} b &{} b\\ a &{} b &{} a &{} b &{} a &{} b &{} a &{} b \end{matrix}}\right] \in L_{k-uin}(G). \end{aligned}$$

Now, if we consider a = black box and b = white box, we get a nice rectangular picture.

Theorem 1

\(\mathcal{{L}_{SPICCAG}}\) is incomparable with \(\mathcal{{L}_{K-UPICCAG}}\) and not disjoint.

Proof

We prove this theorem using following lemmas whose proofs are omitted.    \(\square \)

Lemma 1

\(\mathcal{{L}_{SPICCAG}} - \mathcal{{L}_{K-UPICCAG}} \ne \phi \)

Lemma 2

\(\mathcal{{L}_{K-UPICCAG}} - \mathcal{{L}_{SPICCAG}} \ne \phi \)

Lemma 3

\(\mathcal{{L}_{K-UPICCAG}} \cap \mathcal{{L}_{SPICCAG}} \ne \phi \)

4 Identification of Subclasses of Parallel Internal Column Contextual Array Languages

In this section, we propose an algorithm to infer SPICCAG from positive data only. We recall the notion of an insertion rule. The insertion operation is first considered by Haussler in [9] and based on the operation, insertion systems are introduced by L. Kari in [10]. Informally, if a string \(\alpha \) is inserted between two parts \(w_1\) and \(w_2\) of a string \(w_1w_2\) to get \(w_1\alpha w_2\), we call the operation as insertion.

This algorithm takes finite sequences of positive examples in the different time interval or all together. Our goal is to find out SPICCAG G, such that \(IP\subseteq L(G)\) where IP is the input set of arrays. The algorithm works in the following way. After receiving the first set of arrays as an input, based on the size(actually based on number of columns), firstly the algorithm determines the axiom, then it defines 2D insertion rules in order to find out context and selector from input example. After that, insertion rules are converted into 1-sidedFootnote 1 contextual rules which will be a guess about the unknown grammar. Then we will convert 1-sided contextual rule into 2-sided contextual rule to take care of over generalization. Then updates with new contextual rules if the next input array cannot be generated by the existing contextual rules. All the guessing will be done in a flexible way in the sense that the correction is done at every instance. Finally we will find the parallel internal column contextual rules according to Definition 2.

In this paper we consider single axiom A and finite selector set. Now, we present our algorithm with a description for better understanding.

5 Pseudocode of Our Algorithm

figure a

In the next few subsections we will explain all the steps of our pseudocode in detail.

5.1 Finding Axiom - Pseudocode-Step: 1

axiom \(\leftarrow \) Find – Smallest(IPS): It finds the smallest array from the IPS (input set). The output of the function will be considered as an axiom.

In order to find out the axiom, the number of columns of each array is evaluated, the array with the smallest number of columns, will be considered as the axiom. Also a new input array will be compared with the existing axiom based on the number of columns, and the smaller one will be considered as an axiom and Let the single axiom be denoted by A.

5.2 Defining Insertion Rule and Converting It into Contextual Rule - Pseudocode-Step: 2, 8, 9

  • \(\mathbf{insr \leftarrow Generate-Inser(axiom, IP_i)}\) : It generates the insertion rule from axiom and member of input set \((IP_i)\). The output of the function will be stored in insr as an insertion rule.

  • \(\mathbf{1\!-\!Sided\!-\!Contextual\!-\!Rule.push \leftarrow [Convert-into-Contextual -}\) \(\mathbf{Rule(inser)]}\) : It converts insr into \(1-Sided-Contextual-Rule\) and store that.

  • \(\mathbf{IPS \leftarrow Remove(IPS, IP_i)}\) : It removes the current input member \(IP_i\) from IPS.

  • We now shortly describe about the intuitive idea of the parts 1–4. We try to identify the selectors from the axiom and contexts from examining input.

  • Let the format of 2D insertion rule be LIR where \(L,I,R \in V^{++}\) are left context, inserted portion, and right context respectively. Axiom and examining array are respectively

$$\begin{aligned} A= \left[ {\begin{matrix} a_{1,1} &{} \ldots &{} a_{1,n}\\ a_{2,1} &{} \ldots &{} a_{2,n}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,1} &{} \ldots &{} a_{m,n} \end{matrix}}\right] , \, E=\left[ {\begin{matrix} a_{1,1} &{} \ldots &{} a_{1,p}\\ a_{2,1} &{} \ldots &{} a_{2,p}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,1} &{} \ldots &{} a_{m,p} \end{matrix}}\right] \end{aligned}$$

Let the initial insertion rule be LIR and from the axiom we can have the following consideration:

Part 1:

$$\begin{aligned} L=\left[ {\begin{matrix} a_{1,1}\\ a_{2,1}\\ \vdots \\ a_{m,1} \end{matrix}}\right] , \, R=\left[ {\begin{matrix} a_{1,2} &{} \ldots &{} a_{1,n}\\ a_{2,2} &{} \ldots &{} a_{2,n}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,2} &{} \ldots &{} a_{m,n} \end{matrix}}\right] \end{aligned}$$

Check whether any \(I=[I_{i,j}]_{m \times r}\) where \(r \le p\) exists with \(LIR \in sub(E)\) or not. If yes then fix that \(I=[I_{i,j}]_{m\times r}\) and go to part 3, else go to part 2.

Part 2: Remove the last column of the right context R and the rule becomes LIR where

$$\begin{aligned} L=\left[ {\begin{matrix} a_{1,1}\\ a_{2,1}\\ \vdots \\ a_{m,1} \end{matrix}}\right] , \, R=\left[ {\begin{matrix} a_{1,2} &{} \ldots &{} a_{1,n-1}\\ a_{2,2} &{} \ldots &{} a_{2,n-1}\\ \ldots &{} \ldots &{} \ldots \\ a_{m,2} &{} \ldots &{} a_{m,n-1} \end{matrix}}\right] \end{aligned}$$

Check whether any \(I=[I_{i,j}]_{m\times r}\) where \(r \le p\) exists with \(LIR \in sub(E)\) or not. If yes then fix that \(I=[I_{i,j}]_{m\times r}\) and go to part 3, else go to part 2 recursively, until \(L=\left[ {\begin{matrix} a_{1,1}\\ a_{2,1}\\ \vdots \\ a_{m,1} \end{matrix}}\right] , \, R=\left[ {\begin{matrix} a_{1,2} \\ a_{2,2} \\ \vdots \\ a_{m,2} \end{matrix}}\right] \), and then go to part 4.

Part 3 - Conversion of 2D insertion rule into 1 sided 2D contextual rule: Here \(L^{IN},I^{IN},R^{IN}\) are left context, inserted portion, and right context for insertion rule respectively. On the other hand, \(L^{IC}, x^{IC}, R^{IC}\) are left context, selector, and right context for internal contextual rule respectively.

\((LIR)^{IN}\rightarrow (\hat{\varphi }[x]=L\psi R)^{IC}\) where \(x^{IC}=L^{IN}, L^{IC}=\varLambda , R^{IC}=I^{IN}\). Once we get a selector and associated context with it, we have the following conditions for each 2D insertion rule:

  • Condition 1: If \((|L|+|I|+ |R|)^{IN}=|E|\), it implies that on this current axiom A, only one rule has been applied and we obtain the rule.

  • Condition 2: If \((|L|+|R|)^{IN}\le |A|\), then we remove \(L^{IN}\) from axiom A, and obtain a new temporary axiom, also consider \(R^{IN}\) as a \(L^{IN}\) for the next insertion rule. Also we remove \((LI)^{IN}\) as a subarray from the examining input E and obtain a new temporary input. Now we continue our procedure with this temporary axiom and temporary examing input in the same way.

  • Condition 3: If \((|L|+|I|+ |R|)^{IN}\le |E|\) but \((|L|+|R|)^{IN}=|A|\), then it can be understood that some part of the examining input is still left to scan, and that is considered directly as the left context \(L^{IC}\) of the first selector \(x^{IC}_{first}\) or right context \(R^{IC}\) of the last selector \(x^{IC}_{last}\). We define new rule internal contextual rule.

  • \((\hat{\varphi }[x]=L\psi R)_{new}\) where \(L_{new}=L^{IC},R_{new}= \varLambda , x_{new}=x^{IC}_{first}\), another rule can be \((\hat{\varphi }[x]=L\psi R)_{new}\) where \(L_{new}=\varLambda , R_{new}= R^{IC}, x_{new}=x^{IC}_{last}\). It should be noted that these particular rules will not be considered for updation and correction.

Part 4: At that moment, existing first column of R will be concatenated with existing L.

$$\begin{aligned} L=\left[ {\begin{matrix} a_{1,1} &{} a_{1,2}\\ a_{2,1} &{} a_{2,2}\\ \vdots &{} \vdots \\ a_{m,1} &{} a_{m,2} \end{matrix}}\right] , \, R=\left[ {\begin{matrix} a_{1,3} &{} \ldots &{} a_{1,n}\\ a_{2,3} &{} \ldots &{} a_{2,n}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,3} &{} \ldots &{} a_{m,n} \end{matrix}}\right] , \, \text {go to part 1 until } L=\left[ {\begin{matrix} a_{1,1} &{} \ldots &{} a_{1,n}\\ a_{2,1} &{} \ldots &{} a_{2,n}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,1} &{} \ldots &{} a_{m,n} \end{matrix}}\right] , \end{aligned}$$

in that case defining insertion rule is not possible. We may need to define insertion rule with the current examining array, if we are still unable to define insertion rule, then we will conclude that the choosen axiom is wrong. It is a negative example as we are dealing with single axiom.

So in this section, we get the selectors from axiom and contexts from examining input. Later on for new input, we may need to guess (next section).

5.3 Making Correction and Updating Rules - Pseudocode-Step: 10–16

  • \(\mathbf{S\! \leftarrow \! Check\!-\!Contextual-Rule(1-Sided-Contextual-Rule_i, IP_i)}\) : It checks the correctness of \(1-Sided-Contextual-Rule_i\) for \(IP_i\). If S is true then the correct \(1-Sided-Contextual-Rule_i\) will be pushed onto set \(\{1-Sided-Correct-Rule\}\) or it goes for correction.

  • \(\mathbf{Correction\!-\!Contextual\!-\!Rule(1-Sided-Contextual-Rule_i, IP_i)}\) : In that case we need to go for correction of the rule in such a way so that our new corrected rule can take care of new inputs and as well as previous inputs.

  • Let the initial rule be \(\hat{\varphi }[x_i]=L_i \psi R_i\) where \(L_i, R_i\) are ith left and right context of the ith selector \(x_i\). Here \(x_{i+1}\) is also introduced because we will make the correction using \(x_{i+1}\).

Proposition 2

In case of correction, we deal with only 1-sided contextual rules where left context is always empty and selector is not the last one. (see condition 3 of Subsect. 5.2) We will try to find the rule as a subarray from the examining input.

Let the examining input be \(E= \left[ {\begin{matrix} a_{i,1} &{} \ldots &{} a_{i,p}\\ a_{i+1,1} &{} \ldots &{} a_{i+1,p}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,1} &{} \ldots &{} a_{m,p} \end{matrix}}\right] \). We can represent the examining input in the following format \(E=P\varPhi x_{i}\varPhi Q \varPhi x_{i+1}\varPhi Z\). where PZ are the rest of the part of string and they can be empty also, Q is the inserted subarray portion. Now we present the examining input in 2D form.

$$\begin{aligned} E= P \varPhi \left[ {\begin{matrix} a_{i,k} &{} \ldots &{} a_{i,\alpha }\\ a_{i+1,k} &{} \ldots &{} a_{i+1,\alpha }\\ \vdots &{} \vdots &{} \vdots \\ a_{m,k} &{} \ldots &{} a_{m,\alpha } \end{matrix}}\right] \varPhi Q \varPhi \left[ {\begin{matrix} a_{i,j} &{} \ldots &{} a_{i,\beta }\\ a_{i+1,j} &{} \ldots &{} a_{i+1,\beta }\\ \vdots &{} \vdots &{} \vdots \\ a_{m,j} &{} \ldots &{} a_{m,\beta } \end{matrix}}\right] \varPhi Z \end{aligned}$$

Now we need to check the contexts. R must be matched with Q. \(R=R_{i}\varPhi R_{i+1}\varPhi ...\varPhi R_{w}\) where \(1\le i \le w\), and \(R_i\) presents the ith column of array. \(Q=Q_{i}\varPhi Q_{i+1}\varPhi ...\varPhi Q_{z}\) where \(1\le i \le z\), and \(Q_i\) presents the ith column of array.

Here we are making an analysis to find out the partially equal part (as a prefix/suffix) between \(R_1\varPhi R_2\varPhi ...\varPhi R_w\) and \(Q_1\varPhi Q_2\varPhi ...\varPhi Q_z\) and we have shown the correction part for one rule, in the same way can make the correction for other rules. In Theorems 3 and 4, we obtain the common-prefix and common-suffix part between R and Q.

Theorem 2

If the analysis starts with equality such that \(Q_{1}={R}_{1}, Q_{2}={R}_{2}\varPhi ...\varPhi Q_f={R}_s\), and \(Q_{f+1}\ne R_{s+1}\) or \(f=z\) or \(s=w\), then we can have four different types of errors which are stated in terms of following lemmas.

Lemma 4

If \((f=z\) and \(s=w)\) then it implies that matching is correct, so no need to make any correction for this rule and the rule is correct.

Lemma 5

If \((f=z\) and \(s<w)\) then we infer the following two new rules.

  • \(Rule_{i'}:\hat{\varphi }[x_{i'}]=L_{i'}\psi R_{i'}\) where \(R_{i'}=Q_1\varPhi Q_2\varPhi ...\varPhi Q_f,L_{i'}=\varLambda , x_{i'}=x_i\).

  • \(Rule_{(i+1)'}: \hat{\varphi }[x_{(i+1)'}]= L_{(i+1)'}\psi [R_{(i+1)'}\) where \(L_{(i+1)'}=R_{s+1}\varPhi R_{s+2}\varPhi ...\varPhi R_w, R_{(i+1)'}= \varLambda , x_{(i+1)'}=x_{(i+1)}\).

Lemma 6

If \((f<z\) and \(s=w)\) then we infer the following two new rules.

  • \(Rule_{i'}:\hat{\varphi }[x_{i'}]=L_{i'}\psi R_{i'}\) where \(R_{i'}= R_1\varPhi ..\varPhi R_w, L_{i'}=\varLambda , x_{i'}=x_i\).

  • \(Rule_{(i+1)'}:\hat{\varphi }[x_{(i+1)'}]=L_{(i+1)'}\psi R_{(i+1)'}\) where \(L_{(i+1)'}=Q_{f+1}\varPhi Q_{f+2}\varPhi ...\varPhi Q_z,R_{(i+1)'}=\varLambda , x_{(i+1)'}=x_{(i+1)}\).

Lemma 7

If \((f<z\) and \(s<w)\) then we infer the following three new rules.

  • \(Rule_{i'}:\hat{\varphi }x_{i'}=L_{i'}\psi R_{i'}\) where \(R_{i'}=Q_1\varPhi Q_2\varPhi ...\varPhi Q_f,L_{i'}=\varLambda , x_{i'}=x_i\).

  • \(Rule_{(i+1)'}:\hat{\varphi } [x]_{(i+1)'}=L_{(i+1)'}\psi R_{(i+1)'}\) where \(L_{(i+1)'}={R}_{s+1}\varPhi ...\varPhi {R}_w, R_{(i+1)'}=\varLambda , x_{(i+1)'}=x_{i+1}\).

  • \(Rule_{(i+2)'}:\hat{\varphi } [x]_{i+2}=L_{(i+2)'}\psi R_{(i+2)'}\) where \(L_{(i+2)'}=Q_{f+1}\varPhi ...\varPhi Q_z,R_{(i+2)'}= \varLambda ,x_{(i+2)'}=x_{i+1}\).

Theorem 3

If the analysis starts with inequality such that \(Q_1 \ne R_1\), but \(Q_{z}={R}_{w}, Q_{z-1}={R}_{w-1}\varPhi ...\varPhi Q_{f}={R}_{s}\), and \( Q_{f-1}\ne R_{s-1}\) then we can have three different types of errors which can be seen in the following lemmas.

Lemma 8

If \((s=1, f>1)\) then we infer the following two new rules.

  • \(Rule_{i'}: \hat{\varphi }[x_{i'}]=L_{i'}\psi R_{i'}\) where \(L_{i'}={R}_1\varPhi {R}_2\varPhi ...\varPhi {R}_w, R_{i'}=\varLambda , x_{i'}=x_{i+1}\).

  • \(\hat{\varphi }[x_{(i+1)'}]=L_{(i+1)'}\psi R_{(i+1)'}\) where \(R_{(i+1)'}=Q_{1}\varPhi Q_{2}\varPhi ...\varPhi Q_{f-1},L_{(i+1)'}=\varLambda ,x_{(i+1)'}=x_{i}\).

Lemma 9

If \((s>1)\) then we infer the following three new rules. \(Rule_{i'}:\hat{\varphi }[x_{i'}]=L_{i'}\psi R_{i'}\) where \(L_{i'}={R}_s\varPhi {R}_{s+1}\varPhi ...\varPhi {R}_w, R_{i'}=\varLambda , x_{i'}=x_{i+1}\). \(Rule_{(i+1)'}:\hat{\varphi }[x_{(i+1)'}]=L_{(i+1)'} \psi R_{(i+1)'}\) where \(R_{(i+1)'}=Q_{1}\varPhi Q_{2}\varPhi ...\varPhi Q_{f-1},L_{(i+1)'}=\varLambda , x_{(i+1)'} = x_i\). \(Rule_{(i+2)'}:\hat{\varphi }[x_{(i+2)]'}=L_{(i+2)'}\psi R_{(i+2)'}\) where \(L_{(i+2)'}=\varLambda , R_{(i+2)'}= {R}_1\varPhi {R}_2\varPhi ...\varPhi {R}_{s-1}, x_{(i+2)'}=x_i\).

Lemma 10

If \(Q_z \ne R_w\) then we infer the following two new rules.

  • \(Rule_{i'}:\hat{\varphi }[x_{i'}]=L_{i'}\psi R_{i'}\) where \(R_{i'}={R}_1\varPhi {R}_{2}\varPhi ...\varPhi {R}_w, L_{i'}=\varLambda , x_{i'}=x_i\).

  • \(Rule_{(i+1)'}:\hat{\varphi }[x_{(i+1)'}]=L_{(i+1)'}\psi R_{(i+1)'}\) where \(R_{(i+1)'}=Q_{1}\varPhi Q_{2}\varPhi ...\varPhi Q_{z},L_{(i+1)'} =\varLambda , x_{(i+1)'}=x_i\).

In this section, we must notice that we have different rules with same selectors. According to Definitions 4 and 5, for each selector there must be one rule. As we are inferring 1-sided contextual rule, it does not satisfy our Definitions 4 and 5. In the next section we will convert 1-sided contextual rule into 2-sided contextual rule in order to take care of over generalization and Definitions 4 and 5.

5.4 Controlling over Generalization - Pseudocode-Step: 17–21

  • \(\mathbf{Table.insert[Find-Nof-App-of-EachRule-in-EachMember}\) \(\mathbf{(1-Sided-Correct-Rule_i,IP_i)]}\) : It finds out the application of each rule on each member of the input and insert that record into the table.

  • \(\mathbf{2\!-\!Sided-Correct-Rule.push[Merge(1-Sided-Correct-Rule_i,}\) \(\mathbf{1-Sided-Correct-Rule_j)]}\) : In this case if we find that ith row \((TableRow_i)\) and jth row \((TableRow_j)\) is same then we merge these two rules \((1-Sided-Correct-Rule_i, 1-Sided-Correct-Rule_j)\) and store as a \(2-Sided-Correct-Rule\).

  • In this section we determine the number of applications of each rule to generate the given input set. It will be presented in table. We put priority in applying rules where left context is empty and context is smaller in size. If it is found that without using any rule we can generate the full input set then we can ignore that rule.

  • Actually all the rules are 1-sided where left contexts or right contexts are empty that generate more elements. Thus, to control this over generalization, we check that how many times each rule is applied in each member of the input set. Rules which are applied equal number of times in each member, those can be merged into one rule based on condition (discussed in Lemmas 11 and 12).

  • Also in this way we satisfy our required condition for SPICCAG (Definition 4), that is, for each selector atmost one rule is applicable.

Lemma 11

If consecutive selectors are \(x_i, x_j\) with \((j-i)=1\) and left contexts(right contexts) are empty in a set of rule then we can get 1-sided or 2-sided internal contextual rule after merging them.

Proof

Let \(x_i, x_j\) denote ith and jth selector, \(R_i, R_{j}\) be ith and jth right context and \(L_i, L_{j}\) are ith and jth left context.

  • case 1: If \(x_i, x_j\) are such that \((j-i)=1\) and if \(R_i= R_j=\varLambda \) then rule becomes \(\hat{\varphi }[x_i]=L_i\psi R_i\) where \(R_i= L_j\).

  • case 2: If \(x_i, x_j\) are such that \((j-i)=1\) and if \(L_i= L_j=\varLambda \) then the rule becomes \(\hat{\varphi }[x_i]=L_i\psi R_i\) where \(L_j= R_i, x_i=x_j\).

Lemma 12

If consecutive selectors are \(x_i, x_j\) with \((j-i)=1\) and left contexts of ith rule and right context of jth rule are empty then we can get 1-sided internal contextual rule after merging them.

Proof

Let \(x_i, x_j\) denote ith and jth selector, \(R_i, R_j\) are left contexts of ith rule and right context of jth rule respectively.

If \(x_i, x_j\) are such that \((j-i)=1\) and if \(L_i= R_j=\varLambda \) then the rule becomes \(\hat{\varphi }[x_i]=L_i\psi R_i\) where \(R_i= R_i\varPhi R_j\)

5.5 Parallalization Contextual Array Rules - Pseudocode-Step: 22, 23

  • \(\mathbf{Parallel-Rule.push(2-Sided-Correct-Rule_i)}\) : It converts the \(2-Sided-Correct-Rule_i\) into parallel rule and push onto set \(\{Parallel-Rule\}\). If we get a rule \(\hat{\varphi }[x]=L\psi R\) where

    $$\begin{aligned} x=\left[ {\begin{matrix} a_{i,k} &{} \ldots &{} a_{i,\alpha }\\ a_{i+1,k} &{} \ldots &{} a_{i+1,\alpha }\\ \vdots &{} \vdots &{} \vdots \\ a_{m,k} &{} \ldots &{} a_{m,\alpha } \end{matrix}}\right] , L=\left[ {\begin{matrix} a_{i,j} &{} \ldots &{} a_{i,k-1}\\ a_{i+1,j} &{} \ldots &{} a_{i+1,k-1}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,j} &{} \ldots &{} a_{m,k-1} \end{matrix}}\right] , R=\left[ {\begin{matrix} a_{i,\alpha +1} &{} \ldots &{} a_{i,n}\\ a_{i+1,\alpha +1} &{} \ldots &{} a_{i+1,n}\\ \vdots &{} \vdots &{} \vdots \\ a_{m,\alpha +1} &{} \ldots &{} a_{m,n} \end{matrix}}\right] \end{aligned}$$

According to Definition 2, we can have \((m-1)\) parallel rules \(\varphi [Px_i]=PL_i \psi PR_i\) where \(Px_{i},PL_{i}, PR_{i}\) are respectively selector, left context, right context.

$$\begin{aligned} Px_i=\left[ {\begin{matrix} a_{i,k} &{} \ldots &{} a_{i,\alpha }\\ a_{i+1,k} &{} \ldots &{} a_{i+1,\alpha } \end{matrix}}\right] ,PL_i= \left[ {\begin{matrix} a_{i,j} &{} \ldots &{} a_{i,k-1}\\ a_{i+1,j} &{} \ldots &{} a_{i+1,k-1} \end{matrix}}\right] , PR_i= \left[ {\begin{matrix} a_{i,\alpha +1} &{} \ldots &{} a_{i,n}\\ a_{i+1,\alpha +1} &{} \ldots &{} a_{i+1,n} \end{matrix}}\right] \end{aligned}$$

where \(1 \le i \le m-1\).

Remark 1

The above algorithm can also be used to identify a \(k-UPICCAG\). A modification required in the algorithm is that, k is also given along with the positive presentation as an input to the algorithm.

In this case, at the time of defining insertion rule (Sect. 5.2), we need to focus on the size of selectors and contexts in terms of number of columns as k is given as an input. Defining insertion rule should be done in the following way, \(LIR \in sub(E)\) where \(|I|=|L|=|R|=k\) and also \(|A|=mk, L,I,R \in V^{++}\).

6 Correctness of the Algorithm and Characteristic Sample

The correctness of the algorithm can be noticed in view of the fact that the specific properties of the subclasses considered allow the positive examples. The correctness of the algorithm can be seen by considering a characteristic sample for a target language. Also it can be seen that the algorithm runs in polynomial time in the sum of the size of the examples given. (discussed in Sect. 7). The correctness of the algorithm, can be seen by considering a characteristic sample for a target SPICCAL. Let L be an SPICCAL. A finite set IPS is called a characteristic sample of L if and only if L is the smallest SPICCAL containing IPS.

7 Running Time Complexity of Our Algorithm

In this section we show the running time of our algorithm to infer the column contextual rules.

Theorem 4

The running time complexity of the given pseudocode in Sect. 5, is polynomial in the size of the input set, that is, SumofSize(IPS) where \(IPS=\{IP_i,IP_{i+1},...,IP_{k}\}\).

Proof

proof is omitted.

8 Conclusion and Future Work

In this paper we present a polynomial time algorithm to infer subclasses of parallel internal column contextual array languages from positive examples only. Here we deal with only column contextual rules. In the form of future direction of this work, we can deal with column and row contextual rules together, that is, parallel internal array contextual languages.