Bidirectionalizing Graph Transformations

Similar documents
CS 491G Combinatorial Optimization Lecture Notes

Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

I 3 2 = I I 4 = 2A

2.4 Theoretical Foundations

Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

Bidirectionalizing Graph Transformations

Lecture 2: Cayley Graphs

Lecture 6: Coding theory

22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of:

Solutions to Problem Set #1

CSE 332. Sorting. Data Abstractions. CSE 332: Data Abstractions. QuickSort Cutoff 1. Where We Are 2. Bounding The MAXIMUM Problem 4

CS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014

Lecture 8: Abstract Algebra

CIT 596 Theory of Computation 1. Graphs and Digraphs

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

CSC2542 State-Space Planning

System Validation (IN4387) November 2, 2012, 14:00-17:00

Necessary and sucient conditions for some two. Abstract. Further we show that the necessary conditions for the existence of an OD(44 s 1 s 2 )

Factorising FACTORISING.

CS 573 Automata Theory and Formal Languages

Numbers and indices. 1.1 Fractions. GCSE C Example 1. Handy hint. Key point

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

6.5 Improper integrals

18.06 Problem Set 4 Due Wednesday, Oct. 11, 2006 at 4:00 p.m. in 2-106

Automata and Regular Languages

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Mid-Term Examination - Spring 2014 Mathematical Programming with Applications to Economics Total Score: 45; Time: 3 hours

for all x in [a,b], then the area of the region bounded by the graphs of f and g and the vertical lines x = a and x = b is b [ ( ) ( )] A= f x g x dx

NON-DETERMINISTIC FSA

Particle Physics. Michaelmas Term 2011 Prof Mark Thomson. Handout 3 : Interaction by Particle Exchange and QED. Recap

Chapter 4 State-Space Planning

Nondeterministic Automata vs Deterministic Automata

CS 360 Exam 2 Fall 2014 Name

CARLETON UNIVERSITY. 1.0 Problems and Most Solutions, Sect B, 2005

Section 2.3. Matrix Inverses

CS261: A Second Course in Algorithms Lecture #5: Minimum-Cost Bipartite Matching

Lecture 11 Binary Decision Diagrams (BDDs)

Subsequence Automata with Default Transitions

Now we must transform the original model so we can use the new parameters. = S max. Recruits

Nondeterministic Finite Automata

INTRODUCTION TO AUTOMATA THEORY

The DOACROSS statement

Graph Theory. Simple Graph G = (V, E). V={a,b,c,d,e,f,g,h,k} E={(a,b),(a,g),( a,h),(a,k),(b,c),(b,k),...,(h,k)}

Unfoldings of Networks of Timed Automata

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

Compression of Palindromes and Regularity.

AP Calculus BC Chapter 8: Integration Techniques, L Hopital s Rule and Improper Integrals

A Disambiguation Algorithm for Finite Automata and Functional Transducers

Lecture 08: Feb. 08, 2019

Surds and Indices. Surds and Indices. Curriculum Ready ACMNA: 233,

POSITIVE IMPLICATIVE AND ASSOCIATIVE FILTERS OF LATTICE IMPLICATION ALGEBRAS

Computing all-terminal reliability of stochastic networks with Binary Decision Diagrams

Coalgebra, Lecture 15: Equations for Deterministic Automata

Total score: /100 points

Common intervals of genomes. Mathieu Raffinot CNRS LIAFA

Bisimulation, Games & Hennessy Milner logic

If the numbering is a,b,c,d 1,2,3,4, then the matrix representation is as follows:

1. For each of the following theorems, give a two or three sentence sketch of how the proof goes or why it is not true.

Lecture 4: Graph Theory and the Four-Color Theorem

Solids of Revolution

= state, a = reading and q j

arxiv: v2 [math.co] 31 Oct 2016

Algebra 2 Semester 1 Practice Final

Symbolic Automata for Static Specification Mining

COMPUTING THE QUARTET DISTANCE BETWEEN EVOLUTIONARY TREES OF BOUNDED DEGREE

Behavior Composition in the Presence of Failure

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution

Section 2.1 Special Right Triangles

INTEGRATION. 1 Integrals of Complex Valued functions of a REAL variable

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Introduction to Olympiad Inequalities

Implication Graphs and Logic Testing

Computing on rings by oblivious robots: a unified approach for different tasks

F / x everywhere in some domain containing R. Then, + ). (10.4.1)

Eigenvectors and Eigenvalues

Exam 1 Study Guide. Differentiation and Anti-differentiation Rules from Calculus I

If we have a function f(x) which is well-defined for some a x b, its integral over those two values is defined as

Designing finite automata II

Data Structures LECTURE 10. Huffman coding. Example. Coding: problem definition

Finite State Automata and Determinisation

A Primer on Continuous-time Economic Dynamics

SOME INTEGRAL INEQUALITIES FOR HARMONICALLY CONVEX STOCHASTIC PROCESSES ON THE CO-ORDINATES

XML and Databases. Exam Preperation Discuss Answers to last year s exam. Sebastian Maneth NICTA and UNSW

COMPUTING THE QUARTET DISTANCE BETWEEN EVOLUTIONARY TREES OF BOUNDED DEGREE

Let s divide up the interval [ ab, ] into n subintervals with the same length, so we have

Logic, Set Theory and Computability [M. Coppenbarger]

Discrete Structures Lecture 11

Situation Calculus. Situation Calculus Building Blocks. Sheila McIlraith, CSC384, University of Toronto, Winter Situations Fluents Actions

Aperiodic tilings and substitutions

1 Nondeterministic Finite Automata

Separable discrete functions: recognition and sufficient conditions

Monochromatic Plane Matchings in Bicolored Point Set

Computing the Quartet Distance between Evolutionary Trees in Time O(n log n)

On the Spectra of Bipartite Directed Subgraphs of K 4

Welcome. Balanced search trees. Balanced Search Trees. Inge Li Gørtz

Metaheuristics for the Asymmetric Hamiltonian Path Problem

Electromagnetism Notes, NYU Spring 2018

On a Class of Planar Graphs with Straight-Line Grid Drawings on Linear Area

Solving the Class Diagram Restructuring Transformation Case with FunnyQT

Parse trees, ambiguity, and Chomsky normal form

Transcription:

