1 <?xml version="1.0" encoding="utf-8" ?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
5 <!ENTITY in "<small style='font-size:small'>∈</small>">
6 <!ENTITY notin "<small style='font-size:small'>∉</small>">
13 <!ENTITY cduce "ℂDuce">
16 <!ENTITY setminus "∖" >
19 <!ENTITY subseteq "⊆" >
24 <!ENTITY lbrack "<span style='font-size:xx-large;'>⟦</span>" >
25 <!ENTITY rbrack "<span style='font-size:xx-large;'>⟧</span>" >
27 <!ENTITY left "<tt style='color:#d33'>L</tt>" >
28 <!ENTITY right "<tt style='color:#33d'>R</tt>">
30 <!ENTITY rleadsto "⟿"> <!-- -->
37 <html xmlns="http://www.w3.org/1999/xhtml" >
39 <title>A Core Calculus for XQuery 3.0</title>
41 <meta http-equiv="Content-Type"
42 content="text/html; charset=utf-8" />
43 <meta name="copyright"
44 content="Copyright © 2013 Kim Nguyễn" />
47 <script src="../jquery-2.0.3.min.js" type="text/javascript" ></script>
48 <script src="../libs/raphael-min.js" type="text/javascript" ></script>
49 <!-- Load the library -->
50 <script src="../simpleWebSlides.js" type="text/javascript" ></script>
52 <link rel="stylesheet" href="../simpleWebSlides.css" type="text/css" media="all" />
53 <!-- Load a custom Theme, the class-element marks this style-sheet
54 a "theme" that can be swtiched dynamicaly -->
55 <link class="sws-theme" rel="stylesheet" title="U-Psud style" href="../themes/uPsud.css" type="text/css" />
57 <!-- Customize some templates and initialize -->
59 <script type="text/javascript">
60 SWS.Config['sws-slide-change'] = SWS.Effects.slideChangeFadeOutIn;
61 SWS.Config['sws-object-deactivate'] = SWS.Effects.objectDeactivateFadeOut;
62 SWS.Config['sws-object-activate'] = SWS.Effects.objectActivateFadeIn;
64 //Ensures that we load SWS at the very end, after MathJax has
67 $(window).load(SWS.Presentation.init);
69 var col_change = function (sel, col) {
70 return function (canvas) {
71 canvas.find(".xpath *").css("color","");
72 var objs = canvas.find(sel);
73 objs.css("color", col);
76 var reg = SWS.Presentation.registerCallback;
82 src: url("OpenSans-Regular.ttf") format("truetype");
83 font-family: "Open Sans";
88 src: url("OpenSans-Bold.ttf") format("truetype");
89 font-family: "Open Sans";
94 src: url("OpenSans-Italic.ttf") format("truetype");
95 font-family: "Open Sans";
100 src: url("OpenSans-BoldItalic.ttf") format("truetype");
101 font-family: "Open Sans";
109 font-family: 'Open Sans',sans-serif;
111 background-color: white;
121 pre, dfn, .infer { font-family : serif;
128 vertical-align:text-bottom;
129 display:inline-block;
140 vertical-align:text-bottom;
141 display:inline-block;
147 margin: 0pt 0pt 0pt 0pt;
148 padding: 0pt 0pt 0pt 0pt;
151 .infer > span:last-child {
152 margin: 0pt 0pt 0pt 0pt;
153 padding: 0pt 0pt 0pt 0pt;
154 border-width: 1pt 0pt 0pt 0pt;
156 border-color: #292928;
159 vertical-align:text-top;
165 margin: 0pt 0pt 0pt 0pt;
166 padding: 0pt 0pt 0pt 0pt;
168 span.fill { display:inline-block;
176 <div class="sws-slide sws-cover sws-option-nofooter">
177 <h1 style="font-size:200%;position:relative;top:-1em;">A Core Calculus for XQuery 3.0</h1>
178 <h3>Combining Navigational and Pattern-Matching Approaches</h3>
179 <div style="text-align:center;">
180 <table style="display:inline-block">
182 <td>Giuseppe Castagna<sup>1</sup></td>
183 <td>Hyeonseung Im<sup>2</sup></td>
186 <td><u>Kim Nguyễn</u><sup>3</sup></td>
187 <td>Véronique Benzaken<sup>3</sup></td>
191 <p style="font-size:80%;position:absolute;bottom:2.5em;left:4em;">
192 1 CNRS, PPS, Université Paris-Diderot, Paris, France <br/>
193 2 Kangwon National University, Chuncheon, Rep. of Korea<br/>
194 3 LRI, Université Paris-Sud, Orsay, France
197 <div class="sws-slide">
199 <p>W3C standard language for querying XML
200 databases/documents</p>
201 <code style="background:white">
202 declare function <u>get_links</u>(<u>$page</u>, <u>$print</u>) {
204 <span class="for">for</span> <u>$i</u> <span class="for">in</span> <u>$page</u><span class="xpath">/descendant::a[not(ancestor::b)]</span>
205 <span class="for">return</span> <u>print</u>(<u>$i</u>)
208 declare function <u>pretty</u>(<u>$link</u>) {
209 <span class="ts">typeswitch</span>(<u>$link</u>)
210 <span class="ts">case</span> <u>$l</u> <span class="ts">as element(a)</span>
211 return <span class="sw">switch</span> (<u>$l</u><span class="xpath">/@class</span>)
212 <span class="sw">case</span> "style1"
213 return <a href={<u>$l</u><span class="xpath">/@href</span>}><b>{<u>$l</u><span class="xpath">/text()</span>}</b></a>
214 default return <u>$l</u>
216 <span class="ts">default return</span> <u>$link</u>
219 <script type="text/javascript">
220 reg ("0", col_change(".xpath, .for, .ts, .sw",""));
221 reg ("1", col_change(".xpath", "#f80"));
222 reg ("2", col_change(".for",""));
223 reg ("2", col_change(".for", "#290"));
224 reg ("3", col_change(".ts", ""));
225 reg ("3", col_change(".ts", "#80f"));
226 reg ("4", col_change(".sw", ""));
227 reg ("4", col_change(".sw", "#0f2"));
230 <div class="sws-slide">
235 + nice declarative syntax for paths
238 - weird distinction between types/value case<br/>
239 - <s>no type-checking for functions</s>
242 <p>It's a pity since XML <em>documents</em> are very precisely
243 typed (DTD, XMLSchemas)</p>
244 <p>Document type information is validated at runtime rather than
245 checked statically</p>
247 <div class="sws-slide">
249 <p>A polymorphic functional language (ML-style) equipped with
250 semantic subtyping</p>
253 let <u>pretty</u> (<a>_ -> <a>_ & Any\<a>_ &rarrow; Any\<a>_)
255 | <a class="style1" href=<u>h</u> ..> <u>l</u> &rarrow; <a href=<u>h</u>>[ <b><u>l</u> ]
259 let <u>get_links</u> (page: <_>_) (print: <a>_ -> <a>_) : [ <a>_ * ] =
262 <a>_ & x &rarrow; [ (print x) ]
263 | < (_\‘b) > l &rarrow;
264 (transform l with (i & <_>_) &rarrow; get_links i print)
274 <div class="sws-slide">
278 + Statically typed <br/>
279 + compact (and efficient) type and value pattern-matching
282 - <s>complex navigation encoded through recursion</s><br/>
283 - no type inference for functions
286 <p>Writing functions to traverse documents is painfull</p>
288 <div class="sws-slide">
290 <ol style="margin-left:1em; margin-right:0.25em;list-style-position:inside;">
291 <li id="tobox" style="padding:1em 0em 1em 0em;"><span class="lh">Add support for path navigation to
293 <ul style="margin-top:2em;">
294 <li>Enrich the type algebra with <em>zippers</em> (à la Huet)</li>
295 <li>Extend pattern-matching construct to <em>zipped values and types</em></li>
296 <li>Encode path expressions as recursive patterns</li>
299 <li class="ll" style="padding:1em 0em 1em 0em;">Perform a type-directed translation from XQuery to
302 <script type="text/javascript">
303 reg (1, col_change(".lh", "#f83"));
304 reg (1, col_change(".ll", "#bbb"));
307 <div class="sws-slide">
308 <h1>&cduce;'s type algebra</h1>
310 t ::= b | c | <u>t × t</u> | <u>t &rarrow; t</u> | <a>t &lor; t</a> | <mark>t &land; t</mark> | <mark>t ∖ t</mark> | <mark>⊤</mark> | <mark>⊥</mark> | α
312 <p><dfn>b</dfn> : ranges over basic types (<tt>Int</tt>, <tt>String</tt>, …)<br/>
313 <dfn>c</dfn> : ranges over singleton types
314 (<tt>`A</tt>, <tt>42</tt>, …)<br/>
315 <u>Type constructors</u> <br/>
316 <mark>Boolean connectives</mark> <br/>
317 <dfn>α</dfn> : type variables<br/>
318 types are interpreted co-inductively: recursive types and regular
319 expression types<br/>
321 <div style="vertical-align:top;">
322 <pre style="width:50%;display:inline-block;"> t<sub>1</sub> ≡ (<tt>Int</tt> × t<sub>1</sub>) &lor; t<sub>2</sub>
323 t<sub>2</sub> ≡ (<tt>Bool</tt> × t<sub>2</sub>) &lor; (<tt>Bool</tt> × <tt>`nil</tt>)
325 <pre style="width:30%;display:inline-block;"> <span class="sws-pause">t<sub>1</sub> ≡ <tt>[ Int* Bool+ ]</tt></span></pre>
328 <div class="sws-slide">
329 <h1>Semantic subtyping</h1>
330 <pre style="text-align:center;">
331 t ≤ s &Lrarrow; [t] ⊆ [s]
333 <p><dfn>[ ]</dfn> interpretation of types as sets of
335 Allows to reason <i>modulo</i> semantic equivalence of type connectives :
338 <tt>[ Int* (Int | Bool*)? ]</tt> &land; <tt>[ Int+ (Bool+ | Int)* ]</tt> ≡ <tt>[Int+ Bool*]</tt>
341 <div class="sws-slide">
342 <h1>&cduce; data-model</h1>
343 <p>The usual sets of values: constants, λ-abstractions, pairs, …</p>
344 <p>Sequences are nested pairs: <dfn><tt>[</tt> v<sub>1</sub> … v<sub>n</sub> <tt>]</tt> ≡ (v<sub>1</sub>, (…, (v<sub>n</sub>, <tt>`nil</tt>)))
346 <p>XML documents are tagged sequences: <pre style="text-align:center;"><tt><foo>[</tt> v<sub>1</sub> … v<sub>n</sub> <tt>]</tt> ≡ (<tt>`foo</tt>, <tt>[</tt> v<sub>1</sub> … v<sub>n</sub> <tt>]</tt>)</pre>
348 <p>(Sometimes we write <tt>[ ]</tt> for the variant <tt>`nil</tt>)</p>
350 <div class="sws-slide">
351 <h1>&cduce; patterns</h1>
352 <p><i>(a.k.a. the left-hand side of an arrow in a match … with)</i></p>
353 <pre style="text-align:center;"> p ::= t | x | <u>(p, p)</u> | <mark>p | p</mark> | <mark>p & p</mark> </pre>
354 <p><dfn>t</dfn> ranges over types<br/>
355 <dfn>x</dfn> ranges over capture variables<br/>
356 <u>Pair patterns</u><br/>
357 <mark> Alternation |, Intersection &</mark><br/>
358 patterns are also co-inductively interpreted (recursive patterns)
360 <p><dfn><u>v / p</u></dfn> : matching a value against a pattern yields a
361 substitution from variables to values<br/>
362 <dfn><u>&lbag; p &rbag;</u></dfn> : the set of values accepted by a
363 pattern is <u>a type</u><br/>
364 <dfn><u> t / p</u></dfn> : matching a type against a pattern yields a
365 substitution from variables to types<br/>
368 <div class="sws-slide">
369 <h1>&cduce; patterns (example)</h1>
370 <p>Assume <tt><u>l</u></tt> has type <tt>[ Int+ Bool* ]</tt>, consider:</p>
373 [ _* (<u>x</u> & Int) Bool* (<u>y</u> & Bool) ] &rarrow; (<u>x</u>, <u>y</u>)
374 | [ _* (<u>x</u> & Int) ] &rarrow; (<u>x</u>, `false)
375 | [ ] &rarrow; (0, `false)
378 <li><dfn>&lbag;<tt>[ _* (<u>x</u> & Int) Bool* (<u>y</u> & Bool) ]</tt>&rbag; ≡ <tt>[ ⊤* Int Bool+ ]</tt></dfn><br/>
379 yield : { x ↦ <tt>Int</tt>, y ↦ <tt>Bool</tt> }
381 <li><dfn>&lbag;<tt>[ _* (<u>x</u> & Int) ]</tt>&rbag; ≡ <tt>[ ⊤* Int ]</tt></dfn><br/>
382 yield : { x ↦ <tt>Int</tt> }
384 <li>Since <dfn><tt>[Int+ Bool* ]</tt> ∖ ( <tt>[ ⊤* Int Bool+ ]</tt> &lor; <tt>[ ⊤* Int]</tt>) ≡ ⊥ </dfn>
385 the third case is unreachable.
393 <div class="sws-slide">
394 <h1>Zippers (1/2)</h1>
396 <li>Introduced in 1997 by Gérard Huet</li>
397 <li>Stack of visited nodes</li>
398 <li>Push the current node on the stack when traversing a pair</li>
399 <li>Take top of the stack to go backward</li>
400 <li>Tag the elements of the stack to remember which component of a
401 pair we have visited</li>
403 <pre style="text-align:center;"> v ::= … | v<sub>δ</sub>
404 δ ::= &bcirc; | &left;v · δ | &right;v · δ
408 <div class="sws-slide">
409 <h1>Zippers (2/2)</h1>
410 <p><tt><u>fst</u></tt> (resp. <tt><u>snd</u></tt>) takes the first (resp. second)
411 projection of a pair and update its zipper accordingly:</p>
412 <pre> v<sub>1</sub> ≡ (1, (2, (3, (4, `nil))))<sub>&bcirc;</sub>
413 v<sub>11</sub> ≡ fst v<sub>1</sub> ≡ 1<sub>&left;(1, (2, (3, (4, `nil))))<sub>&bcirc;</sub> · &bcirc; </sub>
414 v<sub>2</sub> ≡ snd v<sub>1</sub> ≡ (2, (3, (4, `nil)))<sub>&right;(1, (2, (3, (4, `nil))))<sub>&bcirc;</sub> · &bcirc; </sub>
415 v<sub>3</sub> ≡ snd v<sub>2</sub> ≡ (3, (4, `nil))<sub>&right;v<sub>2</sub> · &right;v<sub>1</sub> · &bcirc; </sub>
417 <p><tt><u>up</u></tt> returns the head of the zipper: </p>
418 <pre> up v<sub>3</sub> ≡ v<sub>2</sub> ≡ (2, (3, (4, `nil)))<sub>&right;(1, (2, (3, (4, `nil))))<sub>&bcirc;</sub> · &bcirc; </sub>
421 <div class="sws-slide">
422 <h1>Zipper types</h1>
423 <p>We extend the type-algebra with zipper types:</p>
424 <pre style="text-align:center;"> t ::= … | t<sub>τ</sub>
425 τ ::= &bcirc; | &left;t · τ | &right;t · τ | τ &lor; τ | τ ∖ τ | &ztop;
427 <p><dfn>&bcirc;</dfn>: singleton type denoting the empty zipper (root element)<br/>
428 <dfn>&ztop;</dfn>: the top zipper type<br/>
429 Zipper types are interpreted co-inductively<br/><br/>
430 <dfn><tt>Int</tt><sub>(&left;⊤)* &bcirc;</sub></dfn> <span style="float:right;">type of
431 integers that are the leftmost descendant of a tree</span><br/><br/>
432 <dfn><tt><![CDATA[<html>[ <head>[…] <body>[…] ]]]></tt><sub>&bcirc;</sub></dfn> <span style="float:right;">type of
433 HTML documents</span><br/><br/>
434 <dfn><tt><![CDATA[<a href=String>[ … ]]]></tt><sub>(&right; ⊤) · &ztop;</sub></dfn> <span style="float:right;">types of links in any context</span>
438 <div class="sws-slide">
439 <h1>Tree navigation</h1>
440 <p>Since patterns contain types, we can check complex
442 <pre style="width:60%;display:inline-block;border-width:0pt 1pt 0pt
443 0pt; border-style:dashed;border-color: black;vertical-align:middle"> <span style="font-family:'Open Sans';">Has a descendant <tt><a>_</tt>:</span>
444 p ≡ <tt id="test"><a>_</tt> &lor; <tt><_>[ _* p _* ]</tt>
446 <span style="font-family:'Open Sans';">Deos not have an ancestor <tt><b>_</tt>:</span>
447 τ ≡ &bcirc; &lor; &right;(⊤∖ <tt><b>_</tt>) · τ &lor; &left;(⊤∖ <tt><b>_</tt>) · τ
450 <code style="width:20%;display:inline-block;vertical-align:middle">
452 <dfn>p<sub>τ</sub></dfn> & <u>x</u> &rarrow; …
453 | _ &rarrow; …</code>
454 <p style="background:white">We want more, namely return <i>all</i> descendants (ancestors,
455 children, siblings, …) of a node matching a particular condition
457 Remark: (recursive) patterns <u>already perform a recursive traversal
460 <em>Idea</em>: Piggy back on the traversal and <em>accumulate</em>
461 nodes in special variables
464 <div class="sws-slide">
465 <h1>Operators and Accumulators</h1>
466 <p>An <u>operator</u> is a 4-tupple <dfn>(o, n<sub>o</sub>,
467 &rleadsto;<sub>o</sub>, &rarrow;<sub>o</sub>)</dfn>, where:</p>
468 <p><dfn><u>o</u></dfn>: is the accumulator name<br/>
469 <dfn><u>n<sub>o</sub></u></dfn>: is the arity of <u>o</u><br/>
470 <dfn><u>&rleadsto;<sub>o</sub></u></dfn>:
471 &mathV;<sup>n<sub>o</sub></sup> &rsarrow; &mathV;, the reduction relation <br/>
472 <dfn><u>&rarrow;<sub>o</sub></u></dfn>:
473 &mathT;<sup>n<sub>o</sub></sup> &rsarrow; &mathT;, the typing relation <br/>
475 <p>An <u>accumulator</u> is a variable (ranged over
476 by <u>ẋ</u>, <u>ẏ</u>, …) with:<br/><br/>
477 <dfn><u>Op(ẋ)</u></dfn>: an operator<br/>
478 <dfn><u>Init(ẋ)</u> ∈ &mathV;</dfn> : an initial value<br/>
481 <div class="sws-slide">
482 <h1>Some operators</h1>
484 v, v' &rleadsto;<sup>cons,</sup> (v, v') <br/>
485 v, <tt>`nil</tt> &rleadsto;<sup>snoc</sup> (v, <tt>`nil</tt>)<br/>
486 v, (v',v'') &rleadsto;<sup>snoc</sup> (v', snoc(v,v''))<br/>
488 <p>Now we can use accumulators equipped with cons/snoc in
489 patterns. Instead of matching a single node against a variable, it
490 <u>accumulates</u> that node in sequence (in reverse or in-order).</p>
492 <div class="sws-slide">
493 <h1>Pattern matching semantics (v/p)</h1>
494 <pre style="text-align:center;">
495 σ; δ ⊢ v / p &rleadsto; γ, σ'
497 <p style="font-size:90%"><dfn><u>σ</u>, <u>σ'</u></dfn>: mapping from accumulators to
499 <dfn><u>v</u></dfn>: input value<br/>
500 <dfn><u>p</u></dfn>: pattern<br/>
501 <dfn><u>γ</u></dfn>: mapping from capture variables to
503 <dfn><u>δ</u></dfn>: current context
505 <div style="padding:0em 1em 0em; text-align:justify;font-size:85%;background:white;">
507 <span> v ∈ [ t ]</span>
508 <span>σ; δ ⊢ v / t &rleadsto; ∅,
510 </div><span>(type)</span>
514 <span>σ; δ ⊢ v / ẋ &rleadsto; ∅,
515 σ[ ẋ := Op(ẋ) (v<sub>δ</sub>, σ(ẋ)) ]</span>
516 </div><span>(acc)</span>
520 <span>σ; δ ⊢ v / x &rleadsto; { x ↦ v },
522 </div><span>(var)</span>
525 <span>σ; &left;v · δ ⊢ (fst v)/p<sub>1</sub>
526 &rleadsto; γ<sub>1</sub>, σ' </span>
527 <span>σ'; &right;v · δ ⊢ (snd v)/p<sub>2</sub>
528 &rleadsto; γ<sub>2</sub>, σ''
530 <span>σ; δ ⊢ v /
531 (p<sub>1</sub>, p<sub>2</sub>) &rleadsto;
532 γ<sub>1</sub>∪ γ<sub>2</sub>,
534 </div><span>(pair)</span> <span class="fill"></span>
535 <span>… and some other rules for alternation, failure, recursion, <i>etc.</i></span>
538 <div class="sws-slide">
539 <h1>Typing of patterns (with accumulators) 1/2</h1>
540 <p>Well known that typing path expressions escapes regular tree languages
541 (i.e. &cduce;'s types). Consider:
543 <pre style="margin:-3em 0pt -1em;">
544 t ≡ <tt><c>[ <u><a>[]</u> t <u><b>[]</u> ] </tt> &lor; <tt><c>[]</tt> <img style="margin-left:3em;width:15%;vertical-align:middle;" src="anbn_tree.svg" alt="anbn"/>
546 <p>The set of all <tt><u>a</u></tt> or <tt><u>b</u></tt> labeled
548 is <dfn>{ <tt>[<u><a>[]</u></tt><sup>n</sup> <tt><u><b>[]</u></tt><sup>n</sup> <tt>]</tt> | n ≥ 0 }</dfn>
549 which is not a type.</p>
550 <p> Intuitively it means that when applying a
551 recursive pattern against a recursive type, we may generate an
552 <s>infinite number of distinct types</s> for an accumulator.
555 <div class="sws-slide">
556 <h1>Typing of patterns (with accumulators) 2/2</h1>
557 <p>We use the typing relation of operators to introduce
560 <u>t<sub>0</sub></u>, <tt>[</tt> (t<sub>1</sub> &lor; … &lor; t<sub>n</sub>)<tt>* ]</tt> &rarrow;<sup>cons</sup> <tt>[</tt> (<u>t<sub>0</sub></u> &lor; t<sub>1</sub> &lor; … &lor; t<sub>n</sub>)<tt>* ]</tt> <br/>
561 <u>t<sub>0</sub></u>, <tt>[</tt> (t<sub>1</sub> &lor; … &lor; t<sub>n</sub>)<tt>* ]</tt> &rarrow;<sup>snoc</sup> <tt>[</tt> (<u>t<sub>0</sub></u> &lor; t<sub>1</sub> &lor; … &lor; t<sub>n</sub>)<tt>* ]</tt>
563 <p>Ensures termination of typechecking of patterns.</p>
565 <div class="sws-slide">
567 <p>Zippers (in values, types, patterns) are orthogonal to the rest of the language</p>
569 <li><u>Subtyping and typechecking</u> are extended straightforwardly</li>
570 <li>Typing of patterns introduces <u>sound approximations</u> only for accumulators</li>
571 <li>Provided the operators are sound, the whole language remains <u>type-safe</u></li>
574 <div class="sws-slide">
575 <h1>From zippers to XPath</h1>
576 <p>We use <u>regular expressions</u> over basic &left;/&right; zippers to encode XPath</p>
577 <code style="width:50%;float:left;"> <![CDATA[<a>[ <b>[
583 </code><img style="width:17.5%;" src="ex_ntree.svg" alt="ex_ntree" /><br/>
584 <p class="sws-pause"><img style="margin-top:-1em;margin-left:5%;width:85%;" src="rb_tree.svg" alt="rb_tree"/></p>
586 <div class="sws-slide">
587 <h1>Downward XPath axes</h1>
588 <pre style="background:white"> <tt>self ::</tt> t ≡ (ẋ <tt>&</tt> t | _ )<sub>&ztop;</sub> (Init(ẋ) = [], Op(ẋ) = <tt>snoc</tt>)
590 <span class="sws-pause"><tt>child ::</tt> t ≡ <tt><_>[</tt> (ẋ <tt>&</tt> t | _ )<tt>* ]</tt><sub>&ztop;</sub></span>
592 <p class="sws-pause">Example: applying <tt><u>child::<b>_</u></tt> to the document</p>
593 <code> <doc>[ <a>[] <b>[] <c>[] <b>[] ]<sub>&bcirc;</sub>
594 <span class="sws-pause"><_>[ <span class="sws-pause"> _</span> <mark class="sws-pause">(ẋ & <b>_)</mark> <span>_</span> <mark>(ẋ & <b>_)</mark>]<sub >&ztop;</sub></span>
596 <span class="sws-pause"> ẋ↦ [ <b>[]<sub>&left;… &right;… &right;… &bcirc;</sub> <b>[]<sub>&left;… &right;… &right;… &right;… &right;… &bcirc;</sub> ] </span>
599 <pre class="sws-pause">
600 <tt>descendant-or-self::</tt> t ≡ X ≡ ((ẋ <tt>&</tt> t | _ ) <tt> & <_>[</tt> X <tt>* ]</tt>)<sub>&ztop;</sub>
602 <tt>descendant</tt> :: t ≡ <tt><_>[ (descendant-or-self::</tt>t<tt>)* ]</tt><sub>&ztop;</sub>
605 <script type="text/javascript">
610 svgDoc = svgDoc || document.getElementById("svgRBTree").contentDocument;
611 var f = svgDoc.getElementById("nodef");
612 f.style['fillOpacity'] = "0";
613 var elems = svgDoc.getElementsByClassName("parentf");
614 for(var i = 0; i < elems.length; i++) {
615 elems[i].style['strokeWidth'] = '2px';
619 reg (0, function (c) {
624 reg (1, function (c) {
626 var f = svgDoc.getElementById("nodef");
627 console.log(' Opacity ' + f.style['fillOpacity']);
628 f.style['fillOpacity'] = "0.5";
629 console.log(' Opacity ' + f.style['fillOpacity']);
632 reg (2, function (c) {
634 var elems = svgDoc.getElementsByClassName("parentf");
635 for(i = 0; i < elems.length; i++) {
636 elems[i].style['strokeWidth'] = '6px';
639 reg (3, function (c) { console.log(3); reset(); });
644 <div class="sws-slide">
645 <h1>Upward XPath axes</h1>
646 <div style="position:absolute; width:80%; left:10%;top:15%">
647 <object id="svgRBTree" data="rb_tree.svg" type="image/svg+xml" style="z-index:1;position:absolute;width:100%" />
648 <object class="sws-onframe-1" id="svgRBTree1" data="rb_tree01.svg" type="image/svg+xml" style="z-index:1;position:absolute;width:100%" />
649 <object class="sws-onframe-2" id="svgRBTree2" data="rb_tree02.svg" type="image/svg+xml" style="z-index:3;position:absolute;width:100%" />
650 <object class="sws-onframe-3" id="svgRBTree3" data="rb_tree03.svg" type="image/svg+xml" style="z-index:4;position:absolute;width:100%" />
651 <object class="sws-onframe-4" id="svgRBTree4" data="rb_tree04.svg" type="image/svg+xml" style="z-index:5;position:absolute;width:100%" />
653 <pre style="position:absolute;bottom:5%;z-index:1;"> <tt>parent ::</tt> t ≡ ⊤<sub> (&left;_) · (&right;_)* · (&right; ẋ & t) · (( (&left; _) · &ztop;) &lor; &bcirc; )</sub>
655 <span class="sws-onframe-5"> <tt>ancestor ::</tt> t ≡ ⊤<sub> ( (&left;_) · (&right;_)* · (&right; ẋ & t) )* · &bcirc; </sub></span>
661 <pre style="position:absolute;bottom:5%;z-index:2;">
663 <span class="sws-onframe-1" style="font-size:110%;color:#1fb01b;">⬆</span> <span class="sws-onframe-2" style="font-size:110%;color:#1fb01b;">⬆</span> <span class="sws-onframe-3" style="font-size:110%;color:#1fb01b;">⬆</span> <span class="sws-onframe-4" style="font-size:110%;color:#1fb01b;">⬆</span>
665 <span style="color:#1fb01b;border-color:#1fb01b;border-top-style:dashed;border-top-width:3pt;position:relative;top:0.5em;"> parent </span>
671 <div class="sws-slide">
672 <h1>Other results</h1>
674 <li>Encoding of paths is compositional</li>
675 <li>Once we have path, translation from XQuery to &cduce; is straightforward</li>
676 <li>We also give a direct typing algorithm for XQuery 3.0 rather than typing the translation to &cduce;</li>
679 <div class="sws-slide">
680 <h1>Conclusion, thoughts and future work</h1>
682 <li>Adding path expressions to a functional language such as &cduce; is possible </li>
683 <li>Semantic subtyping and regular expression types play nicely with zippers</li>
684 <li>In terms of language design, exposing directly zippers patterns to the programmer is a big no-no</li>
685 <li>Can also be applied to XSLT</li>
686 <li>Implementation on-going (including a &cduce; to javascript backend)</li>
687 <li>Extend the approach to Json (google ``path language for json''), i.e. generalise from products to extensible records</li>