Ambiguity of context free languages as a function of the word length Mohamed NAJI Email: MohamedNaji@web.de WWW: http://www.mohamednaji.de.vu Mobile 49-160-1127558 November 1998 Abstract In this paper we discus the concept of ambiguity of context free languages and grammars. We prove the existence of constant ambiguous, exponential ambiguous and polynomial ambiguous languages and we give examples for these classes of ambiguity Contents 1 Introduction 3 2 Preliminaries 3 2.1 context free grammar....................... 3 2.2 O Notations............................ 4 2.3 Ogden s Lemma......................... 4 1
LIT OF FIGURE 2 3 Ambiguity 5 4 Constant ambiguous languages 7 5 Exponential ambiguous languages 12 6 Polynomial ambiguous languages 18 7 Conclusion 24 references 24 Index 25 List of Figures 1 derivation trees and A pumptrees................ 5 2 derivation tree B i with A i pumptree for z i := a h b hh! 1... b hh! i 1 bh i b hh! i1... bhh! k.................. 9 3 A i on the left of A j in the tree T................ 10 4 A i is a descendant of A j in the tree T for z=a hh! b hh! 1 b hh! 2... b hh! k.................... 11 5 Illustration of the path π i and the factorization z= û i v q i w ix q i ŷi 13 6 a derivation tree B(z) for a word z from {a h b h c hh!, a h b hh! c h } k 15 7 derivation tree T(z) for the word(a hh! b hh! c hh! ) k....... 15 8 the A i pumptree is on the left of the Ãi pumptree in T (z, z). 16 9 A i is a descendant of Ãi..................... 17 10 a derivation tree B(z) for a word z = z i1 z i2... z ik........ 19 11 a derivation tree T(z) for the word (a hh! (b hh! c) p ) k...... 20 12 A ij on the left of Aĩj in T (z, z)................. 21
1 INTRODUCTION 3 13 A ij is a descendant of Aĩj.................... 22 1 Introduction The concept of ambiguity plays a fundamental role in formal language theory. Measuring the amount of ambiguity in context free grammars is well known; see for example [1, ection 7.3]. We define the ambiguity as a function of the word length 2 Preliminaries We use the following notations and definitions of grammars and languages as introduced in [5]: 2.1 context free grammar A context free grammar (CFG) is a quadruple G=(N, Σ, P, ) where N and Σ are finite disjoint sets of nonterminals and terminals respectively; P is a finite set of productions of the form A α where A N and α (N Σ) ; N is the start symbol. If A α is in P and α 1, α 2 are in (N Σ), then we write α 1 Aα 2 = α 1 αα 2. i = is the i fold product, = is the transitive, = the reflexive and transitive closure of =. The context free language (CFL) generated by G is L(G):= {w Σ = w}. A language L is termed context free if L=L(G) for a CFG G. # a (w) denotes the number of a s in w, w the length of w.
2 PRELIMINARIE 4 2.2 O Notations Let f, g : N R be functions g = O(f) : ( c R, n o N) : ( n n 0 ) : (g(n) cf(n)) g = Ω(f) : ( c R, n o N) : ( n n 0 ) : (g(n) cf(n)) g = Θ(f) : g = O(f) g = Ω(f) g = 2 O(n) : ( c R, n o N) : ( n n 0 ) : (g(n) 2 cn ) g = 2 Ω(n) : ( c R, n o N) : ( n n 0 ) : (g(n) 2 cn ) g = 2 Θ(n) : g = 2 O(n) and g = 2 Ω(n) 2.3 Ogden s Lemma [5] Let G=(N, Σ, P, ) be a CFG. Then there is a constant h=h(g), such that for every word z L(G) with at least h marked positions, there is a factorization z=uvwxy with: 1. w contains at least one of the marked positions 2. Either u and v both contain marked positions, or x and y both contain marked positions 3. vwx has at most h marked positions 4. A N such that = uay = uvaxy =... integers q 0 = uv q Ax q y = uv q wx q y L(G) for all Remark 2.1 Point (4) of Ogden s Lemma (on page 4) says, that each derivation tree of z=uvwxy in G has a subtree rooted at A which could be
3 AMBIGUITY 5 pumped to obtain a derivation tree of uv q wx q y in G for q > 0. We call such a subtree a A pumptree. (see Figure 1 on page 5) u A y pump the A-pumptree q times u A y v A x v q A x q w w Figure 1: derivation trees and A pumptrees 3 Ambiguity Measuring the amount of ambiguity in context free grammars is well known, see for example, [1, ection 7.3]. We define the ambiguity as a function of the word length n. Definition 3.1 (Ambiguity of CFG) Let k > 0 be an arbitrary integer, f : N R be a non constant function and {O, Ω, Θ}. The ambiguity da G (w) of a word w in a CFG G is da G (w):=number of derivation trees (leftmost derivations) 1 of w in G. The ambiguity da G (n) of a CFG G is da G (n):=sup{da G (w) w Σ and w n}. 1 For the definition of derivation and leftmost derivation see [5]
3 AMBIGUITY 6 G is at least k ambiguous : There is a word in L(G) for which there is at least k distinct derivation trees in G. G is at most k ambiguous : There is a word with at most k derivation trees in G. G is k ambiguous : (G is at least k ambiguous) and (G is at most k ambiguous). G is polynomial of degree k ambiguous : da G (n) = Θ(n k ). G is exponential ambiguous : da G (n) = 2 Θ(n). G is (f(n)) ambiguous : da G (n) = (f(n)). G is 2 (f(n)) ambiguous : da G (n) = 2 (f(n)). Definition 3.2 (Ambiguity of CFL) Let k > 0 be an arbitrary integer and f : N R be a non constant function. A CFL L is k ambiguous : each CFG for L is at least k ambiguous and there is an at most k ambiguous CFG for L. A CFL L is polynomial of degree k ambiguous : each CFG for L is Ω(n k ) ambiguous and there is a O(n k ) ambiguous CFG for L. A CFL L is exponential ambiguous : each CFG for L is 2 Ω(n) ambiguous and there is a 2 O(n) ambiguous CFG for L. A CFL L is Θ(f(n)) ambiguous : each CFG for L is Ω(f(n)) ambiguous and there is a O(f(n)) ambiguous CFG for L.
4 CONTANT AMBIGUOU LANGUAGE 7 Theorem 3.1 For all cycle free 2 CFG G, da G (n) 2 cn for some c > 0. Proof Let G=(N, Σ, P, ) be a cycle free CFG. The number of derivation trees, which can be obtained in i leftmost derivations steps, is at most P i. For every cycle free grammar there are integers a, b such that (A i = w) implies (i a w b) [2, Theorem 4.1]. Thus the number of derivation trees of a word w in a cycle free CFG G is at most P a w b = 2 (anb) log P, where n := w and log denotes the binary logarithm. Remark 3.1 By Theorem 3.1 there isn t any CFL which has an ambiguity bigger than 2 Θ(n) (e. g.θ(n n )). Wich [6] has proven, that there isn t any grammar (and so there isn t any language) with ambiguity bigger than polynomial but smaller than proper exponential (e. g. Θ(2 n )) 4 Constant ambiguous languages Maurer [3] has proven the existence of context free languages which are inherently ambiguous of any degree. We reprove this result using Ogden s Lemma (on page 4) and another (less complicated) language Theorem 4.1 Let k be a constant from N. L k := {a m b m 1 1 b m 2 2... b m k k m, m 1, m 2,..., m k 1, i with m = m i } is k ambiguous. A. 2 A CFG is cycle free if there is no derivation of the form A = A for any nonterminal
4 CONTANT AMBIGUOU LANGUAGE 8 Proof For k=1 we obtain the well known unambiguous language L 1 := {a m b m 1 m 1}. Let k 2, L k = L(G) for some CFG G=(N, Σ, P, ) and h be the constant for G from Ogden s Lemma (on page 4). Now we consider the words z i := a h b h 1 1 b h 2 2... b h k k with h j := h, if j = i h h!, otherweise, for i = 1,..., k where all the a s are marked. It s not difficult to prove, that for every factorization z i = u i v i w i x i y i satisfying conditions (1)-(4) of Ogden s Lemma (on page 4) ince u i = a r i 1 r i h 2, v i = a s i 1 s i h 2, w i = a h s i r i b hh! 1... b hh! i 1 bt i i 0 t i h 1, x i = b s i i y i = b h s i t i i b hh! i1... bhh! k. = u i A i y i = u i v i A i x i y i = u i v i w i x i y i = z i, every derivation tree B i of z i in G has an A i pumptree (see Figure 2 on page 9)
4 CONTANT AMBIGUOU LANGUAGE 9 u i A i y i a r i b h s i t i i b hh! i1...bhh! k v i A i x i a s i w i b s i i a h s i r i b hh! 1...b hh! i 1 bt i i Figure 2: derivation tree B i with A i pumptree for z i := a h b hh! 1... b hh! i 1 bh i b hh! i1... bhh! k We pump the A i pumptree (of the derivation tree B i ) q i := h! s i 1 times, we obtain a derivation tree T i for the word z := a hh! b hh! 1 b hh! 2... b hh! k in G. ince i=1,...,k, we obtain k derivation trees T 1, T 2,..., T k for the word z := a hh! b hh! 1 b hh! 2... b hh! k in G. We now prove that these k derivation trees are distinct. uppose there are i, j {1,..., k} with i j but T i = T j = T. The derivation tree T must have both nodes A i (because T = T i ) and nodes A j (because T = T j ). Case 1: Neither A i nor A j appears (in the tree T) as a descendant of the other. w. l. o. g. A i appears on the left of A j (see Figure 3 on page 10) The frontier of T is a word in which b s would precede a s and hence is
4 CONTANT AMBIGUOU LANGUAGE 10 not in L k, a contradiction (see Figure 3 on page 10) u i A i w A j y j v q i i w i x q i i v q j j w j x q j j b i a Figure 3: A i on the left of A j in the tree T other Case 2: Either A i or A j appears (in the tree T) as a descendant of the w. l. o. g. A i is a descendant of A j. (see Figure 4 on page 11)
4 CONTANT AMBIGUOU LANGUAGE 11 u j A j y j v q j j A j x q j j u A i y v q i i A i x q i i w i Figure 4: A i is a descendant of A j in the tree T for z=a hh! b hh! 1 b hh! 2... b hh! k We obtain: = u j A j y j = u j v q j j A jx q j j y j = u j v q j j ua iyx q j j y j = u j v q j j uvq i i w ix q i i yxq j j y j = z L k where # a (z) = # br (z) = h h! r {1,..., i,..., j,..., k} But if we pump the A i pumptree of the A j pumptree (in the tree T),
5 EXPONENTIAL AMBIGUOU LANGUAGE 12 then we obtain: = u j A j y j = u j v q j1 j A j x q j1 j y j = u j v q j1 j ua i yx q j1 j y j = u j v q j1 j uv q i1 i w i x q i1 i yx q j1 j y j := z L k where: # a ( z) = # a (z) v j v i = h h! v j v i # bi ( z) = # bi (z) x i = h h! v i # bj ( z) = # bj (z) x j = h h! v j # br ( z) = # br (z) = h h! Thus r {1,..., k}, # a ( z) # br ( z), a contradiction of u j v q j1 j uv q i1 i w i x q i1 i yx q j1 j y j := z L k. Each CFG for L k is therefore at least k ambiguous. It is not difficult to give an at most k ambiguous CFG for L k. An at most k ambiguous CFG for L k can be found in [4]. 5 Exponential ambiguous languages Theorem 5.1 Let L = {a i b i c j i, j 1} {a i b j c i i, j 1}. L is exponential ambiguous. Proof Let L =L(G) for a CFG G=(N, Σ, P, ) and h be the constant from Ogden s Lemma (on page 4) for G. We consider the words of L of the form
5 EXPONENTIAL AMBIGUOU LANGUAGE 13 z = z 1 z 2... z k, where z i {a h b h c hh!, a h b hh! c h } i {1,..., k} and mark all the a s. ince the number of the marked positions in each z i is equal to h, for each given i we can find a factorization z = û i v i w i x i ŷ i and we can construct a path π i in each derivation tree B(z) for z in G (with the same idea as the well known proof of Ogden s Lemma [5, Theorem 2.24]) such that: 1. w i contains at least one of the marked positions of z i 2. Either û i and v i both contain marked positions of z i, or x i and ŷ i both contain marked positions of z i. 3. v i w i x i has at most h marked positions of z i. 4. = û i A i ŷ i = û i v i A i x i ŷ i =... = û i v q i A ix q i ŷi = û i v q i w ix q i ŷi L for all integers q 0 The situation is depicted in Figure (see Figure 5 on page 13) û i A i ŷ i v i A i x i w i Figure 5: Illustration of the path π i and the factorization z= û i v q i w ix q i ŷi
5 EXPONENTIAL AMBIGUOU LANGUAGE 14 We can further prove: z i = a h b h c hh! : û i = z 1... z i 1 u i u i = a r i and 1 r i h 2, v i = a s i 1 s i h 2, w i = a h r i s i b h s i t i 0 t i h 1, x i = b s i ŷ i = y i z i1... z k y i = b t i c hh!. z i = a h b hh! c h : û i = z 1... z i 1 u i u i = a r i and 1 r i h 2, v i = a s i 1 s i h 2, w i = a h r i s i b hh! c t i 0 t i h 1, x i = c s i ŷ i = y i z i1... z k y i = c h t i s i. The proof is straightforward and will be omitted here, you can see [4] ince A i = v i A i x i, the derivation tree B(z) has an A i pumptree, whose frontier v i w i x i is a subword of z i. We can use this argumentation for each i {1,..., k}, thus the derivation tree B(z) consists of the k A 1, A 2,..., A k pumptrees, which are in B(z) parallel to themselves. (see Figure 6 on page 15)
5 EXPONENTIAL AMBIGUOU LANGUAGE 15 u 1 A 1 A 2... A k v 1 A 1 x 1 v 2 A 2 x 2 v k A k x k w 1 w 2 w k Figure 6: a derivation tree B(z) for a word z from {a h b h c hh!, a h b hh! c h } k If we pump each A i pumptree in the tree B(z) q i := h! s i 1 times, we will obtain a derivation tree T(z) for the word (a hh! b hh! c hh! ) k (see Figure 7 on page 15) u 1 A 1 A 2... A k v q 1 1 A 1 x q 1 1 v q 2 2 A 2 x q 2 2 v q k k A k x q k k w 1 w 2 w k Figure 7: derivation tree T(z) for the word(a hh! b hh! c hh! ) k ince there are 2 k words of the form z = z 1 z 2... z k where z i {a h b h c hh!, a h b hh! c h } i {1, 2,..., k}, there are 2 k derivation trees of the form T(z) for the word (a hh! b hh! c hh! ) k.
5 EXPONENTIAL AMBIGUOU LANGUAGE 16 We now prove that these 2 k derivation trees are distinct. uppose there are z = z 1 z 2... z k and z = z 1 z 2... z k where z i, z i {a h b h c hh!, a h b hh! c h } with z z but T (z) = T ( z) = T (z, z). z z implies there is i {1,..., k} with z i z i. W. l. o. g. let z i = a h b h c hh! and z i = a h b hh! c h. The tree T (z, z) must have both an A i pumptree (because T (z, z)=t(z)) and an Ãi pumptree (because T (z, z)=t ( z)). We discuss the two following cases. Case 1: Neither the A i pumptree nor the Ãi pumptree is a subtree of the other. w. l. o. g. the A i pumptree is on the left of the Ãi pumptree in the tree T (z, z) (see Figure 8 on page 16) (a hh! b hh! c hh! ) i 1 u i A i y i wũ i à i ỹ i (a hh! b hh! c hh! ) k i v q i i w i x q i i ṽ q i i w x q i i i Figure 8: the A i pumptree is on the left of the Ãi pumptree in T (z, z) The frontier of the tree T (z, z) would have at least (k1) subwords of the form a hh! b hh! c hh!. But the frontier of T (z, z) is the word (a hh! b hh! c hh! ) k, a contradiction. Case 2: Either the Ãi pumptree or the A i pumptree is a subtree of the other
5 EXPONENTIAL AMBIGUOU LANGUAGE 17 w. l. o. g. A i is a descendant of Ãi (see Figure 9 on page 17) (a hh! b hh! c hh! ) i 1 ũ i à i ỹ i (a hh! b hh! c hh! ) k i ṽ i q i à i x i q i u A i y v q i i w i x q i i Figure 9: A i is a descendant of Ãi We obtain here: = (a hh! b hh! c hh! ) i 1 ũ i ṽ i q i à i x i qiỹ i (a hh! b hh! c hh! ) k i = (a hh! b hh! c hh! ) i 1 ũ i ṽ i q i ua i y x i qiỹ i (a hh! b hh! c hh! ) k i = (a hh! b hh! c hh! ) i 1 ũ i ṽ i q i uv q i i A ix q i i y x i qiỹ i (a hh! b hh! c hh! ) k i = (a hh! b hh! c hh! ) i 1 q ũ i ṽ i i uv q i i w ix q i i y x qiỹ i }{{} i (a hh! b hh! c hh! ) k i t 1 = (a hh! b hh! c hh! ) i 1 t 1 (a hh! b hh! c hh! ) k i L. ince the frontier of T (z, z) is the word (a hh! b hh! c hh! ) k, t 1 = a hh! b hh! c hh!.
6 POLYNOMIAL AMBIGUOU LANGUAGE 18 However if we pump the A i pumptree and the Ãi pumptree in the tree T (z, z), then we obtain: = (a hh! b hh! c hh! ) i 1 ũ i ṽ i q i 1 Ã i x i q i 1ỹ i (a hh! b hh! c hh! ) k i = (a hh! b hh! c hh! ) i 1 ũ i ṽ i q i 1 ua i y x i q i 1ỹ i (a hh! b hh! c hh! ) k i = (a hh! b hh! c hh! ) i 1 q ũ i ṽ i 1 i uv q i1 i A i x q i1 q i y x i 1ỹ i i (a hh! b hh! c hh! ) k i = (a hh! b hh! c hh! ) i 1 q ũ i ṽ i 1 i uv q i1 i w i x q i1 q i y x i 1ỹ }{{ i } i (a hh! b hh! c hh! ) k i = (a hh! b hh! c hh! ) i 1 t 2 (a hh! b hh! c hh! ) k i L. t 2 # a (t 2 ) = # a (t 1 ) ṽ i v i = h h! ṽ i v i # b (t 2 ) = # a (t 1 ) x i = h h! v i # c (t 2 ) = # a (t 1 ) x i = h h! ṽ i Thus # a (t 2 ) # b (t 2 ) and # a (t 2 ) # c (t 2 ) and therefore t 2 / L. A contradiction of = (a hh! b hh! c hh! ) i 1 t 2 (a hh! b hh! c hh! ) k i L. We can now conclude, that the 2 k derivation trees are distinct, and each CFG for L is therefore 2 Ω(n) ambiguous. By Theorem 3.1 (on page 7) and Remark 3.1 (on page 7) there isn t any language, which has an ambiguity bigger than 2 Θ(n). Thus L is exponential ambiguous. 6 Polynomial ambiguous languages Theorem 6.1 Let L := {a m b m 1 cb m 2 c... b m p c p N; m, m 1, m 2,..., m p N; i {1, 2,..., p} with m = m i }. L k is polynomial of degree k ambiguous. Proof Let L k = L(G) for some CFG G=(N, Σ, P, ) and h be the constant for G from Ogden s Lemma (on page 4). Now we consider the words of L k
6 POLYNOMIAL AMBIGUOU LANGUAGE 19 of the form z = z i1 z i2... z ik where z ij := a h (b hh! c) ij 1 b h c(b hh! c) p i j, j=1,...,k and i j = 1,..., p and mark all the a s in each z iα with α {1, 2,..., k}. imilar to the proof of Theorem 6.1 we can prove, that each derivation tree B(z) for z in G consists of k A i1, A i2, A ik pumptrees, which are parallel to themselves in the tree B(z). (see Figure 10 on page 19) u i1 A i1 A i2... A ik v i1 A i1 x i1 v i2 A i2 x i2 v ik A ik x ik w i1 w i2 w ik Figure 10: a derivation tree B(z) for a word z = z i1 z i2... z ik We now pump each A ij pumptree of the tree B(z) q ij = h! s ij 1 times, we obtain a derivation tree T(z) for the word (a hh! (b hh! c) p ) k. (see Figure 11 on page 20)
6 POLYNOMIAL AMBIGUOU LANGUAGE 20 u i1 A i1 A i2... A ik v q i 1 i 1 A i1 x q i 1 i 1 v q i 2 i 2 A i2 x q i 2 i 2 v q i k i k A ik x q i k i k w i1 w i2 w ik Figure 11: a derivation tree T(z) for the word (a hh! (b hh! c) p ) k ince there are p k words of the form z = z i1 z i2... z ik where z ij := a h (b hh! c) i j 1 b h c(b hh! c) p i j, j=1,...,k and i j = 1,..., p, there are p k derivation trees of the form T(z). We now prove, that these p k derivation trees of the form T(z) are distinct. uppose there are z = z i1 z i2... z ik where z ij := a h (b hh! c) ij 1 b h c(b hh! c) p i j and z = zĩ1 zĩ2... zĩk where zĩj := a h (b hh! c)ĩj 1 b h c(b hh! c) p z z implies there is j such that i j. The tree T (z, z) must have both an A ij pumptree (because T (z, z)=t(z)) and an Aĩj pumptree (because T (z, z)=t ( z). We discuss the two following
6 POLYNOMIAL AMBIGUOU LANGUAGE 21 cases. Case 1: Neither the A ij pumptree nor the Aĩj pumptree is a subtree of the other w. l. o. g. the A ij pumptree is on the left of the Aĩj pumptree in the tree T (z, z) (see Figure 12 on page 21) (a hh! (b hh! c) p ) i j 1 u ij A ij y ij wuĩj Aĩj yĩj (a hh! (b hh! c) p ) k v q i j i j w ij x q i j i j v q wĩj x q Figure 12: A ij on the left of Aĩj in T (z, z) The frontier of the tree T (z, z) would have at least (k1) subtrees of the form a hh! (b hh! c) p. But the frontier of the tree T (z, z) is the word (a hh! (b hh! c) p ) k, a contradiction. Case 2: Either the A ij pumptree or the Aĩj pumptree is a subtree of the other w. l. o. g. A ij is a descendant of Aĩj (see Figure 13 on page 22)
6 POLYNOMIAL AMBIGUOU LANGUAGE 22 (a hh! (b hh! c) p )ĩj 1 uĩj Aĩj yĩj (a hh! (b hh! c) p ) k v q Aĩj x q u A ij y v q i j i j w ij x q i j i j Figure 13: A ij is a descendant of Aĩj We obtain here: = (a hh! (b hh! c) p )ĩj 1 uĩj v q i j Aĩj x q yĩj (a hh! (b hh! c) p ) k = (a hh! (b hh! c) p )ĩj 1 uĩj v q = (a hh! (b hh! c) p )ĩj 1 uĩj v q ua ij yx q yĩj (a hh! (b hh! c) p ) k uv q i j i j A ij x q i j i j = (a hh! (b hh! c) p )ĩj 1 uĩj v q uv q i j i j w ij x q i j i j yx q yĩj ĩ }{{ j } t 1 = (a hh! (b hh! c) p )ĩj 1 t 1 (a hh! (b hh! c) p ) k L k yx q yĩj (a hh! (b hh! c) p ) k (ahh! (bhh! c)p )k ĩj ince the frontier of T (z, z) is the word (a hh! (b hh! c) p ) k, t 1 = a hh! (b hh! c) p. if we pump however the A i pumptree and the Ãi pumptree in the tree T (z, z), then we obtain:
6 POLYNOMIAL AMBIGUOU LANGUAGE 23 = (a hh! (b hh! c) p )ĩj 1 uĩj v q ĩ 1 j = (a hh! (b hh! c) p )ĩj 1 uĩj v q ĩ 1 j = (a hh! (b hh! c) p )ĩj 1 uĩj v q ĩ 1 j = (a hh! (b hh! c) p )ĩj 1 uĩj v q ĩ 1 j yĩj (a hh! (b hh! c) p ) k ua ĩ ij yx q ĩ 1 j yĩj (a hh! (b hh! c) p ) k j Aĩj x q ĩ 1 j uv q i j 1 i j A ij x q i j 1 uv q i j 1 i j w ij x q i j 1 }{{} t 2 = (a hh! (b hh! c) p )ĩj 1 t 2 (a hh! (b hh! c) p ) k L k i j yx q ĩ 1 j yĩj (a hh! (b hh! c) p ) k i j yx q ĩ 1 j yĩj (ahh!(bhh! c)p )k ĩj # a (t 2 ) = # a (t 1 ) vĩj v ij = h h! vĩj v ij The number of the b s in each b Block of t 2 is either hh! or hh! xĩj or h h! x ij and therefore unequal to the numbere of the a s in t 2. Thus t 2 / L. This is a contradiction to (a hh! (b hh! c) p )ĩj 1 t 2 (a hh! (b hh! c) p ) k L k. We can conclude, that the word a hh! (b hh! c) p ) k has at least p k derivation trees in G. ince n := (a hh! (b hh! c) p ) k = k(p(hh!1)hh!), da G (n) = Ω(n k ). The grammar with the productions: E k E at bca at bc T at b ε A A ba bca bc produces L k and is O(n k ) ambiguous. [4]
7 CONCLUION 24 7 Conclusion From this work we obtain the following classes of CFL: constant ambiguous languages: e.g. L k := {a m b m 1 1 b m 2 2... b m k k m, m 1, m 2,..., m k 1, i with m = m i } polynomial ambiguous languages: e.g. L k where L := {a m b m 1 cb m 2 c... b mp c p N; m, m 1, m 2,..., m p N; i {1, 2,..., p} with m = m i } subbexponential ambiguous languages (e.g. Θ(2 n ) ambiguous languages): There isn t any language exponential ambiguous languages: e.g. 1} {a i b j c i i, j 1} L where L = {a i b i c j i, j Languages, whose ambiguity bigger than exponential (e.g. Θ(n n ) ambiguous languages): There isn t any language However there remain the following questions: 1. Is there any Θ(n r ) ambiguous languages, where r is a non natural number? 2. Is there any sublinear ambiguous languages (e. g. Θ(log(n)) ambiguous languages)? References [1] M. A. Harrison, Introduction to Formal language Theory, Addison Wesley, 1978.
REFERENCE 25 [2]. Heilbrunner, Parsing automata approach to LR theory, Theoret. Comput. ci. (1981), no. 15, 117 157. [3] H. Maurer, The existence of context free languages which are inherently ambiguous of any degree, Department of Mathematics Research eries; University of Calgary, (1968). [4] M. Naji, Der Grad der Mehrdeutigkeit kontextfreier Grammatiken und prachen, Master s thesis, Fachbereich Informatik; Universität Frankfurt am Main, 1998. [5] A. V. Aho & J. D. Ullman, The Theory of Parsing, Translation and Compiling, Prentice Hall, 1972. [6] K. Wich, Kriterien für die Mehrdeutigkeit kontextfreier Grammatiken, Master s thesis, Fachbereich Informatik; Universität Frankfurt am Main, 1997.
Index A ambiguity, 3, 5 G grammar context free, 3 cycle free, 7 L language constant ambiguous, 7 context free, 3 exponential ambiguous, 12 polynomial ambiguous, 18 O Ogden s Lemma, 4 P pumptree, 5 26