Biiretionlizing Grph Trnsformtions Soihiro Hik Kzuhiro In Zhenjing Hu Hiroyuki Kto Ntionl Institute of Informtis, Jpn {hik,hu,kin,kto}@nii..jp Kzutk Mtsu Tohoku University, Jpn kztk@k.eei.tohoku..jp Keisuke Nkno The University of Eletro-Communitions, Jpn ksk@s.ue..jp Astrt Biiretionl trnsformtions provie novel mehnism for synhronizing n mintining the onsisteny of informtion etween input n output. Despite mny promising results on iiretionl trnsformtions, these hve een limite to the ontext of reltionl or XML (tree-like) tses. We hllenge the prolem of iiretionl trnsformtions within the ontext of grphs, y proposing forml efinition of well-ehve iiretionl semntis for UnCAL, i.e., grph lger for the known UnQL grph query lnguge. The key to our suessful formliztion is full utiliztion of oth the reursive n ulk semntis of struturl reursion on grphs. We refully refine the existing forwr evlution of struturl reursion so tht it n proue suffiient tre informtion for lter kwr evlution. We use the tre informtion for kwr evlution to reflet in-ple uptes n eletions on the view to the soure, n opt the universl resolving lgorithm for inverse omputtion n the nrrowing tehnique to tkle the iffiult prolem with insertion. We prove our iiretionl evlution is well-ehve. Our urrent implementtion is ville online n onfirms the usefulness of our pproh with nontrivil pplitions. Ctegories n Sujet Desriptors D.3.2 [Progrmming Lnguges]: Lnguge Clssifitions Speilize pplition lnguges; E. [Dt Strutures]: Grphs n networks Generl Terms Design, Lnguges Keywors iiretionl trnsformtion, view upting, grph query n trnsformtion, struturl reursion. Introution Biiretionl trnsformtions (Czrneki et l. 2009; Foster et l. 2005) provie novel mehnism for synhronizing n mintining the onsisteny of informtion etween input n output. They onsist of pir of well-ehve trnsformtions: forwr trnsformtion is use to proue trget view from soure, while the kwr trnsformtion is use to reflet moifition on the view to the soure. This pir of forwr n kwr trnsformtions shoul stisfy ertin iiretionl properties. Biiretionl trnsformtions re inee pervsive n n e seen in mny interesting Permission to mke igitl or hr opies of ll or prt of this work for personl or lssroom use is grnte without fee provie tht opies re not me or istriute for profit or ommeril vntge n tht opies er this notie n the full ittion on the first pge. To opy otherwise, to repulish, to post on servers or to reistriute to lists, requires prior speifi permission n/or fee. ICFP 0, Septemer 27 29, 200, Bltimore, Mryln, USA. Copyright 200 ACM 978--60558-794-3/0/09... $0.00 pplitions, inluing the synhroniztion of replite t in ifferent formts (Foster et l. 2005), presenttion-oriente struture oument evelopment (Hu et l. 2008), intertive user interfe esign (Meertens 998), ouple softwre trnsformtion (Lämmel 2004), n the well-known view upting mehnism whih hs een intensively stuie in the tse ommunity (Bnilhon n Spyrtos 98; Dyl n Bernstein 982; Gottlo et l. 988; Hegner 990; Lehtenörger n Vossen 2003). Despite mny promising results on iiretionl trnsformtions, they re limite to the ontext of reltionl or XML (tree-like) tses. It remins unresolve (Czrneki et l. 2009) whether iiretionl trnsformtions n e resse within the ontext of grphs ontining noe shring n yles. It woul e remrkly useful in prtie if iiretionl trnsformtion oul e pplie to grph t strutures, euse grphs ply n irreplele role in nturlly representing more omplex t strutures suh s those in iologil informtion, WWW, UML igrms in softwre engineering (Stevens 2007), n the Ojet Exhnge Moel (OEM) use for exhnging ritrry tse strutures (Ppkonstntinou et l. 995). There re mny hllenges in ressing iiretionl trnsformtion on grphs. First, unlike reltionl or XML tses, there is no unique wy of representing, onstruting, or eomposing generl grph, n this requires more preise efinition of equivlene etween two grphs. Seon, grphs hve shre noes n yles, whih mkes oth forwr n kwr omputtion muh more omplite thn tht on trees; nïve omputtion on grphs woul visit the sme noes mny times n possily infinitely. It is prtiulrly iffiult to hnle insertion in kwr trnsformtion euse it requires suitle sugrph to e rete n inserte into proper ple in the soure. This pper reports our first solution to the prolem of iiretionl grph trnsformtion. We pproh this prolem y proviing iiretionl semntis for UnCAL, whih is grph lger for the known grph query lnguge UnQL (Bunemn et l. 2000); forwr semntis (forwr evlution) orrespons to forwr trnsformtion n kwr semntis (kwr evlution) orrespons to kwr trnsformtion. We hoose UnQL/UnCAL s the sis of our iiretionl grph trnsformtion for two min resons. First, UnQL/UnCAL is grph query lnguge tht hs een well stuie in the tse ommunity with soli fountion n effiient implementtion. It hs onise n prtil surfe syntx se on selet-where luses like SQL, n n e esily use to esrie mny interesting grph trnsformtions. Seon, n more importntly, grph trnsformtions in UnQL n e utomtilly mppe to those in terms of struturl reursion in UnCAL, whih n e evlute in ulk mnner (Bunemn et l. 2000); struturl reursion is evlute y first proessing in prllel on ll eges of the input grph n

then omining the results. This ulk semntis signifintly ontriutes to our iiretionliztion, proviing smrt wy of treting shre noes n yles in grphs n of tring k from the view to the soure. Our min tehnil ontriutions re summrize s follows. We re, s fr s we re wre, the first to hve reognize the importne of struturl reursion n its ulk semntis in ressing the hllenging prolem of iiretionl grph trnsformtion, n sueee in novel two-stge frmework of iiretionl grph trnsformtion se on struturl reursion. We emonstrte tht grph trnsformtions efine in terms of struturl reursions (eing suitle for optimiztion s hve een intensively stuie thus fr (Bunemn et l. 2000)) mke kwr evlution esier. We give forml efinition of iiretionl semntis for Un- CAL y () refining the existing forwr evlution so tht it n proue useful tre informtion for lter kwr evlution (Setion 4), n (2) using the tre informtion to reflet in-ple uptes n eletions on the view to the soure, n opt the nrrowing tehnique to tkle the iffiult prolem with insertion (Setion 5). We prove our iiretionl evlution is well-ehve. We hve fully implemente our iiretionliztion presente in this pper n onfirme the effetiveness of our pproh through mny non-trivil exmples, inluing ll those presente in this pper n some typil iiretionl grph trnsformtions in tse mngement n softwre engineering. More exmples n emos re ville on our BiG projet We site. We onsier n opertion se pproh, whih mens tht the user expliitly provies eiting opertions in terms of renme, elete, n insert. Currently these opertions re trete oring to the orer speifie y users. It might e hllenging to proue these opertion sequenes utomtilly from the sttes efore n fter user s moifitions on the view, ut it is eyon the sope of this pper. The forwr trnsformtions we onsier is se on UnCAL, whih is isimultion generi, mening tht the trnsformtion n t istinguish etween grphs tht re isimilr. For exmple, it n t extrt first hil of noe. Extening our moel to ope with orer is inlue in our future work. Also note tht kwr trnsformtion is not isimultion generi, mening tht two results of uptes tht re isimilr o not lwys le to isimilr soure. However, this is not neessrily limittion introue y our iiretionliztion, sine this symmetry omes from the expressiveness of onitionl expression in the originl UnCAL grph lger. Similr rgument pply for isomorphi uptes. Outline We strt with rief review of the si onept of grph t moel n the struturl reursion of UnCAL in Setion 2. Then, we lrify the iiretionl properties within our ontext n give n overview of our two-stge frmework for iiretionlizing grph trnsformtions in Setion 3. After explining how to exten the forwr evlution of UnCAL with tre informtion in Setion 4, we give forml efinition of iiretionl semntis for UnCAL n prove tht it is well-ehve in Setion 5. We isuss implementtion issues in Setion 6 n relte work in Setion 7. We onlue the pper in Setion 8. http://www.igl.org 2 5 6 3 4 () A Simple Grph 6 2 5 0 3 52 62 42 () An Equivlent Grph Figure. Grph Equivlene Bse on Bisimultion 2. UnCAL: A Grph Alger We opte UnCAL (Bunemn et l. 2000), well-stuie grph lger, s the sis of our iiretionl grph trnsformtion. We will riefly review its grph t moel n the ore of UnCAL. 2. Grph Dt Moel We el with roote, irete, n ege-lele grphs with no orer on outgoing eges. They re ege-lele in the sense tht ll informtion is store on lels of eges while lels of noes serve only s unique ientifier without prtiulr mening. UnCAL grph t moel hs two prominent fetures, mrkers n ε-eges. Noes my e mrke with input n output mrkers, whih re use s n interfe to onnet them to other grphs. An ε-ege represents shortut of two noes, working like the ε-trnsition in n utomton. We use Lel to enote the set of lels n M to enote the set of mrkers. Formlly, grph G, sometimes enote y G (V,E,I,O), is quruple (V, E, I, O), where V is set of noes, E V (Lel {ε}) V is set of eges, I M V is set of pirs of n input mrker n the orresponing input noe, n O V M is set of pirs of output noes n ssoite output mrkers. For eh mrker &x M, there is t most one noe v suh tht (&x, v) I. The noe v is lle n input noe with mrker &x n is enote y I(&x). Unlike input mrkers, more thn one noe n e mrke with n ientil output mrker. They re lle output noes. Intuitively, input noes re root noes of the grph (we llow grph to hve multiple root noes, n for singly roote grphs, we often use efult mrker & to inite the root), while n output noe n e seen s ontext-hole of grphs where n input noe with the sme mrker will e plugge lter. We write inmrker(g) to enote the set of input mrkers n outmrker(g) to enote the set of output mrkers in grph G. In ition, we write lel(ζ) to enote the lel of the ege ζ. Note tht multiple-mrker grphs re ment to e n internl t struture for grph omposition. In ft, the initil soure grphs of our trnsformtion hve one input mrker (single-roote) n no output mrkers (no holes). For instne, the grph in Figure () is enote y (V, E, I, O) where V = {, 2, 3, 4, 5, 6}, E = {(,, 2), (,, 3), (,, 4), (2,, 5), (3,, 5), (4,, 4), (5,, 6)}, I = {(&, )}, n O = {}. Vlue Equivlene etween Grphs Two grphs re vlue equivlent if they re isimilr. Plese refer to (Bunemn et l. 2000) for the omplete efinition. Informlly, grph G is isimilr to grph This nlogy woul hoose NFA rther thn DFA, sine we llow multiple outgoing eges with ientil lels from noe. 4 4

