Sewing Contexts and Mildly Context-Sensitive Languages - CiteSeerX

0 downloads 0 Views 229KB Size Report
languages has been done. The aim of our paper is to introduce very simple grammars that can de ne families of mildly context-sensitive families of lan- guages.
Sewing Contexts and Mildly Context-Sensitive Languages

Carlos Martin-Vide

Research Group in Mathematical Linguistics and Language Engineering (GRLMC) Universitat Rovira i Virgili, 43005 Tarragona, Spain, e-mail: [email protected]

Alexandru Mateescu

Turku Centre for Computer Science, 20520 Turku, Finland and Faculty of Mathematics, University of Bucharest, Romania, email: mateescu@utu.

Arto Salomaa

Turku Centre for Computer Science, Lemminkaisenkatu 14 A, 20520 Turku, Finland, email: asalomaa@utu.

Turku Centre for Computer Science TUCS Technical Report No 257 March 1999 ISBN 952-12-0417-6 ISSN 1239-1891

Abstract Sewing grammars introduced below are very simple grammars, still able to de ne families of mildly context-sensitive languages. These grammars are inspired from Marcus contextual grammars and simple matrix grammars. We consider various families of sewing grammars. Some of them lead to very special families of languages such that each such family is a mildly context-sensitive family of languages, and, moreover, most of the fundamental problems, like the equivalence problem, the inclusion problem, etc., are decidable. The aim of this paper is to investigate some of the properties of these grammars and to suggest new directions of research in this area.

TUCS Research Group

Mathematical Structures of Computer Science

1 Introduction The need of mildly context-sensitive families of languages was emphasized in connection with linguistics, see [4] and [5]. As far as we know, no systematic investigation of grammars or other devices that de ne such families of languages has been done. The aim of our paper is to introduce very simple grammars that can de ne families of mildly context-sensitive families of languages. Our paper is just a rst step in order to have a systematic view of those grammars that de ne mildly context-sensitive families of languages. A mildly context-sensitive family of languages should contain the most signi cant languages that occur in the study of natural languages. Languages in such a family must be semilinear languages, and, moreover, they should be computationally feasible, i.e., the membership problem for languages in such a family must be solvable in deterministic polynomial time complexity. It is well known that the hierarchy of Chomsky does not contain such a family. Whereas the family of context-free languages has good computational properties, it does not contain some important languages that appear in the study of natural languages. The family of context-sensitive languages contains all important languages that occur in the study of natural languages, but no algorithm in deterministic polynomial time is known for its membership problem.

Remark 1.1 By a mildly context-sensitive family of languages we mean a family L of languages such that the following conditions are ful lled: (i) each language in L is semilinear, (ii) for each language in L the membership problem is solvable in deterministic polynomial time, and (iii) L contains the following three non-context-free languages: - multiple agreements:

L = faibici j i  0g; 1

- crossed agreements:

L = faibj cidj j i; j  0g, and 2

- duplication:

L = fww j w 2 fa; bgg: 3

1

Note that in the literature some authors consider that such a family contains all context-free languages, and/or some other non-context-free languages: k multiple agreements: L0 = fai ai : : :aik j i  0g where k  3; marked duplication: L0 = fwcw j w 2 fa; bgg. In the sequel we will consider these variants, too The paper is organized as it follows. Firstly, we introduce the basic type of sewing grammar and we show that the corresponding family of languages is a mildly context-sensitive family of languages. This type of grammars is extended to a more general type of grammars. We investigate pumping lemmata for the languages de ned by these grammars as well as closure properties of these families of languages. Next we de ne some families of languages that are almost mildly contextsensitive, and, moreover, for languages in these families the problems of equivalence, of inclusion, etc., are decidable problems. Finally, we discuss some other extended models as well as further topics of research. Now we recall some terminology and de nitions that we will use in this paper. Let  be an alphabet and let  be the free monoid generated by  with the identity denoted by . The free semigroup generated by  is  =  ?fg. Elements in  ( ) are referred to as words (nonempty words).  is the empty word. A context is a pair of words, i.e., (u; v), where u; v 2 . The families of regular, linear, context-free, context-sensitive and recursively enumerable languages are denoted by REG, LIN , CF , CS and RE , respectively. Assume that  = fa ; a ; : : :; ak g. The Parikh mapping, denoted by , is: :  ?! N k ; (w) = (jwja1 ; jwja2 ; : : :; jwja ): If L is a language, then the Parikh set of L is de ned by 1

1 2

3

+

+

1

2

k

