Validating XML Documents in the Streaming Model with External Memory

Size: px
Start display at page:

Download "Validating XML Documents in the Streaming Model with External Memory"

Transcription

1 Vlidting XML Douments in the Steming Model with Extenl Memoy Chistin Kond LIAFA, Univ. Pis Dideot; Pis, Fne; nd Univ. Pis-Sud; Osy, Fne. Fédéi Mgniez LIAFA, Univ. Pis Dideot, CNRS; Pis, Fne. ABSTRACT We study the poblem of vlidting XML douments of size N ginst genel DTDs in the ontext of steming lgoithms. The stting point of this wok is well-known spe lowe bound. Thee e XML douments nd DTDs fo whih p-pss steming lgoithms equie Ω(N/p) spe. We show tht when llowing ess to extenl memoy, thee is deteministi steming lgoithm tht solves this poblem with memoy spe O(log 2 N), onstnt numbe of uxiliy ed/wite stems, nd O(log N) totl numbe of psses on the XML doument nd uxiliy stems. An impotnt intemedite step of this lgoithm is the omputtion of the Fist-Child-Next-Sibling (FCNS) enoding of the initil XML doument in steming fshion. We study this poblem independently, nd we lso povide memoy effiient steming lgoithms fo deoding n XML doument given in its FCNS enoding. Futhemoe, vlidting XML douments enoding biny tees in the usul steming model without extenl memoy n be done with subline memoy. Thee is one-pss lgoithm using O( N log N) spe, nd bidietionl twopss lgoithm using O(log 2 N) spe pefoming this tsk. Ctegoies nd Subjet Desiptos F.2.2 [Theoy of Computtion]: Anlysis of lgoithms nd poblem omplexity Nonnumeil Algoithms nd Poblems Genel Tems Algoithms, Theoy 1. INTRODUCTION Suppoted by the Fenh ANR SeSu nd Defis pogms unde ontts ANR-07-SESU-013 (VERAP pojet) nd ANR-08-EMER-012 (QRAC pojet). Chistin Kond is suppoted by Fondtion CFM-JP Aguil gnt. Pemission to mke digitl o hd opies of ll o pt of this wok fo pesonl o lssoom use is gnted without fee povided tht opies e not mde o distibuted fo pofit o ommeil dvntge nd tht opies be this notie nd the full ittion on the fist pge. To opy othewise, to epublish, to post on seves o to edistibute to lists, equies pio speifi pemission nd/o fee. ICDT 2012, Mh 26 30, 2012, Belin, Gemny. Copyight 2012 ACM /12/03...$10.00 The e of steming lgoithms hs expeiened temendous gowth ove the lst dede in mny pplitions. Steming lgoithms sequentilly sn the whole input piee by piee in one pss, o in smll numbe of psses (i.e., they do not hve ndom ess to the input), while using subline memoy spe, idelly polylogithmi in the size of the input. The design of steming lgoithms is motivted by the explosion in the size of the dt tht lgoithms e lled upon to poess in eveydy el-time pplitions. Exmples of suh pplitions ou in bioinfomtis fo genome deoding, in Web dtbses fo the seh of douments, o in netwok monitoing. The nlysis of Intenet tffi [1], in whih tffi logs e queied, ws one of the fist pplitions of this kind of lgoithm. Thee e vious extensions of this bsi steming model. One of them gives the steming lgoithm ess to n extenl memoy onsisting of sevel ed/wite stems [8, 10, 6]. Then the steming lgoithm is lso elxed to pefom multiple psses in ny dietion ove the input stem nd the uxiliy stems. In most of the pplitions, the numbe of uxiliy stems is onstnt nd the totl numbe of psses is logithmi in the input size. Veifying popeties o evluting queies of mssive dtbses is n tive nd hllenging topi. Fo eltionl lgeb queies ginst eltionl dtbses, the sitution is quite le. Thee e bidietionl O(log N)-pss deteministi steming lgoithms with onstnt memoy spe nd onstnt numbe of uxiliy stems [7]. Moeove, the logithmi numbe of psses is neessy ondition in ode to keep the memoy spe subline, even if ndomiztion is llowed. The ltte ws initilly stted fo one-sided eo [7] nd then extended to two-sided eo [4, 3]. In the ontext of dt exhnge, espeilly on the Web, Extended Mkup Lnguge (XML) is emeging s the stndd, nd is uently dwing muh ttention in dt mngement eseh. Only few is known on XML quey poessing when only steming ess is llowed to the XML doument. Fo evluting XQuey nd XPth queies ginst XML douments of size N, only the lowe bound hs been extended [7, 4, 3], mening tht Ω(log N) psses e neessy. Fo the uppe bound, only simple efinements of the diet lgoithm e known: no uxiliy stem, one pss nd line memoy in the height of the XML doument, whih in the wost se is s lge s N. This ppe onsides the poblem of vlidting XML douments ginst given Doument Type Definition (DTD) in steming fshion without estitions on the DTD. Pio

2 woks on tht topi [16, 15] essentilly ty to hteize those DTDs fo whih vlidity n be heked by finitestte utomton, tht is one-pss deteministi steming lgoithm with onstnt memoy. Conening bity DTDs, two ppohes hve been onsideed in [16]. The fist one leds to n lgoithm with memoy spe line in the height of the XML doument [16]. The seond one onsists in onstuting efined DTD of t most qudti size, whih defines simil fmily of tee douments s the oiginl one, nd ginst whih vlidtion n be done with onstnt spe. Nonetheless, fo n existing doument nd DTD, the lte equies tht both, douments nd DTD, e onveted befoe vlidtion. One of the obstles pio woks hd to ope with ws to hek well-fomedness of XML douments, tht is evey opening tg mthes its sme-level losing tg. Due to the pst wok of [12], we n now pefom suh veifition with onstnt-pss ndomized steming lgoithm with subline memoy spe nd no uxiliy stems. In onepss the memoy spe is O( N log N), nd ollpses to O(log 2 N) with n dditionl pss in evese dietion. The stting point of this wok is the ft tht heking vlidity is hd without uxiliy stems. Thee e DTDs defining teny XML douments fo whih ny p-pss bidietionl ndomized steming lgoithm equies Ω(N/p) spe. This lowe bound omes fom enoding well known ommunition omplexity poblem, Set-Disjointness, s n XML vlidity poblem. This lowe bound should be wellknown, howeve we e not we of omplete poof in the litetue. In [9], simil ppoh using teny tees with edution to Set-Disjointness is used fo poving lowe bounds fo queies. Fo the ske of ompleteness we povide poof in Appendix A. An XML doument is vlid ginst DTD if fo eh node, the sequene of the lbels of thei hilden fulfills egul expession defined in the DTD. Fo the se of XML douments enoding biny tees, we pesent in Setion 3 two deteministi steming lgoithms fo heking vlidity with subline spe. As onsequene, the pesene of nodes of degee t lest 3 is indeed neessy ondition fo the line spe lowe bound fo genel douments. We fist show how to design one-pss lgoithm with spe O( N log N) (Theoem 1). We onjetue tht thee is Ω(N α ) lowe bound fo one-pss lgoithms fo some 1 3 α 1. With seond pss in evese dietion the memoy 2 ollpses to O(log 2 N) (Theoem 2). These two lgoithms mke use of the simple, but fundmentl ft tht in one pss ove n XML doument eh node is seen twie in fom of its opening nd losing tg. Hene, it is not neessy to emembe ll opening tgs in the stem sine thee is seond hne to get the sme infomtion by thei losing tgs. Ou lgoithms exploit this obsevtion. Then, in Setion 4 we pesent ou min esult. Coolly 1 sttes tht vlidity of ny XML doument ginst ny DTD n be heked in the steming model with extenl memoy with poly-logithmi spe, onstnt numbe of uxiliy stems, nd O(log N) psses ove these stems. Vlidity of node depends on its hilden, hene is uil to hve esy ess to the sequene of hilden of ny node. The fundmentl ide to estblish this is, fistly, to ompute the Fist-Child-Next-Sibling (FCNS) enoding, n enoding s 2-nked tee of the XML doument. In this enoding, the sequene of losing tgs of the hilden of node e onseutive. The omputtion of this enoding is the hd pt of the vlidtion poess, nd the esoue equiements of ou vlidtion lgoithm stem fom this opetion (Theoem 3). Sine the FCNS enoding n be seen s eodeing of the tgs of the oiginl doument, ou sttegy is to see this poblem s soting poblem with ptiul ompison funtion. Mege sot n be implemented s steming lgoithm, nd we mke use of it ustomized by n dpted mege funtion. The sme ide n be used fo deoding with simil omplexity (Theoem 7). Then, bsed on the FCNS enoding, veifition n be done eithe in one pss nd O( N log N) spe (Theoem 4), o in two bidietionl psses nd O(log 2 N) spe (Theoem 5). Conening FCNS enoding nd deoding, we show line spe lowe bound fo one-pss lgoithms. Fo deoding, we pesent O( N log N) lgoithm (Theoem 6) tht pefoms one pss ove the input, but two psses ove the output. We onjetue fo enoding tht memoy spe emins Ω(N) fte ny onstnt numbe of psses, whih would show tht deoding is esie thn enoding. This suggests systemti use of the FCNS enoding fo lge douments sine vlidity n be heked esily without uxiliy stems nd in subline spe. Fo use intetions, the oiginl doument n be obtined by the subline spe 3-pss lgoithm. The pplibility of this ide is left s n open question. 2. PRELIMINARIES Fom now Σ is finite lphbet. The k-th lette of X Σ N is denoted by X[k], fo 1 k N, nd the onseutive lettes of X between positions i nd j by X[i, j]. A subsequene of X is ny sting X[i 1]X[i 2] X[i k ], whee 1 i 1 < i 2 <... < i k N. 2.1 Steming model In steming lgoithms, pss ove input X Σ N mens tht X is given s input stem X[1], X[2],, X[N], whih ives sequentilly, i.e., lette by lette in this ode. Steming lgoithms hve ess to ndom ess memoy spe, nd, s the se my be, to ed-wite extenl memoy s in [7, 5]. See lso the eview in [8]. We ssume tht ny lette of Σ fits into one ell of intenl/extenl memoy. The extenl memoy is olletion of uxiliy stems, tht we see s ed/wite stems with, gin, sequentil ess. When needed, we ugment the lphbet of uxiliy stems fom Σ by k-tuples of elements in Σ [0, 2N], fo some fixed onstnt k, whih theefoe fit in one ell of uxiliy stems. At the beginning of eh pss on ed/wite stem, the lgoithm deides whethe it pefoms ed o wite pss. The input stem is ed-only. On witing pss, the lgoithm n eithe wite lette, nd then move to the next ell, o move dietly to the next ell. Fo the se of bidietionl steming lgoithms, opposed to unidietionl steming lgoithm whee eh pss is in the sme ode, the lgoithm n deide the dietion of the sequentil ess. Fo simpliity, we ssume thoughout this tile tht the length of the input is known in dvne by the lgoithm. Nonetheless, ll ou lgoithms n be dpted to the se in whih the length is unknown until the end of pss. See [13] fo n intodution to steming lgoithms.

