.
[hacks/simpleWebSlides.git] / pres-esop15 / 01.xhtml
diff --git a/pres-esop15/01.xhtml b/pres-esop15/01.xhtml
new file mode 100644 (file)
index 0000000..845513e
--- /dev/null
@@ -0,0 +1,672 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
+[
+         <!ENTITY in  "<small style='font-size:small'>∈</small>">
+         <!ENTITY notin  "<small style='font-size:small'>∉</small>">
+         <!ENTITY emptyset  "⦰">
+         <!ENTITY cup       "∪">
+         <!ENTITY cap       "∩">
+         <!ENTITY mapsto  "↦">
+         <!ENTITY rarrow   "⟶">
+         <!ENTITY rsarrow   "→">
+         <!ENTITY cduce   "&#x2102;Duce">
+          <!ENTITY land    "∧" >
+          <!ENTITY lor      "∨" >
+          <!ENTITY setminus "∖" >
+         <!ENTITY bottom   "𝟘" >
+         <!ENTITY top      "𝟙" >
+         <!ENTITY subseteq "⊆" >
+         <!ENTITY leq      "≤" >
+         <!ENTITY Lrarrow  "⟺">
+         <!ENTITY lbag  "⟅">
+         <!ENTITY rbag  "⟆">
+         <!ENTITY lbrack "<span style='font-size:xx-large;'>⟦</span>" >
+         <!ENTITY rbrack "<span style='font-size:xx-large;'>⟧</span>" >
+         <!ENTITY bcirc  "⏺" >
+         <!ENTITY left  "<tt style='color:#d33'>L</tt>" >
+         <!ENTITY right  "<tt style='color:#33d'>R</tt>">
+         <!ENTITY ztop      "⊤" >
+         <!ENTITY rleadsto  "⟿"> <!-- -->
+         <!ENTITY rwave   "↝">
+         <!ENTITY mathV     "𝓥">
+         <!ENTITY mathT     "𝓣">
+         <!ENTITY vdash     "⊢">
+]
+          >
+<html xmlns="http://www.w3.org/1999/xhtml" >
+  <head>
+    <title>A Core Calculus for XQuery 3.0</title>
+
+    <meta http-equiv="Content-Type"
+          content="text/html; charset=utf-8" />
+    <meta name="copyright"
+          content="Copyright &#169; 2013 Kim Nguyễn" />
+
+    <!-- Load jQuery -->
+    <script src="../jquery-2.0.3.min.js" type="text/javascript" ></script>
+    <script src="../libs/raphael-min.js" type="text/javascript" ></script>
+    <!-- Load the library -->
+    <script src="../simpleWebSlides.js" type="text/javascript" ></script>
+
+    <link rel="stylesheet" href="../simpleWebSlides.css" type="text/css"  media="all" />
+    <!-- Load a custom Theme, the class-element marks this style-sheet
+         a "theme" that can be swtiched dynamicaly -->
+    <link class="sws-theme" rel="stylesheet"  title="U-Psud style"  href="../themes/uPsud.css" type="text/css" />
+
+    <!-- Customize some templates and initialize -->
+
+    <script type="text/javascript">
+      SWS.Config['sws-slide-change'] = SWS.Effects.slideChangeFadeOutIn;
+      SWS.Config['sws-object-deactivate'] =  SWS.Effects.objectDeactivateFadeOut;
+      SWS.Config['sws-object-activate'] = SWS.Effects.objectActivateFadeIn;
+
+      //Ensures that we load SWS at the very end, after MathJax has
+      //been initialized
+
+      $(window).load(SWS.Presentation.init);
+
+      var col_change = function (sel, col) {
+      return function (canvas) {
+        canvas.find(".xpath *").css("color","");
+        var objs = canvas.find(sel);
+        objs.css("color", col);
+      };
+      };
+      var reg = SWS.Presentation.registerCallback;
+    </script>
+    <style>
+      <![CDATA[
+
+       @font-face {
+         src: url("OpenSans-Regular.ttf") format("truetype");
+         font-family: "Open Sans";
+         font-weight: normal;
+       }
+
+      @font-face {
+         src: url("OpenSans-Bold.ttf") format("truetype");
+         font-family: "Open Sans";
+         font-weight: bold;
+       }
+
+      @font-face {
+         src: url("OpenSans-Italic.ttf") format("truetype");
+         font-family: "Open Sans";
+         font-style: italic;
+       }
+
+      @font-face {
+         src: url("OpenSans-BoldItalic.ttf") format("truetype");
+         font-family: "Open Sans";
+         font-weight: bold;
+         font-style: italic;
+       }
+
+        ]]>
+
+      body {
+      font-family: 'Open Sans',sans-serif;
+      font-size: 3.75vh;
+      background-color: white;
+      color:  #393938;
+      }
+
+      .sws-canvas {
+            color: #393938;
+      }
+      code, tt {
+                  color: #292928;
+      }
+      pre, dfn, .infer { font-family : serif;
+      font-style:normal;
+      color: #292928;
+      }
+
+      .stack {
+      text-align:center;
+      vertical-align:text-bottom;
+      display:inline-block;
+      }
+      .over {
+      display:block;
+      font-size:small;
+      margin: 0pt;
+      padding: 0pt;
+      }
+
+      .infer {
+      text-align:center;
+      vertical-align:text-bottom;
+      display:inline-block;
+      margin-bottom:1em;
+      margin-top:0em;
+      }
+      .infer > span {
+               display:block;
+               margin: 0pt 0pt 0pt 0pt;
+               padding: 0pt 0pt 0pt 0pt;
+               border-width: 0pt;
+      }
+      .infer > span:last-child {
+               margin: 0pt 0pt 0pt 0pt;
+               padding: 0pt 0pt 0pt 0pt;
+               border-width: 1pt 0pt 0pt 0pt;
+               border-style: solid;
+               border-color:  #292928;
+      }
+      .infer + span {
+               vertical-align:text-top;
+               position:relative;
+               top:-1.75em;
+               display:inline;
+               font-size:80%;
+               color: #00486c;
+               margin: 0pt 0pt 0pt 0pt;
+               padding: 0pt 0pt 0pt 0pt;
+      }
+      span.fill { display:inline-block;
+                  width:100%;
+                  height: 0pt;
+      }
+
+    </style>
+  </head>
+  <body>
+    <div class="sws-slide sws-cover sws-option-nofooter">
+      <h1 style="font-size:200%;position:relative;top:-1em;">A Core Calculus for XQuery 3.0</h1>
+      <h3>Combining Navigational and Pattern-Matching Approaches</h3>
+      <div style="text-align:center;">
+       <table style="display:inline-block">
+         <tr>
+           <td>Giuseppe Castagna<sup>1</sup></td>
+           <td>Hyeonseung Im<sup>2</sup></td>
+         </tr>
+         <tr>
+           <td><u>Kim Nguyễn</u><sup>3</sup></td>
+           <td>Véronique Benzaken<sup>3</sup></td>
+         </tr>
+       </table>
+      </div>
+      <p style="font-size:80%;position:absolute;bottom:2.5em;left:4em;">
+       CNRS, PPS, Université Paris-Diderot, Paris, France <br/>
+       Kangwon National University, Chuncheon, Rep. of Korea<br/>
+       LRI, Université Paris-Sud, Orsay, France
+      </p>
+    </div>
+    <div class="sws-slide">
+      <h1>XQuery 3.0</h1>
+      <p>W3C standard language for querying XML
+      databases/documents</p>
+<code style="background:white">
+   declare function <u>get_links</u>(<u>$page</u>, <u>$print</u>) {
+
+       <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>
+       <span class="for">return</span> <u>print</u>(<u>$i</u>)
+   }
+
+   declare function <u>pretty</u>(<u>$link</u>) {
+       <span class="ts">typeswitch</span>(<u>$link</u>)
+           <span class="ts">case</span> <u>$l</u> <span class="ts">as element(a)</span>
+              return <span class="sw">switch</span> (<u>$l</u><span class="xpath">/@class</span>)
+                 <span class="sw">case</span> "style1"
+                     return &lt;a href={<u>$l</u><span class="xpath">/@href</span>}&gt;&lt;b&gt;{<u>$l</u><span class="xpath">/text()</span>}&lt;/b&gt;&lt;/a&gt;
+                 default return <u>$l</u>
+
+           <span class="ts">default return</span> <u>$link</u>
+   }
+</code>
+    <script type="text/javascript">
+      reg ("0", col_change(".xpath, .for, .ts, .sw",""));
+      reg ("1", col_change(".xpath", "#f80"));
+      reg ("2", col_change(".for",""));
+      reg ("2", col_change(".for", "#290"));
+      reg ("3", col_change(".ts", ""));
+      reg ("3", col_change(".ts", "#80f"));
+      reg ("4", col_change(".sw", ""));
+      reg ("4", col_change(".sw", "#0f2"));
+    </script>
+    </div>
+    <div class="sws-slide">
+      <h1>XQuery 3.0</h1>
+      <ul>
+       <li>Pros<br/>
+         + standardized <br/>
+         + nice declarative syntax for paths
+       </li>
+       <li>Cons<br/>
+         - weird distinction between types/value case<br/>
+         - <s>no type-checking for functions</s>
+       </li>
+      </ul>
+      <p>It's a pity since XML <em>documents</em> are very precisely
+      typed (DTD, XMLSchemas)</p>
+      <p>Document type information is validated at runtime rather than
+      checked statically</p>
+    </div>
+    <div class="sws-slide">
+      <h1>&cduce;</h1>
+      <p>A polymorphic functional language (ML-style) equipped with
+      semantic subtyping</p>
+
+<code>
+  let <u>pretty</u> (&lt;a&gt;_ -&gt; &lt;a&gt;_  &amp;  Any\&lt;a&gt;_ &rarrow; Any\&lt;a>_)
+
+    | &lt;a class="style1" href=<u>h</u> ..&gt; <u>l</u> &rarrow; &lt;a href=<u>h</u>&gt;[ &lt;b&gt;<u>l</u> ]
+    | x &rarrow; x
+
+
+  let <u>get_links</u> (page: &lt;_&gt;_) (print: &lt;a&gt;_ -&gt; &lt;a&gt;_) : [ &lt;a&gt;_ * ] =
+
+      match page with
+      &lt;a&gt;_ &amp; x &rarrow; [ (print x) ]
+    | &lt; (_\‘b) &gt; l &rarrow;
+                 (transform l with (i &amp; &lt;_&gt;_) &rarrow; get_links i print)
+    | _ -&gt; [ ]
+
+
+
+
+</code>
+
+
+    </div>
+    <div class="sws-slide">
+      <h1>&cduce;</h1>
+      <ul>
+       <li>Pros<br/>
+         + Statically typed <br/>
+         + compact (and efficient) type and value pattern-matching
+       </li>
+       <li>Cons<br/>
+         - <s>complex navigation encoded through recursion</s>
+         - no type inference for functions
+       </li>
+      </ul>
+      <p>Writing functions to traverse documents is painfull</p>
+    </div>
+    <div class="sws-slide">
+      <h1>This work</h1>
+      <ol style="margin-left:1em; margin-right:0.25em;list-style-position:inside;">
+       <li id="tobox" style="padding:1em 0em 1em 0em;"><span class="lh">Add support for path navigation to
+           &cduce;</span>
+         <ul id="toshow" style="margin-top:2em;display:none;">
+           <li>Enrich the type algebra with <em>zippers</em> (à la Huet)</li>
+           <li>Extend pattern-matching construct to <em>zipped values  and types</em></li>
+           <li>Encode path expressions as recursive patterns</li>
+         </ul>
+       </li>
+       <li style="padding:1em 0em 1em 0em;">Perform a type-directed translation from XQuery to
+         &cduce;</li>
+
+      </ol>
+      <script type="text/javascript">
+       reg ("0", col_change(".lh",""));
+       reg ("1", col_change(".lh", "#f80"));
+
+       reg ("2", function (canvas) { $("#toshow").show(); });
+       reg ("3", function (c) { $("#tobox").css (
+       { 'background' : '#dfd', 'border-radius': '1em' });});
+      </script>
+    </div>
+    <div class="sws-slide">
+      <h1>&cduce;'s type algebra</h1>
+<pre>
+    t ::=  b  |  c  |  t × t  |  t &rarrow; t  |  t &lor; t  |  t  &land; t  |  t &setminus; t  |  &top;  |  &bottom;  |  &alpha;
+</pre>
+<p><dfn>b</dfn> : ranges over basic types (<tt>Int</tt>, <tt>String</tt>, …)<br/>
+   <dfn>c</dfn> : ranges over singleton types
+   (<tt>`A</tt>, <tt>42</tt>, …)<br/>
+   <dfn>&alpha;</dfn> : type variables<br/>
+   types are interpreted co-inductively (recursive types) and regular
+   expression types<br/>
+</p>
+<pre>
+    t<sub>1</sub> ≡ (<tt>Int</tt> × t<sub>1</sub>) &lor; t<sub>2</sub>
+    t<sub>2</sub> ≡ (<tt>Bool</tt> × t<sub>2</sub>) &lor; (<tt>Bool</tt> × <tt>`nil</tt>)
+
+    <span class="sws-pause">t<sub>1</sub> ≡ <tt>[ Int* Bool+ ]</tt></span>
+
+</pre>
+    </div>
+    <div class="sws-slide">
+      <h1>Semantic subtyping</h1>
+<pre style="text-align:center;">
+t &leq; s   &Lrarrow;   &lbrack;t&rbrack; &subseteq;  &lbrack;s&rbrack;
+</pre>
+<p><dfn>&lbrack; &rbrack;</dfn> interpretation of types as sets of
+  values<br/>
+  Allows to reason <i>modulo</i> semantic equivalence of type connectives :
+</p>
+<pre >
+      <tt>[ Int* (Int | Bool*)? ]</tt> &land; <tt>[ Int+ (Bool+ | Int)* ]</tt> ≡ <tt>[Int+ Bool*]</tt>
+</pre>
+</div>
+<div class="sws-slide">
+      <h1>&cduce; patterns</h1>
+<pre style="text-align:center;">    p ::=  t  |  p | p  |  p &amp; p  | (p, p) |  x   </pre>
+<p><dfn>t</dfn> ranges over types<br/>
+  <dfn>x</dfn> ranges over capture variables<br/>
+  patterns are also co-inductively interpreted (recursive patterns)
+</p>
+<p><dfn><u>v / p</u></dfn> : matching a value against a pattern yields a
+  substitution from variables to values<br/>
+   <dfn><u>&lbag; p &rbag;</u></dfn> : the set of values accepted by a
+   pattern is <u>a type</u><br/>
+   <dfn><u> t / p</u></dfn> : matching a type against a pattern yields a
+   substitution from variables to types<br/>
+</p>
+</div>
+<div class="sws-slide">
+      <h1>&cduce; patterns (example)</h1>
+<p>Assume <tt><u>l</u></tt> has type <tt>[ Int+ Bool* ]</tt>,  consider:</p>
+<code>
+       match <u>l</u> with
+       [ _* (<u>x</u> &amp; Int) Bool* (<u>y</u> &amp; Bool) ] &rarrow;  (<u>x</u>, <u>y</u>)
+    |  [ _* (<u>x</u> &amp; Int) ]                  &rarrow;  (<u>x</u>, `false)
+    |  [ ]                               &rarrow;  (0, `false)
+</code>
+<ol>
+<li><dfn>&lbag;<tt>[ _* (<u>x</u> &amp; Int) Bool* (<u>y</u> &amp; Bool) ]</tt>&rbag; ≡ <tt>[ &top;* Int Bool+ ]</tt></dfn><br/>
+  yield : { x &mapsto; <tt>Int</tt>, y &mapsto; <tt>Bool</tt> }
+</li>
+<li><dfn>&lbag;<tt>[ _* (<u>x</u> &amp; Int) ]</tt>&rbag; ≡ <tt>[ &top;* Int ]</tt></dfn><br/>
+  yield : { x &mapsto; <tt>Int</tt> }
+</li>
+<li>Since <dfn><tt>[Int+ Bool* ]</tt> &setminus; ( <tt>[ &top;* Int Bool+ ]</tt> &lor;  <tt>[ &top;* Int]</tt>) ≡ &bottom;  </dfn>
+    the third case is unreachable.
+</li>
+
+
+</ol>
+
+</div>
+<div class="sws-slide">
+<h1>&cduce; data-model</h1>
+<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>)))
+</dfn></p>
+<p>XML documents are tagged sequences: <pre style="text-align:center;"><tt>&lt;foo&gt;[</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>
+</p>
+<p>Ususal lisp-like encoding of trees, how to perform navigation
+  (including upward ?)</p>
+</div>
+<div class="sws-slide">
+<h1>Zippers (1/2)</h1>
+<ul>
+  <li>Introduced in 1997 by Gérard Huet</li>
+  <li>Stack of visited</li>
+  <li>Push the current node on the stack when descending</li>
+  <li>Put the top of the stack and pop it to go backward</li>
+  <li>Tag the elements of the stack to remember which of a node we
+  have visited</li>
+</ul>
+<pre style="text-align:center;"> v ::=  …  |  v<sub>&delta;</sub>
+ &delta; ::=  &bcirc;  | &left;v · &delta; | &right;v · &delta;
+</pre>
+
+</div>
+<div class="sws-slide">
+<h1>Zippers (2/2)</h1>
+<p><tt><u>fst</u></tt> (resp. <tt><u>snd</u></tt>) takes the first (resp. second)
+  projection of a pair and update its zipper accordingly:</p>
+<pre>    v<sub>1</sub> ≡ (1, (2, (3, (4, `nil))))<sub>&bcirc;</sub>
+    v<sub>11</sub> ≡ fst v<sub>1</sub> ≡ 1<sub>&left;(1, (2, (3, (4, `nil))))<sub>&bcirc;</sub> · &bcirc; </sub>
+    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>
+    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>
+</pre>
+<p><tt><u>up</u></tt> pops returns the head of the zipper: </p>
+<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>
+</pre>
+</div>
+<div class="sws-slide">
+  <h1>Zipper types</h1>
+<p>We extend the type-algebra with zipper types:</p>
+<pre style="text-align:center;"> t ::=  …  |  t<sub>&tau;</sub>
+ &tau; ::=  &bcirc;  |  &left;t · &tau;  | &right;t · &tau;  |  &tau; &lor; &tau;  |  &tau; &setminus; &tau;  |  &ztop;
+</pre>
+<p><dfn>&bcirc;</dfn>: singleton type denoting the empty zipper<br/>
+   <dfn>&ztop;</dfn>: the top zipper types<br/>
+   Zipper types are interpreted co-inductively (regular expressions on
+   zippers)<br/><br/>
+   <dfn><tt>Int</tt><sub>(&left;&top;)* &bcirc;</sub></dfn>: type of
+   integers that are the leftmost descendant of a tree.<br/>
+   <dfn><tt><![CDATA[<html>[ <head>[…] <body>[…] ]]]></tt><sub>&bcirc;</sub></dfn>: type of
+   HTML documents<br/>
+   <dfn><tt><![CDATA[<a href=String>[ … ]]]></tt><sub>&ztop;</sub></dfn>: types of links in any context
+
+</p>
+</div>
+<div class="sws-slide">
+<h1>Tree navigation</h1>
+<p>Since patterns contain types, we can check complex
+  conditions:</p>
+<pre style="width:60%;display:inline-block;border-width:0pt 1pt 0pt 0pt; border-style:dashed;border-color: black;vertical-align:middle">
+    p ≡ <tt id="test">&lt;a&gt;_</tt>   &lor;   <tt>&lt;_&gt;[ _* p _* ]</tt>
+    &tau; ≡ &bcirc;   &lor;   &right;&top; · &tau;   &lor;   &left;(&top;&setminus; <tt>&lt;b&gt;_</tt>) · &tau; 
+
+</pre>
+<code style="width:20%;display:inline-block;vertical-align:middle">
+    match <u>v</u> with
+       <dfn>p<sub>&tau;</sub></dfn> &amp; <u>x</u> &rarrow; …
+   | _        &rarrow; …
+</code>
+<p style="background:white">
+We want more, namely return <i>all</i> descendants (ancestor,
+  children,  siblings, …) of a node matching a particular condition
+<br/><br/>
+Remark: (recursive) patterns <u>already perform a recursive traversal
+  of the value</u>
+<br/><br/>
+<em>Idea</em>: Piggy back on the traversal and <em>accumulate</em>
+nodes in special variables
+</p>
+<script type="text/javascript">
+  reg (0, col_change ("#test", ""));
+  reg (1, col_change ("#test", "orange"));
+</script>
+</div>
+<div class="sws-slide">
+  <h1>Operators and Accumulators</h1>
+<p>An <u>operator</u> is a 4-tupple <dfn>(o, n<sub>o</sub>,
+    &rleadsto;<sub>o</sub>, &rarrow;<sub>o</sub>)</dfn>, where:</p>
+<p><dfn><u>o</u></dfn>: is the accumulator name<br/>
+<dfn><u>n<sub>o</sub></u></dfn>: is the arity of <u>o</u><br/>
+<dfn><u>&rleadsto;<sub>o</sub></u></dfn>:
+&mathV;<sup>n<sub>o</sub></sup> &rsarrow; &mathV;, the reduction relation <br/>
+<dfn><u>&rarrow;<sub>o</sub></u></dfn>:
+&mathT;<sup>n<sub>o</sub></sup> &rsarrow; &mathT;, the typing relation <br/>
+</p>
+<p>An <u>accumulator</u> is a variable (ranged over
+  by <u>ẋ</u>, <u>ẏ</u>, …) with:<br/><br/>
+  <dfn><u>Op(ẋ)</u></dfn>: an operator<br/>
+  <dfn><u>Init(ẋ)</u> &in; &mathV;</dfn> : an initial value<br/>
+</p>
+</div>
+<div class="sws-slide">
+  <h1>Some operators</h1>
+  <pre>
+    v, v' &rleadsto;<sup>cons,</sup> (v, v') <br/>
+    v, <tt>`nil</tt> &rleadsto;<sup>snoc</sup> (v, <tt>`nil</tt>)<br/>
+    v, (v',v'') &rleadsto;<sup>snoc</sup> (v', snoc(v,v''))<br/>
+  </pre>
+<p>Now we can use accumulators equipped with cons/snoc in
+  patterns. Instead of matching a single node against a variable, it
+  <u>accumulates</u> that node in sequence (in reverse or in-order).</p>
+</div>
+<div class="sws-slide">
+<h1>Pattern matching semantics (v/p)</h1>
+<pre style="text-align:center;">
+  &sigma;; &delta; &vdash; v / p &rleadsto; &gamma;, &sigma;'
+</pre>
+<p style="font-size:90%"><dfn><u>&sigma;</u>, <u>&sigma;'</u></dfn>: mapping from accumulators to
+  values<br/>
+  <dfn><u>v</u></dfn>: input value<br/>
+  <dfn><u>p</u></dfn>: pattern<br/>
+  <dfn><u>&gamma;</u></dfn>: mapping from capture variables to
+  values<br/>
+  <dfn><u>&delta;</u></dfn>: current context
+</p>
+<div style="padding:0em 1em 0em; text-align:justify;font-size:85%;background:white;">
+  <div class="infer">
+    <span> v &in; &lbrack; t &rbrack;</span>
+    <span>&sigma;; &delta; &vdash; v / t &rleadsto; &emptyset;,
+      &sigma;</span>
+  </div><span>(type)</span>
+
+  <div class="infer">
+    <span></span>
+    <span>&sigma;; &delta; &vdash; v / ẋ &rleadsto; &emptyset;,
+      &sigma;[ ẋ := Op(ẋ) (v<sub>&delta;</sub>, &sigma;(ẋ)) ]</span>
+  </div><span>(acc)</span>
+
+  <div class="infer">
+    <span></span>
+    <span>&sigma;; &delta; &vdash; v / x &rleadsto; { x &mapsto; v },
+      &sigma;</span>
+  </div><span>(var)</span>
+
+  <div class="infer">
+    <span>&sigma;; &left;v · &delta; &vdash; (fst v)/p<sub>1</sub>
+    &rleadsto; &gamma;<sub>1</sub>, &sigma;' </span>
+    <span>&sigma;'; &right;v · &delta; &vdash; (snd v)/p<sub>2</sub> 
+      &rleadsto; &gamma;<sub>2</sub>, &sigma;''
+    </span>
+    <span>&sigma;; &delta; &vdash; v /
+      (p<sub>1</sub>, p<sub>2</sub>)  &rleadsto;
+      &gamma;<sub>1</sub>&cup; &gamma;<sub>2</sub>,
+      &sigma;''</span>
+  </div><span>(pair)</span>  <span class="fill"></span>
+<span>… and some other rules for alternation, failure, recursion, <i>etc.</i></span>
+</div>
+</div>
+<div class="sws-slide">
+  <h1>Typing of patterns (with accumulators) 1/2</h1>
+  <p>Well known that typing path expressions escapes regular tree languages
+    (i.e. &cduce;'s types). Consider:
+  </p>
+<pre style="margin:-3em 0pt -1em;">
+      t ≡ <tt>&lt;c&gt;[ <u>&lt;a&gt;[]</u> t <u>&lt;b&gt;[]</u> ] </tt>   &lor;   <tt>&lt;c&gt;[]</tt>   <img style="margin-left:3em;width:15%;vertical-align:middle;" src="anbn_tree.svg" alt="anbn"/>
+</pre>
+<p>The set of all <tt><u>a</u></tt> or <tt><u>b</u></tt> labeled
+  descendants
+  is <dfn>{ <tt>[<u>&lt;a&gt;[]</u></tt><sup>n</sup> <tt><u>&lt;b&gt;[]</u></tt><sup>n</sup> <tt>]</tt>  | n ≥ 0 }</dfn>
+which is not a type.</p>
+<p> Intuitively it means that when applying a
+  recursive pattern against a recursive type, we may generate an
+  <s>infinite number of distinct types</s> for an accumulator.
+</p>
+</div>
+<div class="sws-slide">
+  <h1>Typing of patterns (with accumulators) 2/2</h1>
+  <p>We use the typing relation of operators to introduce
+  approximations:</p>
+  <pre>
+    <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/>
+    <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>
+  </pre>
+  <p>Ensures termination of typechecking of patterns.</p>
+</div>
+<div class="sws-slide">
+  <h1>Results</h1>
+<p>Zippers (in values, types, patterns) are orthogonal to the rest of the language</p>
+<ul>
+  <li><u>Subtyping and typechecking</u> are extended straightforwardly</li>
+  <li>Typing of patterns introduces <u>sound approximations</u> only for accumulators</li>
+  <li>Provided the operators are sound, the whole language remains <u>type-safe</u></li>
+</ul>
+</div>
+<div class="sws-slide">
+  <h1>From zippers to XPath</h1>
+  <p>We use  <u>regular expressions</u> over basic &left;/&right; zippers to encode XPath</p>
+<code style="width:50%;float:left;">   <![CDATA[<a>[ <b>[
+          <c>[]
+          <d>[]
+          <e>[ <f> [] ]
+        ]
+   ]]]>
+</code><img style="width:17.5%;" src="ex_ntree.svg" alt="ex_ntree" /><br/>
+<p class="sws-pause"><img style="margin-top:-1em;margin-left:5%;width:85%;" src="rb_tree.svg" alt="rb_tree"/></p>
+</div>
+<div class="sws-slide">
+<h1>Downward axes</h1>
+<tt>  <![CDATA[<a>[ <b>[  <c>[]  <d>[] <e>[ <f> [] ]   ]  ]]]><sub>&bcirc;</sub></tt>
+<object id="svgRBTree" data="rb_tree.svg" type="image/svg+xml" style="margin-left:7.5%;width:85%"  />
+<pre>
+     <tt>self ::</tt> t ≡    (ẋ <tt>&amp;</tt> t | _ )<sub>&ztop;</sub>
+     <tt>child ::</tt> t ≡  <tt>&lt;_&gt;[</tt> (ẋ <tt>&amp;</tt> t | _ )<tt>* ]</tt><sub>&ztop;</sub>
+     <tt>descendant-or-self::</tt> t ≡   X ≡ ((ẋ <tt>&amp;</tt> t | _ ) <tt> &amp; &lt;_&gt;[</tt> X <tt>* ]</tt>)<sub>&ztop;</sub>
+     <tt>descendant</tt> :: t ≡ <tt>&lt;_&gt;[ (descendant-or-self::</tt>t<tt>)* ]</tt><sub>&ztop;</sub>
+</pre>
+<!--
+<script type="text/javascript">
+/* <![CDATA[ */
+  var svgDoc = null;
+
+  function reset () {
+        svgDoc = svgDoc || document.getElementById("svgRBTree").contentDocument;
+        var f = svgDoc.getElementById("nodef");
+        f.style['fillOpacity'] = "0";
+        var elems = svgDoc.getElementsByClassName("parentf");
+        for(var i = 0; i < elems.length; i++) {
+            elems[i].style['strokeWidth'] = '2px';
+       };
+  };
+
+  reg (0, function (c) {
+         console.log(0);
+         reset();
+  });
+
+  reg (1, function (c) {
+         console.log(1);
+         var f = svgDoc.getElementById("nodef");
+         console.log(' Opacity ' + f.style['fillOpacity']);
+         f.style['fillOpacity'] = "0.5";
+         console.log(' Opacity ' + f.style['fillOpacity']);
+     });
+
+  reg (2, function (c) {
+         console.log(2);
+        var elems = svgDoc.getElementsByClassName("parentf");
+        for(i = 0; i < elems.length; i++) {
+             elems[i].style['strokeWidth'] = '6px';
+          }
+     });
+   reg (3, function (c) {          console.log(3); reset(); });
+/*]]>*/
+</script>
+-->
+</div>
+<div class="sws-slide">
+<h1>Upward axes</h1>
+<tt>  <![CDATA[<a>[ <b>[  <c>[]  <d>[] <e>[ <f> [] ]   ]  ]]]><sub>&bcirc;</sub></tt>
+<object id="svgRBTree" data="rb_tree.svg" type="image/svg+xml" style="margin-left:7.5%;width:85%"  />
+<pre>
+     <tt>parent ::</tt> t ≡   &top;<sub> (&left;_) · (&right;_)* · (&right; ẋ &amp; t) · (( (&left; _) · &ztop;)  &lor;  &bcirc; )</sub>
+     <tt>ancestor ::</tt> t ≡   &top;<sub> ((&left;_) · (&right;_)* · (&right; ẋ &amp; t))* · &bcirc; </sub>
+</pre>
+</div>
+<div class="sws-slide">
+  <h1>Other results</h1>
+<ul>
+  <li>Encoding of paths is compositional</li>
+  <li>Once we have path, translation from XQuery to &cduce; is straightforward</li>
+  <li>We also give a direct typing algorithm for XQuery 3.0 rather than typing the translation to &cduce;</li>
+</ul>
+</div>
+<div class="sws-slide">
+<h1>Conclusion, thoughts and future work</h1>
+<ul>
+  <li>Adding path expressions to a functional language such as &cduce; is possible </li>
+  <li>Semantic subtyping and regular expression types play nicely with zippers</li>
+  <li>In terms of language design, exposing directly zippers patterns to the programmer is a big no-no</li>
+  <li>Can also be applied to XSLT</li>
+  <li>Implementation on-going (including a &cduce; to javascript backend)</li>
+  <li>Extend the approach to Json (google ``path language for json''), i.e. generalise from products to extensible records</li>
+</ul>
+
+</div>
+
+  </body>
+</html>