(L) = f (w) j w 2 Lg:

A linear set is a set M  N k such that M = fv + Pmi vixi j xi 2 N g, for some v ; v ; : : : ; vm in N k . A semilinear set is a nite union of linear sets and a semilinear language is a language L such that (L) is a semilinear set. In the sequel we recall the de nition of a simple matrix grammar. 0

0

=1

1

De nition 1.1 A simple matrix grammar of degree n (see [3] ) is an ordered system G = (N ; : : : ; Nn; ; P; S ) where Ni ; 1  i  n, are nite pairwise 1

2

disjoint sets of nonterminals,  is a terminal alphabet, S is the start symbol, n [ S 2=  [ N ; i=1

i

and P is a nite set of n-dimensional vectors of rules, (r1 ; : : :; rn ), where each rule ri is a context-free rule over the alphabet Ni [  such that for all pairs of rules, ri : Ai ?! xi , rj : Aj ?! xj it follows that jxi jN = jxj jN , 1  i; j  n. Moreover, P contains rules of the form (S ! u), with u 2  and also rules of the form (S ! A1A2 : : :An), where Ai 2 Ni , 1  i  n. i

j

2

Let G be a simple matrix grammar of degree n. G de nes a relation of direct derivation as follows:

S )G v i (S ! v) 2 P and

u X u : : : Xn un )G u v u : : :vnun i (X ! v ; : : :; Xn ! vn) 2 P; 0

1

1

0 1

1

1

1

where uj 2 ( [ Sni Ni); j = 0; 1; : : : ; n; Xi 2 Ni ; i = 1; : : : ; n, and, moreover, the derivation is leftmost on each of the n substrings in (Ni [ ) of the current string. The derivation relation induced by G, denoted )G, is the re exive and transitive closure of )G. The language generated by a simple matrix grammar G of degree n is: =1

L(G) = fw 2  j S )G wg:

2

In this paper the so called regular, resp. linear, simple matrix grammars are of a special interest.

De nition 1.2 A regular, resp. linear, simple matrix grammar of degree n, where n  1, is a simple matrix grammar of degree n, G = (N ; : : : ; Nn; ; P; S ) 1

such that all the rules occurring as components in the n-dimensional vectors from P , excepting the rules starting with S , are Chomsky regular, resp. linear, rules.

3

2

Contextual grammars were rstly considered in [7] with the aim to model some natural aspects from descriptive linguistics like for instance the acceptance of a word (construction) only in certain contexts. For a detailed presentation of this topic, the reader is referred to the recent monograph [10].

De nition 1.3 A Marcus simple contextual grammar is an ordered system

G = (; B; C ), where  is the alphabet of G, B is a nite subset of , called the base of G and C is a nite set of contexts, i.e., a nite set of pairs of words over . C is called the set of contexts of G.

2

Let G = (; B; C ) be a Marcus simple contextual grammar. The direct derivation relation with respect to G is a binary relation between words over , denoted )G , or ) if G is understood from context. By de nition, x )G y, where x; y 2  i y = uxv for some (u; v) 2 C . The derivation relation with respect to G, denoted )G, or ) if G is understood from context, is the re exive and transitive closure of the relation )G.

De nition 1.4 Let G = (; B; C ) be a Marcus simple contextual grammar. The language generated by G, denoted L(G), is de ned as:

L(G) = fy 2  j there exists x 2 B; such that x )G yg:

2

One can verify that the language generated by G = (; B; C ) is the smallest language L over  such that: (i) B  L. (ii) if x 2 L and (u; v) 2 C , then uxv 2 L. Moreover, it is easy to observe that: L(G) = B [ fun : : :u xv : : :vn j n  1; x 2 A; (ui; vi) 2 C; 1  i  ng: The family of all Marcus simple contextual languages is denoted by SM. 1

1

Remark 1.2 SM  LIN . If G = (; A; C ) is a simple contextual gram-

mar, then one can de ne an equivalent Chomsky linear grammar G0 = (fX g; ; X; P ), where X is a new symbol and the set P of productions is de ned as follows: P = fX ! j 2 Ag [ fX ! uXv j (u; v) 2 C g: Note also that SM is a strict subfamily of LIN and, moreover, the families SM and REG are incomparable, see [10].

2 4

Remark 1.3 A simple contextual grammar generates a language starting

from a nite set of strings (the base) and iteratively adjoining to it contexts, i.e., pairs of strings from C , at the ends of the current string. In other families of contextual grammars, such as the internal contextual grammars, [10], the contexts are adjoined inside of the current string.

The reader is referred to [12] or [11] for the basic notions of formal languages we use in the sequel and to [1] and [6] for interrelations between linguistics and formal languages.

2 Sewing grammars: the basic model Here we introduce the basic model of sewing grammars, we give some examples and we show some properties of these grammars.

De nition 2.1 A sewing grammar is a construct G = (; B; C; n; f ), where  is an alphabet, n  1 is an integer called the degree of G, B  ()n, B nite, is the base of G, C  ()n , C nite, is the set of contexts (or rules) of G and f is a recursive function, f : ( )n ?!  , called the zipper function of G.

Using the above notations, a sewing grammar G de nes a relation of direct derivation, denoted =)G or =), between elements in ( )n. By de nition (x ; x ; : : :; xn) =)G (y ; y ; : : :yn ) 1