3 Definition 1 (Steming lgoithm). A p(n)- pss steming lgoithm A with s(n) spe, k(n) uxiliy stems, t(n) poessing time pe lette is n lgoithm suh tht fo evey input stem X Σ N : 1. A hs ess to k(n) uxiliy ed/wite stems, 2. A pefoms in totl t most p(n) psses on X nd uxiliy stems, 3. A mintins memoy spe of size s(n) lettes of Σ nd bits while eding X nd uxiliy stems, 4. A does not exeed unning time of t(n) between two wite o ed opetions. We sy tht A is bidietionl if it pefoms t lest one pss in eh dietion. Othewise A is impliitly unidietionl. We do not mention the numbe of uxiliy stems when thee e none (k(n) = 0). Futhemoe, we ssume tht opetions on numbes N [0, 2N] n be done in onstnt time. 2.2 XML douments We onside finite unnked odeed lbeled tees t, whee eh tee node is lbeled by some lbel in Σ, nd its oot hs distinguished lbel. Moeove, the hilden of evey non-lef node e odeed. Fom now, we omit the tems odeed nd lbeled. Then k-nked tees e speil se whee eh node hs t most k hilden. Biny tees e speil type of 2-nked tees, whee eh node is eithe lef o hs extly 2 hilden. Fo eh lbel Σ, we ssoite its oesponding opening tg nd losing tg, stnding fo nd / in the usul XML nottions. An XML sequene is sequene ove the lphbet Σ = {, : Σ}. The XML sequene of tee t is the sequene of opening tgs nd losing tgs in the ode of depth fist tvesl of t (Figue 1): when t step i we visit node with lbel top-down (espetively bottom-up), we let X[i] = (espetively X[i] = ). Hene X is wod ove Σ = {, : Σ} of size twie the numbe of nodes of t. The XML file desibing t is unique, nd we denote it s XML(t). b b b Figue 1: Let Σ = {, b, }, nd let t be the tee s bove. Then XML(t) = bbbbbb. We ssume tht the input XML sequenes X e wellfomed, nmely X = XML(t), fo some tee t. The pst wok of [12] legitimtes this ssumption sine heking wellfomedness is t lest s esy s ny of ou lgoithms fo heking vlidity. Hene we ould un n lgoithm fo wellfomedness in pllel without inesing the esoue equiements. Note, tht ndomness is neessy fo heking well-fomedness with subline spe, whees we will show tht ndomness is useless fo vlidtion. Let us intodue moe useful nottions. Sine the length of well-fomed XML sequene is known in dvne, we will denote it by 2N insted of N. Eh opening tg X[i] nd mthing losing tg X[j] in X = XML(t) oesponds to unique tee node v of t. We sometimes denote v eithe by X[i] o X[j]. We lso wite (mbiguously) v fo its oesponding opening tg, nd v fo its oesponding losing tg. Then, the position of v in X is pos(v) = i. Similly, pos(v) = j. We onside XML vlidity ginst some DTD. A DTD is mpping D fom Σ to egul expessions ove Σ. Let t be tee. Then node v t with lbel v nd hilden v 1, v 2,, v k with espetive lbels v 1, v 2,, v k is vlid ginst D if v 1, v 2,, v k stisfies the egul expession D(v). In ptiul, v n be lef if nd only if the empty wod ε stisfies the egul expession D(v). Then t is vlid ginst D if ll its nodes e vlid ginst D. Thoughout the doument we ssume tht DTDs e onsidebly smll nd ou lgoithms hve full ess to them without ounting this to thei spe equiements. Definition 2 (Vlidity). Let D be some DTD. The poblem Vlidity onsists of deiding whethe n input tee t given by its XML sequene XML(t) on n input stem is vlid ginst D. We denote by Vlidity(2) the poblem Vlidity estited to input XML sequenes desibing biny tees. 3. VALIDITY OF BINARY TREES Fo simpliity, we only onside biny tees in this setion. A left opening/losing tg (espetively ight opening/losing tg) of n XML sequene X is tg whose oesponding node is the fist hild of its pent (espetively seond hild). Ou lgoithms fo biny tees n be extended to 2- nked tees. This equies few hnges in the one-pss Algoithm 1 nd the two-pss Algoithm 2 (indeed in the suboutine Algoithm 3), tht we do not desibe hee. We fix now DTD D, nd ssume tht, in ou lgoithms, we hve ess to poedue hek(, b, ) tht signlizes invlidity nd bots if b is not vlid ginst the egul expession D(). Othewise it etuns without ny tion. 3.1 One-pss lgoithm In ode to vlidte n XML doument, we ensue vlidity of ll tee nodes. Fo heking vlidity of node v with two hilden, we hve to elte 3 lbels, tht is the lbel v of the node itself, nd the lbels of the two hilden nodes v 1, v 2. In top-down veifition we use the opening tg v of the pent node v fo veifition, in bottom-up veifition we use the losing tg v of the pent node v. Algoithm 1 mkes use of the ft tht thee e these two hnes to veify node. It uses stk onto whih it pushes ll opening tgs in ode to pefom top-down veifitions one the infomtion of the hilden nodes ives on the stem. v 1v 2 foms substing of the input, hene top-down veifition equies only the stoge of the opening tg v sine the lbels of the hilden ive in blok. The lgoithm s spe equiements depend on pmete K (we optimize by setting K = N log N). One the numbe of opening tgs on the stk is bout to exeed K, we emove the bottom-most opening tg. The oesponding node will then be veified bottom-up. Note tht v 2v foms substing of the input. Hene fo bottom-up veifitions it is enough to stoe the lbel of the left hild v 1 on the stk sine the lbel of the ight hild ives in fom of losing tg ight befoe the losing tg of the pent node. See Algoithm 1 fo detils. Fo the unique identifition of losing tgs on the stk, we hve to stoe them with thei depth in the tee. A stk

4 item oesponding to losing tg equies hene O(log N) spe. Opening tgs don t equie the stoge of thei depth (we stoe depth of 1 whih we ssume to equie only onstnt spe). Algoithm 1 Vlidity of biny tees in 1-pss Requie: input stem is well-fomed XML doument 1: d 0, S empty stk 2: K N log N 3: while stem not empty do 4: x next tg on stem 5: if x is n opening tg then 6: if x is lef then hek(, ɛ, ɛ) end if 7: if S hs on top (, 1), (b, d) then 8: hek(, b, ); pop S {Top-down veifition} 9: end if 10: if {(, 1) S opening } K then 11: emove bottom-most (, 1) in S, opening 12: end if 13: d d : push (x, 1) 15: else if x is losing tg then 16: d d 1 17: if S hs on top (, d + 1), (b, d + 1) then 18: hek (,, b) {Bottom-up veifition} 19: pop S, pop S 20: else if S hs on top (b, d + 1) then pop S 21: end if 22: if S hs on top (, 1) then pop S end if 23: push (x, d) 24: end if 25: end while 4. A left losing tg is only emoved fom S upon veifition of its pent node. Lemm 1. Let S = (x 1, d 1), (x k, d k ) be the stk t the beginning of the while loop in line 3. Let ( i, d i), ( i+1, d i+1) be two onseutive left losing tgs in S suh tht ( i+1, d i+1) is not the topmost one. Then pos( i+1) pos( i) + 2K. Poof. Denote by X = X[1]X[2] X[2N] the input stem. Sine i+1 is not the topmost left losing tg in S, the lgoithm hs ledy poessed the ight sibling opening tg X[pos( i+1) + 1] of i+1. By Item 4 of Ft 1, no veifition hs been done of the pent of i+1, sine i+1 is still in S. Theefoe, the pent s opening tg X[k] of i+1 hs been deleted fom S, whee pos( i) < k < pos( i+1). This n only hppen if t lest K opening tgs hve been pushed on S between X[k] nd i+1. Sine these K opening tgs must hve been losed between X[k] nd i+1 we obtin pos( i+1) pos( i) + 2K. 1 2 k The quey in line 6 n be implemented by lookhed of 1 on the stem. The opening tg x oesponds to lef only if the subsequent tg in the stem is the oesponding losing tg x. Figue 2 visulizes the diffeent ses with thei stk modifitions ppeing in Algoithm 1. b 1 b 3 b l b 2 line 6 line 7 line 17 line 20 line 22 b b b X X Xb X Xb X Xb X X X Figue 2: Visuliztion of the diffeent onditions in Algoithm 1 with the pplied stk modifitions. X epesents the bottom pt of the stk. Note tht Algoithm 1 pushes the uently teted tg o on the stk in Line 14 o Line 23. o oesponds to the highlighted node. Ft 1 (not poved hee) nd Lemm 1 onen the stutue of the stk S used in Algoithm 1. Ft 1. Let S = (x 1, d 1), (x k, d k ) be the stk t the beginning of the while loop in line 3. Then: 1. pos(x 1) < pos(x 2) < pos(x k ), 2. depth(x 1) depth(x 2) depth(x k ) d. Moeove, if depth(x i) = depth(x i+1) then x i is the left sibling of x i+1, 3. The sequene x 1 x k stisfies the egul expession b (ɛ de), whee e left losing tgs, b e opening tgs, is losing tg, d is left losing tg, nd e is ight losing tg. Figue 3: Visuliztion of the stutue of the stk used in Algoithm 1. The stk fulfills the egul expession b (ɛ de), ompe Item 3 of Ft 1. The ( i ) i=1...k e losing tgs whose pents nodes wee not veified top-down. Fo j > i, j is onneted to i by the ight sibling of i. The (b i ) i=1...l fom sequene of opening tgs suh tht b i is the pent node of b i+1. On top of the stk might be one o two losing tgs depending on the uent stte of the veifition poess. Ft 1 nd Lemm 1 povide moe insight in the stk stutue nd e used in the poof of Theoem 1. Item 3 of Ft 1 sttes tht the stk bsilly onsists of sequene of left losing tgs whih e the left hilden tht e needed fo bottom-up veifitions of nodes tht ould not be veified top-down. This sequene is followed by sequene of opening tgs fo whih we still im top-down veifition. The poof of Lemm 1 explins the ft tht the two sequenes e stitly septed: left-losing tg v 1 only emins on the stk if t the moment of insetion thee e no opening tgs on the stk. Theoem 1. Algoithm 1 is one-pss steming lgoithm fo Vlidity(2) with spe O( N log N) nd O(1) poessing time pe lette. Poof. To pove oetness, we hve to ensue vlidity of ll nodes. Leves e oetly vlidted upon ivl of its opening tg in line 6. Conening non-lef nodes, fistly,

5 note tht ll losing tgs e pushed on S in line 23, in ptiul ll losing tgs of left hilden ppe on the stk. The lgoithm emoves left losing tgs only fte vlidtion of its pent node, no mtte whethe the veifition ws done top-down o bottom-up, ompe Item 4 of Ft 1. Emptiness of the stk fte the exeution of the lgoithm follows fom Item 2 of Ft 1 nd implies hene the vlidtion of ll non-lef nodes. Fo the spe bound, Line 10 guntees tht the numbe of opening tgs in S is lwys t most K. We bound the numbe of losing tgs on the stk by N +2. Item 3 of Ft 1 K sttes tht the stk ontins t most one ight losing tg. Fom Item 4 of Ft 1 we dedue tht S ompises t most N K +1 left losing tgs, sine the stem is of length 2N, nd the distne in the stem of two onseutive left losing tgs tht eside on S exept the top-most one is t lest 2K. A losing tg with depth (, d) Σ [N] equies O(log N) spe, n opening tg equies only onstnt spe. Hene the totl spe equiements e O(( N +2) log N +K) whih K is minimized fo K = N log N. Conening the poessing time pe lette, the lgoithm only pefoms onstnt numbe of lol stk opetions in one itetion of the while loop. Remk Algoithm 1 n be tuned into n lgoithm with spe omplexity O( D log D), whee D is the depth of the XML doument. If D is known befoehnd, it is enough to set K = D log D in line 2. If D is not known in dvne, we mke use of n uxiliy vible D stoing guess fo the doument depth. Initilly we set D = C, C > 0 some onstnt, we set K = D log D, nd we un Algoithm 1. Eh time d exeeds D, we double D, nd we updte K odingly. This guntees tht the numbe of opening tgs on the stk is limited by O( D log D). Sine we stted with too smll guess fo the doument depth, we my hve emoved opening tgs tht would hve emined on the stk if we hd hosen the depth oetly. This leds to futhe bottom-up veifitions, but no moe thn O( D/ log D) gunteeing O( D log D) spe. 3.2 Two-pss lgoithm The bidietionl two-pss Algoithm 2 uses suboutine tht heks in one-pss vlidity of ll nodes whose left subtee is t lest s lge s its ight subtee. Feeding into this suboutine the XML doument ed in evese dietion nd intepeting opening tgs s losing tgs nd vie ves, it heks vlidity of ll nodes whose ight subtee is t lest s lge s its left subtee. In this wy ll tee nodes get veified. The suboutine pefoms only heks in bottom-up fshion, tht is, the veifition of node v with hilden 1, 2 mkes use of the tgs 1 nd 2 (whih e djent in the XML doument nd hene esy to eognize) nd the losing tg of v. When 1, 2 ppes in the stem, 4-tuple onsisting of 1, 2, depth( 1) nd pos( 1) gets pushed on the stk. Upon ivl of v, depth( 1) is needed to identify 1, 2 s the hilden of v. pos( 1) is needed fo lening the stk: with the help of the pos vlues of the stk items, we identify stk items whose pents nodes hve lge ight subtees thn left subtees, nd these stk items get emoved fom the stk. In so doing, we guntee tht the stk size does not exeed log(n) elements whih is n exponentil impovement ove the one-pss lgoithm. Note tht the evese pss n be done independently of the fist one, nmely eventully in pllel. Algoithm 2 Two-pss lgoithm vlidting biny tees un Algoithm 3 eding the stem fom left to ight un Algoithm 3 eding the stem fom ight to left, whee opening tgs e intepeted s losing tgs, nd vie ves. Algoithm 3 Vlidting nodes with size(left subtee) size(ight subtee) 1: l 0; n 0; S empty stk 2: while stem not empty do 3: x next tg on stem (nd move stem to next tg) 4: y next tg on stem, without onsuming it yet 5: n n + 1 6: if x is n opening tg then 7: l l + 1 8: if y = then hek(, ɛ, ɛ) end if 9: else {x is losing tg } 10: l l 1 11: if S hs on top (,, l + 1, ) then 12: (, b,, ) pop fom S; hek(,, b) 13: end if 14: if y is n opening tg d then 15: push (, d, l, n) to S 16: end if 17: end if 18: while thee is s 1 = (,,, n 1 ) just below s 2 = (,,, n 2 ) in S with n n 2 > n 2 n 1 do 19: suppess s 2 fom S 20: end while 21: end while Figue 4 visulizes the diffeent ses in Algoithm 3. line 8 line 11 line 14 b d Figue 4: Visuliztion of the diffeent onditions in Algoithm 3. The inoming tg x oesponds to the highlighted node. We highlight some popeties onening the stk used in Algoithm 3. Ft 2. S in Algoithm 3 stisfies the following: 1. If ( 2, b 2, depth( 2), pos( 2)) is below ( 1, b 1, depth( 1), pos( 1)) in S, then pos( 2) < pos( 1), depth( 2) < depth( 1), nd 1, b 1 e in the subtee of b Conside l t the end of the while loop in line 20. Then thee e no stk elements (,, l, ) with l > l. Figue 5 illusttes the eltionship between two onseutive stk elements s disussed in Item 1 of Ft 2. Lemm 2. Algoithm 3 veifies ll nodes v whose left subtee is t lest s lge s its ight subtee. Poof. Let q be suh node. Let 1, b 1 be the hilden of q. Then it holds tht pos( 1) pos( 1) pos(b 1) pos(b 1), (1)

