![](bg2.png)
(l,m, m
′
) if
l =max{|α| | (u,α,v) ∈ P};
m =max{|u| | (u,α,v) ∈ P};
m
′
=max{|v| | (u, α,v) ∈ P}.
For example, consider an insertion system of the
weight (2,0,0) Π = ({a,b},{ε},{(ε,ab, ε)}). Then,
it is clear that Π generates the Dyck language.
We denote by INS
m,m
′
l
the family of languages
generated by insertion systems of weight (l,m,m
′
).
In the sequels we will restrict ourselves to inser-
tion systems of weight (l,1,1), i.e., we assume that
all insertions have the form (a,a
1
··· a
k
,b), where
a,a
1
,... ,a
k
,b ∈ V, and k ≤ l. It is well-known that the
family of languages INS
1,1
l
,l ≥ 1 is a proper subfam-
ily of context-free languages (P˘aun, 1997), for which
there are well-known parsers working in polynomial
time. Therefore, we expect to find parsers of poly-
nomial power for insertion systems of weight (l,1,1)
too.
3 PARSING FOR SIMPLE
INSERTION SYSTEMS
For the sake of simplicity, first we assume that A is a
singleton having a string of length two. We call this
type of insertion systems simple.
For simple insertion systems, we can show an ef-
fective parsing technique based on the idea of CYK
algorithm (Cocke and Schwartz, 1970; Kasami, 1965;
Younger, 1967). The input to the algorithm is a
simple insertion system G = (V,A,P) and a string
w = a
1
··· a
n
∈ V
∗
. In O(n
3
) time, the algorithm con-
structs a table that checks whether w is in L(G ). Note
that when computing the running time of the check-
ing, the system itself is considered fixed, and its size
contributes only a constant factor to the running time,
which is measured in terms of the length of the string
w whose membership in L(G ) is being tested. In this
algorithm, we construct a triangular table, called pars-
ing table, as shown in Table 1.
The parsing table consists of n− 1 rows and n− 1
columns, where n denotes the length of the parsed
word. To fill the table, we work row-by-row up-
wards. Each row corresponds to substrings of the
given length; the bottom row is for strings of length 2,
the second row for strings of length 3, etc., until the
top row corresponds to the only substring of length
n, which is the parsed word. By the proposed algo-
rithm it takes O(n) time to compute each entry of the
table. Since there are n(n − 1)/2 entries, the whole
table construction takes O(n
3
) time.
Table 1: Parsing Table.
X
15
X
14
X
25
X
13
X
24
X
35
X
12
X
23
X
34
X
45
a
1
a
2
a
3
a
4
a
5
The Algorithm
1. If a
1
a
m
is not the (only) axiom (i.e. {a
1
a
m
} 6= A)
then a
1
···a
m
/∈ L(G ) and we are ready.
2. Otherwise, we consider the following treatment.
(a) for every j = 1, ..., m−1, we put ( j, j + 1) into
X
j, j+1
.
(b) for every i = 2,...,m − 1 and j = 1,..., m − i,
we put ( j,i+ k) into X
j,i+k
if we did not do
it so far in the previous steps, and there ex-
ists an insertion (a
j
,a
j
1
a
j
2
···a
j
s
,a
i+k
) (1 ≤
j < j
1
< j
2
< ··· < j
s
< i + k ≤ m) such that
( j, j
1
) ∈ X
j, j
1
,( j
1
, j
2
) ∈ X
j
1
, j
2
,... ,( j
s−1
, j
s
) ∈
X
j
s−1
, j
s
,( j
s
,i+ k) ∈ X
j
s
,i+k
1
(c) Finally, if (a
1
,a
m
) ∈ X
1,m
then a
1
···a
m
∈ L(G ),
otherwise not.
Prove that the algorithm works in polynomial
(O(n
3
)) time. Moreover, for every string a
1
··· a
m
∈
V
∗
, we have a
1
···a
m
∈ L(G ) if and only if (a
1
,a
m
) ∈
X
1,m
.
Theorem 1. Let Π be a simple insertion systems and
let n be the length of the parsed word. There exists a
parser working on Π in polynomial (O(n
3
)) time.
Proof:
The reason the algorithm puts the correct pairs of
characters is the following. In the bottom row, which
has the length n − 1, for every position we put a pair
consisting of the line number of the position and the
consecutive one. Thus, the first pair is (1,2) and the
last pair is (n− 1,n).
Then, for every i = 2,...,m− 1 and j = 1, ..., m−i,
we can put (s,t) into the j-th position of the i-th row
if and only if two conditions are holding: a.) s = j; b.)
there exist an insertion (a
j
,a
j
1
a
j
2
···a
j
s
,a
i+1
) and po-
sitions X
j, j
1
−1
,X
j
1
, j
2
−1
,... ,X
j
s−1
, j
s
−1
,X
j
s
, j
i+k
which
1
Note that, by our assumptions, | a
j
1
a
j
2
···a
j
s
| ≤ ℓ.
Therefore, the number of elementary operations in step 2
is not more that (m− 2)(m− i)ℓ.
ICAART 2010 - 2nd International Conference on Agents and Artificial Intelligence
384