G {} { : G} &x... &xm &z G G2 G G G2 &x... &xm &x... &xm G G 2 &y... &yn &y... &yn G G 2 &z := G &z () &x... &x m G &y... &yn ε ε &y... &yn ε G2 &z... &zp G@G2 &z Figure 2. Grph Construtors &x... &xm ε ε &x... &x m G &x... &x m yle (G) ε e ::= {} {l : e} e e &x := e &y () e e e @ e yle(e) { onstrutor } $g { grph vrile } if l = l then e else e { onitionl } re(λ($l, $g).e)(e) { struturl reursion pplition } l ::= $l { lel ( Lel) n lel vrile } Figure 3. Core UnCAL Lnguge Exmple. The grph equivlent to tht in Figure () n e onstrute s follows (though not uniquely). &z @ yle((&z := { : { : &z }} { : { : &z }} { : &z 2 }) (&z := { : {}}) (&z 2 := { : &z 2})) For simpliity, we often write { : G,..., n : G n } to enote { : G } { n : G n }. G 2 if every noe x in G hs t lest isimilr ounterprt x 2 in G 2 n vie vers, n if there is n ege from x to y in G, then there is orresponing ege from x 2 to y 2 in G 2 tht is isimilr ounterprt of y, n vie vers. Therefore, unfoling yle or upliting shre noes oes not relly hnge grph. This notion of isimultion is extene to ope with ε-eges. For instne, the grph in Figure () is vlue equivlent to the grph in Figure (); the new grph hs n itionl ε-ege (enote y the otte line), uplites the grph roote t noe 5, n unfols n splits the yle t noe 4. Unrehle prts re lso isregre, i.e., two isimilr grphs re still isimilr if one s sugrphs unrehle from input noes. Grph Construtors Figure 2 summrizes the nine grph onstrutors tht re powerful enough to esrie ritrry (irete, ege-lele, n roote) grphs (Bunemn et l. 2000): G ::= {} { single noe grph } { : G} { n ege pointing to grph } G G 2 { grph union } &x := G { lel the root noe with n input mrker } &y { noe grph with n output mrker } () { empty grph } G G 2 { isjoint grph union } G @ G 2 { ppen of two grphs } yle(g) { grph with yles } Here, {} onstruts root-only grph, { : G} onstruts grph y ing n ege with lel Lel {ε} pointing to the root of grph G, n G G 2 s two ε-eges from the new root to the roots of G n G 2. Also, &x := G ssoites n input mrker, &x, to the root noe of G, &y onstruts grph with single noe mrke with one output mrker &y, n () onstruts n empty grph tht hs neither noe nor n ege. Further, G G 2 onstruts grph y using omponentwise (V, E, I n O) union. iffers from in tht unifies input noes while oes not. requires input mrkers of operns to e isjoint, while requires them to e ientil. G @ G 2 omposes two grphs vertilly y onneting the output noes of G with the orresponing input noes of G 2 with ε-eges, n yle(g) onnets the output noes with the input noes of G to form yles. Newly rete noes hve unique ientifiers. We will give this retion rule extene for our iiretionliztion in Setion 4.. The efinition here is se on grph isomorphism (ientil grph onstrution expressions results in ientil grphs up to isomorphism), n they re, together with other opertors, lso isimultion generi (Bunemn et l. 2000), i.e., isimilr result is otine for isimilr inputs. 2.2 The Core UnCAL UnCAL (Unstruture Clulus) is n internl grph lger for the grph query lnguge UnQL, n its ore syntx is epite in Figure 3. It onsists of the grph onstrutors, vriles, onitionls, n struturl reursion. We hve lrey etile the t onstrutors, while vriles n onitionls re self explntory. Therefore, we will fous on struturl reursion, whih is powerful mehnism in UnCAL to esrie grph trnsformtions. A funtion f on grphs is lle struturl reursion if it is efine y the following equtions f({}) = {} f({$l : $g}) = e @ f($g) f($g $g 2 ) = f($g ) f($g 2 ), where the expression e my ontin referenes to vriles $l n $g (ut no reursive lls to f). Sine the first n the thir equtions re ommon in ll struturl reursions, we write the struturl reursion in UnCAL simply s f($) = re(λ($l, $g).e)($). Despite its simpliity, the ore UnCAL is powerful enough to esrie interesting grph trnsformtion inluing ll grph queries (in UnQL) (Bunemn et l. 2000), n nontrivil moel trnsformtions (Hik et l. 2009). Some simple exmples re given elow. Exmple 2. The following struturl reursion 2 reples ege lel with n leves other lels unhnge. 2($) = re(λ($l, $g). if $l = then { : & } 2 else {$l : & 3 } 4 ) ($) 5 (The supersripts re for ientifying oe positions, whih will e importnt in Setion 4; they n simply e ignore for now.) Here is n instne of n exeution: ( 2 ) = where enotes the root of the grph. Informlly, the mening of this efinition n e onsiere to e fixe point (though my not neessrily unique) over the grph, whih is gin efine y set of equtions using the three onstrutors {}, :, n. For instne, the grph in Figure () n e onsiere to e the fixe point of the following equtions: G root = { : { : G 5 }, : { : G 5 }, : G 4 } G 5 = { : {}} G 4 = { : G 4 }.