6 p 2 b 2 q 1 b 1 Stk S. ( 1, b 1, pos( 1), depth( 1)) ( 2, b 2, pos( 2), depth( 2)). n 1 1, we obtin tht n i 2i 1 n + 1, nd, in ptiul, n t 1 (n 1) + 1. Sine ll ni e integes, it holds 2 i 2 i n tht n t 1 n. Futhemoe, sine n t > n t 1, we obtin n log n+1 n + 1 whih is ontdition, sine the element t position n + 1 hs not yet been seen. Sine n 2N nd the size of stk element is in O(log n), Algoithm 3 uses spe O(log 2 N). This lso implies tht the while-loop t line 18 of Algoithm 3 n only be iteted O(log n) times duing the poessing of tg on the stem. The poessing time pe lette is then O(log N), sine we ssume tht opetions on the stk un in onstnt time. Figue 5: is the uent element unde onsidetion in Algoithm 3. 1, b 1 is in the subtee of b 2, ompe Item 1 of Ft 2.. sine the size of the left subtee of q is t lest s lge s the size of the ight subtee. Upon ivl of 1 Algoithm 3 pushes the 4-tuple t = ( 1, b 1, pos( 1), depth( 1)) onto the stk S. We hve to show tht t emins on the stk until the ivl of q. Moe peisely, we hve to show tht the ondition in line 18 is neve stisfied fo s 2 = t. Sine the lgoithm neve deletes the bottom-most stk item, we onside the se whee thee is stk item ( 2, b 2, pos( 2), depth( 2)) just below t. Item 1 of Ft 2 tells us tht 1, b 1 e in the subtee of b 2. Let be the uent tg unde onsidetion suh tht pos(b 1) < pos() < pos(q). The sitution is visulized in Figue 5. Aoding to the ondition of line 18, t gets emoved fom the stk if pos() pos( 1) > pos( 1) pos( 2). (2) Note tht the left side of Inequlity 2 is lowe bound on the size of the ight subtee of q. Futhemoe, the ight side of Inequlity 2 uppe bounds the size of the left subtee of q. Using pos() pos( 1) pos(b 1) pos(b 1) + 1 nd pos( 1) pos( 2) > pos( 1) pos( 1), Inequlity 2 ontdits Inequlity 1 whih shows tht t emins on the stk until the ivl of q. Item 2 of Ft 2 guntees tht thee is no othe stk element on top of t upon ivl of q. This guntees the veifition of node q nd poves the lemm. Theoem 2. Algoithm 2 is bidietionl two-pss steming lgoithm fo Vlidity(2) with spe O(log 2 N) nd O(log N) poessing time pe lette. Poof. To pove oetness of Algoithm 2, we ensue tht ll nodes get veified. By Lemm 2, in the fist pss, ll nodes with left subtee being t lest s lge s its ight subtee get veified. The seond pss ensues then veifition of nodes with ight subtee tht is t lest s lge s its left subtee. Next, we pove by ontdition tht fo ny uent vlue of vible n in Algoithm 3, the stk ontins t most log(n) elements. Assume tht thee is stk onfigution of size t log(n) + 1. Let (n 1, n 2, n t) be the sequene of the fouth pmetes of the stk elements. Sine these elements e not yet emoved, due to line 18 of Algoithm 3, it holds tht n n i n i n i 1, o equivlently n i 1/2(n + n i 1), fo ll 1 < i t. Sine 4. VALIDITY OF GENERAL TREES 4.1 Peption The FCNS enoding (see fo instne [14]) is n enoding of unnked tees s extended 2-nked tees, whee we distinguish left hild fom ight hild. This is n extension of odeed 2-nked tees, sine node my hve left hild but no ight hild, nd vie ves. We theefoe duplite the lbels Σ to L nd R, fo espetively left nd ight opening/losing tgs. The FCNS tee is obtined by keeping the sme set of tee nodes. The oot node of the unnked tee emins the oot in the FCNS tee, nd we nnotte it by defult left. The left hild of ny intenl node in the FCNS tee is the fist hild of this node in the unnked tee if it exists, othewise it does not hve left hild. The ight hild of node in the FCNS tee is the next sibling of this node in the unnked tee if it exists, othewise it does not hve ight hild. Fo tee t, we denote FCNS(t) the FCNS tee, nd XML(FCNS(t)) the XML sequene of the FCNS enoding of t. Insted of nnotting by left/ight, nothe wy to uniquely identify node s left o ight is to inset dummy leves with lbel. Fo tee t, we denote the biny vesion without nnottions nd insetion of leves by FCNS. The two epesenttions n be esily tnsfomed into eh othe. In this setion, we ompute the FCNS enoding with nnottions. In the next setion, we pesent lgoithms fo the vlidtion of the enoded fom tht mke use of the epesenttion using dummy leves. See Figue 6 fo n exmple. b b b b Figue 6: Left: intodutoy exmple tee t ledy shown in Figue 1. Middle: FCNS enoding of t: XML(FCNS(t)) = L b L L R R R R L b R b R L R R L R R b R b R b L L. Right: FCNS enoding of t: XML(FCNS (t)) = b b b bbb. In the following subsetions we povide steming lgoithms fo the tnsfomtion of XML(t) to XML(FCNS(t)), tht we ll the FCNS enoding, nd its invese, the FCNS deoding. The FCNS enoding n be seen s eodeing of the tgs of XML(t) nd n nnottion of the tgs with left/ight. b b b b b

7 We stte sevel popeties bout the eltionship of the odeing of the tgs in XML(t) nd XML(FCNS(t)). Ft 3 onens the stutue of the subsequene of opening tgs in XML(FCNS(t)), Ft 4 onens the stutue of the subsequene of losing tgs in XML(FCNS(t)), nd Ft 5 onens the inteply of the subsequenes of opening nd losing tgs in XML(FCNS(t)). Ft 3. The opening tgs in XML(t) e in the sme ode s the opening tgs in XML(FCNS(t)). Fo node v of some tee t, let pos (v) nd pos ( v) be the espetive positions of the opening nd losing tgs of v in XML(FCNS(t)). Ft 4. Nodes v 1, v 2 of t stisfy pos (v 1) < pos (v 2) iff one of the following onditions holds: 1. v 1 is in the subtee of v 2 in t; 2. o v 1 is ight sibling of v 2 in t; 3. o thee is node u with depth(u) depth(v 1) 2 suh tht pos(v 1) < pos(u) pos(v 2). Ft 5. Nodes v 1, v 2 of t stisfy pos (v 1) < pos (v 2) iff thee is node u with depth(u) depth(v 1) 2 suh tht pos(v 1) < pos(u) pos(v 2). 4.2 FCNS enoding In this setion, we e inteested in omputing the tnsfomtion XML(t) XML(FCNS(t)). Ou sttegy is to ompute the subsequene of opening tgs of XML(FCNS(t)) (using Ft 3 nd disussed in subsetion 4.2.1) nd the subsequene of losing tgs (using Ft 4 nd disussed in 4.2.2) of XML(FCNS(t)) independently, nd mege them ftewds (using Ft 5 nd disussed in subsetion 4.2.3) Computing the sequene of opening tgs Conening the opening tgs, sine due to Ft 3 the subsequenes of opening tgs in XML(t) nd XML(FCNS(t)) oinide, we extt the subsequene of opening tg of XML(t), nd we nnotte them with left o ight s they should be in XML(FCNS(t)). Remind tht n opening tg is left if it is the opening tg of fist hild, othewise it is ight. Futhemoe, fo lte use we nnotte eh opening tg with depth() in t nd the position in the stem pos(). We summize this s ft: Ft 6. Thee is steming lgoithm with spe O(log N) tht, given XML(t) s input, outputs on n uxiliy stem the sequene of opening tgs of XML(FCNS(t)) with left/ight nnottions, nd futhemoe, nnottes eh tg with depth() nd pos(), pefoming one pss on eh stem Computing the sequene of losing tgs Fo omputing the sequene of losing tgs, we stt with the sequene of opening tgs of XML(FCNS(t)) s podued by the output of the lgoithm of Ft 6, tht is, oetly nnotted with left/ight nd with depth nd position nnottions. To obtin the oet subsequene of losing tgs s in XML(FCNS(t)), we intepet the opening tgs s losing tgs nd we sot them with mege sot lgoithm. Mege sot n be implemented s steming lgoithm with O(log(N)) psses nd 3 uxiliy stems [7]. Fo the ske of simpliity, Algoithm 4 ssumes n input of length 2 l fo some l > 0. Algoithm 4 Mege sot Requie: unsoted dt of length 2 l on stem 1 1: fo i = 0 l 1 do 2: opy dt in bloks of length 2 i fom stem 1 ltentely onto stem 2 nd stem 3 3: fo j = 1 2 l i 1 mege(2 i ) end fo 4: end fo mege(b) eds simultneously the next b vlues fom stem 2 nd stem 3, nd meges them onto stem 1. The whole loop in Line 3 of Algoithm 4 equies one ed pss on stem 2, one ed pss on stem 3, nd one wite pss on stem 1. See Figue 7 fo n illusttion. st 1: st 2: st 3: line 2 (opy) B 1 B 2 B 3 B 4 B 2 l i B 1 B 3 B l i 1 B 2 B 4 B l i line 3 (mege) B 12 B 34 B 2 l i 1 2 l i B 1 B 2 B 3 B 4 B l i 1 B l i Figue 7: In Line 2, bloks fom stem 1 e opied onto stem 2 nd stem 3. The B i e soted bloks. In line 3, ll bloks B i nd B i+1 e meged into soted blok B i(i+1). In ode to use mege sot, we hve to define ompto funtion tht, given two losing tgs 1, 2, deides whethe pos ( 1) < pos ( 2). Fistly, onside nodes v 1, v 2 with pos(v 1) < pos(v 2) to be s in Point 1 o Point 2 of Ft 4, tht is, eithe v 1, v 2 e siblings o one node is ontined in the subtee of the othe one. Obviously, thei odeing with espet to pos n esily be deided by thei depth: pos (v 1) < pos (v 2) iff depth(v 1) > depth(v 2). If neithe v 1, v 2 e siblings, no v 2 is in the subtee of v 1 (Point 3 of Ft 4), then pos (v 1) < pos (v 2), independently of thei depths. A ompison funtion hene should be ble to infe the eltionship of the two nodes, howeve, this seems to be diffiult in the steming model. To oveome this poblem, insted of defining ompison funtion, we design omplete mege funtion in Lemm 3 tht, by onstution, only ompes two nodes of the fist kind. The key ide is to intodue septo tgs whih we denote by new tg outside Σ. They e initilly inseted ight fte eh losing tg of lst hild u, tht is extly befoe the depth deeses. We denote by u the septo we intodue when seeing the lst hild u, nd we define depth(u) = depth(u). Ft 7. Thee is steming lgoithm with spe O(log N) tht, given sequene XML(t) on stem, omputes on nothe stem the sequene of opening tgs XML(FCNS(t)) togethe with thei septos, nd nnotted with depth, pos nd left/ight, pefoming one pss on eh stem. We hve to define the wy we integte the septos into ou soting. Let v 1, v 2,, v k be the odeed sequene of the hilden of some node. Fo the septo v k we sk thei position mong the losing tgs to stisfy fo eh node v: pos (v) < pos (v k ) iff pos (v) pos (v 1); (3) nd fo ny othe septo w k : pos (v k ) < pos (w k ) iff pos (v k ) < pos (w k ). (4) Bloks ppeing in mege sot fulfill popety tht we ll well-soted. A blok B of losing tgs is well-soted