2

1

2

i there exists (z ; z ; : : :; zn) 2 C , such that yi = xizi, 1  i  n. The re exive and transitive closure of =)G or =) is denoted by =)G or =) and called the relation of derivation de ned by G. The n-arry language de ned by G, denoted by nL(G), is by de nition: 1

2

nL(G) = f(x ; x ; : : :; xn ) 2 ()n j (u ; u ; : : :; un ) =)G (x ; x ; : : :; xn); 1

2

1

1

2

2

for some (u ; u ; : : : ; un) 2 B g: 1

2

De nition 2.2 Let G = (; B; C; n; f ) be a sewing grammar. The language de ned by G is:

L(G) = ff (x ; x ; : : :; xn) j (x ; x ; : : : ; xn) 2 nL(G)g: 1

2

1

5

2

Therefore the language de ned by a sewing grammar G = (; B; C; n; f ) is the set of all words obtained by applying the zipper function f to the n-tuples from the language nL(G). Notation. We denote by SW n(f ) the family of all languages generated by sewing grammars of degree n and with the zipper function f .

Remark 2.1 In this paper we mainly consider that the zipper function f is

the catenation function of arity n, denoted catn, i.e., the function, catn : ()n ?! , catn(u1; u2; : : :; un) = u1u2 : : : un: We will drop the indice f whenewer this is the case. For instance SW n denotes the family SW n(f ), where f is the catenation function. Moreover, note that for n < m, it follows that SW n  SW m .

2

Theorem 2.1 Let  be an alphabet. (i) The languages ;,  , F   , F nite are in SW n for every n  1. (ii) The language: - multiple agreements,

is in SW n for every n  3. (iii) The language: - crossed agreements,

L = faibici j i  0g; 1

L = faibj cidj j i; j  0g is in SW n for every n  4. 2

(iv) The language: - duplication,

L = fww j w 2 fa; bgg: is in SW n for every n  2. 3

Proof. (i) The language ; is generated by a sewing grammar of degree 1 with B = ;. The language  is generated by a sewing grammar of degree 1 with B = f()g and the contexts C = f(a) j a 2 g. Finally, a nite language F is generated by a sewing grammar of degree 1 with B = f(u) j u 2 F g and the contexts C = f()g. Therefore all these languages are in SW 1 and, using Remark 2.1 it follows that they are in all families SW n , with n  1.

6

(ii) The language L is generated by the sewing grammar 1

G = (fa; b; cg; B; C; 3; cat ); 1

3

where B = f(; ; )g and C = f(a; b; c)g. (iii) The language L is generated by the sewing grammar 2

G = (fa; b; c; dg; B; C; 4; cat ); 2

4

where B = f(; ; ; )g and C = f[(a; ; c; )]; [(; b; ; d)]g. (iv) Finally, the language L is generated by the sewing grammar 3

G = (fa; b; g; B; C; 2; cat ); 3

2

where B = f(; )g and C = f(a; a); (b; b)g. Therefore, using Remark 2.1 we conclude the proof.

2

Comment. Concerning the language: k-multiple agreements: L0 = fai ai : : :aik j i  0g where k  3; one can easily prove, using the method from Theorem 2.1, that L0 is in SW n , for n  k. 1

1 2

1

