Semi-Conditional Grammars
Tom65 Nlasopust
Dept. of Information Systems, Faculty of Information Technology, Brno University of Technology, BoZet6chova 2,
612 66 Brno, Czech Republic nasopust@fit . vutbr. cz
Abstract. The descriptional complexity of semi-conditional grammars is studied. A proof that every recursively enumerable language is gener-
lji";'I":ff ffi ru*::?H:"ffi Xl,?li".ffi f iJ,,-,T?,ll,J"'"'n'"
Keywords: formal languages, descriptional complexity, semi-conditio- nal grammars
1 fntroduction
This paper studies the descriptional complexity of semi-conditional grammars (see [4, 7-9] for more details) with respect to the number of conditional produc- tions and nonterminals.
Semi-conditional grammars are modified context-free grammars, where a per- mitting and a forbidding context is associated with each production. This means that a production is applicable if its permitting context is contained in the cur- rent sentential form and its forbidding context is not. As a special case of semi- conditional grammars, we obtain simple semi-conditional grammars introduced in [3], where one of the contexts is required to be a special symbol 0, i.e., either a permitting or a forbidding context is associated with each production.
Whereas the descriptional complexity of simple semi-conditionai grammars has been studied carefully (see [5, 7, B, 10]), the descriptional complexity of semi- conditional grammars has not been studied at all, and all results concerning the descriptional complexity of semi-conditional grammars are consequences of results concerning the descriptional complexity of simple semi-conditional gram- mars. Specifically, in [8], u proof that every recursively enumerable language is generated by a (simple) semi-conditional grammar of degree (2,1) with no more than twelve conditionai productions and thirteen nonterminals was given. Later, in Ii0], this result was improved and a proof that every recursively enumerable Ianguage is generated by a (simple) semi-conditional grammar of d.egree (2,I) with no more than ten conditional productions and twelve nonterminals was given. Finally, the result from [10] was improved in [5], where a proof that ev- ery recursively enumerable language is generated by a (simple) semi-conditional
grammar of d.egree (2, 1) with no more than nine conditional productions and ten nonterminals was given. However, a better result can be achieved for semi- cond.itional grammars than for simple semi-conditional grammars. In this pa- per, a proof that every recursively enumerable language is generated by a semi- conditional grammar of degree (2, 1) with no more than seven conditional pro- ductions and eight nonterminais is given.
2 Preliminaries and Definitions
This paper assumes that the reader is familiar with the theory of formal lan- guages (see 11,6]). For an aiphabetV, V* represents the free monoid generated by v. The unit off v* is d.enoted by e. set v+ :v* -
{r}. set sub(u) : {u : u is a substring of tr.r).
In [2], it was shown that every recursively enumerable language is generated by a grammar
G : ( { S , A , B , C ) , 7 , P U { A B C - + s } , S ) in the Geffert
form
S -, uSa, S -. uSu, S '-+ uu,
nor.mal form, where P contains context-free productions of the
w h e r e u e { A , A B } . , a e T , w h e r e u € { A , A B } - , u € { B C , C } * , w h e r e u € { A , A B } . , , u e { B C , C } - .
In addition, any terminal derivation is of the form ,S =+* w1u2w
b y p r o d u c t i o n s fr o m P , w h e r e w t e {A, B}-, u2 € {B,C}.,, w e ?*, and
W 1 U 2 W 1 " 1 1 1
by ABC -- e.
A semi,-condi,tional grammar,G, is a quadruple G : (l/, T, P, S),
where- ,Af is a nonterminal alphabet,
- ? is a terntinal alphabet such that I/ )T :0, - S e l/ is the start sYmbol, and
- P is a fi.nite set of productions of tlr.e form ( X * a , u , u )
w i t h X € l / , a € ( l / U ? ) - , a n d u , t ) e ( l / u T ) * u { 0 } , r v h e r e 0 / I / u T i s a special symbol.
It u l0 or u f 0, then the production (X - a,u,u) € P is said to be condi,t'ional.
G h a s d e g r e e ( i , j ) i f f o r a l i p r o d u c t i o n s (X , etu,u) € P,u* 0 implies l"l <i and u l 0 implies lul < j. For n € (.4/UZ)+ and y € (liU?)., r directly deriues y a c c o r d i n g t o t h e p r o d u c t i o n ( X * a , u , u ) € P , d e n o t e d b y
n + a
i f . r: r 1 X r 2 , U : r y a r , 2 , f o r s o m e fr r t r z € ( l f U T ) * , a n d u , l0 i m p l i e s th a t u e sub(r) and u + 0 implies that u / sub(r). As usual, =+ is extended to =)', for i ) 0, 9*, and +*. The language generated by a semi-conditional grammar, G, is defined as
g ( G ) :
{ w e T " : S = + * u } .
L e t G : ( l / , 7 , P , . 9 ) b e a s e m i - c o n d i t i o n a l g r a m m a r . I f ( X > e..tt",u) € P implies that 0 e {u,u}, then G is said to be a si,mpLe semi,-condi,ti,onal gro,n'Lmar.
Main Result
This section presents the main result concerning the descriptionai complexity of semi-condit ic.rnal grammars.
Theorem 1. Euery recursiuelA enumerable language i,s generated by a semi- conditional grammar of degree (2, 1) w'ith no more than 7 condit'ional product,ions and B nonterminals.
Proof i,dea.
The main idea of the proof is to simulate a terminal derivation of a grammar, G, in the Geffert normal form.
To do this, we first appiy all context-free productions as applied in the G's derivation, and then we simulate the production ABC --+ E so that we mark with ' only one occurrence of A, one of B, and one of C and check that these marked symbols form a substring A'B'C' of the current sentential form. If so, the marked symbols can be removed, which completes the simulation of the production ABC --+ e in G; otherwise, the derivation must be blocked.
The formal proof follows.
Proof. Let L be a recursively enumerable language. There is a grammar G : ( { S , A , B , C } , T , P U { A B C - + s i , ^ 9 )
in thc Geffcrt normal form such that L: 9(G). Construct the grammar
where
G' : ({^9, A, B, C, A' , B' , C', $} ,7, P' U P" ,, S),
P ' : { ( X * a , 0 , 0 ) : X - - - a e P } ,
and P" contains foiiowing seven conditional productions:1 . ( A * $ , 4 ' , 0 , $ ) , 2 . ( B - B ' , A ' , B ' ) , 3 . ( C - C ' $ , A ' B ' , C ' ) , 4 . ( B ' - e , B ' C ' , 0 ) , , 5 . ( C ' - e , A ' C ' ,0 ) , 6 . ( A ' - e , A ' $ , 0 ) , 7 . ( $ - e , 0 , A ' ) .
To prove thar I (G) e
g(G'), consider a derivation ,S =+* wABCw'y ) 111111tyin G by productions from P with only one application of the productio n ABC -- e , w h e r e w , w ' e {A, B,C}* and u €. T*. Then,
S + * w A B C w ' u
in G' by productions from P'. iVloreover, try productions r, 2, z, 4, b, 6, 7, 7, we
C'pr.
b - "
uABCw'u + w$A'BCw'u + w$A' B'Cw'u + w$A' B'C'$w'u + w$A'C'$w'u + w$A'$w'u
=+ tl$$tr'u + w $ w ' u
+ lt;lt)'U.
The inclusion follows by induction.
To prove that 9(G) )_ -?(G'), consider a terminal derivation. Let X € {A,B,C} be in a sentential form of this d.erivation. To eliminate X, there are followirig three possibilities:
1. If X - A, then there must be derivation;
2. If X - B, then there must be derivation;
3. If X - C, then there must be derivation.
C and A (bV productions 6 and 3) in the C and A (by productions 4 and 3) in the A and B (bV productions 5 and 3) in the
In all above ca^ses, there are A, B, and C in the derivation. By productions 1,2, 3, and 7, there cannot be more than one A', B', and C, in any sentential form of this terminal derivation. Nloreover, by productions 3 and ,1, A' B'C' is a substring of a sentential form of tltis terminal derivation, and. there is no terminal syrnbol between any fwo nonterminals; otherrvise, there will be a situation in which (zrt
Ieast) one of productions 3 and 4 will not be applicable. Thus, any first part of a terminal derivation in G' is of the fornr
, S + * u l A B C w 2 w + 3 w t $ A ' B ' C ' $ w 2 w ( 1 ) by productions from P' and productions 1, 2, and 3, where u.,1 € {A, B}*, w z e {B,C}*, and w e T*. Next, only production 4 is applicable. T h u s ,
I wt,g.A' C'$wzw .
Besides a possible application of production 2, oniy production 5 is applicable.
Thus,
+ + r \ 9 A ' $ w ' r w
w h e r e t r ' , € {A,B,B'}*,.L € {8, B',,C}*. Besides a possible application of production 2, only production 6 is applicable. Thus,
+ + u ' 1 $ $ w ' J w
w h e r e w ' i e {A,B,B'}",wU € {B,B',C}*. Finally, only production 7 is appli- c a b l e . i. e . .
+2 w'lw'/w .
Thus, by productions I, 2, 3, or 1, 3, if production 2 has already been applied, we get
*" "tt'utD .
H e r e '
u u t u € . {ur'A' B' c'$u2w : u1 e. {A, B}* , uz € {B , c}- } o r u u : € .
Thus, the substring ABC and only this substring was eliminated during the previous derivation. By induction (see (1)), the inclusion hoids. This derivation can be performed in G with an application of the production ABC ---+ €, too. D
Thzs work has been supported by the Grant Agency of the Czech Republi,c within the project I'{o. 102/05/H050, FRVS grant I{o. FR762/2007/G1, and the Czech Mtni,stry of Education under the Research PIan No. MSM 0021630528.
References
1. J. Dassow and Gh. PXun. Regulated Rewriti,ng i,n Formal Language Theory.
Springer-Verlag, Berlin, 1989.
2. V. Geffert. Context-free-like fornrs for the phrase-stnrcture grammars. Tn X,I. Chytil, L. Janiga, and V. Koubek, editors, MFCS, volume 324 of Lecture Notes i,n Computer Sc'ience, pages 309-317. Springer, 1988.
, f .
,1
o .
6 . 7 .
8 . 9 .
A. Gopalaratnam and A. Meduna. On semi-conditional grammars with productions having either forbidding or permitting conditions. .4cfa Cybernetica, LL(4):307-324, 1 9 9 4 .
J. Kelemen. Conditional grammars: Motivations, definitions, and some properties.
In Proc. Conf. Automata, Languages and Mathemati,cal Sciences, pages 110-123, Salg6tarjein, 1984.
T. IVlasopust. An improvement of the descriptional complexity of grammars reg- ulated by context conditions. In Second Doctoral Workshop on Mathematical and Engineering Method,s in Computer Sc'ience (MEMICS 2006), pages 105-1i2, NIikulov, 2006.
A. N{eduna. Automata and Languages: Theory and Applicat'ions. Springer-Verlag, London, 2000.
A. Nleduna and M. Svec. Reduction of simple semi-conditional grammars with respect to the number of conditional productions. Act,a Cybent,et'ica, 15:353-360, 2002.
A. l\,leduna and M. Svec. Gramrnars wi,th Contert Conditions and Thei,r Appli,ca- tions. John Wiley & Sons, New York, 2005.
Gh. Piun. A variant of random context grammars: Semi-conditional grammars.
Theoret'ical Computer Sc'ience, 47:7-17, 1985.
Gy. Vaszil. On the descriptional complexity of some rewriting mechanisms regu- lated by context conditions. Theoret'ical Computer Sci,ence,330:361-373, 2005.
1 0 .