8 if the oesponding tgs in XML(FCNS(t)) ppe in the sme ode, nd fo ll v 1, v 2 B with pos(v 1) < pos(v 2), ll losing tgs v of nodes v with pos(v 1) < pos(v) < pos(v 2) e in B s well. In ddition, fo two bloks B 1, B 2 of losing tgs, we sy tht (B 1, B 2) is well-soted djent pi, if B 1 nd B 2 e well-soted, fo eh losing tg v 1 B 1 nd eh losing tg v 2 B 2 pos(v 1) < pos(v 2) is stisfied, nd futhemoe, ll losing tgs v of nodes v with pos(v 1) < pos(v) < pos(v 2) e eithe in B 1 o B 2. The only funtion to design is ompto deiding fo two losing tgs v 1, v 2 fom well-soted djent pi (B 1, B 2) whethe pos (v 1) < pos (v 2). The following lemm shows tht we n mege wellsoted djent pi oetly. Lemm 3. Let (B 1, B 2) be well-soted djent pi, nd let v 1 = B 1[p 1] nd v 2 = B 2[p 2] fo some p 1, p 2. Assume tht pos (v) < pos (v 1) nd pos (v) < pos (v 2), fo ll v B 1[1, p 1 1] B 2[1, p 2 1]. Then: 1. If v 1 is septo, o thee is septo in B 1 fte v 1, then pos (v 1) < pos (v 2); 2. Else if v 2 is septo then: () if depth(v 1) < depth(v 2) then pos (v 1) < pos (v 2), (b) else pos (v 1) > pos (v 2); 3. Else (neithe v 1 no v 2 is septo): () if depth(v 1) depth(v 2) then pos (v 1) < pos (v 2), (b) else pos (v 1) > pos (v 2). Poof. Let (B 1, B 2) be well-soted djent pi. Let l = mx{i : B 1[i] is septo}. If thee e no septos in B 1, let l = 0. Fist, we pove Point 1. Sine B 1 is well-odeed, we only need to hek tht pos (B 1 [l]) < pos (B 2 [1]). Denote by u the lst hild tht ws esponsible fo the insetion of the septo tg B 1[l]. Let u be the left-most sibling of u. Due to Eqution (3) it suffies to show tht pos (u ) < pos (B 2[1]). Clely, the shotest pth fom u to B 2[1] psses by ommon nesto p of u nd B 2[1] whih is not the pent of u sine the septo B 1[l] indites tht the lst hild u hs been seen. Then, by the thid ondition of Ft 4, we get pos (u ) < pos (B 2[1]). Fo poving Points 2 nd 3 we use the obsevtion tht if the pemises to Point 1 e not fulfilled, v 1, v 2 do not hve ommon nesto p s.t. pos(v 1) < pos(p) < pos(v 2) nd p is not the pent node of v 1. Futhemoe, this obsevtion implies tht depth(v 2) depth(v 1) 1 nd hene, if depth(v 2) > depth(v 1) then v 2 is in the subtee of v 1. This nd Ft 4 pove Points 2, 2b, 3 nd 3b. We pove the obsevtion by ontdition. Assume tht thee is suh node p. Sine (B 1, B 2) is well-odeed djent pi nd pos(v 1) < pos(p) < pos(v 2), node p would be in B 1 B 2. Theefoe, the septo u inseted fte the ightmost sibling of v 1 would be lso in B 1 B 2 s well. Moe peisely, this septo would be in B 2[1 p 2 1] sine othewise Point 1 would hve been pplied. This, howeve, is ontdition to the ssumption tht pos (v) < pos (v 1) v B 1[1 p 1 1] B 2[1 p 2 1] sine it holds tht pos (v 1) < pos (u). Hene suh node does not exist. Lemm 4. Thee is O(log N)-pss steming lgoithm with spe O(log N) nd 3 uxiliy stems tht omputes the subsequene of losing tgs of the FCNS enoding of ny XML doument given in the input stem. Poof. Using Ft 7, we ompute on the fist uxiliy stem the sequene of opening tgs with oesponding nnottions, togethe with septos, nd intepet opening tgs s losing tgs. We show tht we n do mege sot lgoithm with mege funtion inspied by Lemm 3 on the fist thee uxiliy stems with O(log N) spe nd psses. Fo tht ssume tht the fist stem ontins sequene (B 1, B 2,, B M ) of bloks of size 2 i. Fo simpliity we ssume tht M is even, othewise we dd n empty blok. We ltentely opy odd bloks on the seond stem, nd even bloks on the thid stem. Fo blok B 2i tht we wite on the thid stem, we wite befoe eh of them, the numbe of septos tht ou in the blok B 2i 1 tht ws opied on the seond stem. Then we mege sequentilly ll pis of bloks (B 2k 1, B 2k ) fo 1 k M/2 using Lemm 3. Note tht (B 2k 1, B 2k ) i e ll well-fomed pis. Let l = mx{i : B 2k 1 [i] is septo}. Fistly, we opy elements B 2k 1 [1, l] onto uxiliy stem 1. Knowing the numbe of septos in B 2k 1 llows us to pefom this opetion. The oetness of this step follows fom Point 1 of Lemm 3. Then, we mege bloks B 2k 1 [l+1, 2 i ] nd B 2k by using the ompison funtion defined in Points 2 nd 3 of Lemm Meging opening nd losing tgs Meging the subsequene of opening tgs of XML(FCNS(t)) nd the subsequene of losing tgs of XML(FCNS(t)) n be done using one dditionl pss. Lemm 5. Thee is steming lgoithm with spe O(log N) tht, given the sequene of opening tgs of XML(FCNS(t)) on stem, nd the sequene of losing tgs of XML(FCNS(t)) on nothe stem, omputes XML(FCNS(t)) on thid stem using one pss on eh stem. Poof. We dietly pply Ft 5, so tht we know when to ltente fom the sequene of opening tgs to the one of losing tgs, nd onvesely. Fom Ft 6, Lemm 4 nd Lemm 5 we obtin Theoem 3. Theoem 3. Thee is O(log N)-pss steming lgoithm with spe O(log N) nd 3 uxiliy stems nd O(1) poessing time pe lette tht omputes on the thid uxiliy stem the FCNS tnsfomtion of ny XML doument given in the input stem. Poof. Fistly, we ompute oding to Lemm 4 the sequene of losing tgs nd we stoe them on uxiliy stem 1. Then, by Ft 6 we extt the sequene of opening tgs, nd we stoe them on uxiliy stem 2. By Lemm 5 we n mege the tgs of uxiliy stem 1 nd uxiliy stem 2 oetly onto stem 3. The spe equiements of these opetions do not exeed O(log N). The poessing time pe lette of these opetions is onstnt. 4.3 Cheking Vlidity on the enoding fom

9 In this setion, we euse the lgoithms fo vlidting biny tees fo the vlidtion of the enoded fom. We disuss one-pss ed/wite steming lgoithms (one fo leftto-ight psses, nd one fo ight-to-left psses) tht ed XML(FCNS (t)) nd output n XML doument with nnottions on losing tgs tht n be fed into Algoithm 1 o Algoithm 2. This equies little modifitions in Algoithm 1 nd Algoithm 2 sine vlidity then depends on the nnottions. Sine we wnt to euse the lgoithms fo the vlidtion of biny tees, we suppose tht XML(FCNS (t)) is vilble s input. The lgoithm stted in Theoem 3 n be esily dpted suh tht it outputs XML(FCNS (t)) insted of XML(FCNS(t)). The poblem of vlidting the enoded fom nd the poblem of vlidting biny tees e simil. Note tht the hilden v 1, v k of node v fom substing in XML(FCNS (t)), see Figue 8. Hene, fo vlidting node v, the lbel v hs to be elted to the blok of hilden nodes v k v 1. This is simil to the tsk of the vlidtion of biny tees whee the pent lbel v hs to be elted to the blok of hilden nodes v 1v 2. t : v v 1 v 2 v k t 1 t 2 t k FCNS (t) : t 1 v 1 t 2 v v 2 Figue 8: A tee t nd its FCNS enoding. While the opening nd losing tgs of the hilden of node v e septed by the subtees t 1, t k in XML(t), the losing tgs of the hilden of v e onseutive in XML(FCNS (t)) in evese ode, tht is v k v k 1 v 2 v 1 is substing of XML(FCNS (t)). Fo node v, we gthe the infomtion of the hilden nodes v 1,, v k by the help of finite utomt A 1 (fo leftto-ight psses) nd A 2 (fo ight-to-left psses) tht we define lte, nd the infomtion - stte of the utomt - is nnotted t the losing tg of lef v 1 (left-to-ight) o v k (ight-to-left). Then, by the help of Algoithm 1 o Algoithm 2, this infomtion is elted to the pent lbel v. We define utomt A 1 nd A 2 now. A 1 is onstuted fom utomton A. Let A = (Σ, Q, q 0, δ, F ) be deteministi finite utomton whee Σ is its input lphbet, Q is the stte set, q 0 is its initil stte, δ : Q Σ Q is the tnsition funtion, nd F is set of finl sttes. Fo Σ nd the input DTD D, denote by A deteministi finite utomton tht epts the egul expession D(). We ompose the A s in the left illusttion of Figue 9 to n utomton A tht epts wods ω suh tht ω = ω, Σ, ω Σ if ω D(). Let A 1 = (Σ, Q 1, (q 0) 1, δ 1, F 1) be deteministi finite utomton tht epts wod ω, iff ω ev is epted by A, whee ω ev denotes ω ed fom ight to left. Let A 2 = (Σ, Q 2, (q 0) 2, δ 2, F 2) be deteministi finite utomton tht epts wod ω suh tht ω = ω, Σ, ω Σ if ω D(). A 2 is vesion of the utomton in the ight illusttion of Figue 9 without ɛ tnsitions. In the following, we ssume fo evey stte q 1 Q 1 nd t k v k q Σ A 1 A 2. A Σ q 0 Figue 9: Left: Automton A. A 1 epts wods ω if A epts ω ev. Right: Automton A 2 is vesion of the illustted utomton without ɛ tnsitions. q 2 Q 2 tht δ 1(q 1, ) = q 1 nd δ 2(q 2, ) = q 2. Given XML(FCNS (t)), fo left-to-ight pss, we nnotte losing tgs v by stte fom the stte set Q 1 of utomton A 1. We denote the nnottion fo left-to-ight psses of v by nn 1(v). if v is lef then nn 1(v) = δ 1((q 0) 1, v), othewise let u be the ight hild of v, then nn 1(v) = δ 1(nn 1(u), v). Fo ight-to-left pss, we nnotte losing tgs v by stte fom the stte set Q 2 of utomton A 2. We denote the nnottion of ight-to-left psses of v by nn 2(v). ǫ ǫ ǫ A 1 A 2. A Σ if v is left hild then nn 2(v) = δ 2((q 0) 2, v), if v is ight hild of u then nn 2(v) = δ 2(nn 2(u), v). Fo the ske of ompleteness, the oot n be nnotted by nn 2() = (q 0) 2, though this nnottion will not be used fo heking vlidity. Figue 10 shows the nnottions of the hilden nodes v 1,, v k of node v. v 1 v v 2 v k v v 1(δ 1(nn 1(v 2), v 1)) v 2(δ 1(nn 1(v 3), v 2)) v k(δ 1((q 0) 1, v k)) v v 1(δ 2((q 0) 2, v 1)) 1 2 Σ v 2(δ 2(nn 2(v 1), v 2)) q f v k(δ 2(nn 2(v k 1), v k)) Figue 10: Left: node v with its hilden v 1, v k in the FCNS tee. Middle: nnottions fo left-to-ight psses. v is vlid if δ 1 (nn 1 (v 1 ), v) esults in n epting stte of A 1. Right: nnottions fo ight-to-left psses. v is vlid if δ 2 (nn 2 (v k ), v) is n epting stte of A 2. The nnottion opetions n be seen s steming lgoithms pefoming one ed pss ove the input nd one wite pss ove nothe stem using onstnt spe, sine the nnottion of losing tg v only depends on the nnottion of its ight hild (fo left-to-ight psses) o its pent (fo ightto-left psses). The espetive losing tg is in both ses the tg pio to v in the input stem XML(FCNS (t)). Remembe tht we onside ight-to-left pss fo the nnottion with nn 2. In the following, we pove tht given the nnottions, Algoithm 1 nd Algoithm 2 n be dpted to deide vlidity of the enoded fom. Theoem 4. Thee is one-pss deteministi lgoithm fo Vlidity with spe O( N log N) nd O(1) poessing time pe lette when the input is given in its FCNS enoding. Poof. Append the ule D( ) = ɛ to the input DTD

