Hexagonal array grammars

7
COMPUTER GRAPHICS AND IMAGE PROCESSING 10, 38~394 (1979) NOTE Hexagonal Array Grammars K. G. SUBRAMANIAN Departmolt of Mathematics, Madras Christian College, Tambaram, Madras 600059, D~dia Received January 4, 1979 Hexagonal Kolam Array Grammars were introduced by Siromoney and Siromoney (Comput. Graphics Image Processing 5, 1976, 353-381) but limited to right-linear and linear rules due to constraints imposed by arrowhead eatenation. Here we modify the definition which helps us to consider context-free and context-sensitive rules as well, thus increasing the generative capacity which means more interesting hexagonal arrays on a triangular grid are generated. A hierarchy among the families of hexagonal array languages is presented. 1. INTRODUCTION Motivated by the kolam patterns, array rewriting rules for generation of digitized rectangular arrays were introduced by Siromoney, Siromoney, and Krithivasan [-21. These models were then extended to generation of hexagonal arrays on triangular grids by Siromoney and Siromoney [-1~. They define hexag- onal kolam array grammars (HKAG) [-lJ by introducing eatenation of arrow- heads to hexagonal arrays. The rewriting rules of a HKAG are of three types : nonterminal rules involving nonterminals and intermediates but restricted to right-linear and linear rules due to constraints imposed by arrowhead eatenations; a single terminal rule which rewrites a nonterminal as a hexagonal array of terminals ; and intermediate rules which generate R, CF, or CS intermediate languages, written in the form of arrowheads of fixed depth. During the first stage of derivations, a string of intermediates and a single nonterminal, catenated together with arrowhead directions and suitable parentheses, is generated. In the second stage, the single nonterminal is replaced by a hexagonal array of terminals. During the third stage of derivations, starting with the innermost parentheses, each intermediate is replaced by an arrowhead from the corresponding intermediate arrowhead language, subject to conditions of arrowhead eatenations, resulting in a hexagonal kolam array of terminals. 388 0146-664X/79/080388-07502.00/0 Copyright ~ 1979 by Academic Press, Inc. All rights of reproduction in any form reserved.

Transcript of Hexagonal array grammars

Page 1: Hexagonal array grammars

COMPUTER GRAPHICS AND IMAGE PROCESSING 10, 38~394 (1979)

NOTE

Hexagonal Array Grammars

K . G . S U B R A M A N I A N

Departmolt of Mathematics, Madras Christian College, Tambaram, Madras 600059, D~dia

Received January 4, 1979

Hexagonal Kolam Array Grammars were introduced by Siromoney and Siromoney (Comput. Graphics Image Processing 5, 1976, 353-381) but limited to right-linear and linear rules due to constraints imposed by arrowhead eatenation. Here we modify the definition which helps us to consider context-free and context-sensitive rules as well, thus increasing the generative capacity which means more interesting hexagonal arrays on a triangular grid are generated. A hierarchy among the families of hexagonal array languages is presented.

1. INTRODUCTION

Mot iva ted by the kolam patterns, ar ray rewriting rules for generation of digitized rectangular arrays were introduced by Siromoney, Siromoney, and Kri thivasan [-21. These models were then extended to generation of hexagonal arrays on tr iangular grids by Siromoney and Siromoney [-1~. They define hexag- onal kolam array grammars (HKAG) [-lJ by introducing eatenation of arrow- heads to hexagonal arrays.

The rewriting rules of a H K A G are of three types : nonterminal rules involving nonterminals and intermediates but restricted to right-linear and linear rules due to constraints imposed by arrowhead eatenations; a single terminal rule which rewrites a nonterminal as a hexagonal ar ray of terminals ; and intermediate rules which generate R, CF, or CS intermediate languages, wri t ten in the form of arrowheads of fixed depth. During the first stage of derivations, a string of intermediates and a single nonterminal, catenated together with arrowhead directions and suitable parentheses, is generated. In the second stage, the single nonterminal is replaced by a hexagonal array of terminals. During the third stage of derivations, starting with the innermost parentheses, each intermediate is replaced by an arrowhead from the corresponding intermediate arrowhead language, subject to conditions of arrowhead eatenations, resulting in a hexagonal kolam array of terminals.

388

0146-664X/79/080388-07502.00/0 Copyright ~ 1979 by Academic Press, Inc. All rights of reproduction in any form reserved.

Page 2: Hexagonal array grammars

HEXAGONAL ARRAY GRAMMARS 389

Here we retain the arrowhead eatenations but modify the definition of a HKAG by allowing initial rules which cause any derivation from the start symbol to begin with an initial hexagonal array H, in the first phase. We then have R, CF, or CS nonterminal and terminal rules involving nonterminals and intermediates. These rules are used in subsequent derivation steps of the first phase just as in string grammars, until all the nonterminals are replaced. To each intermediate, there corresponds an intermediate arrowhead language. In the second phase of derivations, the intermediates occuring after H in the strings generated in the first phase are successively replaced by arrowheads from the corresponding inter- mediate arrowhead languages and catenated to H, one after another, subject to conditions of arrowhead catenations, thus generating a hexagonal array of terminals. We eM1 the resulting model a hexagonal array grammar (HAG).

Thus in an HKAG, the initial hexagonal array is inside the innermost paren- theses and the arrowheads are eatenated to it starting from the innermost paren- theses and proceeding outwards; whereas in an HAG, the initial hexagonal array is kept in the leftmost position and arrowheads are eatenated to it from left to right successively. This helps us to consider context-free and context-sensitive rules as well, thereby increasing the generative capacity and enabling us to generate more interesting picture classes of hexagonal arrays on triangular grids. Thus we here define R, CF, and CS HAGs and HALs and exhibit a hierarchy among the families of HALs. The family of regular (resp. CF) HALs is shown to properly include the family of regular (resp. linear) HKALs.

2. HEXAGONAL ARRAY GRAMMARS

The reader is referred to [-1, 2~ for those notions and notations that are not given here.

DEFINITION 2.1. A hexagonal array grammar (HAG) is G = (N, I, T, P, S, ~), where N, I, and T are finite sets of nonterminals, intermediates, and terminals, respectively; P is a finite set of productions; P = P1%J P2 and S C N is the start symbol. For each A in I, L~ is an intermediate language which is a regular CF or CS string language written in the appropriate arrowhead form. An arrow- head is written in the form { . . . (v) . . . }, where (v) denotes the vertex and the arrowhead is written in the clockwise direction. 2 = {L~/A C I}.

P1 consists of an initial rule of one of the following forms:

(1) s M@s', (4) S - - - ~ H Q S ' , (5) S - - - ~ H O S ' , (6) S - - * H O S ' ,

where S' C N, S' ~ S, and H is a hexagonal array over T. G is regular if the rules of P2 are of the forms

(5) s , - , A ( D s2, (6) s l A s,, (7) s , A,

where S~, S~ E N; S~, $2 ~ S, and A ~ I. Further if the initial rule in P~ is

Page 3: Hexagonal array grammars

390 K. G. SUBRAMANIAN

of the form (r), then P2 does not contain any rule of the form (r + 1), if r is odd and (r - 1), if r is even, r = 1, . . . , 6. Also ,P2 does not contain rules of bo th the forms (r) and (r -I- 1), r .~ 1, 3, 5.

G is CF if the rules of P2 are of the form S~ --~ at | . . . | ak, w h e r e S ~ N ; $ 1 ~ S, a n d a i E ( N - {S})k . ) I (1 ~< i ~< k) and (~) denotes any one of the six arrowhead eatenations: @ , ~ , ( ~ ) , @ ' (~) ' ( D "

G is CS if the rules of P2 are-- of tl% form

or $1 | ~--~3' | ~ or S1--~%

where S ~ Q N ; St r S, and r 7, ~ are of the form ~ (~) . . . | ak, with a ~ C ( N - - { S } ) ~ I , 1 ~< i ~< k.

In particular, G is called (X :R)HAG or (X :CF)HAG or (X:CS)HAG, for X C {R, CF, CS}, according as all the intermediate languages are regular or at least one of them is CF or at least one of them is CS.

Derivations proceed as follows : First, an initial rule of P t is applied and then the rules of P2 are applied sequentially as in string grammars until all the non- terminals are replaced, resulting in a string of the form H | A~ | . . . | A~, where Ai ~ I (1 ~< i ~< ~). In the second phase of 'derivations Ax is replaced by an arrowhead from LA~ and catenated to the hexagonal array H according to the arrowhead eatenation symbol between H and At. This is continued until A, is replaced, resulting in a hexagonal array of terminals. The length of the arrowhead is determined by the condition for arrowhead eatenation.

DEFINITION 2.2. For X, Y C { R, CF, CS }, the (X : Y) hexagonal array language ((X: Y)HAL) generated by the (X: Y)HAG G is

L(G) = {H/S ~ *aH, H is a hexagonal array}.

Notation. The families of (X: Y)HALs, for X, Y C {R, CF, CS}, and (X: Y) hexagonal kolam array languages, for X = R or linear and Y ~ {R, CF, CS}, are denoted by (X: Y)HAL and (X: Y)HKAL, respectively.

We illustrate with an example.

�9 . X . X . X �9 e . i e ' X * t eex

x X x , . . X x x * x X , X X . * * X e X l X * * e X ~

�9 x*.Sx . . . X . X �9 X �9 x Xxx~ ***,*,Xe~xXew* x

oe.~ x �9 �9 �9 X �9 �9 �9 �9 m o , . x o e X

.**** �9 **x �9 �9 �9 x . . �9 �9 x X x * * x x x . * * X X X . � 9

x X . X x * * X . X . X . . X . X * * * . X * * X * * X . X * * * X * * * x x * * * x X * * x . . x . x * * *

�9 X XXX X . X XXX * * x . X X x X . * . x �9 * * x * . * * X * �9 * * * * * ' x e . * * * * * * * * X �9 " X ' X ' X " ' ' x ' ' x ' ' ' ' ' X " . ~ X ~ . ~ . ' , ' . ' . ~ X

X . x . * * * x . X * * * * * * X X X * * x X . x X . . X * * X x * * x * * x

x . X * * X x . X * * X X X*X *** X X x * * X X XxX . *xX

�9 X . . X X . . . x * x . . x x * * x * * * ~ x X * * X * * * x X X * X * x x x * * * * X XXex*xX x*x*x XxXxX

XxX XxX x

Fro. 1. Hexagonal arrays of Example 2.1.

Page 4: Hexagonal array grammars

H E X A G O N A L ARRAY G R A M M A R S 391

EXAMPLE 2.1. Consider the (R:R)HAG

G = ({S, S~}, {A~, A2, A3}, {., x}, P, S, ~), where P = P~ %) P~,

- - ((i/<i> x ~":~. L~ H ~ x X x �9 ~ . x * * X o �9

�9 x o* xxXxX X

{? o()+y I, LA~ = x . n ~ 1 , X . j

We derive the element H2 C L(G) = [H , /n >/ 1}

�9 " ~ X x x X X �9 �9 o X .:.'.:- �9169 QA,~ QA~ �9 ==)'x x;x . QA1 **X" ".:. "Xx.x @AI a~

X . X �9 " ~ �9 3; f X � 9 eX X

X X ' X ' X X X = X X �9 XXX 3; ~ e x �9 ' .

X e i x . ~ x

XXxX

" Z X Z~f

X l a o X o " XXXIX~ e :.:::.:.:. @A,�9 �9

e~ XeX~ I 4 . : @ ' . : " : X X X �9 Z o x �9 . X X

�9 X e e e X xX.X.X~ XoX ~ � 9 e�9 XxX X . X . e . �9 X " X o �9 XX~ �9 "

H~, H2, and H.~ are given in Fig. 1.

} �9 n > / 1 ,

A 3 ~ H.~.

3. H I E R A R C H Y AND COMPARISON

We now establish a hierarchy among the nine classes of (X:Y)HAL, X, Y H {R, CF, CS}. We first give two lemmas. We assume in the lemmas that N and I are finite subsets of {S~/i >/ 1] and [Ai / i >1 1}, respectively.

LEMMA 3.1. (i) The H A L generated by the (R :CF)HA G

G = (N, I, {., x}, Pl k.J P2, ~1, ~},

where Px = {S1---* H @ S2}

and

H = ~ . La, = { ( . ) ~ ( x } ( . ) " / n ~ 1}, LA, = { ( . )"+' (x} ( . )" /n /> 1},

La3 = LAI is a (R :CF)HAL which can~wt be generated by any (R :R)HAG.

Page 5: Hexagonal array grammars

392 K.G. SUBRAMANIAN

(ii) The H A L generated by the (R :CS)HAG G dejMed as in (i) except that x

H . . . . LA1 = { (.)'~x (. } (.)"-~x (.)'~/n >/ i } x ' x ~

ex*

L~ 2 = {(:)n+l(x}(:)~/n ) 1}, LA3 = {(.)2"(X)(.)~+~/n ) 1}

is a (R :CS)HAL, which cannot be ge~terated by a~y (R :CF)HAG.

The lemma follows by observing tha t the intermediate languages in (i) are CF whereas LA~ in (ii) is a CSL.

LEMMA 3.2. (i) The H A L generated by the (CF :R)HAG

G = (N, I, { . , x, + } , P~ ~_) P2, S~, ~), where

P1 = {SI ~ H @ S:} and

$2 44 As

xXx H = -~ LA, = / ( . ) n { . ) ( . ) n / n >/ 1}, L ; 2 - - {x~+l<x)xn/n /> 1}, x

Lx~ = { +~+~(+)-t-~+~/n. ) 1}, L.4, = L.4~={+~(+}q-n/n >/ i}

and LA~ = {-t-'~+~(-t-)+"/n >/ I} is a (CF :R)HAL, which is not generable by any (R :R)HAG or (Lin :R)HKAG.

(ii) The H A L generated by the (CF:CF)HAG g defined as in (i) but with H and La~ (i = 1, 2, 3) as defined in Lemma 3.1 (i), is a (CF :CF)HAL which is not generatable by any (CF :R)HAG or (R :CF)HAG or (Lin :CF)HKAG.

(iii) The H A L generated by the (CF :CS)HAG G defined as in (ii) except that H and LA~(i = I, 2, 8) are as defined in Lemma 3.1 (ii) and LA~ = { +~,+1(+)+2, /

Jr- n + l + + n /> 1}, LA~ = {(+) {+)(+)'~/n ) 1}, LA, = {-t-2n(-}-}+"+~/n >/ 1} i sa (CF: CS)HAL which is not generatable by a~iy (CF:CF)HAG or (R:CS)HAG or (Lin: CS)HKAD.

Proof. We just note tha t the effect of the rule

S1---+S~_@A or S~---~S~_@A or S~---~S.2@A, S ~ , S 2 C N, A C [,

is to do, subject to the conditions of arrowhead catenations, a sequence of catena- tions on H (namely, catenation of an element from LA1, LA~, and LA~ in the up, upper left, and upper right directions, respectively), a certain number of times and follow it by another sequence of catenations (namely, catenation of an element from LA~, LA~, and LA~ in the up, upper left, and upper right directions, respectively), the same number of times. This is not possible with RHAG rules only or with Linear H K A G rules only. Hence the lemma.

THEOREM 2.1. (i) For X = R, CF, or CS,

(X :R)HAL ~ (X :CF)HAL ~ (X :CS)HAL.

Page 6: Hexagonal array grammars

HEXAGONAL ARRAY GRAMMARS 393

(ii) For Y = R, CF, or CS, (R:Y)HAL ~ (CF:Y)HAL ~ (CS:Y)HAL.

Proof. The inclusions are clear from the definitions. Proper inclusions follow from Lemmas 3.1 and 3.2, when X = R, CF, and can be similarly proved when X = CS.

We now show tha t the families of R H K A L and linear H K A L are properly included in the corresponding families of R H A L and CFHAL, respectively.

THEOREM 2.2 For Y ~ {R, CF, CS}, (i) (R:Y)HKAL ~ (R:Y)HAL. (ii) (Li~:Y)HKAL ~ (CF: Y)HAL.

Proof. Let L be a regular H K A L generated by the regular H K A G G = (N ~J I, T, P, S, 2), where N, I, and T are finite sets of nonterminals, intermediates, and terminals, respectively; P is a finite set of productions; P = P1 L) P2; P1 con- sists of nonterminal rules of the form

S2-~ A, Q A2 @ A ~ O S2 O A~ Q A ~ Q A 6

and P2 consists of a single terminal rule of the form

S~ ~ H, S~ C N and H is a hexagonal aH'ay over T.

2~ = {LA/A C I}. LA is a R, CF, or CS intermediate language. Let Lab (P) be the labels of productions in P. Let

Sz(G) = {a = fq.. . f i~_l/fff C Lab(P) , for 1 ~ j ~ n and

L~::~*f," 1 (,k~ l @ A , ) ~ J ' ~ . . . ~<,~ ( ( . . . ( ( H (7) A,,) (~) A,,--,) (~) . . . ) (7) A1)}.

Sz(G) is the set of control words of derivations in (; from S, of words over I, in the first phase. Let (;1 = (N~, Lab (P), P~, X0) be a right-linear grammar generat- ing mi (Sz (G)). Let PI consist of rules of the form XI ~ fX.e, X1 ~ f, X1, X2 C N~, f C Lab(P) .

To complete the proof, we construct a regular HAG (;' so that L(G') = L. Let G' = (N, I, T, P', S', .e). We now describe the rules of P ' . Corresponding to each rule Xo ~ fX , in P~, where f, is the label of the rule ,q2 -+ S~ C) A in P, we form a rule S ' ~ H 1~ $2 in P'. Corresponding to each pair of rules X,---, fX.., and X2-~ gX~ in P~, where f and g are, respectively, labels of rules A1 ---* S., (~) IA1 and $3 --+ $1 (~) 2A2 in P, we form a rule S~ --~ A1 (~) ._,$3 in P' . Corresponding to each pair of rules X, ~ fX2 and X2 --~ g in P~, where f and g are, respeetively, the labels of the rules S1----> t~2 Q 1AI and Sa-~ S1 (7) ~A2 in P, we form a rule $3--~ A2 in P ' . I t can be seen that L((;') = L((;) = L. This proves the inclusion in s ta tement (i) of the theorem.

The inclusion in s ta tement (ii) is similar. The proper inclusions in (ii) follow from Lemma 3.2 and proper inclusions in (i) can be similarly seen.

ACKNOWLEDGMENT

The author would like to thank Dr. RaM Siromoney for fruitful discussions and for her useful comments in the preparation of the paper.

Page 7: Hexagonal array grammars

394 K. G. SUBRAMANIAN

REFERENCES

1. G. Siromoney and R. Siromoney, Hexagonal arrays and rectangular blocks, Comput. Graphics Image Processing 5, 1976, 353-381.

2. G. Siromoney, R. Siromoney, and K. Krithivasan, Picture languages with array rewriting rules, Inform. Contr. 22, 1973, 447-470.

3. G. Siromoney, R. Siromoney, and K. Krithivasan, Array grammars and kolam, Comput. Graphics Image Processing 3, 1974, 63-82.