() Before Removing ε-eges S2 S3 S4 E2 2 S25 E25 5 S56 E56 E3 3 S35 E35 E4 4 S44 E44 6 () Removing ε- eges () After Removing ε- eges Figure 4. Bulk Semntis of Struturl Reursion in UnCAL Exmple 3. The following struturl reursion 2 x reples ll lels with n removes eges lele. 2 x($) = re(λ($l, $g). if $l = then { : & } 2 else if $l = then {ε : & 3 } 4 else {$l : & 5 } 6 ) ($) 7 Applying the funtion 2 x to the grph in Figure () yiels the grph in Figure 4(). Exmple 4. The following struturl reursion onseutive extrts sugrphs tht n e essile y trversing two onnete eges of the sme lel. onseutive($) = re(λ($l, $g). re(λ($l, $g ). if $l = $l then {result : $g } else {} 2 )($g) 3 )($) 4 For exmple, we hve ( ) onseutive X Y = result X Note tht the struturl reursive efinition of onseutive uses grph prmeter $g to hieve the trnsformtion. Also note tht struturl reursions re llowe to e neste, n inner reursion n refer to outer vriles (s $l in the exmple). This enles us to express the join of multiple queries. Exmple 5. Although the exmples given so fr re self-reursive, it is possile to simulte mutul reursion y returning grphs with multiple mrkers. For instne, the following funtion ($) = &z @ re(λ($l, $g). &z :={ : &z 2 } &z 2 :={ : &z })($) hnges ll eges of even istnes from the root noe to, n o istne eges to. We my onsier the mrkers &z i s mutully reursive ll, n to onsist of two mutul reursive funtions. The first is &z, whih, t eh ege in the originl grph, genertes new ege pointing to the result of &z 2 t the originl estintion noe. The seon is &z 2 tht genertes eges pointing to the result of &z from its estintion. The result of the whole expression is efine to e the result of the &z t the root noe of the rgument grph. The following figure shoul e helpful. The she eges enote the eges tht re unrehle from the output root noe. ( e ) = = 2.3 Bulk Semntis of Struturl Reursion By llowing ε-eges, we n evlute struturl reursion in ulk mnner. Consier the struturl reursion, re(λ($l, $g). e) whih is to e pplie to n input grph G. In ulk semntis, we pply oy e inepenently on every ege (, G ) in G where is the lel of the ege n G is the grph tht the ege is pointing to, then join the results with ε-eges (s in the @ onstrutor). Rell the struturl reursion 2 x efine in Exmple 3. Applying it to the input grph in Figure () yiels the grph in Figure 4(), where eh ege from i to j in the input grph les to sugrph ontining grph with n ege from Sij to Eij in the output grph (where the otte ege enotes n ε-ege), n these sugrphs re onnete with ε-eges oring to the originl shpe of the grph. If we eliminte ll ε-eges s expline in Setion 3.2, we otin stnr grph in Figure 4(). One istint feture of ulk semntis is tht the shpe of the input grph is rememere through itionl ε-eges, whih will e fully utilize in our lter iiretionliztion. 3. Overview: Biiretionlizing UnCAL It is more hllenging to iiretionlize trnsformtions on grphs thn trees, euse grphs my ontin shre noes or yles. We shll emonstrte tht the struturl reursion in UnCAL n serve s the sis to solve this prolem. Although struturl reursion ws propose within the ontext of query optimiztion, we will show tht it plys ruil role in our iiretionliztion. 3. Biiretionl Properties Biiretionliztion is use to erive kwr trnsformtion from forwr trnsformtion. We pproh the prolem of iiretionliztion in grph trnsformtion y proviing iiretionl semntis for UnCAL; forwr semntis (forwr evlution) orrespons to forwr trnsformtion n kwr semntis (kwr evlution) orrespons to kwr trnsformtion. Before giving our iiretionl semntis for UnCAL, let us lrify the iiretionl properties tht the forwr n kwr evlutions shoul stisfy. Let F[[e]]ρ enote forwr evlution (get) of expression e uner environment ρ to proue view, n B[[e]](ρ, G ) enote kwr evlution (put) of expression e uner environment ρ to reflet possily moifie view G to the soure y omputing n upte environment. ρ is set of mppings with form $x G with grph (or lel) G. The following re two importnt properties: F[[e]]ρ = G B[[e]](ρ, G) = ρ (GETPUT) B[[e]](ρ, G ) = ρ G Rnge(F[[e]]) F[[e]]ρ = G (PUTGET) The (GETPUT) property sttes tht unhnge view G shoul give no hnge on the environment ρ in the kwr evlution, while the (PUTGET) property sttes tht if view is moifie to G whih is in the rnge of the forwr evlution, then this moifition n e reflete to the soure suh tht forwr evlution will proue the sme view G.

v ε losure v ε losure Figure 5. Generl ε-ege Elimintion Proeure These two properties re essentilly the sme s those in (Foster et l. 2005). One prolem with the (PUTGET) property is tht it nees to hek whether grph is in the rnge of forwr evlution, whih is iffiult to o in prtie. To voi this rnge heking, we llow the moifie view n the view otine y kwr evlution followe y forwr evlution to iffer, ut require oth views to hve the sme effet on the originl soure if kwr evlution is pplie. B[[e]](ρ, G ) = ρ F [e]ρ = G B [e](ρ, G ) = ρ (WPUTGET) The get in our (WPUTGET) n e onsiere s n menment of the moifie view G to G. Certinly, if the (PUTGET) property hols, so oes the (WPUTGET). We sy tht pir of forwr n kwr evlutions is well-ehve if it stisfies (GETPUT) n (WPUTGET) properties. In the rest of this pper, we will give iiretionl evlution (semntis) for UnCAL, n prove the following theorem, whih is iret onsequene of Lemms 2, 3, n 4 tht will e isusse lter. Theorem (Well-ehveness). Our forwr n kwr evlutions re well-ehve, provie their evlutions suee. 3.2 Two-Stge Biiretionliztion Rell 2 x, whih mps the soure grph in Figure () to the view grph in Figure 4(). The ig gp etween the soure n the view mkes it hr to reflet hnges on the view to the soure. Our ie to rige this gp ws to ivie the forwr evlution into two esily hnle stges: Stge : Forwr evlution (in the ulk semntis) with suffiient ε-eges, so tht the output grph will hve similr shpe to the input grph, mking the lter kwr evlution esier. Stge 2: Elimintion of ε-eges to proue usul view. For 2 x, Stge mps the soure grph to the intermeite grph in Figure 4(), n Stge 2 mps the intermeite grph to the view grph (Figure 4()). By oing so, eh stge eomes esier to iiretionlize. First, let us onsier Stge 2. The ε-ege elimintion proeure is simple: new eges re e to skip the ε-losure (Figure 5). It is esy to efine well-ehve kwr evlution for this proeure. First, ll noes in the result grph, G v, exist in the originl grph, G s, so eh noe in G v n e tre to G s. Seon, lthough n ege in G s my e uplite in G v ((E25,, E56) n (E35,, E56) in Figure 4()), eh ege in G v shoul hve uniquely orresponing ege in G s. Therefore, ing new noe to G v orrespons to ing new noe to G s, n ing new ege to G v orrespons to ing new ege etween two orresponing noes in G s. Similr orresponene hols for eletions of noes n eges, n in-ple uptes of eges. Note tht Figure 4() oes not hve this uplition euse for this prtiulr grph, it is sfe to glue the soure n the estintion noes of n ε-ege together. It is unsfe, if n only if, the soure hs nother outgoing ege n the estintion hs nother inoming ege. Here, uplition is unvoile. Next, let us onsier Stge. One ft worth noting is tht fter the kwr evlution in Stge 2, the moifition to the view in Stge stisfies the ε-mrker preserving property: () No ε-eges re e or elete, (2) Mrkers re not e, elete, or hnge n (3) Unrehle prts re not moifie. This property is very importnt in our iiretionliztion, euse it not only enfores the nine grph onstrutors so tht they re invertile, ut it lso mkes it esy to iiretionlize struturl reursion euse there is ler orresponene etween the input n output grphs. In the rest of this pper, we will fous on iiretionl grph trnsformtion in Stge. 4. Trele Forwr Evlution An UnCAL expression usully speifies forwr evlution mpping grph tse (whih is just grph) to view grph (in Setion 2). The min purpose of the present pper is to give kwr evlution (kwr semntis), whih speifies how to reflet view uptes to the grph tse. For this purpose, we hve to etet how eh noe of the view is generte, prtiulrly when it is onstrute through onneting input/output mrkers n removing ε-eges, whih re no longer in the view. To mke the view more informtive, viz., trele, we enrih the originl semntis of UnCAL y emeing tre informtion (like provenne tres (Cheney et l. 2008)) in ll noes of the view tht possily inlues ε-eges. In this setion, we explin wht kin of tre informtion is emee in the view, n exten the originl semntis for UnCAL expressions to e evlute into trele views. 4. Trele Views A view is otine y evluting n UnCAL expression with tse. Every noe of the view origintes in either noe of the tse or onstrut in the UnCAL expression, exept when the noe is generte through struturl reursion with re onstrut (in the ulk semntis). Rell tht n expression re(λ($l, $g).e )(e 2 ) is evlute y ining vriles $l n $g in e to prt of the evlution result of e 2. In this se, noe in the view my originte not only in the whole re expression ut lso su-expression in e 2. A trele view is view eh noe of whih hs informtion for tring its origin. The informtion, lle tre ID, is efine y TreID ::= SrID Coe Pos Mrker ReN Pos TreID Mrker ReE Pos TreID Ege, where SrID rnges over ientifiers uniquely ssigne to ll noes of the tse, Pos rnges over oe positions in the UnCAL expression, Mrker rnges over input/output mrkers, n Ege stns for TreID Lel TreID with set of lels Lel. We now riefly explin the mening of eh tre ID. Let i e tre ID of noe u in trele view. When i is noe ientifier in SrID, noe u origintes in the noe ssigne y i in the tse. When i is Coe p &m with oe position p n input mrker &m, noe u origintes in the suexpression t p in the UnCAL expression. The mrker &m is only require when the suexpression is given y the or yle onstrut. This is euse these onstruts yiel s mny ε-eges s input mrkers. When i is either ReN p i 0 &m or ReE p i 0 (i,, i 2 ), noe u is generte through the re onstrut t the oe position p. ReN n ReE stn for wht noe n ege, respetively, of the rgument of the reursion, the noe origintes in. Let us explin these ses through n exmple where the Un- CAL expression 2 x in Exmple 3 is pplie to the tse G sr in Figure (). The trele view we wnt n e o-