10 D. Compute utomton A 1. Compute new XML stem with nnottions nn 1 nd feed this stem dietly into Algoithm 1. In ode to veify node v, Algoithm 1 uses the losing tg v 1 of the left hild v 1 of v. Sine v is vlid if δ 1(nn 1(v 1), v) is n epting stte, we only hve to eple the hek funtion used in Algoithm 1. The new hek funtion omputes δ 1(nn 1(v 1), v) nd bots if the esulting stte is not epting. The spe equiements nd the poessing time pe lette inheit fom Algoithm 1. Theoem 5. Thee is bidietionl two-pss deteministi lgoithm fo Vlidity with spe O(log 2 N) nd O(log N) poessing time pe lette when the input is given in its FCNS enoding. Poof. Append the ule D( ) = ɛ to the input DTD D. Compute utomt A 1 nd A 2. Fistly, in left-to-ight pss, s in the poof of Theoem 4 we ompute new XML stem with nnottions nn 1 nd feed this stem dietly into Algoithm 3. We dpt the hek funtion s bove. Conening the ight-to-left pss, we ompute the nnottions nn 2, nd feed this stem dietly into Algoithm 3 intepeting opening tgs s losing tgs, nd vie ves. Note tht the nnottions nn 2 e hene nnotted on opening tgs. Let v be node with hilden v 1,, v k. We hve to show how Algoithm 3 n be dpted to elte the nnottion of the opening tg v k to v. When Algoithm 3 eds the losing tg w nd the opening tg v 1, it pushes (w, v 1,, ) on the stk, whee w is the sibling of v 1 in the FCNS enoding. Note tht the subsequent tgs on the stem e v 2, v 3, v k. Node v k n be identified sine v k is eithe lef o followed by tg with lbel. Hene, the stk item (w, v 1,, ) n be nnotted with nn 2(v k ) when v k is seen. Agin by dpting the hek outine, we n ompute δ 2(nn 2(v k ), v 1) nd bot if the esult is not n epting stte. The spe equiements nd the poessing time pe lette inheit fom Algoithm 2. Applying the bidietionl lgoithm of Theoem 5 on the enoded fom XML(FCNS (t)), we obtin tht vlidity of genel tees n be deided memoy effiiently in the steming model with uxiliy stems. Coolly 1. Thee is bidietionl O(log N)-pss deteministi steming lgoithm fo Vlidity with spe O(log 2 N), O(log N) poessing time pe lette, nd 3 uxiliy stems. 4.4 Deoding In the following, we pesent steming lgoithm fo FCNS deoding, tht is, given XML(FCNS(t)) of some tee t, output XML(t). We stt with non-steming lgoithm, Algoithm 5 pefoming this tsk. We desibe how this lgoithm n be onveted into steming lgoithm. Fo some opening tg X[i], heking the ondition in Line 4 n esily be done by investigting X[i + 1]. If X[i + 1] is ight opening tg o equls X[i], X[i] does not hve left subtee. The diffiulty in onveting this lgoithm into steming lgoithm is in Line 8, it is diffiult to keep tk of opening tgs until the espetive losing tgs of thei left hilden e seen, nd indeed, this n not be done with subline spe in one pss (Ft 10). Algoithm 5 offline lgoithm fo FCNS deoding 1: fo i = 1 2N do 2: if X[i] is n opening tg then 3: wite X[i] 4: if X[i] does not hve left subtee then 5: wite X[i] 6: end if 7: else if X[i] is left losing tg then {See Figue 11} 8: let p be the pent node of X[i] 9: wite p 10: end if 11: end fo p v 1 v 2 subtee of v 1 subtee of v 2 Figue 11: The min diffiulty of the FCNS deoding is to wite the losing tg of node p when the losing tg of its left hild is seen. This is diffiult when the subtees of v 1 nd v 2 e lge. In the following, we pesent steming lgoithm tht pefoms one pss ove the input, but two psses ove the output, nd uses O( N log N) spe, nd steming lgoithm tht pefoms O(log N) psses ove the input nd 3 uxiliy stems using O(log 2 (N)) spe One ed-pss nd two wite-psses We ed bloks of size N log N nd exeute Algoithm 5 on tht blok. In Lemm 6 we show tht in ny blok thee is t most one left losing tg fo whih the pent s opening nd losing tg e not in tht blok. Hene pe blok thee is t most one left losing tg fo whih we n not obtin the lbel of the pent node. We ll this losing tg itil. In this se we wite dummy symbol on the output stem tht will be ovewitten by the pent losing tg in the seond pss. The losing tg of the pent node will ive in subsequent blok, nd it n esily be identified s this sine it is the next losing tg iving t depth 1 of the itil losing tg. We stoe it upon its ivl in ou ndom ess memoy. Sine thee is t most one itil losing tg pe blok nd we hve blok size of N log N, we hve to eove t most O( N/ log N) pent nodes. At the end of the pss ove the input stem we hve eoveed ll losing tgs of pent nodes fo whih we wote dummy symbols on the output stem. In seond pss ove the output stem we ovewite the dummy symbols by the oet losing tgs. The omplexity deives fom the following lemm demonstting tht in blok thee is t most one itil left losing tg. Lemm 6. Let X[i, j] be blok. Then thee is t most one left losing tg with pent node p suh tht: pos(p) < i pos() j < pos(p). (5) Poof. By ontdition, ssume tht thee e 2 left losing tgs, b with p being the pent node of, nd q being the pent node of b, fo whih Inequlity 5 holds. Wlog we ssume tht pos(p) < pos(q). Sine pos(p) < pos(q) < pos(), q is ontined in the subtee of o q =. This, howeve, implies tht pos(q) pos() < j ontditing

11 pos(q) > j. Theoem 6. Thee is steming lgoithm using O( N log N) spe nd O(1) poessing time pe lette whih pefoms one pss ove the input stem ontining XML(t) nd two psses ove the output stem onto whih it outputs XML(FCNS(t)) Logithmi numbe of psses Agin, we use the offline Algoithm 5 s stting point fo the lgoithm we design now. Fo oping with the poblem tht it is hd to emembe ll opening pent tgs when thei oesponding losing tg ought to be witten on the output, we wite tegoilly dummy symbols on the output stem fo ll pent losing tgs. The ux then is the following obsevtion: Ft 8. Let 1L N L be the subsequene of losing tgs of left hilden of XML(FCNS(t)). Then the sequene p 1 p N is subsequene of XML(t) whee p i is the pent node of i in FCNS(t). We pply modified vesion of ou bidietionl two-pss Algoithm 2 to eove the missing tgs. Insted of heking vlidity, one the hek funtion is lled in Algoithm 3 with vibles (, b, ), we output the pent lbel onto n uxiliy stem, nnotted with pos(b). We do the sme in evese pss ove the input stem ounting positions fom 2N downwds to 1. In so doing, the uxiliy stem ontins ll pent lbels fo whih dummy symbols e witten on the output stem. Ft 8 shows tht it is enough to sot by mens of two futhe uxiliy stems the uxiliy stem with espet to the nnotted position of the losing tgs of the left hilden of these nodes. In lst pss we inset the pent losing tgs into the output stem. Theoem 7. Thee is O(log N)-pss steming lgoithm with spe O(log 2 N) nd O(log N) poessing time pe lette nd 3 uxiliy stems tht omputes on the thid uxiliy stem the FCNS deoding of ny FCNS enoded doument given in the input stem. 5. LOWER BOUNDS FOR FCNS ENCOD- ING AND DECODING We define fmily of hd instnes of length N = Θ(n) fo the omputtion of the FCNS enoding of tee s in Figue 12. x 1 x 2 x n x 1 x 2 Figue 12: Left: hd instne. Right: its FCNS enoded fom. It is esy to see tht omputing the sequene of losing tgs in the FCNS enoding equies to invet stem. Let t be hd instne. Then XML(t) = x 1x 1x 2x 2 x nx n, nd XML(FCNS(t)) = Lx 1Lx 2R x nrx nrx n 1R x 2Rx 1L L. Sine the witing x n on the stem n only stt fte eding x n, we dedue tht memoy spe Ω(n) is equied, in ode to stoe ll pevious tgs. Ft 9. Evey one-pss ndomized steming lgoithm fo FCNS enoding with bounded eo equies Ω(N) spe. We onjetue tht this gument n be extended s follows: Conjetue 1. Any p-psses ndomized steming lgoithm fo FCNS enoding with bounded eo equies spe Ω(N/p). We now define nothe fmily of hd instnes of length N = Θ(n) fo deoding FCNS enoded tee s in Figue 13. x n x k+1 x k x k 1 subtee y x 1 x k x k+1 x n x 1 x k 1 subtee z Figue 13: Left: hd instne in FCNS fom, whee y is ny tee of size Θ(n). Right: its deoded fom. Intuitively, deoding the tee of ny hd instne equies to put the full tee y into memoy. Let XML(FCNS(t)) denote hd instne whih we im to deode into XML(t). Then: XML(FCNS(t)) = x 1L x nlx nl x k+1l Y x kl x 1L L nd the deoded fom is XML(t) = x 1 x nx n x k Zx k 1 x 1 whee Z is the deoded fom of Y. Sine Z n only be witten fte x k, nd sine x k nnot be memoized beuse k ws unknown until we eh Y, memoy spe Ω(n) is equied. This gument n be esily fomlized using stndd infomtion theoy guments. Ft 10. Evey one-pss ndomized steming lgoithm fo FCNS deoding with bounded eo equies spe Ω(N). This gument n be extended to two-pss ndomized steming lgoithms. Constut hd instne of size Θ(n 2 ) by gluing n pevious instnes (x i, k i, y i ) 1 i n s follows: instne (x i+1, k i+1, y i+1 ) is bnhed to the left most lef of instne (x i, k i, y i ). Afte the fist pss, the lgoithm is not ble to wite n losing tgs of fom x i k i. Theefoe he needs to stoe them in ode to wite them t the seond pss. This equies some fomliztion tht we omit hee. Ft 11. Evey ndomized steming lgoithm fo FCNS deoding with bounded eo, one pss on the input stem, nd two psses on the output stem equies spe Ω( N). Aknowledgements The uthos would like to thnk Mihel de Rougemont, who, mong othe things, intodued the uthos to the poblem of vlidting steming XML douments.

Chapter 7. Kleene s Theorem. 7.1 Kleene s Theorem. The following theorem is the most important and fundamental result in the theory of FA s:

