<?xml version="1.0"?><!DOCTYPE article SYSTEM "/project/take/software/searchbench_offline_processing/paperxml_generator/aclextractor/src/python/../resource/dtd/paperxml.dtd"><article><header><firstpageheader><page local="1" global="96"/><title>Formal Grammars for Linguistic Treebank Queries</title><pubinfo>Proceedings of the Australasian Language Technology Workshop 2005,pages 96-104, Sydney, Australia, December 2005.</pubinfo><author surname="Dras" givenname="Mark"><org  name="Macquarie University" country="Australia" city="Sydney"/></author><author surname="Cassidy" givenname="Steve"><org  name="Macquarie University" country="Australia" city="Sydney"/></author></firstpageheader><frontmatter><p><b>Formal Grammars for Linguistic Treebank Queries</b></p><p><b>Mark Dras</b></p><p>Centre for Language Technology Macquarie University madras@ics.mq.edu.au</p><p><b>Steve Cassidy</b></p><p>Centre for Language Technology Macquarie University Steve.Cassidy@mq.edu.au</p></frontmatter><abstract>There has been recent interest in looking at what is required for a tree query language for linguis­tic corpora. One approach is to start from exist­ing formal machinery, such as tree grammars and automata, to see what kind of machine is an ap­propriate underlying one for the query language. The goal of the paper is then to examine what is an appropriate machine for a linguistic tree query language, with a view to future work defining a query language based on it. In this paper we review work relating XPath to regular tree gram­mars, and as the paper's first contribution show how regular tree grammars can also be a basis for extensions proposed for XPath for common lin­guistic corpus querying. As the paper's second contribution we demonstrate that, on the other hand, regular tree grammars cannot describe a number of structures of interest; we then show that, instead, a slightly more powerful machine is appropriate, and indicate how linguistic tree query languages might be augmented to include this extra power. </abstract></header><body><section number="1" title="Introduction"><p>There has been recent interest in looking at what is required for a query language for annotated linguistic corpora (Lai and Bird, 2004). These corpora are used in a range of areas of natural language processing (NLP)—parsing, machine translation, and so on—where they form the basis of training data for statistical methods; and also in lin­guistics, where they are used to extract ex­amples of particular phenomena for analy­sis and testing of hypotheses. As noted by Lai and Bird, the prototypical hierarchical linguistic annotation is the syntax tree, and consequently the type of query language that is of interest is a tree query language.</p><p>One approach to deciding what is required in a tree query language, taken by Lai and Bird (2004), is to examine and compare a range of existing ones: for example, TGrep2 (Ro-hde, 2001), TIGERSearch (König and Lez-ius, 2001), or Emu (Cassidy and Harrington, 2001). One of their goals is to understand better the formal properties required of query languages.</p><p>It has been noted in a number of places that treebank querying is in essence a spec­ification of a tree pattern, which matches against the desired trees in the treebank cor­pus (Abiteboul, 1997). These tree patterns can be described by existing formal machin­ery such as tree grammars and automata. An approach complementary to the one men­tioned above is thus to examine the extent to which this formal machinery is adequate for describing tree patterns relevant for the sorts of queries of interest in NLP or linguis­tics, and then to link this to a query lan­guage. A reason for being interested in this link between tree query languages and for­mal machinery is that standard results are available for these latter. For example, an algorithm for recognition exists that is linear in the number of nodes in the tree and the size of the automaton; it is decidable whether the set of matches will be empty; and so on (Comon et al., 1997). Further, there is the promise of the availability of standard tools and efficient techniques that could be used by a tree query language. This is the case for formal machines over strings (for example, the library of finite-state string transducers of Mohri (1997)), although not yet for trees.<page local="2" global="97"/></p><p>A number of researchers have looked at this complementary approach. One alternative is to design from scratch a tree query language derived from a tree grammar or automaton; this is taken by, for example, Chidlovskii (2000). Another is to relate an existing query language to a formal machine: Murata et al. (2000) present a taxonomy of XML schema languages using formal language theory.</p><p>In this paper, we follow the second of these alternatives. Existing work, mostly focussed on XML, has looked only at regular tree grammars and automata for modelling query languages; we examine the extent to which this is the case for linguistic treebanks, and what other machinery might be appropriate for a linguistic tree query language. We ar­gue that while regular tree grammars might be satisfactory for a querying a broad range of phenomena, not all queries over trees rep­resenting natural language can be based on a regular tree grammar. This is a structural analogue of the work of Shieber (1985), which showed that natural language as a string lan­guage cannot be generated by a context-free grammar, which corresponds at the tree level to a regular tree grammar.</p><p>In Section 2 we give the definition of regu­lar tree grammars, along with an approach used to relate them to XPath. In Section 3 we look at extensions to XPath that Cassidy (2003) argues are necessary for linguistic cor­pus querying, and show that these can be captured by regular tree grammars. In Sec­tion 4, however, we present some examples from Dutch from the work of Bresnan et al. (1982) to show that not all desired queries can be represented by regular tree grammars, and examine the question of what strong gen­erative capacity is necessary in a tree gram­mar for representing natural language. Sec­tion 5 gives the definition of a more power­ful grammar, the context-free tree grammar, and shows how this can describe queries re­lated to the Dutch instance, along with what properties a query language based on these might have. Finally, Section 6 concludes.</p></section><section number="2" title="Regular Tree Grammars"><p>Regular tree grammars (RTGs) are in essence those trees whose paths are defined by reg­ular grammars. Comon et al. (1997) pro­vide an introduction to necessary concepts in tree grammars, along with well known results such as that the string languages yielded by RTG trees are the context-free languages. In their treatment they divide tree representations into two types: those for ranked trees (that is, where each symbol has a fixed number of children, with this num­ber constituting the rank of the symbol), and those for unranked trees. XML schema lan­guages typically use unranked trees, so we adopt, slightly modified, the definitions of these from Briiggemann-Klein et al. (2001) and Murata et al. (2000).</p><doubt alpha="65.6" length="61" tooSmall="False" monospace="0.0">A regular tree grammar is a 4-tuple G = (S, N,P, S) such that</doubt><p>• S is a finite set of terminal symbols;</p><p>• N is a finite set of nonterminal symbols;</p><p>• P is a finite set of productions of the form X <i>— </i><i>a(R), </i>where X <i>G </i>N, <i>a </i><i>G </i>S, and R is a regular expression over N U S; and</p><p>• S is the start symbol, S G N.</p><p>Derivation =&gt; (with transitive closure 4&gt;) is defined in the usual way, with nonterminals symbols rewritten by means of production rules, starting from the start symbol S. e is the conventional null terminal symbol. The set of trees generated by G is L(G).</p><p><b>Example 2.1 </b>Let Gt = <i>(S,N,P,S</i>) such that S = {a, b}, <i>N</i><i> </i>= {S, X}, and P = {S — <i>a(aSa),S </i><i>— </i><i>a(bXb),X </i><i>— </i><i>b(bXb),X </i><i>— </i><i>b}. </i>A sample derivation is given in Figure 1. <i>L(G</i><i>i </i>) is thus the set of ternary-branching trees over the symbols <i>a</i><i> </i>and <i>b,</i><i> </i>where all nodes to a certain depth D are <i>a</i><i> </i>nodes, and all below are <i>b</i><i> </i>nodes.</p><p>To relate this to a query language, we now re­view the approach presented in Wood (2003) to relate these regular tree grammars to<page local="3" global="98"/></p><doubt alpha="16.7" length="18" tooSmall="False" monospace="0.0">S    =**- a =**- a</doubt><doubt alpha="42.9" length="7" tooSmall="False" monospace="0.0">b   b b</doubt><figure caption="Figure 1: Derivation for RTGGt"></figure><p>XPath (XPath, 1999). XPath is a lan­guage for selecting nodes from XML docu­ment trees, and is thus an important part of XSLT and XQuery. Expressions in XPath in themselves can be seen as simple queries over trees.</p><p>An XPath expression is a mapping from a node (the <i>context</i><i> </i><i>node)</i><i> </i>to the set of all nodes reachable by the specified path. A path ex­pression is written as a series of steps where each step defines the <i>axis</i><i> </i>used to reach new nodes and a node test used to restrict the set of nodes reached along the axis. Axes in­clude <i>child,</i><i> </i><i>descendent,</i><i> </i><i>following,</i><i> </i><i>attribute</i><i> </i>and <i>self.</i><i> </i>Node tests consist of two parts: a restriction on the element name and an op­tional predicate expression. Other features, such as built-in functions, are also allowed. Notationally, a null axis stands for the child axis, // the descendent axis, the wild card * any node label, and [] a predicate expression. The full XPath expression definition is fairly complex, and can be found at XPath (1999); here we give an example.</p><p><b>Example 2.2 </b>[From Wood (2003)] The XPath query <i>a//b[*/i]/g </i>selects nodes la­belled with <i>g</i><i> </i>(called g-nodes for short) that are children of <i>b</i>-nodes, such that the <i>b</i>-nodes are both descendants of the root <i>a</i><i> </i>node and have an <i>i</i>-node as a grandchild. In the left-hand tree in Figure 2, these would be the nodes in bold font. (The return value of the XPath expression would be the node <i>g, </i>but here we are only concerned with the trees that would be matched.) The possibility of arbitary functions for node tests means that XPath can be augmented to be arbitrarily powerful. To investigate ques­tions of formal power, then, only subsets of XPath are examined. Wood's paper notes that, for this reason, a number of other researchers have been interested in the proper­ties of different fragments of XPath, denoted XPlDl, XPlQ'*} and XP{0.*.//}, depending on which XPath constructs are included in the fragment. The work of Wood himself is on the fragment XP{[]'*'//} and the question of whether the containment problem—whether one query is subsumed by another—under a Document Type Definition can be decided in the complexity class ptime. To demon­strate that this is the case he conceives of XPath queries as <i>tree</i><i> </i><i>patterns</i><i> </i>(Abiteboul, 1997; Deutsch et al., 1999), which can be de­scribed by regular tree grammars. For exam­ple, the XPath query of Example 2.2 could be pictured as the tree pattern on the right in Figure 2, where the dotted line indicates non-immediate dominance.</p><doubt alpha="66.7" length="3" tooSmall="False" monospace="0.0">d g</doubt><figure caption="Figure 2: Tree matchinga//b[*/i]/g,and corresponding tree pattern"></figure><p>An RTG then describes all trees matching this tree pattern. In order to define this RTG, Wood defines some shorthand nota­tion, which we will also adopt. For an alpha­bet S = <i>{at</i><i>,</i>..., <i>ak</i><i> </i>}, we write <i>n</i><i> </i><i>—</i><i> </i>S(r) for the set of productions {n — <i>at </i>(r),..., n — <i>ak</i><i> </i>(r)}.</p><p>In order to generate an arbitrary tree over S, we define a nonterminal <i>njj</i><i> </i>by the shorthand production <i>njj</i><i> </i>— S((n^)*).</p><p><b>Example 2.3 </b>For the query <i>Q </i>= <i>a/b </i>over alphabet S, the productions for the corre­sponding RTG are</p><doubt alpha="45.2" length="31" tooSmall="False" monospace="0.0">na— a((nE)*nb(nE)*)nb—b((ns)* )</doubt><p>An additional shorthand is to compress the ordering of siblings implicit in RTGs. Each permutation of children at a node would re­quire a separate production, so as shorthand the &amp; symbol is used:<page local="4" global="99"/> a&amp;b represents <i>ab</i><i> </i>and <i>ba</i><i> (a, b </i><i>G</i><i> </i>S).</p><p><b>Example 2.4 </b>The productions from the query a[b][c] are <b>Example 2.</b><b>5 </b>The productions for the query <i>a//b </i>are <i>n</i><i>a</i><i> </i><i>—</i><i> a((nE</i>)* <i>nb</i><i> (nE</i>)*) <i>nb</i><i> </i><i>—</i><i> b((nE </i>)*) n6 — S((nE)* <i>nb</i><i> (n</i><i>E</i>)*) Wood then defines the following procedure for constructing an RTG <i>G </i>from a query <i>Q, </i>given an alphabet S = <i>[a</i><i>t</i><i>,.</i><i>.., </i><i>ak,</i><i> </i><i>*}</i><i> </i>and Q in XP{[]'*'//1. First, each node in Q is num­bered uniquely, with the root node numbered 1. Then <i>G </i>is given by (S, <i>N, </i><i>P,nt</i><i> </i>), where <i>N </i>= <i>[nt, </i><i>nm</i><i> ,nE </i>}, and <i>P </i>is constructed inductively as follows.</p><doubt alpha="33.3" length="60" tooSmall="False" monospace="0.0">na—a((nE)* &amp; n&amp; &amp;(ns)* &amp; n &amp; (nE)*) n&amp;—b((nr)*) nc —c((nr)*)</doubt><p>1. If node <i>i </i>in <i>Q </i>is a leaf, then <i>P </i>includes <i>n</i><i>i</i><i> </i><i>—</i><i> a</i><i>j</i>((nE)*) if <i>i </i>has label <i>a</i><i>j</i><i> </i>G S, or <i>n</i><i>i</i><i> </i><i>—</i><i> </i>S((nE)*) if <i>i </i>has label *.</p><doubt alpha="61.2" length="121" tooSmall="False" monospace="0.0">2. If nodeiinQhas child nodesjt,jm, thenPincludesni—ai((nE)* &amp;nj1&amp; (nE)* &amp;... &amp;(nE)* &amp; njm&amp; (nE)*) if i has labelalGS, or</doubt><p>ni — S((nE )* &amp; nj <i>1 </i>&amp; (nE )* &amp; <i>...</i></p><p>&amp; (nE)* &amp; <i>n</i><i>jm</i><i> </i>&amp; (nE)*) if <i>i </i>has label *.</p><p>3. If node <i>i </i>in <i>Q </i>is connected to its parent by a descendent edge, then <i>P </i>includes</p><doubt alpha="50.0" length="18" tooSmall="False" monospace="0.0">ni—S((nE)*ni(nE)*)</doubt></section><section number="3" title="XPath Extensions and RTGs"><p>Cassidy (2003) presented some extensions to XPath, based on the requirements of typi­cal linguistic queries. An example is that of finding matches for a given syllable structure: "Find sequences of any number of consonant phonemes followed by a single vowel follow­ing by any number of consonants". This would require a regular expression (C+VC+) over the <b>/following </b>axis. Under the cur­rent definition of XPath, it is not possible to specify regular expressions over axes; nor is it possible to specify more complex defi­nitions of where conditions on nodes should be applied. Cassidy consequently specifies an extension that allows this, which has the following components:</p><p><b>axis </b>This is as for the axes in the standard XPath definition.</p><p><b>step </b>This determines how many steps should be taken along the axis, and takes the form of a list of positive integers or a special value <b>inf. </b>A path length is allowed if it matches one of the integers in the list; any path length is allowed if only the value <b>inf </b>is given; path lengths greater than the highest integer are allowed if the list contains both integers and the value <b>inf. </b>For exam­ple, [2, 3,4] allows paths only of lengths 2, 3 or 4; [1,10, <b>inf] </b>allows paths of length 1 or of length greater than 10.</p><p><b>condition </b>This is a general boolean condi­tion on nodes in the same sense as XPath.</p><p><b>where </b>This specifies where on the path the condition must hold, via a list of positive in­tegers or the special values <b>inf </b>or <b>end. </b>An integer in the list means that the condition is applied to that node; <b>inf </b>means that the condition must hold for all nodes in the path; <b>end </b>means that the condition applies to the final node on the path. For example, the list [1, 2, <b>end] </b>would find paths where the condi­tion was satisfied by the first, second and last nodes on the path.</p><p>A proposed syntax for this, in keeping with the XPath syntax, would be <b>/axis{step}:</b><b>:condition::{where}</b></p><p>The <b>step </b>and <b>where </b>components would de­fault to their XPath values (1 and <b>end </b>re­spectively).</p><p><b>Example 3.1 </b>Cassidy gives an example for the C+VC+ query which uses the <b>/following </b>axis. An analogous example us­ing the axes already presented in Section 2 would be one to match trees with a chain of VP nodes followed immediately below by a chain of NP nodes, such as the one in Fig­ure 3. Such a query could be expressed as<page local="5" global="100"/></p><doubt alpha="100.0" length="1" tooSmall="False" monospace="0.0">S</doubt><doubt alpha="83.3" length="6" tooSmall="False" monospace="0.0">Adv VP</doubt><p>V NP NP PP</p><figure caption="Figure 3: Tree with sequence of VPs and NPs"></figure><doubt alpha="49.1" length="53" tooSmall="False" monospace="0.0">/child{0,inf}::VP::{0,all&gt; /child{0,inf}::NP::{0,all&gt;</doubt><p>The question is then, Can this extension be represented by RTGs? The intuition is that it can—the essence of this aspect of the ex­tension is to allow regular expressions over paths, which is also the essence of RTGs. We demonstrate this below by giving a con­struction of an RTG for each extended XPath query. As with the construction in Sec­tion 2, we will look at just a restricted sub­set of this XPath extension: <b>axis /child </b>and <b>/descendent </b>(which is in fact just an infinite <b>/child); step </b>as defined above; <b>condition </b>only labels on nodes, or *; and <b>where </b>as above. We call this XP-ext.</p><p><b>Example 3.2 </b>The query in Example 3.1 would be represented by the RTG ({VP, <i>NP,</i><i> *}, {ns ,nv ,nN </i><i>},P,ri</i><i>s </i>}), where <i>P </i>is the set of productions</p><doubt alpha="47.4" length="95" tooSmall="False" monospace="0.0">ns— S((nE)* nv(ns)*) nv-VP((ns)* nv(nE)*) nv-VP((ns)*nN(ns)*)nN- NP((ns)*) nN-NP((ns)* nN(nE)*)</doubt><p>To derive an RTG corresponding to a query in XP-ext, we identify the corresponding tree pattern(s). First, to allow regular expres­sions over paths in tree patterns, we make a further notational extension, either adding the symbol c next to the non-immediate dominance link in the tree pattern, to indi­cate that the condition holds over the non-immediate dominance link, or the symbol * if it does not.</p><p>Now, we need to look at two separate cases. The first case is the general one: in aim­ing only to match sets of trees by tree pat­terns, only one tree pattern is generally nec­essary, regardless of the number of elements specified in the <b>step </b>and <b>where </b>components. This is because although one pattern tree might be expected for each <b>step </b>value, in fact one describing the smallest step suffices, as it subsumes any other. For example, in the query <b>/child{2,4}::S::{2,4}, </b>any tree which matches the appropriate pattern tree of height 4 will match the pattern tree of height 2. Note that these different <b>step</b>s and <b>where</b>s are differentiated with respect to the XPath return values; however, that is beyond the scope of this paper, which concerns itself only with trees matched.</p><p>The second case deals with the specific case of <b>where </b>value <b>end; </b>the subsumption rela­tionship does not hold here. For example, consider the query <b>/child{2,4} </b><b>::S::</b><b> {end} </b>over trees consisting of a single path. There will be trees where the end of the path <b>(step) </b>of length 2 (matching the label S) do not have an S node at the end of the path of length 4, and vice versa; that is, there is no subset re­lation between the sets of trees specified for <b>step</b>s of lengths 2 and 4.</p><p>We define these two cases below. In these definitions, we take <b>axis /child </b>and <b>condi­tion </b>(i.e. node label) <b>c.</b></p><doubt alpha="55.2" length="87" tooSmall="False" monospace="0.0">Case 1For queryQwithstep[it,..., in,inf](it&lt; ... &lt; in), andwhere[j1 m,inf](j1&lt;...&lt;j m &lt;</doubt><p>we construct a tree pattern of height <i>ip</i>, where <i>ip </i>is the smallest element of [it<i>,in, </i><b>inf] </b>with label <b>c </b>for each node j <i>p(p &lt; m,jp &lt; ip</i>). If <i>ip </i>is <b>inf, </b>we label the non-immediate dominance edge <b>c </b>if <b>where </b>contains <b>inf, </b>* otherwise.</p><p><b>Case 2 </b>For query <i>Q </i>with <b>step </b>[it <i>,...,in, </i><b>inf] </b>(it <i>&lt; ... &lt; in </i>), and <b>where [end]</b>, we construct one tree pattern for each element of <b>step, </b>with the last node in each tree pattern labelled <b>c, </b>and any non-immediate dominance edge labelled *.</p><doubt alpha="61.1" length="36" tooSmall="False" monospace="0.0">Example 3.3The    query    in XP-ext</doubt><page local="6" global="101"/><doubt alpha="100.0" length="1" tooSmall="False" monospace="0.0">S</doubt><doubt alpha="0.0" length="1" tooSmall="False" monospace="0.0">*</doubt><doubt alpha="100.0" length="1" tooSmall="False" monospace="0.0">I</doubt><doubt alpha="66.7" length="3" tooSmall="False" monospace="0.0">s I</doubt><doubt alpha="33.3" length="6" tooSmall="False" monospace="0.0">; (s)I</doubt><figure caption="Figure 4: Pattern tree for Example 3.3"></figure><p><b>/child{inf}::S::{1,3,inf}     </b>would give the pattern tree in Figure 4. Our construction for an RTG is then as for the construction in Section 2, but with part</p></section><section number="3" title="replaced by with 3':"><p>3' If node i in Q is connected to its par­ent by a non-immediate dominance edge labelled with <i>a </i>G S, then P includes <i>ui</i><i> — a((uE</i><i>)*ui(</i><i>ue</i>)*) or if unlabelled, then P includes ui — S((ue)*ui<i>(</i><i>ue</i>)*)</p></section><section number="4" title="Non-Regular Queries"><p>However, some queries that are of interest to (computational) linguists are not able to be expressed by RTGs. There was much discus­sion in the mid- to late-twentieth century re­garding whether natural languages could be described by context-free (string) grammars (CFGs). A fairly common belief was that they could not be, accompanied by attempts to prove this; Pullum and Gazdar (1982) re­futed these earlier arguments, and it was not definitively shown that natural language as a string language was not context-free until the work of Shieber on Swiss German (Shieber, 1985).</p><p>Bresnan et al. (1982), in addition, made an argument based on syntactic structure, using the example of Dutch. We re­present their argument, where they show that an RTG cannot describe this kind of structure—which obviously has some linguis­tic interest—and hence neither can any tree query language based on it. We then con­sider what formal tree machine is minimally needed for describing natural language.</p><p>Cross-serial dependencies occur when de­pendencies in a sentence are interleaved with each other, such that in a string <i>a</i><i>t </i><i>a2.</i><i>.</i><i> </i><i>.anbt</i><i> </i><i>b2..</i><i> </i><i>.bn</i><i> </i>there are dependencies between elements <i>ai</i><i> </i>and bi (i G {1 ...u}). A well known example from Dutch, given in Bresnan et al. (1982), is in Figure 5.</p><p>Pullum and Gazdar (1982) showed that it was possible to describe the string language using a CFG, but noted that the associated structure would not necessarily be useful. Bresnan et al. (1982) then comprehensively investigated what structures would be appro­priate on linguistic grounds. One proposal they considered was for a flat structure of NPs, with right-branching VPs, as in the left­most tree of Figure 5, with evidence for the right-branching VPs coming from possibili­ties of conjunctions in Dutch. However, they noted that the sequence of NPs has more con­stituent structure than indicated in the left­most tree of Figure 5, and conclude that the structure in the centre of Figure 5 is the one that is consistent with the data. They note that this proposed structure should be un-controversial, as it embodies only predicate-argument relations, rather than any aspects of syntax whose representations may be more open to question.</p><p>They use a pumping lemma for regular tree languages to demonstrate that sets of these sorts of trees from Figures 5 cannot be gen­erated by RTGs. Comon et al. (1997) give a more precise definition, but broadly, for any tree <i>T </i>of height greater than some con­stant k in a tree language L, there is a non-trivial segment of T that can be 'pumped' in a manner analogous to in the pumping lemma for regular string grammars; and any tree formed from <i>T </i>with an arbitrary num­ber of these segments inserted appropriately will also be in <i>L. </i>In the case of the centre tree of Figure 5, there is no segment of the tree that can be chosen to be pumped that will maintain equal numbers of NPs and Vs (that is, specifying the same tree language). Roughly speaking, there cannot be counting or matching of numbers of internal symbols in tree patterns.</p><p>We note here that there is an additional pos­sibility that they do not discuss that is also consistent with the data, differing only in the placement of the subtree headed with the V'; this is the rightmost tree in Figure 5.<page local="7" global="102"/> The same pumping lemma shows that the set of these trees also cannot be generated by an RTG.</p></section><section number="5" title="Context-Free Tree Grammar"><p>What, then, can generate these sets of trees? One possibility is a context-free tree gram­mar (CFTG). The basic idea of these is that, whereas trees generated by RTGs have regu­lar paths, CTFGs have context-free paths.</p><p>CFTGs were introduced in Rounds (1970). We do not have space for a full formal pre­sentation of them, and we would also note that unlike the RTGs defined above they are defined over ranked trees. However, here is a brief definition, along with an example. A <i>context-free</i><i> </i><i>tree</i><i> </i><i>grammar</i><i> </i><i>G</i><i> </i>is a 4-tuple (F, <i>$,P, </i>K0) where F is a finite ranked al­phabet; $ = {K0, KtKn<i>}</i><i> </i>is a finite ranked alphabet of nonterminals; <i>P</i><i> </i>is the set of production rules, a finite set of pairs <i>(K</i><i>i</i><i> (x</i><i>t</i><i> ,...,xm ),t</i><i>x</i><i> </i>), where i = 0, <i>...,n, K</i><i>i</i><i> </i>G F, xi are variables, and <i>tx </i>is a tree over F, $ and variables xi; and K0 is the initial nonterminal.</p><p>An application of a production rule to a tree <i>T</i><i> </i>involves choosing a nonterminal Ki with m children, taking a rule with lefthand side Ki (xt,..., xm), identifying the m subtrees of Ki in T with the variables xt,...,xm, and replacing the chosen subtree of T rooted in K<i>i</i><i> </i>with the righthand side of the rule along with appropriately substituted vari­ables xt,..., .</p><p>No CFTG is possible for the leftmost tree of Figure 5, as symbols are ranked, and that tree would require an infinite number of ranked symbols with label S to describe the unbounded number of children NP.</p><p>A CFTG to describe the centre tree of Fig­ure 5 would be G = (F, $,P, K0), where F = <i>{S, </i><i>NP,</i><i> </i><i>VP,</i><i> V'}, </i>$ = {Ko, Kt}, and P is the set of productions given in Figure 6.</p><p>A CFTG to describe the rightmost tree of Figure 5 would be G' = (F, $, PK0), where</p><doubt alpha="60.0" length="5" tooSmall="False" monospace="0.0">Ko— S</doubt><doubt alpha="35.7" length="14" tooSmall="True" monospace="0.0">NP        VP V</doubt><doubt alpha="55.6" length="9" tooSmall="False" monospace="0.0">NPvU~~~V'</doubt><doubt alpha="50.0" length="2" tooSmall="False" monospace="0.0">V3</doubt><doubt alpha="62.5" length="8" tooSmall="False" monospace="0.0">Ki -i Ki</doubt><doubt alpha="13.0" length="23" tooSmall="True" monospace="0.0">X1     X2     X3 ~^^\ ~</doubt><doubt alpha="33.3" length="15" tooSmall="False" monospace="0.0">xi        VP V'</doubt><doubt alpha="50.0" length="10" tooSmall="False" monospace="0.0">NP~~X2V~x3</doubt><doubt alpha="62.5" length="8" tooSmall="False" monospace="0.0">Ki -i VP</doubt><doubt alpha="66.7" length="12" tooSmall="True" monospace="0.0">XIX2X3XiX2X3</doubt><figure caption="Figure 6: CFTG for cross-serial option 2"></figure><doubt alpha="40.0" length="5" tooSmall="False" monospace="0.0">K0— S</doubt><p>NP VP <i>ICi </i>V' V</p><doubt alpha="71.4" length="7" tooSmall="False" monospace="0.0">Ki -ivp</doubt><doubt alpha="50.0" length="8" tooSmall="False" monospace="0.0">x1np^"k1</doubt><doubt alpha="50.0" length="2" tooSmall="False" monospace="0.0">v'</doubt><doubt alpha="42.3" length="26" tooSmall="False" monospace="0.0">Ki        -ivpX1np^~~vp v'</doubt><figure caption="Figure 7: CFTG for cross-serial option 3"></figure><p>F and $ are as for G above, and <i>P'</i><i> </i>is the set of productions in Figure 7.</p><p>In essence, CFTGs allow 'counting ' through­out a tree—in the examples above, the counts of NPs and Vs match—in the same way as CFGs allow counting in a string. Thus CFTGs might be a suitable backbone for a tree query language. However, they are not computationally very attractive. Just as the string languages yielded by RTGs are the context-free languages, the string languages yielded by CFTGs are the indexed languages, which include exponentially increasing lan­guages such as <i>{a<footnote anchor="2"/> </i>| n &gt; 1} that are not a feature of any human language.</p><p>However, the sets of productions P and P'are actually quite diferent. It is straight­forward to demonstrate that those in P' are in fact <i>spinal-formed</i><i> </i>under the definition of Fujiyoshi and Kasai (2000). In essence, a spinal-formed CFTG disallows duplication of counts along diferent paths (as in the duplicate counts of NPs and Vs in sepa­rate subtrees of the centre tree of Figure 5). Spinal-formed CFTGs form a proper sub­set of CFTGs with much restricted power; interestingly, their string languages have been proved by Fujiyoshi and Kasai (2000) to be the class of mildly context-sensitive languages, and recent work (Fujiyoshi and Kawaharada, 2005) has included promising<page local="8" global="103"/></p><doubt alpha="100.0" length="1" tooSmall="False" monospace="0.0">S</doubt><doubt alpha="50.0" length="2" tooSmall="False" monospace="0.0">V3</doubt><p>(1)   ... dat Jan Piet Marie de kinderen zag        helpen   laten zwemmen ... that Jan Piet Marie the children see-PAST help-iNF make-iNF swim-iNF ... that Jan saw Piet help Marie make the children swim results on recognition complexity.</p><doubt alpha="71.4" length="7" tooSmall="False" monospace="0.0">NPi NP2</doubt><doubt alpha="50.0" length="6" tooSmall="False" monospace="0.0">V' NP1</doubt><doubt alpha="63.6" length="11" tooSmall="False" monospace="0.0">vT^v'Nf&gt;2VP</doubt><doubt alpha="50.0" length="2" tooSmall="False" monospace="0.0">V'</doubt><doubt alpha="45.5" length="11" tooSmall="False" monospace="0.0">NP3...Vi V'</doubt><doubt alpha="100.0" length="2" tooSmall="False" monospace="0.0">VP</doubt><doubt alpha="100.0" length="5" tooSmall="False" monospace="0.0">NPiVP</doubt><figure caption="Figure 5: Proposals for cross-serial dependencies"></figure><p>This rightmost tree of Figure 5, then, estab­lishes that a language to query trees repre­senting the syntax of natural language re­quires an underlying tree machine beyond RTGs, but not necessarily beyond the power of spinal-formed CFTGs.</p><p>An additional result of Fujiyoshi and Kasai (2000) is the definition of a Linear Pushdown Tree Automaton (L-PDTA) that recognises exactly the class of trees generated by spinal-formed CFTGs. These are similar to the au­tomata that recognise the tree sets of RTGs, but have a non-duplicable stack in operation as the automaton walks a path of a tree; that is, the stack can only be passed along a single branch of the tree.</p><p>This suggests that a similar mechanism might be appropriate for a tree query lan­guage that would allow limited counting. Us­ing the notation of Section 3, we might have a query to find trees with (not necessarily balanced) NPs and Vs with the structure of the rightmost tree of Figure 5) as follows:</p><doubt alpha="56.9" length="51" tooSmall="False" monospace="0.0">/criild{0,inf}::VP[/criild::NP]::{0,all} /child::VP</doubt><doubt alpha="48.6" length="37" tooSmall="False" monospace="0.0">/child{0,inf}::V[/child::V']::{0,all&gt;</doubt><doubt alpha="57.2" length="187" tooSmall="False" monospace="0.0">We   would   then   extend   this   so that the     number     of     nodes matching/child{0,inf}::VP[/child::NP]::{0,all}would        be        one        less than the number matched by</doubt><doubt alpha="48.6" length="37" tooSmall="False" monospace="0.0">/child{0,inf}::V[/child::V']::{0,all}</doubt><p>in order to match only those trees with appropriately paired NPs and Vs.i Nota-tionally, this might be represented as:</p><doubt alpha="51.8" length="56" tooSmall="False" monospace="0.0">/child{X=|{0,inf&gt;|}::VP[/criild::NP]::{0,all&gt; /child::VP</doubt><doubt alpha="45.5" length="44" tooSmall="False" monospace="0.0">/criild{X=|{0,inf}|&gt;::V[/child::V']::{0,all&gt;</doubt><p>where X is a variable containing the count of nodes matched by the particular components of the query, and |Y| represents the number of steps actually matched for list of steps Y.</p><p>To restrict this to match only those trees de-scribable by spinal-formed CFTGs, passing counts down through predicate expressions, which would in effect permit stack duplica­tion, is disallowed (e.g. <b>VP[/child::NP]).</b></p><p>However, this is just an indication of the form that an XPath-like query language based on a spinal-formed CFTG might take, and is in­tended only to be the starting point for fu­ture work.</p></section><section number="6" title="Conclusion"><p>The aim of this paper has been to examine what formal machinery is necessary for lin­guistic tree query languages. Existing tree query languages are typically related to reg­ular tree grammars, although these query languages are almost exclusively for non-linguistic XML documents. The first con­tribution of the paper has been to show that regular tree grammars can be used as the basis for a range of proposed extensions to XPath motivated by linguistic considera­tions, for very typical sorts of queries such as those representing a search for a regular expression over axes.<page local="9" global="104"/> The paper's second contribution has been to demonstrate that regular tree grammars cannot, however, be a basis for some queries of linguistic inter­est. We have shown that machines with at least the power of spinal-formed context-free tree grammars, with their limited ability to count, can describe those constructions that are beyond RTGs, and made initial sugges­tions on how this ability to count could be incorporated into a query language.</p><footnote label="1">The topmost NP in the tree, under the S, is not matched by the query.</footnote><p>There is much scope for future work in this direction. To deal with XPath return val­ues we are interested in transducers based on (subtypes of) context-free tree grammars which have not yet been defined; many of the properties of the formal mechanisms remain to be investigated; and, most relevant to this paper, it is an open question as to how pre­cisely a query language can be defined based on this mechanism.</p></section><references><p>Serge Abiteboul. 1997. Querying Semi-Structured Data. In Foto Afrati and Phokion Kolaitis, editors, <i>Database Theory—ICDT'97, </i>pages 1-18. Springer-Verlag. Joan Bresnan, Ronald Kaplan, Stanley Peters, and Annie Zaenen. 1982. Cross-serial Dependen­cies in Dutch. <i>Linguistic Inquiry, </i>13(4). Anne Brüggemann-Klein, Makoto Murata, and Derick Wood. 2001. Regular tree and regular hedge languages over unranked alphabets. Tech­nical Report HKUST-TCSC-2001-05, Hong Kong University of Science and Technology. Steve Cassidy and Jonathon Harrington. 2001. Multi-level annotation in the Emu speech database management system. <i>Speech Commu­nication, </i>33(1-2):61-77.</p><p>Steve Cassidy. 2003. Generalizing XPath for di­rected graphs. In <i>Proceedings of Extreme Markup Languages 2003.</i></p><doubt alpha="65.0" length="234" tooSmall="False" monospace="0.0">Boris Chidlovskii. 2000. Using Regular Tree Au­tomata as XML schemas. InProceedings of IEEE Advances in Digital Libraries,pages 89-104. H.    Comon,     M.    Dauchet,     R. Gilleron, F.   Jacquemard,   D.   Lugiez,   S.   Tison, and</doubt><p>M. Tommasi. 1997. Tree Automata Tech­niques and Applications. Available on: http://www.grappa.univ-lille3.fr/tata<b>.</b></p><p>Release October 1st 2002.</p><p>Alin Deutsch, Mary Fernandez, Daniela Florescu, Alon Levy, and Dan Suciu. 1999. A Query Lan­guage for XML. In <i>Proceedings of the 8th Inter­national World Wide Web Conference, </i>pages 77­91.</p><p>A. Fujiyoshi and T. Kasai. 2000. Spinal-Formed Context-Free Tree Grammars. <i>Theory of Com­puting Systems, </i>33:59-83.</p><p>A. Fujiyoshi and I. Kawaharada. 2005. Deter­ministic Recognition of Trees Accepted by a Lin­ear Pushdown Tree Automaton. In <i>Proceedings </i><i>ofthe</i><i> Tenth International Conference on Imple­mentation and Application ofAutomata. </i>Esther Koünig and Wolfgang Lezius. 2001. The TIGER language—a description language for syntax graphs. Part 1: User's guidelines. Tech­nical report, IMS, University of Stuttgart. Catherine Lai and Steven Bird. 2004. Query­ing and Updating Treebanks: A Critical Sur­vey and Requirements Analysis. In <i>Proceedings of the Australasian Language Technology Work­shop 2004.</i></p><p>Mehryar Mohri. 1997. Finite-state transducers in language and speech processing. <i>Computa­tional Linguistics, </i>23(2):269-311. Makoto Murata, Dongwon Lee, and Murali Mani. 2000. Taxonomy of XML Schema Languages us­ing Formal Language Theory. In <i>Proceedings of Extreme Markup Languages 2000. </i>Geoffrey Pullum and Gerald Gazdar. 1982. Nat­ural languages and context-free languages. <i>Lin­guistics and Philosophy, </i>4:471-504. Douglas Rohde, 2001. <i>TGrep2 User Manual. </i>William Rounds.   1970.  Mappings and Gram­mars on Trees.  <i>Mathematical Systems Theory,</i> 4:257-287.</p><p>Stuart Shieber. 1985. Evidence against the context-freeness of natural language. <i>Linguistics and Philosophy, </i>8:333-343.</p><p>Peter Wood. 2003. Containment for XPath Frag­ments under DTD Constraints. In <i>Proceedings of the 9th International Conference on Database Theory, </i>pages 300-314.</p><doubt alpha="50.0" length="40" tooSmall="False" monospace="0.0">XPath.     1999.     XML   Path Language</doubt><p>(XPath), Version 1.0. Available on: http://www.iw3.org/TR/<b>xpath.</b></p></references></body></article>