As in Theorem 2.1, it can be proved that the language: marked duplication: L0 = fwcw j w 2 fa; bgg. is in SW (replace in the grammar associated to L , the set B with B = f(; c)g. 3

2

3

Theorem 2.2 Each language in SW n, where n  1 is a semilinear language. Proof. Let L be a language in SW n , n  1. Let G = (; B; C; n; catn) be a sewing grammar of degree n such that L(G) = L. De ne the Chomsky regular grammar G0 = (fS g; ; S; ), where

 = fS ?! u u v : : : unS j [(u ; u ; : : :un)] 2 C g[ 1

2 2

1

2

[fS ?! x x : : :xn j (x ; x ; : : :xn) 2 B g: 1

2

1

2

Let L0 be the language L(G0). One can easily see that L and L0 are letter equivalent, i.e., (L) = (L0). Since L0 is a regular language, it follows that L0 is a semilinear language. Therefore, also L is a semilinear language.

2

The membership problem consists in the following problem: given a language L   (de ned by a certain type of grammar, automaton, etc.) and 7

a word w 2  to decide by an algorithm whether or not w is in L. The existence of such an algorithm as well as its complexity are very important from the practical point of view. The next theorem shows that the membership problem for languages in SW p, p  1 is in P, the class of all deterministic polynomial time complexity problems. Theorem 2.3 For every p  1 and for every L 2 SW p the membership problem is solvable in deterministic polynomial time. Proof. Let L   be a language in SW p, where p  1, p xed. Moreover, let G = (; B; C; p; catp) be a sewing grammar of degree p such that L(G) = L. We can assume that C does not contain the completely empty context, i.e., a context such that all its components are  (if such a context exists in C , then it can be always removed without changing the language generated by G). Let w be a word from . We describe an algorithm that decides whether or not w 2 L(G). Assume that jwj = n and w = a a : : : an, where ai 2 , 1  i  n. If i; j are integers such that 1  i  j  n, then denote by wi;j the word aiai : : :aj . Moreover, if j < i, then wi;j = . The algorithm that solves the membership problem for L and w is de ned using a Turing machine M with two tapes. The rst tape contains w and its content is not changed during the computations. The second tape is used by M to store 2p counters. Each of the values of these counters will be between 0 and n + 1. Therefore, the space used by M on the second tape in order to store these counters is O(2plogn). The 2p counters are denoted by: i ; j ; i ; j ; : : :; ip; jp: Initially, i = 1 and ip = n + 1. M guesses the counters ik, 2  k  p ? 1 such that: i  i  i  : : :  ip : and M assigns to each jk the value of ik , where 1  k  p ? 1. Now M performs the following test: () if (wi1;j1 ? ; wi2;j2? ; : : : ; wi ;j ? ) 2 B , then M accepts w and Stop. Otherwise, M guesses values for jk such that ik  jk  ik for all 1  k  p. If for these values of the counters (wi1 ;j1 ; wi2;j2 ; : : :; wi ;j ) 2 C; then M replaces the values of ik with jk , 1  k  p 1  k  p and M repeats the above test (). 1 2

+1

1

1

2

2

1

1

2

3

+1

1

1

p

p

1

+1

p

8

p

If there is no guessing for the counters

i ; j ; i ; j ; : : : ; i p ; jp : such that the test () leads to acceptance, then M rejects the input w. Clearly, M accepts w if and only if w 2 L(G). Note that M is a nondeterministic Turing machine that works in space O(2plogn). Hence L(M ) 2 NSPACE (logn) and by an well-known theorem of Turing complexity, it follows that L(M ) 2 P , i.e., L(M ) is of deterministic polynomial time complexity. Therefore the membership problem for languages in SW p is solvable in deterministic polynomial time. 2 From Theorem 2.1, Theorem 2.2 and Theorem 2.3 we obtain the following: 1

1

2

2

Theorem 2.4 For every integer n  4, the family SW n is a mildly context-

sensitive family of languages.

2

1.

Now we prove some pumping lemmata for languages in SW n , where n 

Let G = (; B; C; n; catn) be a sewing grammar of degree n, n  1. Let x = (x ; x ; : : : ; xn) be a vector from B . The length of x, denoted jxj, is by de nition, jxj = jx j + jx j + : : : + jxn j. Similarly, the length of a context c 2 C , c = (u ; u ; : : :; un ) is by de nition jcj = ju j + ju j + : : : + junj. Note that for every c 2 C , jcj > 0, since we can assume that G does not contain the completely empty context. 1

2

1

1

2

2

1

2

Theorem 2.5 Let L   be a language in SW n , n  1. There exist two integers m  1 and k  1 such that: (i) (pumping an arbitrary context) If w 2 L such that jwj > m, then w has a decomposition w = x u x u : : :xn unxn , with 0 < ju j + ju j + : : : + junj  k, such that for all i  0, the following words are in L: 1

1

2

2

+1

1

2

wi = x ui x ui x : : : xnuinxn : 1

2

1

2

3

+1

(ii) (pumping an innermost context) If w 2 L such that jwj > m, then w has a decomposition w = x1u1y1x2u2y2x3 : : : xnunyn xn+1, with 0 < ju1j + ju2j + : : : + junj  k, and jy1j + jy2j + : : : + jynj  m, such that for all i  0, the following words are in L:

wi = x ui y x ui y x : : : xnuinynxn : 1

1 1

2

2 2

9

3

+1

(iii) (pumping an outermost context) If w 2 L such that jwj > m, then w has a decomposition w = u1y1u2 y2 : : :unyn , with 0 < ju1j + ju2j + : : :+ jun j  k, such that for all i  0, the following words are in L:

wi = ui y ui y : : :uin yn: 1 1

2 2

(iv) (pumping all occurring contexts) If w 2 L such that jwj > m, then w has a decomposition w = u1 y1u2 y2 : : :unyn , with 0 < jy1j + jy2j + : : : + jynj  m, such that for all i  0, the following words are in L:

wi = ui y ui y : : :uin yn: 1 1

2 2

(v) (interchanging contexts) If w; w0 2 L such that jwj > m and jw0 j > m, then w and w0 have decompositions: w = x1u1x2u2 : : : xnunxn+1 , and w0 = x01u01x02u02 : : :x0n u0nx0n+1, with 0 < ju1j + ju2j + : : : + junj  k, and with 0 < ju01j + ju02j + : : : + ju0nj  k, such that also the following two words, z and z 0 , are in L,

z = x u0 x u0 : : : xnu0nxn ; and z0 = x0 u x0 u : : :x0nun x0n : 1

2

1

1

+1

2

1

2

2

+1

Proof. (i) Let L be generated by a sewing grammar G = (; B; C; n; catn) and let m and k be de ned as:

m = maxfjsj j s 2 B g; and k = maxfjcj j c 2 C g: Let w be in L such that jwj > m. It follows that w is not in B and therefore w is generated by G using one or more contexts from C . Hence, there is a context from C , say (u ; u ; : : :; un) that appears inside of w, i.e., w = x u x u x : : : xnunxn : The conditions: 0 < ju j + ju j + : : : + junj  k is satis ed, since (u ; u ; : : : ; un) is a context c from C . Now, adjoining c i-times in the same position of c, we obtain that for all i  0, the following words are in L: wi = x ui x ui x : : : xnuinxn : Note that i = 0 means that the context c is erased. 1

2

1

1

2

1

1

2

3

+1

3

+1

2

2

1

1

2

2

10

(ii) The proof is as above, except that we can restrict the choice of the context c to be one of the innermost contexts that occurs in w. (note that since some components of contexts can be empty, the innermost context must not be unique). Also, note that from the choice of c, it follows that jy j + jy j + : : : + jynj  m since (y ; y ; : : :; yn) is from B . (iii) Similarly with (ii), except that now the context c is an outermost context that occurs in w (again, since some components of a context can be empty, the outermost context could be not unique). Note that from the choice of c it follows that: x = x = : : : = xn = . (iv) Since jwj  m it follows that w contains a vector from the base, say (y ; y ; : : : ; yn) as a scattered subword. Moreover, the other parts of w were generated by adjoining contexts from C . Repeating i times the derivation of w one obtains the word wi. (v) The proof is like in the case of (i). Both w and w0 contain some contexts, say w contains the context c = (u ; u ; : : :; un) and w0 contains the context c0 = (u0 ; u0 ; : : :; u0n). Therefore these contexts c and c0 can be interchanged and the resulting words z and z0 are in L, too. 1

1

2

2

1

1

2

+1

2

1

1

2

2

2

Theorem 2.5 can be used to show that certain languages are not in a family SW n, n  1. Theorem 2.6 If m; n  1 such that m < n, then SW m  SW n and the inclusion is strict. Proof. Clearly, SW m  SW n . see Remark 2.1. It remains to show that the inclusion is strict. Consider the language: L = fai ai : : : ain j i  0g: Let G = (; B; C; n; catn) be the following sewing grammar, where:  = fa ; a ; : : :; ang; B = f(; | ;{z: : : ; })g; 1 2

1

2

n

and

C = f(a ; a ; : : : ; an)g: It is easy to see that L(G) = L and hence L 2 SW n. On the other hand L is not in SMm since L does not satisfy the condition from Theorem 2.5 (i). Therefore SW m is strictly included in SW n . 1

2

11

2

Combining Theorem 2.4 and Theorem 2.6 we obtain:

Theorem 2.7 The families (SW n )n de ne an in nite hierarchy of mildly

context-sensitive languages.

4

2

3 Sewing families of languages and decidable problems In this section we introduce some special families of sewing languages. Each such a family is almost a mildly context-sensitive family of languages, and, moreover, each such family has good decidability properties. We start by introducing a special type of sewing grammar. If n is an integer, n  1, then [n] denotes the set f1; 2; : : : ; ng. An n-function is a function g : [n] ?! N , where N denotes the set of all positive integers. The length of an n-function g, denoted jgj, is de ned as jgj = g(1) + g(2) + : : : + g(n).

De nition 3.1 Let n  1 be a xed integer, let g be an n-function and let k  1 be a xed integer. A sewing grammar G = (; B; C; n; catn) is of type (g; k) i for all c = (c ; c ; : : : ; cn) 2 C , jcij = g(i), i = 1; 2; : : : ; n and for all b = (b ; b ; : : :; bn) 2 B , bi =  for all i = 6 k and jbk j  jgj. Notation. Let n  1 be an integer, let g be an n-function and let 1  k  n be an integer. We denote by SW n;g;k the following family of 1

1

2

2

languages:

SW n;g;k = fL j there exists a sewing grammar G = (; B; C; n; catn) of type (g; k) such that L(G) = Lg: Remark 3.1 Assume that n  1 is a xed integer. Let g be an n-function and let 1  k  n be an integer. Consider an alphabet  and let  and  1

be the following two alphabets:

 = f[ ] j j j = jgj; 2 g 1

and

 = f[ ] j j j < jgj; 2 g 2

12

2

Note that for each w 2  there exist two unique integers p; r  0 such that jwj = pjgj + r and 0  r < jgj: Moreover, notice that a unique decomposition exists for w:

w = w w : : : wk wk : : :wn ; such that for all i = 1; 2; : : : ; n, jwi j = pg(i) and j j = r. Hence, each wi, 1  i  n is the catenation of p words from , wi = wi wi : : : wi p with wi j 2 g i , for 1  j  p. 1

2

+1

(1)

( )

(2)

( )

( )

Using the above notations we de ne a function:   'n:k g :  ?!   ; 1

2

such that, p p p 'n;k g (w) = [w w : : :wn ][w w : : :wn ] : : : [w w : : :wn ][ ]: One can easily prove the following: (1) 1

(1) 2

(2) 1

(1)

(2) 2

(2)

( ) 1

( ) 2

( )

Proposition 3.1 The function 'n;k g is a bijective function. Next two results show the importance of the function 'n;k g .

Proposition 3.2 If G = (; B; C; n; catn) is a sewing grammar of type (g; k), then the language 'n;k g (L(G)) is a regular language.

Proof. We de ne a regular grammar G0 = (; fS g; S; P ) where S is a new symbol. The set of productions P is de ned as follows:

P = fS ?! [u u : : : un]S j (u ; u ; : : :; un) 2 C g[ [fS ?! [v v : : : vn] j (v ; v ; : : : ; vn) 2 B g: One can easily prove that L(G0 ) = 'n;k g (L(G)). 1

2

1

1 2

1

2

2

2

As a consequence of this result we show that each family SW n:g;k has good decidability properties.

Theorem 3.1 For each family SW n;g;k the following problems are decidable: (i) the equivalence problem (L = L ?). (ii) the inclusion problem (L  L ?). (iii) the completeness problem (L = ?). 1

1

2

2

13

Proof. (i) Clearly, for a given sewing grammar G of degree n and of type (g; k) one can e ectively nd a regular grammar G0 such that

L(G0) = 'n;k g (L(G)): Since the function 'n;k g is bijective, it follows that two sewing grammars G and G of degree n and of type (g; k) are equivalent if and only if 1

2

n;k 'n;k g (L(G )) = 'g (L(G )): 1

2

Note that the above equality is an equality between regular languages and thus decidable. (ii) Similarly, the inclusion L(G )  L(G ) holds if and only if 1

2

n;k 'n;k g (L(G ))  'g (L(G )): 1

2

(iii) Let G be a sewing grammar of degree n and of type (g; k). One can easily verify that  L(G) =  if and only if 'n;k g (L(G)) =   : 1

2

Again, the second equality is decidable since 'n;k g (L(G)) is a regular language.

2

Remark 3.2 Other problems, for instance the membership problem, the emptiness problem, the niteness problem are decidable problems for each family SW n . 2

Remark 3.3 For every n  4, each family SW n;g;k is almost a mildly context-sensitive family of languages, i.e., each such family satis es all conditions to be a mildly context-sensitive family of languages, except that the language of crossed agreements is not in such a family. A rather long combinatorial argument can be used to show that the language of crossed agreements is not in any such family SW n;g;k .

2 14

4 Isometric zipper functions Let n be a xed natural number, n  1, and let Sn be the group of all permutations of degree n. Let Bn = f0; 1gn be the set of all Boolean ndimensional vectors. We de ne the multiplication of two vectors from Bn componentwise using the rules: 0:0 = 1:1 = 1 and 0:1 = 1:0 = 0. For every p 2 Sn and for every k = (k ; : : : ; kn ) 2 Bn , de ne the catenative function catp;k : ()n !  by catp;k (u ; : : :; un ) = k (up ) : : : kn (up n ), where 0(v) = mi(v) and 1(v) = v. Let Gn be the set fcatp;k j p 2 Sn; k 2 Bng. De ne a binary operation on Gn, denoted \.", (catp;k):(catr;j ) = catpr;kj : It is easy to see that (Gn; :) is a group of order 2n n! and, moreover, that Gn is isomorphic with the group of all isometries (symmetries) of the n-dimensional hypercube. If L is a subset of ()n, then there are 2nn! functions which may transform L into a language over . 1

1

1

(1)

( )

De nition 4.1 An isometric zipper function of degree n is a function catp;k, where p 2 Sn and k 2 Bn. Notation. We denote by SW n (catp;k) the family of those languages generated by sewing grammars of degree n using the zipper function catp;k. One can easily prove the following theorem: Theorem 4.1 Each family SW n (catp;k) is a mildly context-sensitive family of languages, where n  4, p 2 Sn and k 2 Bn. 2

Note that all pumping conditions from Theorem 2.5 can be established for each family SW n(catp;k ) with some adequate modi cations.

Remark 4.1 Note that although for a xed n  1 there are 2n n! di erent zipper functions the number of di erent families SW n(catp;k ) is much smaller. For instance, one can easily see that, for every p; q 2 Sn , SW n (catp;k) = SW n(catq;k). However this is not true if the Boolean vector k is changed. It is an open problem how many di erent families SW n(catp;k) there are for a given number n.

15

5 Comparison with other families of languages In this section we investigate the interrelations between the families SW n, n  1 and the families of languages in the Chomsky hierarchy as well as with families of simple matrix languages. Notation. Let gn;k be the function n;k g

such that

n;k g

:  ?!  1

2

is the inverse of the function 'n;k g .

Proposition 5.1 Let L   be a regular language that can be generated 1

2

by a regular grammar with only one nonterminal and with only one terminal production.. Then the language gn;k (L) is a sewing language of degree n and of type (g; k). Proof. Let L be a language as above and assume that G = (fS g; ; S; P ) is a regular grammar with the only terminal production S ?! . Note that 2 2 . Now we de ne a sewing grammar of degree n and of type (g; k) as it follows: the base of G contains only the vector having all components  except the component k that contains . For each production S ?! S from P we de ne a context in G by dividing according with g. Note that this is possible and gives a unique result, since is in 2.

2

Proposition 5.2 A language L is in SW n if and only if L can be generated by a regular matrix grammar of degree n having only one nonterminal

Proof. Firstly assume that L is generated by a sewing grammar G = (; B; C; n). We de ne a simple matrix grammar G0 = (N ; : : : Nn; ; P; S ) as follows: N = N = : : : = Nn = fAg; P = fS ?! Ang [ f(A ?! c A; : : :; A ?! cn A) j (c ; : : : ; cn) 2 C g[ [f(A ?! b ; : : :; A ?! bn ) j (b ; : : :; bn) 2 B g: One can easily verify that L(G) = L(G0). Conversely, assume that L is generated by a simple matrix grammar G = (N ; : : :Nn ; ; P; S ) such that 1

1

2

1

1

1

1

1

N = N = : : : = Nn = fAg; 1

2

16

We de ne a sewing grammar G = (; B; C; n), where

C = f(c ; : : : ; cn) j (A ?! c A; : : :; A ?! cnA) 2 P g; B = f(b ; : : :; bn) j (A ?! b ; : : : ; A ?! bn) 2 P g: Again one can verify that L(G) = L(G0). 1

1

1

1

2

Proposition 5.3 Assume that n = 2 and let p 2 Sn be a permutation. Consider the Boolean vectors b = (1; 0) and d = (0; 1). The following equalities are true: SW n(catp;b) = SW n(catp;d) = SM: where, we recall that SM is the family of all Marcus simple contextual languages.

Proof. We will prove the case d = (0; 1) and p the the identity permutation. The other cases are similar. Assume that L is generated by a sewing grammar G = (; B; C ) with the zipper function catp;d, where p is the identity permutation and d = (0; 1). We de ne the Marcus simple contextual grammar G0 = (; B 0; C 0), where B 0 = fmi(b)b0 j (b; b0) 2 B g and C 0 = f(mi(c); c0) j (c; c0) 2 C g. Let w be a word in L and consider a derivation of w in G:

(b; b0) =) (bc ; b0c0 ) =) : : : (bc : : : ck ; b0c0 : : : c0k ); 1

1

1

1

such that using the above zipper function we obtain

w = catp;d((bc : : : ck ; b0c0 : : : c0k )) = mi(bc : : :ck )b0c0 : : :c0k ) = = mi(ck) : : : mi(c )mi(b)b0c0 : : :c0k : It follows that w is in L(G0 ) and hence L(G)  L(G0). The converse inclusion, i.e., L(G0)  L(G) is analogous. By a similar construction one can show that if a language L is generated by a Marcus simple contextual grammar, then L is generated also by a sewing grammar with the zipper function catp;d. 2 1

1

1

1

1

1

Remark 5.1 The families SW n (catp;k), n > 1, are not comparable with any of the families REG, LIN and CF . The reason is that the language a [ b is not contained in any of the families SW n (catp;k), whereas each of the families SW n(catp;k), where n > 1 contains non-context-free languages. 17

6 Conclusion Sewing grammars provide a very simple generative device able to de ne classes of mildly context-sensitive languages. A modern trend in linguistics referred to as \minimality" requires very simple models in order to capture most of the facts that occur in natural languages. We hope that sewing grammars will be used as a tool in linguistics. Also, sewing grammars and sewing languages are suitable for other investigations in formal languages and combinatorics of words.

References [1]

Delany, P. and Landow, G. P. (eds); Hypermedia and Literary Studies, The MIT Press, Cambridge, Mass. and London, England, 1991.

[2]

Ehrenfeucht, A., Rozenberg, G. and Paun, G.; \Contextual Grammars and Formal Languages", in Handbook of Formal Languages, G. Rozenberg and A. Salomaa (eds.), Vol. 2, Springer, Berlin, New York, 1997, 237 - 294.

[3]

Ibarra, O.; \Simple matrix languages", Information and Control, 17 (1970), 359 - 394.

[4]

Joshi, A.K., Vijay-Shanker, K. and Weir, D.; \The convergence of mildly context-sensitive grammatical formalisms", in Foundations Issues in Natural Language Processing, Sells, P., Shieber, S. and Wasow, T. (eds.), MIT Press, Cambridge MA, 1991.

[5]

Joshi, A.K. and Schabes, Y.; \Tree-Adjoining Grammars", in Handbook of Formal Languages, G. Rozenberg and A. Salomaa (eds.), Vol. 3, Springer, Berlin, New York, 1997, 69 - 123.

[6]

Marcus, S.; Algebraic Linguistics; Analytical Models, Academic Press, New York and London, 1967.

[7]

Marcus, S.; \Contextual Grammars", Rev. Roum. Math. Pures et Appl., 14, 10 (1969) 1525-1534.

[8]

Marcus S.; \Contextual Grammars and Natural Languages", in Handbook of Formal Languages, G. Rozenberg and A. Salomaa (eds.), Vol. 2, Springer, Berlin, New York, 1997, 215 - 236. 18

[9]

Martin-Vide, C. and Mateescu, A., \Contextual Grammars with Trajectories", to appear. [10] Paun, G. : Marcus Contextual Grammars, Kluwer Academic Publishers, Dordrecht, Boston, London, 1997. [11] Rozenberg, G. and Salomaa, A. (eds.), Handbook of Formal Languages, Vol. 1 - 3, Springer, Berlin, New York, 1997. [12] Salomaa, A. : Formal Languages, Academic Press, New York, London, 1973.

19

Turku Centre for Computer Science Lemminkaisenkatu 14 FIN-20520 Turku Finland http://www.tucs.abo.

University of Turku  Department of Mathematical Sciences

 Abo Akademi University  Department of Computer Science  Institute for Advanced Management Systems Research

Turku School of Economics and Business Administration  Institute of Information Systems Science

Suggest Documents