Chapter 7. Kleene s Theorem. 7.1 Kleene s Theorem. The following theorem is the most important and fundamental result in the theory of FA s: Chpte 7 Kleene s Theoem 7.1 Kleene s Theoem The following theoem is the most impotnt nd fundmentl esult in the theoy of FA s: Theoem 6 Any lnguge tht cn e defined y eithe egul expession, o finite utomt,

More information

The Area of a Triangle

The Area of a Triangle The e of Tingle tkhlid June 1, 015 1 Intodution In this tile we will e disussing the vious methods used fo detemining the e of tingle. Let [X] denote the e of X. Using se nd Height To stt off, the simplest

More information

Data Structures. Element Uniqueness Problem. Hash Tables. Example. Hash Tables. Dana Shapira. 19 x 1. ) h(x 4. ) h(x 2. ) h(x 3. h(x 1. x 4. x 2.

Data Structures. Element Uniqueness Problem. Hash Tables. Example. Hash Tables. Dana Shapira. 19 x 1. ) h(x 4. ) h(x 2. ) h(x 3. h(x 1. x 4. x 2. Element Uniqueness Poblem Dt Stuctues Let x,..., xn < m Detemine whethe thee exist i j such tht x i =x j Sot Algoithm Bucket Sot Dn Shpi Hsh Tbles fo (i=;i

More information

Mathematical Reflections, Issue 5, INEQUALITIES ON RATIOS OF RADII OF TANGENT CIRCLES. Y.N. Aliyev

Mathematical Reflections, Issue 5, INEQUALITIES ON RATIOS OF RADII OF TANGENT CIRCLES. Y.N. Aliyev themtil efletions, Issue 5, 015 INEQULITIES ON TIOS OF DII OF TNGENT ILES YN liev stt Some inequlities involving tios of dii of intenll tngent iles whih inteset the given line in fied points e studied

More information

10.3 The Quadratic Formula

10.3 The Quadratic Formula . Te Qudti Fomul We mentioned in te lst setion tt ompleting te sque n e used to solve ny qudti eqution. So we n use it to solve 0. We poeed s follows 0 0 Te lst line of tis we ll te qudti fomul. Te Qudti

More information

Topic II.1: Frequent Subgraph Mining

Topic II.1: Frequent Subgraph Mining Topi II.1: Fequent Sugph Mining Disete Topis in Dt Mining Univesität des Slndes, Süken Winte Semeste 2012/13 T II.1-1 TII.1: Fequent Sugph Mining 1. Definitions nd Polems 1.1. Gph Isomophism 2. Apioi-Bsed

More information

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.

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. 1 PYTHAGORAS THEOREM 1 1 Pythgors Theorem In this setion we will present geometri proof of the fmous theorem of Pythgors. Given right ngled tringle, the squre of the hypotenuse is equl to the sum of the

More information

Deterministic simulation of a NFA with k symbol lookahead

Deterministic simulation of a NFA with k symbol lookahead Deteministic simultion of NFA with k symbol lookhed SOFSEM 7 Bl Rvikum, Clifoni Stte Univesity (joint wok with Nic Snten, Univesity of Wteloo) Oveview Definitions: DFA, NFA nd lookhed DFA Motivtion: utomted

More information

Math 4318 : Real Analysis II Mid-Term Exam 1 14 February 2013

Math 4318 : Real Analysis II Mid-Term Exam 1 14 February 2013 Mth 4318 : Rel Anlysis II Mid-Tem Exm 1 14 Febuy 2013 Nme: Definitions: Tue/Flse: Poofs: 1. 2. 3. 4. 5. 6. Totl: Definitions nd Sttements of Theoems 1. (2 points) Fo function f(x) defined on (, b) nd fo

More information

Illustrating the space-time coordinates of the events associated with the apparent and the actual position of a light source

Illustrating the space-time coordinates of the events associated with the apparent and the actual position of a light source Illustting the spe-time oointes of the events ssoite with the ppent n the tul position of light soue Benh Rothenstein ), Stefn Popesu ) n Geoge J. Spi 3) ) Politehni Univesity of Timiso, Physis Deptment,

More information

Module 4: Moral Hazard - Linear Contracts

Module 4: Moral Hazard - Linear Contracts Module 4: Mol Hzd - Line Contts Infomtion Eonomis (E 55) Geoge Geogidis A pinipl employs n gent. Timing:. The pinipl o es line ontt of the fom w (q) = + q. is the sly, is the bonus te.. The gent hooses

More information

Previously. Extensions to backstepping controller designs. Tracking using backstepping Suppose we consider the general system

Previously. Extensions to backstepping controller designs. Tracking using backstepping Suppose we consider the general system 436-459 Advnced contol nd utomtion Extensions to bckstepping contolle designs Tcking Obseves (nonline dmping) Peviously Lst lectue we looked t designing nonline contolles using the bckstepping technique

More information

Incremental Maintenance of XML Structural Indexes

Incremental Maintenance of XML Structural Indexes Inementl Mintenne of XML Stutul Indexes Ke Yi Ho He Ion Stnoi Jun Yng Dept. Compute Siene Duke Univesity yike@s.duke.edu Dept. Compute Siene Duke Univesity hohe@s.duke.edu IBMT.J.Wtson Reseh Cente is@us.ibm.om

More information

Swinburne Research Bank

Swinburne Research Bank Swinune Reseh Bnk http://esehnk.swinune.edu.u Zhou, R., Liu, C., Wng, J., & Li, J. (2009). Continment etween unions of XPth queies. Oiginlly pulished in X. Zhou, H. Yokot, K. Deng, & Q. Liu (eds.) Poeedings

More information

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18 Computt onl Biology Leture 18 Genome Rerrngements Finding preserved genes We hve seen before how to rerrnge genome to obtin nother one bsed on: Reversls Knowledge of preserved bloks (or genes) Now we re

More information

Andersen s Algorithm. CS 701 Final Exam (Reminder) Friday, December 12, 4:00 6:00 P.M., 1289 Computer Science.

Andersen s Algorithm. CS 701 Final Exam (Reminder) Friday, December 12, 4:00 6:00 P.M., 1289 Computer Science. CS 701 Finl Exm (Reminde) Fidy, Deeme 12, 4:00 6:00 P.M., 1289 Comute Siene. Andesen s Algoithm An lgoithm to uild oints-to gh fo C ogm is esented in: Pogm Anlysis nd Seiliztion fo the C ogmming Lnguge,

More information

ITI Introduction to Computing II

ITI Introduction to Computing II ITI 1121. Intoduction to Computing II Mcel Tucotte School of Electicl Engineeing nd Compute Science Abstct dt type: Stck Stck-bsed lgoithms Vesion of Febuy 2, 2013 Abstct These lectue notes e ment to be

More information

Prerna Tower, Road No 2, Contractors Area, Bistupur, Jamshedpur , Tel (0657) ,

Prerna Tower, Road No 2, Contractors Area, Bistupur, Jamshedpur , Tel (0657) , R Pen Towe Rod No Conttos Ae Bistupu Jmshedpu 8 Tel (67)89 www.penlsses.om IIT JEE themtis Ppe II PART III ATHEATICS SECTION I (Totl ks : ) (Single Coet Answe Type) This setion ontins 8 multiple hoie questions.

More information

A Bijective Approach to the Permutational Power of a Priority Queue

A Bijective Approach to the Permutational Power of a Priority Queue A Bijective Appoach to the Pemutational Powe of a Pioity Queue Ia M. Gessel Kuang-Yeh Wang Depatment of Mathematics Bandeis Univesity Waltham, MA 02254-9110 Abstact A pioity queue tansfoms an input pemutation

More information

Week 8. Topic 2 Properties of Logarithms

Week 8. Topic 2 Properties of Logarithms Week 8 Topic 2 Popeties of Logithms 1 Week 8 Topic 2 Popeties of Logithms Intoduction Since the esult of ithm is n eponent, we hve mny popeties of ithms tht e elted to the popeties of eponents. They e

More information

Michael Rotkowitz 1,2

Michael Rotkowitz 1,2 Novembe 23, 2006 edited Line Contolles e Unifomly Optiml fo the Witsenhusen Counteexmple Michel Rotkowitz 1,2 IEEE Confeence on Decision nd Contol, 2006 Abstct In 1968, Witsenhusen intoduced his celebted

More information

Language Processors F29LP2, Lecture 5

Language Processors F29LP2, Lecture 5 Lnguge Pocessos F29LP2, Lectue 5 Jmie Gy Feuy 2, 2014 1 / 1 Nondeteministic Finite Automt (NFA) NFA genelise deteministic finite utomt (DFA). They llow sevel (0, 1, o moe thn 1) outgoing tnsitions with

More information

( ) D x ( s) if r s (3) ( ) (6) ( r) = d dr D x

( ) D x ( s) if r s (3) ( ) (6) ( r) = d dr D x SIO 22B, Rudnick dpted fom Dvis III. Single vile sttistics The next few lectues e intended s eview of fundmentl sttistics. The gol is to hve us ll speking the sme lnguge s we move to moe dvnced topics.

More information

Finite State Automata and Determinisation

Finite State Automata and Determinisation Finite Stte Automt nd Deterministion Tim Dworn Jnury, 2016 Lnguges fs nf re df Deterministion 2 Outline 1 Lnguges 2 Finite Stte Automt (fs) 3 Non-deterministi Finite Stte Automt (nf) 4 Regulr Expressions

More information

9.4 The response of equilibrium to temperature (continued)

9.4 The response of equilibrium to temperature (continued) 9.4 The esponse of equilibium to tempetue (continued) In the lst lectue, we studied how the chemicl equilibium esponds to the vition of pessue nd tempetue. At the end, we deived the vn t off eqution: d

More information

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

INTEGRATION. 1 Integrals of Complex Valued functions of a REAL variable INTEGRATION NOTE: These notes re supposed to supplement Chpter 4 of the online textbook. 1 Integrls of Complex Vlued funtions of REAL vrible If I is n intervl in R (for exmple I = [, b] or I = (, b)) nd

More information

Class Summary. be functions and f( D) , we define the composition of f with g, denoted g f by

Class Summary. be functions and f( D) , we define the composition of f with g, denoted g f by Clss Summy.5 Eponentil Functions.6 Invese Functions nd Logithms A function f is ule tht ssigns to ech element D ectly one element, clled f( ), in. Fo emple : function not function Given functions f, g:

More information

2-Way Finite Automata Radboud University, Nijmegen. Writer: Serena Rietbergen, s Supervisor: Herman Geuvers

2-Way Finite Automata Radboud University, Nijmegen. Writer: Serena Rietbergen, s Supervisor: Herman Geuvers 2-Wy Finite Automt Rdoud Univesity, Nijmegen Wite: Seen Rietegen, s4182804 Supeviso: Hemn Geuves Acdemic Ye 2017-2018 Contents 1 Intoduction 3 2 One wy utomt, deteministic nd non-deteministic 5 3 Ovehed

More information

General Physics II. number of field lines/area. for whole surface: for continuous surface is a whole surface

General Physics II. number of field lines/area. for whole surface: for continuous surface is a whole surface Genel Physics II Chpte 3: Guss w We now wnt to quickly discuss one of the moe useful tools fo clculting the electic field, nmely Guss lw. In ode to undestnd Guss s lw, it seems we need to know the concept

More information

Optimization. x = 22 corresponds to local maximum by second derivative test

Optimization. x = 22 corresponds to local maximum by second derivative test Optimiztion Lectue 17 discussed the exteme vlues of functions. This lectue will pply the lesson fom Lectue 17 to wod poblems. In this section, it is impotnt to emembe we e in Clculus I nd e deling one-vible

More information

This immediately suggests an inverse-square law for a "piece" of current along the line.

This immediately suggests an inverse-square law for a piece of current along the line. Electomgnetic Theoy (EMT) Pof Rui, UNC Asheville, doctophys on YouTube Chpte T Notes The iot-svt Lw T nvese-sque Lw fo Mgnetism Compe the mgnitude of the electic field t distnce wy fom n infinite line

More information

An Analysis of the LRE-Algorithm using Sojourn Times

An Analysis of the LRE-Algorithm using Sojourn Times An Anlysis of the LRE-Algoithm using Sooun Times Nobet Th. Mülle Abteilung Infomtik Univesität Tie D-5486 Tie, Gemny E-mil: muelle@uni-tie.de Tel: ++49-65-0-845 Fx: ++49-65-0-3805 KEYWORDS Disete event