tine from the grph G view in Figure 4() y ssigning tre IDs to ll noes. The tre ID ssigne to noe in G view is (ReN 7 &) euse the noe origintes in noe of G sr in SrID, whih is use s prt of the rgument of the re onstrut t oe position 7 in 2 x. The tre ID ssigne to noe S2 in G view is (ReE 7 (Coe 2) (,, 2)) euse the noe origintes in the -lele ege from noe to 2 of G sr in Ege through the grph onstrutor { : } t oe position 2 in the re onstrut t 7 in 2 x. When the rgument of the re onstrut is lso re expression, ReN n ReE in the tre ID re neste like (ReN p (ReE p... )... ) n (ReE p (ReE p... ) (ReN...,, ReN... )). A trele view is enote y quruple (V, E, I, O) just like n orinry UnCAL grph. The only ifferene is tht in trele views, tre IDs re ssigne to ll noes. 4.2 Enrihe Forwr Semntis Trele views n e ompute y simple extension of the originl forwr semntis of UnCAL so tht tring informtion is reore when noe is rete. Let e p enote n UnCAL suexpression e t oe position p. We write ρ($x) for G when ($x G) ρ. ρ is nturlly use s vrile sustitution in UnCAL expressions, e.g., eρ for n expression e. We inutively efine the enrihe forwr semntis F [e p ]ρ for eh UnCAL onstrut of e. Grph Construtor Expressions. The semntis of grph onstrutor expressions is strightforwr oring to the onstrution in Figure 2. For instne, we hve F[[{} p ]]ρ = ({Coe p},, {(&, Coe p)}, ), whih retes grph hving single noe with the tre ID of Coe p (initing the noe is onstrute y the oe t position p), no eges, n input noe (the single noe itself), n no output noes. As nother exmple, the semntis for the expression e e 2 is efine elow to unify two grphs y onneting their input noes with mthing mrkers using ε-eges: F[[(e e 2) p ]]ρ = F [e ]ρ p F [e 2]]ρ, where p is union opertor for two grphs onerning position p n is efine y G p G 2 = (V V V 2, E E E 2, I, O O 2 ) where (V, E, I, O ) = G (V 2, E 2, I 2, O 2 ) = G 2 M = inmrker(g ) = inmrker(g 2) V = {Coe p &m &m M} E = {(Coe p &m, ε, v) (&m, v) I I 2 } I = {(&m, Coe p &m) &m M}. We omit efinitions for other onstrutor expressions. Vrile. A vrile looks up its ining from environment ρ. Conition. F [($v) p ]ρ = ρ($v) The forwr semntis of onition is efine s F[[(if l { = l 2 then e else e 2 ) p ]ρ F [e ]ρ if l = ρ = l 2 ρ F [e 2 ]ρ otherwise. It first evlutes the onitionl expression l = l 2, n with the result it evlutes either the then rnh or the else rnh. Struturl Reursion. The semntis of struturl reursion is given y ulk semntis s reviewe in Setion 2.3, whih n e formlly efine y F[[(re(λ($l, $g). e )(e )) p ]]ρ = ompose p re(fw ehege(g, ρ, e ), G, M) where M = inmrker(e ) outmrker(e ) G = F[[e ]]ρ, where fw ehege n ompose re re efine in Figure 6. Intuitively, fw ehege evlutes the oy expression e t eh ege ζ of the rgument grph G otine y evluting e n returns the set of result grphs. Then, ompose p re glues ll the grphs together long the struture of G onerning oe position p. Note tht sugrph(g, ζ) enotes the sugrph to whih the ege ζ is pointing in the grph G. Exmple 6. We will now illustrte the semntis of re through n exmple: the struturl reursion 2 x, whih is efine with position informtion in Exmple 3, is pplie to G sr in Figure (), n the trele view is grph similr to G view in Figure 4(). First, G sr is oun to vrile $. Then, fw ehege genertes set of pirs of n ege n lol result for eh ege in G sr. The lol result is otine y evluting the oy of re uner ρ = {$ G sr } {$l L, $g G} with the lel L of the ege n sugrph G rehle from the ege. For exmple, s the lol result for ege (3,, 5) in G sr, ege (Coe 2,, Coe ) with input noe Coe 2 n output noe Coe is generte euse the suexpression { : & } 2 is use ue to $l =. The funtion ompose p re glues ll pirs of n ege n lol result fter ing ReN or ReE to their noes. For exmple, regring pir of ege ζ = (3,, 5) n its lol result ontining ege (Coe 2,, Coe ), the set E ReE ontins ege (ReE 7 (Coe 2) ζ,, ReE 7 (Coe ) ζ) where 7 is the oe position of the onerne re, while set E ReN ontins ege (ReN 7 3 &, ε, ReE 7 (Coe 2) ζ) n (ReE 7 (Coe ) ζ, ε, ReN 7 5 &) ue to (&, Coe 2) I n (Coe, &) O. The former orrespons to the ege from S35 to E35 of G view n the ltter orrespons to two eges from 3 to S35 n from E35 to 5 of G view. In this exmple, E ε is n empty set sine G sr hs no ε-eges. The sets I ReN n O ReN of input n output noes re otine with I = {(&, )} n O =, respetively, whih re those of G sr. Hene, I ReN = {(&.&, ReN 7 &)} n O ReN = euse M = inmrker(e ) outmrker(e ) = {&}. Here,. enotes Skolem funtion (Bunemn et l. 2000) tht stisfies (&x.&y).&z = &x.(&y.&z) (ssoitivity) n &.&x = &x.& = &x (left n right ientity). More onretely, if the soure grph is s = 2 x(s) gives the grph ReN 7 & ReE 7 (Coe 6) (,, 2) ReE 7 (Coe 5) (,, 2) ReN 7 2 & whih is isimilr to the grph 5. Bkwr Evlution of UnCAL ReE 7 (Coe 2) (,, 2) ReE 7 (Coe ) (,, 2). 2, With trele views n the ε-mrker preserving property (Setion 3) on the moifition of suh views, kwr evlution (in Stge ) turns out to e simpler for two resons. First, the grph onstrutors eome invertile. For instne, if G = G G 2, G is moifie to G, ut the moifition is

{ } fw ehege(g (,E,, ), ρ, e) = (ζ, F[[e]]ρ ζ ) ζ E, lel(ζ) ε, ρ ζ = ρ {$l lel(ζ), $g sugrph(g, ζ)} ompose p re(g, (V, E, I, O), M) = (V ReE V ReN, E ReE E ReN E ε, I ReN, O ReN ) where V ReE = {ReE p v ζ (ζ, (V ζ,,, )) G, v V ζ } E ReE = {(ReE p u ζ,, ReE p v ζ) (ζ, (, E ζ,, )) G, (u,, v) E ζ } V ReN = {ReN p v &m v V, &m M} E ReN = {(ReN p v &m, ε, ReE p u ζ) &m M, (ζ = (v,, ), (,, I ζ, )) G, (&m, u) I ζ } {(ReE p u ζ, ε, ReN p v &m) &m M, (ζ = (,, v), (,,, O ζ )) G, (u, &m) O ζ } E ε = {(ReN p v &m, ε, ReN p u &m) (v, ε, u) E, &m M} I ReN = {(&n.&m, ReN p v &m) (&n, v) I, &m M} O ReN = {(ReN p v &m, &n.&m) (v, &n) O, &m M} Figure 6. Core of Forwr Semntis of re t Coe Position p ε-mrker preserving; then, we n follow tring informtion, ε-eges, n mrker informtion to uniquely eompose G to G n G 2 suh tht G G 2 G hols. We will write this eomposition s eomp G G 2, n pplying it to G will give (G, G 2). Seon, kwr evlution of struturl reursion re(e) is reue to tht of its oy e (followe y result gluing), euse of the ulk semntis of struturl reursion. Bkwr evlution gretly epens on wht uptes re llowe on the view. We llow the following three generl uptes on our ege-lele grphs: () in-ple uptes s moifition of ege lels, (2) eletion of eges, n (3) insertion of eges or sugrph roote t noe. An we ept sequene of these uptes on the view n reflet them to the soure. In the rest of this setion, we shll explin the respetive kwr evlution for these uptes on views. 5. Refletion of In-ple Uptes In this setion, we formlly efine kwr semntis for UnCAL, where only in-ple uptes re onsiere. Rell tht kwr semntis B[[e](ρ, G ) is use to ompute new environment from the originl input environment ρ n the moifie view G. Like forwr semntis, kwr semntis n e efine inutively over the onstrution of expression. 5.. Bkwr Evlution of Simple Expressions Grph Construtor Expressions. Sine eh onstrutor is revertile n is ssoite with eomposition funtion, we n eompose the views of onstrutor expressions so s to efine the kwr semntis inutively. For exmple, we hve B[[(e e 2 ) p ]](ρ, G ) = B [e ]](ρ, G ) ρ B [e 2 ](ρ, G 2) where G = F [e ]]ρ G 2 = F [e 2]]ρ (G, G 2) = eomp G G 2 (G ) Unlike Foster et l. (2005), we hve vrile ining, n therefore multiple environments proue y kwr evlution of the operns re merge y ρ efine elow, using n pproh similr to tht in Liu et l. (2007), whih els with vrile G (V,E,I,O ) G 2(V2,E 2,I 2,O 2 ), the ext equivlene of two grphs, is efine y V = V 2 E = E 2 I = I 2 O = O 2. It woul e more preise to write it s eomp G,,G 2 in tht the eomposition epens on three rguments. inings. (ρ ρ ρ 2 ) = ($v mg(g, G ($v G ) ρ,, G 2 ) ($v G) ρ, ($v G 2) ρ 2 G if G 2 = G G = G 2 where mg(g, G, G 2 ) = G 2 if G = G FAIL otherwise ρ unifies eh ining y mg. If only the ining on the left hn sie is moifie (G 2 = G), or oth re onsistently upte (G = G 2), then the ining on the left is opte, n vie vers. If oth re upte to ifferent vlues, it fils, leing to the filure of the entire kwr evlution. Lel vrile inings re trete similrly. We hve omite the efinitions for other onstrutor expressions, whih n e efine similrly. Vrile. A vrile simply uptes its ining s B[[$v]](ρ, G ) = ρ[$v G ]. Here, ρ[$v G ] is n revition for (ρ \ {$v G }. Conition. }) {$v The kwr evlution of onition is efine y B[[if l = l 2 then e else e 2 ]](ρ, G ) ρ if l ρ = l 2ρ l ρ = l 2ρ = ρ 2 if l ρ l 2ρ l ρ 2 l 2ρ 2 FAIL otherwise where ρ = B[[e ]](ρ, G ) ρ 2 = B[[e 2]](ρ, G ), whih is reue to the kwr evlution of e if l = l 2 hols, n to the kwr evlution of e 2 otherwise. To gurntee well-ehveness, we ensure tht l = l 2 oes not hnge fter kwr evlution. 5..2 Bkwr Evlution of Struturl Reursion Due to the trele ulk forwr evlution of struturl reursion re n the ε-mrker preserving property tht retins similrity in shpe etween input n output grphs, kwr semntis n esily e efine s B[[re(λ($l, $g). e )(e )]](ρ, G ) = merge(ρ, e, E, w ehege(g, ρ, e, eomp re (G, E ))) where G = (, E,, ) = F[[e ]]ρ This efinition is esy to unerstn if we note ulity with the efinition of its forwr semntis. Bkwr semntis first eomposes through eomp re the moifie result grph G into piees of grphs, whih is intuitively n inverse opertion of ompose re.

ζ E, lel(ζ) ε, V eomp re ((V, E, I, O ), E ) = (ζ, (V ζ, E ζ, I ζ, O ζ )) ζ = {w (ReE p w ζ) V }, E ζ = {(w,, w 2 ) (ReE p w ζ,, ReE p w 2 ζ) E }, I ζ = {(&m, w) (ReN p v &m, ε, ReE p w ζ) E }, O ζ = {(w, &m) (ReE p w ζ, ε, ReN p v &m) E } { } w ehege(g, ρ, e, G ) = (ζ, B[[e]](ρ ζ, G ζ )) (ζ, G ζ ) G, ρ ζ = ρ {$l lel(ζ), $g sugrph(g, ζ)} merge(ρ, e, E, R) = B[[e ]](ρ, G { } ) ρ ρ ζ \ {$l } \ {$g } (ζ, ρ ζ ) R ( where G = V ζ, E eps ) E ζ, I, O E eps = {(u, ( ε, v) (u, ε, v) E } ) (V ζ, E ζ ) = V ζ {u}, E ζ {(u, ρ ζ ($l), I ζ (&))} for eh (ζ, ρ ζ ) R, letting (u,, ) = ζ n (V ζ, E ζ, I ζ, O ζ ) = ρ ζ ($g) Figure 7. Core of Bkwr Semntis of re t Coe Position p For every non-ε ege ζ E in the soure rgument grph, the eomposition extrts (possily moifie) suprt G ζ of G, whih origintes t the result G ζ of the forwr omputtion on the ege. Then, in w ehege, we rry out kwr omputtion of the oy expression e on eh ege n ompute the upte environment ρ ζ. Finlly, these environments re merge into the upte environment ρ of the whole expression. The merge funtion oes two piees of work. First, y omining the informtion ρ ζ($l) n ρ ζ($g) from the upte environments (n ε-eges existing in the eges E of the soure rgument grph), it omputes the moifie rgument grph G. Then, we inutively rry out kwr evlution on the rgument expression e to otin nother upte environment ρ. This ρ n ll ρ ζs re merge into ρ. Let us explin in more etil the efinition of eomp re, whih is the key point of the kwr evlution. The funtion first extrts from result grph G noes V ζ n eges E ζ tht elong to eh ege ζ y mthing tre ID ReE p ζ. Note tht if there re noes tht hve een freshly inserte into the view, we lso require these noes to hve this struture, so tht these noes re lso psse to the kwr evlution of the reursion oy. Input n output noes with mrker &m re reovere y seleting those pointe from/to hu noes hving struture ReN &m. Top-level onstrutors of tre ID re erse so tht we n inutively ompute the kwr imge from the oy expression. Exmple 7. Rell the simple exmple in Exmple 3 where the soure is s = 2, n 2 x(s) gives the grph G. If the grph G is moifie to G where the ege lel is upte to X, then B[[2 x]]({$ s}, G ) returns ining {$ s } X where s = 2. Therefore, the in-ple upte of the hnge on the view grph is reflete to the soure. Lemm 2 (Well-ehveness for In-ple Uptes). If output grphs re moifie y in-ple uptes on eges, then for ny expression e, the two evlutions F[[e] n B [e](, ) form well-ehve iiretionl trnsformtion, if they suee. Proof. This sttement n e prove y inution on the struture of e. For the se se where e is vrile, it lerly hols. Consiering the inutive se, () if e is onstrutor expression, it hols euse eh onstrutor is revertile within our ontext, (2) if e is onition, its kwr evlution is reue to tht on either its true rnh or its flse rnh, so the sttement hols y inution, n (3) if e is struturl reursion, y ulk semntis, its kwr omputtion is reue to its oy expression, so the sttement hols y inution. 5.2 Refletion of Deletion Deletion in view is reflete s eletion of the orresponing prt in the soure y using tre IDs. Suppose we wnt to elete the ege lele in the view of Exmple 7. Sine oth enpoints of the ege hve tre IDs of the form ReE 7 (,, 2), we n see tht the selete ege hs een generte ue to the existene of the soure ege (,, 2), whih is the orresponing prt to e elete in the soure. In generl, for lele ege ζ = (u,, v) with ε, its orresponing ege orr(ζ) is efine s: orr((u,, v)) = (u,, v) if u, v SrID orr((ree p u ζ {,, ReE p v ζ )) orr((u,, v)) if orr((u,, v)) FAIL = orr(ζ ) if orr((u,, v)) = FAIL orr(ζ) = FAIL otherwise. Here, FAIL mens filure on fining the orresponing ege. The first se mens tht if the ege ζ is opy of n ege in the soure, then ζ itself is the orresponing ege. The seon n the thir ses re for when ζ is result of some struturl reursion. Aoring to the forwr semntis of re in Figure 6, the non-ε ege ζ must hve the form (ReE p u ζ,, ReE p v ζ ) for some p, u, v, n nother non-ε ege ζ. This mens tht ζ onsists of n ege (u,, v) originting from n evlution of reursion-oy t ζ. Hene, for this se, we first reursively tre the orresponing soure of (u,, v), n if this fils, then try tht of ζ. In other ses, orr fils to fin the orresponing soure, euse it must e the se tht u hs tre ID of the form Coe, mening tht the ege is not erive from the soure ut from n UnCAL expression. Let $ e the soure grph, G view e the view proue y F[[e]]ρ from forwr omputtion of expression e with environment ρ, n G view e grph from G view with set of eges D out = {ζ,..., ζ n } remove. Our kwr evlution B[[e]](ρ, G view) onsists of the following three steps.. Compute the set of soure eges D in = {orr(ζ i ) ζ i is not n ε-ege}. 2. If FAIL D in, kwr evlution fils. If it is otine suessfully without filure, ompute G sr = ρ($) D in, where G E enotes removl of the eges in the set E from grph G. 3. Return ρ = ρ[$ G sr] s the result if F[[e]]ρ = G view, n fil otherwise.

Lemm 3 (Well-ehveness for Deletion). If output grphs re moifie y ege eletion, then for ny expression e, the two evlutions F[[e]] n B[[e](, ) form well-ehve iiretionl trnsformtion, if they suee. Proof. The (GETPUT) property is ler euse of the ft tht D in = if D out =. For the (WPUTGET) property, it hols euse the thir step tully oes this hek. 5.3 Refletion of Insertion Refletion of insertion is muh more omplite thn tht of inple-upting n eletion. This is euse there re no orresponing eges in the soure for the freshly inserte eges in the view, whih requires us not only to rete new informtion ut lso to it to proper lotion in the soure grph. Our ie ws to use the Universl Resolving Algorithm (URA) (Armov n Glük 2002), powerful metho of inversion omputtion, to erive right inverse of the forwr evlution, n use the istriutive property of struturl reursion re(e)($g $g 2 ) = re(e)($g ) re(e)($g 2 ) to properly reflet insertion to the soure. In this setion, we shll give our lgorithm for this refletion, efore we highlight how URA n e use to erive the right inverse. 5.3. Insertion Refletion with Right Inverse We ssume the monotoniity of insertion in tht n insertion on the view is trnslte to n insertion on the soure rther thn other upting opertions. The monotoniity omes from the sene of isempty (Bunemn et l. 2000) in our ore UnCAL. We only onsier insertion on the view grph proue y forwr omputtion of vrile expression or struturl reursion. For the se of vrile, this refletion is one in the sme wy s in Setion 5... Insertion for struturl reursion, the si omputtion unit in Un- CAL, nees to e refully esigne. In the following, we will fous on struturl reursion, omitting other ses for simpliity. Before giving our refletion lgorithm, we shoul lrify the mening of right inverse. In generl, funtion h is si to e right inverse of f if for ny x in the rnge of f, f(h(x)) = x hols. Within our ontext, for n expression e n grph G, F [[e]](g) is si to e right inverse omputtion if it returns ρ suh tht F[[e]]ρ = G. Now, we will return to our refletion lgorithm. Let G sr e the soure grph, G view = F [re(e)($)]ρ, where ρ = {$ G sr }, n G view e grph from G with new eges inserte. Notie tht it is suffiient to onsier $ s the rgument of re, euse $ n e oun to other expression. Our kwr evlution B[[re(e)($)](ρ, G view) returns ρ s the result if there re no new eges inserte in G view ; otherwise, it oes the following:. Extrt the inserte sugrph G from G view suh tht G view = G view G. 2. Compute with right inverse omputtion: ρ = F [[re(e)($)]](g ). 3. Return ρ 2 = {$ G sr ρ ($)} s the result. The first step of extrtion is possile provie tht insertion hppens t the root noe. The seon step of right inverse omputtion will e expline in Setion 5.3.3. The lst step is to upte Insertions to non-root positions re possile ue to ulk semntis tht llows similr tretment for every noe. the ining of $ n return this environment s our result. The following lemm shows the orretness of the lgorithm. Lemm 4 (Well-ehveness for Insertion). If output grphs re moifie y ege insertion, then for struturl reursion of the form re(e)($) where e ontins no free vriles, then two evlutions F[[e]] n B[[e]](, ) form well-ehve iiretionl trnsformtion, if they suee. Proof. First, the (GETPUT) property lerly hols euse ρ is returne when no insertions our. Next, we prove the (WPUTGET) property y using the following lultion. F[[re(e)($)]]ρ 2 = { prtil pplition } F[[re(e)(ρ 2($))]]ρ 2 = { ef. of ρ 2 } F[[re(e)(G sr ρ ($))]]ρ 2 = { struturl reursion property } F[[re(e)(G sr ) re(e)(ρ ($)))]]ρ 2 = { forwr evlution } F[[re(e)(G sr )]]ρ 2 F[[re(e)(ρ ($)))]ρ 2 = { e oes not ontin free vrile } G view F[[re(e)($)]]ρ = { right inversion } G view G It is worth noting tht we hve simplifie our isussion in oth the ove lgorithm n lemm y mking it requirement tht e in re(e)($) oes not ontin ny free vriles. With this requirement, our forwr n kwr evlution stisfies the stronger (PUTGET) property. In ft, it is eptle to relx this onition y llowing e to ontin other free vriles n the initil ρ ontins ining of other vriles. Then, right inversion will proue ρ tht will e use to upte ll vrile inings in ition to $. In this se, F[[re(e)(G sr )]]ρ my proue grph tht is ifferent from the originl view G view. In ny se, this ifferent grph will not hve n itionl effet on the soure when we pply kwr evlution to this new grph. Therefore, (WPUTGET) lwys hols. With this ie, we shll propose n lgorithm in whih (PUTGET) property is stisfie without ny itionl requirements. The ie is to utilize the Tre ID informtion, s will e isusse lter. 5.3.2 Improving Insertion Refletion The metho ove stisfies the (PUTGET) property only if the vriles of e re isjoint from the vriles oun in the initil environment ρ. However, in generl, sine trnsformtion my hve multiple vrile referenes, more effort is require to hieve the (PUTGET) property. We tkle the prolem y first loting where we insert grph y using tre IDs, n then pplying the URA lgorithm (to e esrie lter) to fin wht grph shoul e inserte. Consier the trnsformtion 2 x n the view in Exmple 6. Suppose we wnt to insert grph G vins roote t the view noe v = ReN 7 2 &. Where shoul some grph e inserte into the soure to reflet this insertion? The nswer is tht we must insert grph roote t the soure noe 2 euse there woul e no ege from v in the view unless there were n ege from 2 in the soure oring to the ulk semntis of struturl reursion. Now, our next tsk is to fin wht grph shoul e inserte uner the soure

noe 2. Tht is, we hope to fin G sins suh tht the following hols. ( ) 2 x 2 G sins ReN 7 & ReE 7 (Coe 4) (,, 2) = ReE 7 (Coe 3) (,, 2) ReN 7 2 & ReE 7 (Coe 2) (,, 2) ReE 7 (Coe ) (,, 2) G vins URA n help us to fin suh G sins for G vins. For exmple, if G vins is { : {}}, then URA returns G sins = { : {}}. If G vins is { : {}}, then URA returns one of the possiilities, G sins = { : {}} or G sins = { : {}}, epening on the serh metho use in URA. Aoring to the sounness n the ompleteness of URA, the refletion y URA is lwys orret in the sense tht (PUTGET) hols, n moreover URA lwys returns G sins if suh G sins exists. Of these, sounness is the key to insertion refletion stisfying (PUTGET) for generl UnCAL trnsformtions. In summry, our insertion-refletion lgorithm is s follows.. Let v e noe uner whih we wnt to insert grph G vins. 2. By using the tr funtion in Figure 8, we fin the soure noe u = tr(v) uner whih we insert grph to reflet the insertion. 3. Let G view e grph otine from the view y ing ε-ege from v to G vins. 4. We fin grph G sins onnete from u y n ε-ege, y pplying URA for G view. 5. We return grph G sr otine from the soure y ing n ε-ege from u to G sins. The sounness of the insertion-refletion lgorithm is iretly erive from the sounness of URA. Lemm 5 (Sounness of Insertion). Our insertion-refletion lgorithm stisfies (PUTGET). Note tht we use URA for G view inste of G vins. Thus, URA rejets ny insertion of G sins tht violtes (PUTGET). In ition, our insertion-refletion lgorithm is omplete in the sense tht, if there exist some soure insertions to reflet the view insertion uner some onitions, the lgorithm will fin one of them. Lemm 6 (Completeness of Insertion). Let v e noe suh tht tr(v) FAIL. For ny soure grph G, we n insert ny grph into its view if there exists soure insertion tht reflets the view insertion n v still ours in the view of the insertion-reflete soure. Rell tht we only onsier insertion on the view grph proue y forwr omputtion of vrile expression or struturl reursion, whih is expresse y tr(v) FAIL. This lemm n e prove using the property of tre IDs stting tht, to insert grph roote t view noe v, we must insert grph roote t soure noe tr(v). By inution on the tre ID of v, we n show tht, if there is n ege from v, it must e the se tht there is n ege from tr(v), whih is implie y the property of tre IDs. Note tht G vins hs no ege to the originl view. However, this is not restrition sine if there is rossing ege pointing to sugrph of the originl view, we n uplite the sugrph n integrte it to G vins so tht the ege n e eliminte. tr(srid) = SrID tr(ren v ) = tr(v) tr(coe ) = FAIL tr(ree v ) = tr(v) Figure 8. Tring Noe ID 5.3.3 Right Inverse Computtion y URA Rell tht the right inverse omputtion of n expression e is to tke grph G view n return ρ suh tht F[[e]]ρ = G view. We opt the universl resolving lgorithm (URA) (Armov n Glük 2002), powerful n generl inversion mehnism, to ompute ρ. The si ie ehin URA is to serh on perfet proess tree (Glük n Klimov 993), whih represents ll possile omputtions of n expression, n to fin omputtion pth tht proue the result. Our right inverse omputtion onsists of three steps.. It lzily enumertes possile evlution pths y symoli omputtion lle neee nrrowing (Antoy et l. 994). 2. From the generte evlution pths, it onstruts tle of input/output pirs of omputtions. 3. If there is pir in the tle whose output is G view, it genertes sustitution (environment) from the pth n returns it s the result. Exmple 8. As simple exmple, let us see how we fin ρ suh tht F[[2 x($x)]]ρ = G view where G view = { : {}}. We serh ρ y symoli evlution of 2 x($x). To evlute 2 x($x), we unfol $x n reursively evlute 2 x, i.e., struturl reursion. There re mny wys to instntite $x suh s $x {}, $x {$l : $x }, $x {$l : $x, $l 2 : $x 2}. If we hoose $x {}, the omputtion finishes, yieling tle onsisting of n input/output pir ({}, {}). Sine this tle oes not ontin pir whose output is G view, we ontinue serhing. Assume tht we hoose $x {$l : $x }. Then 2 x($x) is unfole to (if $l = then { : &} else (if $l = then {ε : &} else {$l : &})) @ 2 x($x ). As evlution gets stuk here euse of free vrile $l in the if onition, we fin suitle $l to resume the evlution. If we hoose $l, then the expression is reue to { : &} @ 2 x($x ) n input/output pir ({ : {}}, { : {}}) is otine y hoosing $x {}. Sine G view = { : {}}, we gther ll inings long this omputtion n return the following environment s the result. {$x { : {}}} Figure 9 shows prt of perfet proess tree in our right-inverse omputtion: the left is the tree n the right is tle of pir of input/output grph templtes (it is more generl thn pir of input/output grph instnes, s we isusse ove). Note this tree is vrint of SLD-resolution trees (Glük n Sørensen 994). To use URA effetively for our right inverse omputtion of UnCAL, we efine smll-step semntis for UnCAL suh tht perfet proess tree n e onstrute though these smll steps. The only non-stnr feture of this semntis is tht we use memoiztion to voi infinite loops proly use y yles in the soure grph (See Appenix of (Hik et l. 200) for etils). In ition, we provie Dijkstr-serhing strtegy to enumerte ll the possile evlution pths so tht solution n lwys e The sme notion is lle riving (Glük n Klimov 993; Glük n Sørensen 994) in (Armov n Glük 2002).