267 Fundamental Study Modular tree transducers Joost Engelfriet Departmenf of Conrpurer Science, Leidm Uniuersics, Niels Bohreg 1, NL-2300 RA Leiden, Nerherlonds Heiko Vogler Lehrsruhl fTir In,formarik II, R WTH Aachen, Ahornrrr. 55, D-5100 Aacben, FRG Communicated by M. Nivat Received May 198s Revised January 1589 Absrracr Engelfrict, J. and H. Vogler, Modular tree transducers, Theoretical Computer Science 7S (1991) 267-303. A new tree transducer, called a modular tree transducer, is introduced. This device specifies operations on trees and ca be considered as a formalization of the concept of nesred simultaneous primitive recursion on trees. Roughly speaking, a modular tree transducer is a specie.1 left-linear and non-overlapping term rewriting system of which the set of ruies is partitioned into modules, es;h module being equipped with a non-negative integer: the xmber of the module. Then, a module with number i may cell modules with numbers oat !ess than i. Three properties are proved: (I) modular tree transducers compote exactly the (inductiv-ely defined) class of primitive recursive functions on trees; (2) the number of moduies in modular tree transducers induces a strict hierarchy on the class of all modular tree transductions, and (3) by appropriate!g res:tictinr the c4iing s~~‘ure between modules, modular tree transducers characterize the compositions of macro tree transducers where the number of modules and the number of compositions coinade. Content5 1. introduction........................._._...._...________...._,_._..___._._.___.... 2. Preliminaries...............__..____.__...._.____..._.._....,..___.____.____._._._. 2.1. General nations . _ . _ . _ . 2.2. Ranked alphabets. trees. trz-‘ f~?tccti-_r.s. aigebras __.~.__.._.~._.._._.._~__..__.... 2.3. Primitive recar;i,xe functions over iU. _ . _ . 2.4. L~pprograms......................._..._~.._.__.__._.._.___.___~_..___.____. 3. Basic definmons and examples _.. _. __._ .___ __ _._. _.. __. 4. Primititre recuxive tree functions . “. .~. ___ __. _. _I _ ._. _._. ._. 5. Cfiaractenzatton of PRec by modular tree transducers . _._. __ _ _._. _ __. __ I __. 5.1. Modular tree transductions are primitive recursiw iree functions _”_. __ _ _ _ _. 5.2. Primitire recursive tree functions are in ModT, _ . _ . __ _ . _. __ . .I _ _. 6. Hierarchy of modular tree transductions _ _ . _ . _. _ _ _ __ _. __. _, 7.Callingrestrictedmhdutartree~nducers .___.__ I . .._________I ______ ~..,_._ __~.~_..,, 8. Conclusions . _ . _ _ __ ___. ______._...._...___.___.___............ References _ . __~~~~~~“~___.~~“._____~~~__~~__~~_.~~~.....~...... 0304-3975/91/SO3.50 Q 199:--Elsevim Science Publishers B.V. (North-Holland; In computer science one is often faced wirh the task of defining a function on tree-structured objects, e.g., as a part of a search algorithm [23], as semantic function in denotational semantics [35. 161 (cf. e.g., 1223 for a functional compiler description in a denotationa! way), oras operation in an abstract data type [24]. If such functions arise from practical problems in a natural way, then frequently it is possible to specify thetn by primitive recursion, i.e., recursion on the structure of the tree- structured object, Thus, every such function .I‘ has a distinguished argument, called the “recursion argument”, which keeps the tree-structured object; we will call the other arg!tments “(context) parameters”. In a fictive metalanguage, the definition off’ may have the form of a case analysis on the structure of the actual value of the recursion argument. Thus, if f has arity r+ 1 and the first argument off is its recursion argument, the definition off looks like .f(x,Y ,,..., y,)=casexof . e, 1.. , Q): expr, ; (*) . end witete x is the recursion argument, +rC9. , yr are the context parameters, and 6(x,, . , xk) describes the structure of a tree in which S is the symbol (with rank k 3 0) labelling the root, and the variables xi,. , x, represent the subtrees. In general, the expression expr, is built up from recursive calls off; calls of functions that are simultaneons!y defined with A calls of previously defined functions, calls of basic functions, the snbtree variables x,, . , xbr and the parameters y,, . , y,. haoreover, since the recursion is primitive, the recursion argument of every recursive call off and every ca!l of a simultaneously defined function is one of the subtree variables. (For previousiy defined functions there is no such restriction.) Note that calls of functions may occur nested in parameters of functions. The dots i~piescnt combinations y(x,, . , x,): expr, for structures different from 8(x,, . _,xL). Intuitively, the expression expr, specifies the value off( 1, a,, . , a,) for every tuple n, , . , n, of values with appropriate type whenever the actual value t of the recursion argument has the structure 6(x,, . , xkf, i.e., the form 6(s,, _ . _, sk) for some trees S,,*..,S& Since we are only interested in devices that formalize operations on trees, also context parameters are of type tree (thus, a,, . , a, are trees). Moreover, we do not specify a particular semantic dostain in which the basic functions are interpreted. Rather we represent every k-ary basic function by a symbol with rank k This amounts to the assumption that the results of our functions are also of type tree. The informal function description (*j follows the concept of nested simultaneous primitive recursion on trees. Ry means of examples we wiil now illustrate the features involved in this concept. Example. We consider the rnnked alphabet V = {o”‘, CT”“}where the superscripts indicate the ranks of the symbols, and we work with binary trees over 2. Figure 1 shows an example of such a tree; the dotted line indicates the so-called “left spine of the tree” and the dashed lines enclose the so-called “l-subtrees”; in a similar way we can identify the “right spine of the tree” and the “r-subtrees”. Fig. 1. Binary tree over (r and a wi:h left spin? and I-sobtrees. (1) We define the unary operation mirror by using the basic concept of prhiriae recursioon (without nested calls or simultaneous definitions of functions). Mirror takes binary trees over P as arguments and transforms the left spine into a right spine without changing the I-subtrees; e.g., if t,, f,, and r3 are binary trees; then mirror(o(cr(o(q t,), t2), ti)) = o(r,, u(tz. o(t,, a))). Mirror can be specified by the fo!lowing case analysis: mirror(x) =ease X Of u(x,, x2): 0(x,, mirror!x,)); a: a end Here, expi,, = 17(.6, mirior(x,)) and expr, = o. Note that the recursion argument of the recursive call of mirror in expr,_ is the subtree variable X, . Note also that the symbofs D and CYare used both as part of tree structures and as basic function symbols. Er’o auxiliary functions are involved In expr, and expr,. iS) We describe the unary operations ane and zero by means of simuiraneous primih’ce recursion. Both operations take binaty trees as arguments, attach inZ?rma- tion above every symbol (namely, the unaty symbols 1 and 0. respestiveefy). and afterwards call the other operation. The operaiion one attaches a 1 to every symbol ?Hl J, En#rgnrr. jf, 1’bgkr thar is at an even disttince from the root. om( x) = case x of a(x,, x2): l(o(zero(x,), zero(xz))); 01: l(n) eml zero(x) = case x of a(x,, x2): O(o(one(x,),one(xz))): a: O(a) end (3) We program the binary operation shovel by using nested primitive recursion. Shovel takes binary trees s, and s> (over Z) as recursion argument and parameter, respectively, and it shovds the I-subtrees of s, on top of s-.; e.g., if s, = u(o(o(o, rr), r2), r,), then shovehs,, s2)= cr(l,, ff(fz, o(t,, s,))) (cf. Fig. 2). Thus, for a tree s, a call shovel(s, CY)transforms the left spine of s into a right spine and reverses the order of the I-subtrees. shovehx, y) = case x of G-(X,, xzj: shovel(x,, a(xz, y)); cx:y end This demonstrates a very simple form of nesting: the basic function o is called in the parameter of the call of shovel. A more complicated form of nested recursion is obtained by taking expr, equal to shovehx,, o(shovel&, w)? y)). In this case, the call shovei(s, o) transforms :he left spire of s into a right spine, reverses the order of the I-subtrees, and recursively applies this same operation to the I-subtrees. shovei / \ / “\A s2 /“Y, = /“\ t2 /o\ t2 t/o\ ,=\ s2 cx t1 Fig. 2. Application of shovel to 5: =u(o(u(e, r,), I?), i,) and s2 with the result rr(t,, u(I*, o(t3, So))). Quite a number of different models have been studied to form..lize such primitive recursion based descriptions of operations on trees. In its simplest form, the descrip- tion method has been formalized by generalized syntax-directed translation schemes [l, 23, top-down tree transducers [36,34], and attribute grammars with synthesized attributes only [26]. Operations like mirror, one, and zero can be specified . >ec:1 of the four mentioned formalisms. In fact, these formal models are equivalem ,.r..ir respect to their transformational power [29, 5, 371. However, for the description of an operation like shovel, more subtle devices are needed: they should be able to handle context information.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages37 Page
-
File Size-