More information

CHAPTER 7 Applications of Integration

CHAPTER 7 Applications of Integration CHAPTER 7 Applitions of Integtion Setion 7. Ae of Region Between Two Cuves.......... Setion 7. Volume: The Disk Method................. Setion 7. Volume: The Shell Method................ Setion 7. A Length

More information

Lecture 10. Solution of Nonlinear Equations - II

Lecture 10. Solution of Nonlinear Equations - II Fied point Poblems Lectue Solution o Nonline Equtions - II Given unction g : R R, vlue such tht gis clled ied point o the unction g, since is unchnged when g is pplied to it. Whees with nonline eqution

More information

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points: Eidgenössishe Tehnishe Hohshule Zürih Eole polytehnique fédérle de Zurih Politenio federle di Zurigo Federl Institute of Tehnology t Zurih Deprtement of Computer Siene. Novemer 0 Mrkus Püshel, Dvid Steurer

More information

Solution to HW 3, Ma 1a Fall 2016

Solution to HW 3, Ma 1a Fall 2016 Solution to HW 3, Ma a Fall 206 Section 2. Execise 2: Let C be a subset of the eal numbes consisting of those eal numbes x having the popety that evey digit in the decimal expansion of x is, 3, 5, o 7.

More information

Part 4. Integration (with Proofs)

Part 4. Integration (with Proofs) Prt 4. Integrtion (with Proofs) 4.1 Definition Definition A prtition P of [, b] is finite set of points {x 0, x 1,..., x n } with = x 0 < x 1

More information

Bisimulation, Games & Hennessy Milner logic

Bisimulation, Games & Hennessy Milner logic Bisimultion, Gmes & Hennessy Milner logi Leture 1 of Modelli Mtemtii dei Proessi Conorrenti Pweł Soboiński Univeristy of Southmpton, UK Bisimultion, Gmes & Hennessy Milner logi p.1/32 Clssil lnguge theory

More information

Green s Theorem. (2x e y ) da. (2x e y ) dx dy. x 2 xe y. (1 e y ) dy. y=1. = y e y. y=0. = 2 e

Green s Theorem. (2x e y ) da. (2x e y ) dx dy. x 2 xe y. (1 e y ) dy. y=1. = y e y. y=0. = 2 e Green s Theorem. Let be the boundry of the unit squre, y, oriented ounterlokwise, nd let F be the vetor field F, y e y +, 2 y. Find F d r. Solution. Let s write P, y e y + nd Q, y 2 y, so tht F P, Q. Let

More information

Properties and Formulas

Properties and Formulas Popeties nd Fomuls Cpte 1 Ode of Opetions 1. Pefom ny opetion(s) inside gouping symols. 2. Simplify powes. 3. Multiply nd divide in ode fom left to igt. 4. Add nd sutt in ode fom left to igt. Identity

More information

Electronic Supplementary Material

Electronic Supplementary Material Electonic Supplementy Mteil On the coevolution of socil esponsiveness nd behvioul consistency Mx Wolf, G Snde vn Doon & Fnz J Weissing Poc R Soc B 78, 440-448; 0 Bsic set-up of the model Conside the model

More information

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

18.06 Problem Set 4 Due Wednesday, Oct. 11, 2006 at 4:00 p.m. in 2-106 8. Problem Set Due Wenesy, Ot., t : p.m. in - Problem Mony / Consier the eight vetors 5, 5, 5,..., () List ll of the one-element, linerly epenent sets forme from these. (b) Wht re the two-element, linerly

More information

Math 301: The Erdős-Stone-Simonovitz Theorem and Extremal Numbers for Bipartite Graphs

Math 301: The Erdős-Stone-Simonovitz Theorem and Extremal Numbers for Bipartite Graphs Math 30: The Edős-Stone-Simonovitz Theoem and Extemal Numbes fo Bipatite Gaphs May Radcliffe The Edős-Stone-Simonovitz Theoem Recall, in class we poved Tuán s Gaph Theoem, namely Theoem Tuán s Theoem Let

More information

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

Project 6: Minigoals Towards Simplifying and Rewriting Expressions MAT 51 Wldis Projet 6: Minigols Towrds Simplifying nd Rewriting Expressions The distriutive property nd like terms You hve proly lerned in previous lsses out dding like terms ut one prolem with the wy

More information

Chapter 4. Sampling of Continuous-Time Signals

Chapter 4. Sampling of Continuous-Time Signals Chapte 4 Sampling of Continuous-Time Signals 1 Intodution Disete-time signals most ommonly ou as epesentations of sampled ontinuous-time signals. Unde easonable onstaints, a ontinuous-time signal an be

More information

EECE 260 Electrical Circuits Prof. Mark Fowler

EECE 260 Electrical Circuits Prof. Mark Fowler EECE 60 Electicl Cicuits Pof. Mk Fowle Complex Numbe Review /6 Complex Numbes Complex numbes ise s oots of polynomils. Definition of imginy # nd some esulting popeties: ( ( )( ) )( ) Recll tht the solution

More information

6.5 Improper integrals

6.5 Improper integrals Eerpt from "Clulus" 3 AoPS In. www.rtofprolemsolving.om 6.5. IMPROPER INTEGRALS 6.5 Improper integrls As we ve seen, we use the definite integrl R f to ompute the re of the region under the grph of y =

More information

, g. Exercise 1. Generator polynomials of a convolutional code, given in binary form, are g. Solution 1.

, g. Exercise 1. Generator polynomials of a convolutional code, given in binary form, are g. Solution 1. Exerise Genertor polynomils of onvolutionl ode, given in binry form, re g, g j g. ) Sketh the enoding iruit. b) Sketh the stte digrm. ) Find the trnsfer funtion T. d) Wht is the minimum free distne of

More information

Mark Scheme (Results) January 2008

Mark Scheme (Results) January 2008 Mk Scheme (Results) Jnuy 00 GCE GCE Mthemtics (6679/0) Edecel Limited. Registeed in Englnd nd Wles No. 4496750 Registeed Office: One90 High Holbon, London WCV 7BH Jnuy 00 6679 Mechnics M Mk Scheme Question

More information

Data Compression LZ77. Jens Müller Universität Stuttgart

Data Compression LZ77. Jens Müller Universität Stuttgart Dt Compession LZ77 Jens Mülle Univesität Stuttgt 2008-11-25 Outline Intoution Piniple of itiony methos LZ77 Sliing winow Exmples Optimiztion Pefomne ompison Applitions/Ptents Jens Mülle- IPVS Univesität

More information

NS-IBTS indices calculation procedure

NS-IBTS indices calculation procedure ICES Dt Cente DATRAS 1.1 NS-IBTS indices 2013 DATRAS Pocedue Document NS-IBTS indices clcultion pocedue Contents Genel... 2 I Rw ge dt CA -> Age-length key by RFA fo defined ge nge ALK... 4 II Rw length

More information

QUADRATIC EQUATION. Contents

QUADRATIC EQUATION. Contents QUADRATIC EQUATION Contents Topi Pge No. Theory 0-04 Exerise - 05-09 Exerise - 09-3 Exerise - 3 4-5 Exerise - 4 6 Answer Key 7-8 Syllus Qudrti equtions with rel oeffiients, reltions etween roots nd oeffiients,

More information

1 Using Integration to Find Arc Lengths and Surface Areas

1 Using Integration to Find Arc Lengths and Surface Areas Novembe 9, 8 MAT86 Week Justin Ko Using Integtion to Find Ac Lengths nd Sufce Aes. Ac Length Fomul: If f () is continuous on [, b], then the c length of the cuve = f() on the intevl [, b] is given b s

More information

Hyers-Ulam stability of Pielou logistic difference equation

Hyers-Ulam stability of Pielou logistic difference equation vilble online t wwwisr-publitionsom/jns J Nonliner Si ppl, 0 (207, 35 322 Reserh rtile Journl Homepge: wwwtjnsom - wwwisr-publitionsom/jns Hyers-Ulm stbility of Pielou logisti differene eqution Soon-Mo

More information

Introduction to Olympiad Inequalities

Introduction to Olympiad Inequalities Introdution to Olympid Inequlities Edutionl Studies Progrm HSSP Msshusetts Institute of Tehnology Snj Simonovikj Spring 207 Contents Wrm up nd Am-Gm inequlity 2. Elementry inequlities......................

More information

Probabilistic Retrieval

Probabilistic Retrieval CS 630 Lectue 4: 02/07/2006 Lectue: Lillin Lee Scibes: Pete Bbinski, Dvid Lin Pobbilistic Retievl I. Nïve Beginnings. Motivtions b. Flse Stt : A Pobbilistic Model without Vition? II. Fomultion. Tems nd

More information

Math 32B Discussion Session Week 8 Notes February 28 and March 2, f(b) f(a) = f (t)dt (1)

Math 32B Discussion Session Week 8 Notes February 28 and March 2, f(b) f(a) = f (t)dt (1) Green s Theorem Mth 3B isussion Session Week 8 Notes Februry 8 nd Mrh, 7 Very shortly fter you lerned how to integrte single-vrible funtions, you lerned the Fundmentl Theorem of lulus the wy most integrtion

More information

MAT 403 NOTES 4. f + f =

MAT 403 NOTES 4. f + f = MAT 403 NOTES 4 1. Fundmentl Theorem o Clulus We will proo more generl version o the FTC thn the textook. But just like the textook, we strt with the ollowing proposition. Let R[, ] e the set o Riemnn

More information

10 Statistical Distributions Solutions

10 Statistical Distributions Solutions Communictions Engineeing MSc - Peliminy Reding 1 Sttisticl Distiutions Solutions 1) Pove tht the vince of unifom distiution with minimum vlue nd mximum vlue ( is ) 1. The vince is the men of the sques

More information

CHAPTER 18: ELECTRIC CHARGE AND ELECTRIC FIELD

CHAPTER 18: ELECTRIC CHARGE AND ELECTRIC FIELD ollege Physics Student s Mnul hpte 8 HAPTR 8: LTRI HARG AD LTRI ILD 8. STATI LTRIITY AD HARG: OSRVATIO O HARG. ommon sttic electicity involves chges nging fom nnocoulombs to micocoulombs. () How mny electons

More information

r r E x w, y w, z w, (1) Where c is the speed of light in vacuum.

r r E x w, y w, z w, (1) Where c is the speed of light in vacuum. ISSN: 77-754 ISO 900:008 Cetified Intentionl Jonl of Engineeing nd Innovtive Tehnology (IJEIT) olme, Isse 0, Apil 04 The Replement of the Potentils s Conseene of the Limittions Set by the Lw of the Self

More information

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

22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of: 22: Union Fin CS 473u - Algorithms - Spring 2005 April 14, 2005 1 Union-Fin We wnt to mintin olletion of sets, uner the opertions of: 1. MkeSet(x) - rete set tht ontins the single element x. 2. Fin(x)

More information

A Study of Some Integral Problems Using Maple

A Study of Some Integral Problems Using Maple Mthemtis n Sttistis (): -, 0 DOI: 0.89/ms.0.000 http://www.hpub.og A Stuy of Some Integl Poblems Ug Mple Chii-Huei Yu Deptment of Mngement n Infomtion, Nn Jeon Univesity of Siene n Tehnology, Tinn City,

More information

Answers to test yourself questions

Answers to test yourself questions Answes to test youself questions opic Descibing fields Gm Gm Gm Gm he net field t is: g ( d / ) ( 4d / ) d d Gm Gm Gm Gm Gm Gm b he net potentil t is: V d / 4d / d 4d d d V e 4 7 9 49 J kg 7 7 Gm d b E

More information

More Properties of the Riemann Integral

More Properties of the Riemann Integral More Properties of the Riemnn Integrl Jmes K. Peterson Deprtment of Biologil Sienes nd Deprtment of Mthemtil Sienes Clemson University Februry 15, 2018 Outline More Riemnn Integrl Properties The Fundmentl

More information

A Lower Bound for the Length of a Partial Transversal in a Latin Square, Revised Version

A Lower Bound for the Length of a Partial Transversal in a Latin Square, Revised Version A Lower Bound for the Length of Prtil Trnsversl in Ltin Squre, Revised Version Pooy Htmi nd Peter W. Shor Deprtment of Mthemtil Sienes, Shrif University of Tehnology, P.O.Bo 11365-9415, Tehrn, Irn Deprtment

More information

Chapter 3: Theory of Modular Arithmetic 38

Chapter 3: Theory of Modular Arithmetic 38 Chapte 3: Theoy of Modula Aithmetic 38 Section D Chinese Remainde Theoem By the end of this section you will be able to pove the Chinese Remainde Theoem apply this theoem to solve simultaneous linea conguences

More information

The Regulated and Riemann Integrals

The Regulated and Riemann Integrals Chpter 1 The Regulted nd Riemnn Integrls 1.1 Introduction We will consider severl different pproches to defining the definite integrl f(x) dx of function f(x). These definitions will ll ssign the sme vlue

More information

TOPIC: LINEAR ALGEBRA MATRICES

TOPIC: LINEAR ALGEBRA MATRICES Interntionl Blurete LECTUE NOTES for FUTHE MATHEMATICS Dr TOPIC: LINEA ALGEBA MATICES. DEFINITION OF A MATIX MATIX OPEATIONS.. THE DETEMINANT deta THE INVESE A -... SYSTEMS OF LINEA EQUATIONS. 8. THE AUGMENTED

More information

Review for the previous lecture

Review for the previous lecture Review fo the pevious letue Definition: sample spae, event, opeations (union, intesetion, omplementay), disjoint, paiwise disjoint Theoem: ommutatitivity, assoiativity, distibution law, DeMogan s law Pobability

More information

Important design issues and engineering applications of SDOF system Frequency response Functions

Important design issues and engineering applications of SDOF system Frequency response Functions Impotnt design issues nd engineeing pplictions of SDOF system Fequency esponse Functions The following desciptions show typicl questions elted to the design nd dynmic pefomnce of second-ode mechnicl system

More information

CS 573 Automata Theory and Formal Languages

CS 573 Automata Theory and Formal Languages Non-determinism Automt Theory nd Forml Lnguges Professor Leslie Lnder Leture # 3 Septemer 6, 2 To hieve our gol, we need the onept of Non-deterministi Finite Automton with -moves (NFA) An NFA is tuple

More information

Logic Synthesis and Verification

Logic Synthesis and Verification Logi Synthesis nd Verifition SOPs nd Inompletely Speified Funtions Jie-Hong Rolnd Jing 江介宏 Deprtment of Eletril Engineering Ntionl Tiwn University Fll 2010 Reding: Logi Synthesis in Nutshell Setion 2 most

More information

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b CS 294-2 9/11/04 Quntum Ciruit Model, Solovy-Kitev Theorem, BQP Fll 2004 Leture 4 1 Quntum Ciruit Model 1.1 Clssil Ciruits - Universl Gte Sets A lssil iruit implements multi-output oolen funtion f : {0,1}

More information

Chapter Seven Notes N P U1C7

Chapter Seven Notes N P U1C7 Chpte Seven Notes N P UC7 Nme Peiod Setion 7.: Angles nd Thei Mesue In fling, hitetue, nd multitude of othe fields, ngles e used. An ngle is two diffeent s tht hve the sme initil (o stting) point. The

More information

Physics 2A Chapter 10 - Moment of Inertia Fall 2018

Physics 2A Chapter 10 - Moment of Inertia Fall 2018 Physics Chapte 0 - oment of netia Fall 08 The moment of inetia of a otating object is a measue of its otational inetia in the same way that the mass of an object is a measue of its inetia fo linea motion.

More information

6. Numbers. The line of numbers: Important subsets of IR:

6. Numbers. The line of numbers: Important subsets of IR: 6. Nubes We do not give n xiotic definition of the el nubes hee. Intuitive ening: Ech point on the (infinite) line of nubes coesponds to el nube, i.e., n eleent of IR. The line of nubes: Ipotnt subsets

More information

Equations from the Millennium Theory of Inertia and Gravity. Copyright 2004 Joseph A. Rybczyk

Equations from the Millennium Theory of Inertia and Gravity. Copyright 2004 Joseph A. Rybczyk Equtions fo the illenniu heoy of Ineti nd vity Copyight 004 Joseph A. Rybzyk ollowing is oplete list of ll of the equtions used o deived in the illenniu heoy of Ineti nd vity. o ese of efeene the equtions

More information

Section 1.3 Triangles

Section 1.3 Triangles Se 1.3 Tringles 21 Setion 1.3 Tringles LELING TRINGLE The line segments tht form tringle re lled the sides of the tringle. Eh pir of sides forms n ngle, lled n interior ngle, nd eh tringle hs three interior

More information

Analysis of Variance for Multiple Factors

Analysis of Variance for Multiple Factors Multiple Fto ANOVA Notes Pge wo Fto Anlsis Anlsis of Vine fo Multiple Ftos Conside two ftos (tetments) A nd B with A done t levels nd B done t levels. Within given tetment omintion of A nd B levels, leled

More information

Two dimensional polar coordinate system in airy stress functions

Two dimensional polar coordinate system in airy stress functions I J C T A, 9(9), 6, pp. 433-44 Intentionl Science Pess Two dimensionl pol coodinte system in iy stess functions S. Senthil nd P. Sek ABSTRACT Stisfy the given equtions, boundy conditions nd bihmonic eqution.in

More information

NON-DETERMINISTIC FSA

NON-DETERMINISTIC FSA Tw o types of non-determinism: NON-DETERMINISTIC FS () Multiple strt-sttes; strt-sttes S Q. The lnguge L(M) ={x:x tkes M from some strt-stte to some finl-stte nd ll of x is proessed}. The string x = is

More information

CS 275 Automata and Formal Language Theory

CS 275 Automata and Formal Language Theory CS 275 utomt nd Forml Lnguge Theory Course Notes Prt II: The Recognition Prolem (II) Chpter II.5.: Properties of Context Free Grmmrs (14) nton Setzer (Bsed on ook drft y J. V. Tucker nd K. Stephenson)

More information

(a) A partition P of [a, b] is a finite subset of [a, b] containing a and b. If Q is another partition and P Q, then Q is a refinement of P.

(a) A partition P of [a, b] is a finite subset of [a, b] containing a and b. If Q is another partition and P Q, then Q is a refinement of P. Chpter 7: The Riemnn Integrl When the derivtive is introdued, it is not hrd to see tht the it of the differene quotient should be equl to the slope of the tngent line, or when the horizontl xis is time

More information

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

Technische Universität München Winter term 2009/10 I7 Prof. J. Esparza / J. Křetínský / M. Luttenberger 11. Februar Solution Tehnishe Universität Münhen Winter term 29/ I7 Prof. J. Esprz / J. Křetínský / M. Luttenerger. Ferur 2 Solution Automt nd Forml Lnguges Homework 2 Due 5..29. Exerise 2. Let A e the following finite utomton:

More information

On the Eötvös effect

On the Eötvös effect On the Eötvös effect Mugu B. Răuţ The im of this ppe is to popose new theoy bout the Eötvös effect. We develop mthemticl model which loud us bette undestnding of this effect. Fom the eqution of motion

More information

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

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS The University of ottinghm SCHOOL OF COMPUTR SCIC A LVL 2 MODUL, SPRIG SMSTR 2015 2016 MACHIS AD THIR LAGUAGS ASWRS Time llowed TWO hours Cndidtes my omplete the front over of their nswer ook nd sign their

More information

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6 CS311 Computtionl Strutures Regulr Lnguges nd Regulr Grmmrs Leture 6 1 Wht we know so fr: RLs re losed under produt, union nd * Every RL n e written s RE, nd every RE represents RL Every RL n e reognized

More information

MATH34032: Green s Functions, Integral Equations and the Calculus of Variations 1. 1 [(y ) 2 + yy + y 2 ] dx,

MATH34032: Green s Functions, Integral Equations and the Calculus of Variations 1. 1 [(y ) 2 + yy + y 2 ] dx, MATH3403: Green s Funtions, Integrl Equtions nd the Clulus of Vritions 1 Exmples 5 Qu.1 Show tht the extreml funtion of the funtionl I[y] = 1 0 [(y ) + yy + y ] dx, where y(0) = 0 nd y(1) = 1, is y(x)

More information

Supplementary information Efficient Enumeration of Monocyclic Chemical Graphs with Given Path Frequencies

Supplementary information Efficient Enumeration of Monocyclic Chemical Graphs with Given Path Frequencies Supplementay infomation Efficient Enumeation of Monocyclic Chemical Gaphs with Given Path Fequencies Masaki Suzuki, Hioshi Nagamochi Gaduate School of Infomatics, Kyoto Univesity {m suzuki,nag}@amp.i.kyoto-u.ac.jp

More information

Review of Mathematical Concepts

Review of Mathematical Concepts ENEE 322: Signls nd Systems view of Mthemticl Concepts This hndout contins ief eview of mthemticl concepts which e vitlly impotnt to ENEE 322: Signls nd Systems. Since this mteil is coveed in vious couses

More information

arxiv: v1 [math.ca] 21 Aug 2018

arxiv: v1 [math.ca] 21 Aug 2018 rxiv:1808.07159v1 [mth.ca] 1 Aug 018 Clulus on Dul Rel Numbers Keqin Liu Deprtment of Mthemtis The University of British Columbi Vnouver, BC Cnd, V6T 1Z Augest, 018 Abstrt We present the bsi theory of

More information

working pages for Paul Richards class notes; do not copy or circulate without permission from PGR 2004/11/3 10:50

working pages for Paul Richards class notes; do not copy or circulate without permission from PGR 2004/11/3 10:50 woking pages fo Paul Richads class notes; do not copy o ciculate without pemission fom PGR 2004/11/3 10:50 CHAPTER7 Solid angle, 3D integals, Gauss s Theoem, and a Delta Function We define the solid angle,

More information

SAMPLE LABORATORY SESSION FOR JAVA MODULE B. Calculations for Sample Cross-Section 2

SAMPLE LABORATORY SESSION FOR JAVA MODULE B. Calculations for Sample Cross-Section 2 SAMPLE LABORATORY SESSION FOR JAVA MODULE B Calulations fo Sample Coss-Setion. Use Input. Setion Popeties The popeties of Sample Coss-Setion ae shown in Figue and ae summaized below. Figue : Popeties of

More information

Exercise sheet 6: Solutions

Exercise sheet 6: Solutions Eerise sheet 6: Solutions Cvet emptor: These re merel etended hints, rther thn omplete solutions. 1. If grph G hs hromti numer k > 1, prove tht its verte set n e prtitioned into two nonempt sets V 1 nd

More information

Supplementary Information. Origin of Chains of Au-PbS Nano-Dumbbells in. Space

Supplementary Information. Origin of Chains of Au-PbS Nano-Dumbbells in. Space Supplementy Infomtion Oigin of Chins of Au-PbS Nno-Dumbbells in Spe Chndn Mondl, Ali Hossin Khn, Bidis Ds, Somobt Ahy* & Sujit Sengupt*, Cente fo Advned Mteils, Indin Assoition fo the Cultivtion of Siene,

More information

Topics for Review for Final Exam in Calculus 16A

Topics for Review for Final Exam in Calculus 16A Topics fo Review fo Finl Em in Clculus 16A Instucto: Zvezdelin Stnkov Contents 1. Definitions 1. Theoems nd Poblem Solving Techniques 1 3. Eecises to Review 5 4. Chet Sheet 5 1. Definitions Undestnd the

More information

7.2 The Definite Integral

7.2 The Definite Integral 7.2 The Definite Integrl the definite integrl In the previous section, it ws found tht if function f is continuous nd nonnegtive, then the re under the grph of f on [, b] is given by F (b) F (), where

More information

Upward order-preserving 8-grid-drawings of binary trees

Upward order-preserving 8-grid-drawings of binary trees CCCG 207, Ottawa, Ontaio, July 26 28, 207 Upwad ode-peseving 8-gid-dawings of binay tees Theese Biedl Abstact This pape concens upwad ode-peseving staightline dawings of binay tees with the additional

More information

Fluids & Bernoulli s Equation. Group Problems 9

Fluids & Bernoulli s Equation. Group Problems 9 Goup Poblems 9 Fluids & Benoulli s Eqution Nme This is moe tutoil-like thn poblem nd leds you though conceptul development of Benoulli s eqution using the ides of Newton s 2 nd lw nd enegy. You e going

More information