<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>A Formalism for Graph Databases and its Model of Computation</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Juan Reutter</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Tony Tan</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>University of Edinburgh</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>Graph databases are directed graphs in which the edges are labeled with symbols from a finite alphabet. In this paper we introduce a logic for such graphs in which the domain is the set of edges. We compare its expressiveness with the standard logic in which the domain the set of vertices. Furthermore, we introduce a robust model of computation for such logic, the so called graph pebble automata.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        The study of graph structured data has received much attention lately, due to numerous
applications in areas such as biological networks [
        <xref ref-type="bibr" rid="ref12 ref15">12, 15</xref>
        ], social networks [
        <xref ref-type="bibr" rid="ref17">17</xref>
        ], and the
semantic Web [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. The common database model proposed by such applications is most
commonly denoted as graph databases, in which nodes are objects, and edge labels
define relationships between those objects [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ].
      </p>
      <p>
        For querying graph structured data, one normally wishes to specify certain types of
paths between nodes. Most common examples of these queries are conjunctive
regular path queries [
        <xref ref-type="bibr" rid="ref1 ref14 ref3 ref6">1, 14, 6, 3</xref>
        ]. Those querying formalisms have been thoroughly studied,
and their algorithmic properties are more or less understood. On the other hand, there
has been much less work devoted on other formalisms other than graph reachability
patterns, say, for example, the integrity constraints such as labels with unique names,
typing constraints on nodes, functional dependencies, domain and range of properties.
See, for instance, the survey [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] for more examples of integrity constraints.
      </p>
      <p>Our intention is to study formalisms for such graph databases which is capable of
expressing these integrity constraints, while at the same time still feature manageable
model checking properties. Obviously such formalisms depend on how the underlying
directed graph of the databases are represented in the first place.</p>
      <p>The standard representation of directed graphs is simply a set of nodes, together
with a binary relation on these nodes to represent the edge among them. The labeling of
the edges is represented as a function from the edges to the finite alphabet of symbols.
We call such representation the vertex representation.</p>
      <p>Another less common way to represent directed graphs is to take the edges as the
domain, together with some well defined binary relations on these edges to indicate how
two edges intersect. The labeling of the edges is represented as a set of unary predicates
on the domain. We call such representation the edge representation.</p>
      <p>In the first part of our paper we propose a vocabulary for the edge representation,
which we call E-vocabulary. We call V-vocabulary the vocabulary for the vertex
representation. We study the expressive power of E and compare it to V-vocabulary. In this
respect our contributions are the following.</p>
      <p>– The logic that we propose for edge representation is robust, in the sense that for
each graph database in the vertex representation, there exists a unique (up to
isomorphism) graph database in the edge representation that have the same underlying
directed graph. Vice versa, for each graph database in the edge representation, there
exists a unique (up to isomorphism) graph database in the vertex representation that
have the same underlying directed graph.
– Next, we turn our attention to expressivity of E-vocabulary. For first-order logic
(FO) we show that it is equivalent to V-vocabulary. On the other hand, for the
existential monadic second-order logic (9MSO), as well as monadic second-order
logic (MSO), the E-vocabulary is more expressive than the V-vocabulary. That is,
there are 9MSO and MSO sentences in E-vocabulary that cannot be expressed in
sentences in V-vocabulary in 9MSO and MSO logics, respectively.</p>
      <p>
        In the second part of our paper we introduce a notion of automata for graph databases.
We follows the direction in [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ] by defining pebble automata for directed graphs.
      </p>
      <p>
        Pebble automata was initially introduced for words over finite alphabet in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. Later
it was extended words over infinite alphabets in [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ]. Roughly speaking, a k pebble
automaton, in short k-PA, is a finite state automaton equipped with k pebbles. The
pebbles are placed on/lifted from the input word in the stack discipline – first in last
out – and are intended to mark positions in the input word. One pebble can only mark
one position and the most recently placed pebble serves as the head of the automaton.
The automaton moves from one state to another depending on the equality tests among
data values in the positions currently marked by the pebbles, as well as, the equality
tests among the positions of the pebbles.
      </p>
      <p>
        Later in [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ] the connection between graphs and pebble automata was initially
introduced. The main idea in [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ] is that a word of even length over an infinite alphabet can
be viewed as a directed graph, hence pebble automata for words over infinite alphabets
can be viewed as a model of computation for directed graphs.
      </p>
      <p>
        In this paper we extend this connection to the case of graph databases, i.e., directed
graphs in which edges are labeled with symbols from a finite alphabet . Some of the
results in this paper are the following.
1. We define the notion of k pebble graph automata, or in short k-PA, for graph
databases.
2. Every first-order sentences of quantifier rank k over graph databases can be
simulated by k-PA.
3. We demonstrate the robustness of pebble automata by showing the equivalence
between two-way alternating k-PA and one-way deterministic k-PA. This result
settles a question raised in [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ]. It was first spelled in [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ] for words over infinite
alphabet, but no formal proof has been given until now.
      </p>
      <p>This robustness immediately implies that the class of families of directed graphs
captured by k-PA is closed under boolean operations.</p>
      <p>
        We also note that almost all results in [
        <xref ref-type="bibr" rid="ref19">19</xref>
        ] can be carried over to the case of graph
databases, including the fact that reachability from the source node s to the target node
t can be checked by k-PA if and only if the distance from s to t is less than or equal
to 2k. This fact, together with item (1) above, yields the fact that reachability can be
expressed by first-order sentence of quantifier rank k if and only if the distance between
source and target nodes is less than or equal to 2k. As the proof is non standard, in the
sense that we do not use the standard Ehrenfeucht-Fra¨ısse´ approach which is commonly
used in most finite definability results, it is worth to mention that pebble automata can
be a potentially useful tool to prove definability results in first-order logic over graph
databases.
      </p>
      <p>
        Related work. Closely related to our work is Courcelles work [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], which appears to be
the first ones that suggest including the graph edges as part of the domain. The results
and definitions here do not follow from [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The first reason is that the logic introduced
by Courcelle is essentially two sorted logic. That is, the domain consists of two kinds of
elements: the vertices and the edges. Whereas, the logic that we define here has only the
edges as the domain. Thus, the logic is defined with different vocabulary than ours. The
second reason is that it has not been shown that every structure defined in the vocabulary
in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] is indeed a directed graph. It is not clear at all in the first place why it is true. We
prove in this paper that indeed such is the case.
      </p>
      <p>
        Later on in the paper [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] monadic second-order logic was introduced for abstract
matroids, which are extensions of graphs. It was shown in [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] that many results in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]
also hold in this setting. However, the emphasis in [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ] is decidability issue for
satisfaction problem. So naturally it only considers the family of matroids with bounded branch
width, the analog of tree width for graphs. While in our paper we are more interested
in a model of computation for graph databases that feature manageable model checking
properties.
      </p>
      <p>
        Another work related to ours is the work in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. In that paper two models of
computation for directed graphs are introduced, the so called V -automata and E-automata.
In brief, given an input directed graph G, a V -automaton marks the vertices of G with
symbols from finite alphabet. The decision to accept G or not depends on this labeling.
E-automata operate in the same manner, except that they mark the edges, instead of
vertices. It is shown in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] that V -automata are weaker than E-automata.
      </p>
      <p>These models, the V - and E-automata, are incomparable to our graph pebble
automata. On one side, E-automata are capable of simulating -calculus on directed
graphs, but they are not closed under negation. On the other side, our graph pebble
automata are capable of simulating the whole first-order logic on directed graphs, closed
under all boolean operations.</p>
      <p>Organization. This paper is organized as follows. In Section 2 we define the
vocabularies V and E. Then in Section 3 we define the notion of structural equivalent, the notion
to compare two structures from V and E logics. In Section 4 we compare the expressive
power between V and E logics. We introduce graph pebble automata in Section 5. We
then extend all previous definitions to the labeled edges graphs in Section 6. Finally we
conclude with a future direction for our work in Section 7.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Representation for graph databases</title>
      <p>
        Graph databases are usually defined as finite edge-labeled directed graphs [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. In this
paper, in order to keep the presentations simple, we shall work only with unlabeled
directed graphs. We will explain how to extend these results for the case of labeled
graphs in Section 6.
      </p>
      <p>In what follows, we state two representations for graph databases. The first is the
standard one, where a directed graph is just a set of vertices equipped with a binary
relation on the vertices. We will denote its vocabulary by V.</p>
      <p>The second one is our proposed representation for directed graphs where the edges
are the domain. We will denote its vocabulary by E.</p>
      <p>The vocabulary V. The vocabulary V simply consists of one binary predicate E. We
denote by STRUCT[V] the set of structures of V, which are simply directed graphs. A
V-structure is a structure in STRUCT[V].</p>
      <p>We will usually write G = (V (G); E(G)) for structures in STRUCT[V], where
V (G) = Dom(G) is the domain and E(G) is the binary relation on the elements in
V (G).</p>
      <p>The atomic formula in the logic V is either x = y or E(x; y). The meaning of</p>
      <sec id="sec-2-1">
        <title>E(x; y) is simply (x; y) 2 E. The first-order logic FO[V] is obtained by closing the</title>
        <p>atomic formulas under the Boolean connectives and first-order quantification over V .
The logic MSO[V], which stands for monadic second-order, is obtained by adding
quantification over unary predicates on the domain. If the unary predicates
quantifications are all existential, then we denote it by 9MSO[V]. A V-sentence is a sentence
using the vocabulary V. A sentence ' defines a set of directed graphs via G(') := fG j
G j= 'g.</p>
      </sec>
      <sec id="sec-2-2">
        <title>For the sake of presentation, we only consider graphs G 2 STRUCT[V] in which</title>
        <p>there is no isolated vertices and there is no self loop.</p>
        <p>The vocabulary E. Intuitively, rather than viewing a directed graph G = (V; E) as a set
V of vertices and E a binary relation on V , we take E as the domain and define some
relations among the elements in E.</p>
        <p>Let u and v be two vertices and e be an edge from u to v. What we mean by the head
of e is the vertex v, while the tail of e is the vertex u. Now the vocabulary E consists
of the binary relations HeadHead, HeadTail and TailTail on the directed edges, where
the intentions of each predicate are as follows.</p>
        <p>– TailTail(e1; e2) means that the tails of e1 and e2 are the same.
– HeadHead(e1; e2) means that the heads of e1 and e2 are the same.
– HeadTail(e1; e2) means that the head of e1 is the tail of e2.</p>
        <p>As above, STRUCT[E] denotes the set of all structures of E and an E-structure is
a structure in STRUCT[E]. We assume that the structures in STRUCT[E] satisfy the
following axioms.</p>
        <p>E1: Both HeadHead and TailTail are equivalence relations.</p>
        <p>E2: If HeadHead(e1; e2) and HeadTail(e1; e3), then HeadTail(e2; e3).
E3: If TailTail(e1; e2) and HeadTail(e3; e1), then HeadTail(e3; e2).</p>
        <p>E4: If HeadTail(e1; e3) and HeadTail(e2; e3), then HeadHead(e1; e2).
E5: If HeadTail(e3; e1) and HeadTail(e3; e2), then TailTail(e1; e2).</p>
        <p>E6: If HeadHead(e1; e2) and TailTail(e1; e2), then e1 = e2.</p>
        <sec id="sec-2-2-1">
          <title>E7: For all e, :HeadTail(e; e).</title>
          <p>The purpose of axioms E1–E5 are for consistency, that is, the structures in STRUCT[E]
are really graphs in the ordinary sense of graphs as structures in STRUCT[V]. (See
Proposition 2 below.) Axiom E6 does not allow multiple edges, whereas Axiom E7
does not allow self-loop. Axioms E6 and E7 are not essential, but they will be useful
for our convenience in the presentation.</p>
        </sec>
      </sec>
      <sec id="sec-2-3">
        <title>As usual, FO[E], MSO[E] and 9MSO[E] denote the classes of first-order, monadic</title>
        <p>second-order and existential monadic second-order sentences in the logic E. An
Esentence is a sentence using the vocabulary E.</p>
      </sec>
      <sec id="sec-2-4">
        <title>We will usually write E to denote the elements in STRUCT[E] and Dom(E ) to denote the domain of E . A sentence ' in E-logic defines a set of E-structures via</title>
        <p>G(') := fE j E j= 'g:
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>The equivalence between edge and vertex representations</title>
      <p>In this section we will show that both the edge and the vertex representations essentially
denote the same class of objects.</p>
      <p>Definition 1. Let G 2 STRUCT[V] and G 2 STRUCT[E]. We say that G and E are
structurally equivalent if there exists a 1-1 mapping : E(G) ! Dom(E ) such that for
all (v1; v2); (v2; v3); (v1; v3) 2 E(G) and e1; e2 2 Dom(E ),
1. (v1; v2) = e1 and (v2; v3) = e2 if and only if HeadTail(e1; e2);
2. (v1; v2) = e1 and (v1; v3) = e2 if and only if TailTail(e1; e2); and
3. (v1; v3) = e1 and (v2; v3) = e2 if and only if HeadHead(e1; e2).
The 1-1 mapping is called a (V; E)-isomorphism.</p>
      <sec id="sec-3-1">
        <title>In other words, if G and E are structurally equivalent, then they essentially denote the</title>
        <p>same underlying directed graph. The following proposition states that this notion is
robust.</p>
        <p>Proposition 1.
(a) Let G be a V-structure and E 1, E 2 be E-structures. If both E 1 and E 2 are
structurally equivalent to G, then E 1 and E 2 are isomorphic.
(b) Let G1, G2 be V-structures and E be a E-structure. If both G1 and G2 are
equivalent to E , then G1 and G2 are isomorphic.</p>
        <p>Moreover, the following proposition shows that both edge and vertex
representations are equivalent, in the sense that each graph stored using the standard vertex
representation can be coded as a graph under the edge representation, and vice versa.
Proposition 2. 1. For every V-structure G, there exists a unique (up to isomorphism)</p>
        <p>E-structure E which is structurally equivalent to G.
2. For every E-structure E , there exists a unique (up to isomorphism) V-structure G
structurally equivalent to E .</p>
        <p>We do not state the full proof, but rather give an example of how the edge to vertex
translation works.</p>
      </sec>
      <sec id="sec-3-2">
        <title>Example 1. Let E be an E-structure, where</title>
        <p>– Dom(E ) = fe1; e2; e3g;
– HeadHead = f(e1; e1); (e2; e2); (e3; e3); (e1; e3); (e3; e1)g;
– TailTail = f(e1; e1); (e2; e2); (e3; e3)g;
– HeadTail = f(e1; e2); (e2; e3); (e3; e2)g.</p>
      </sec>
      <sec id="sec-3-3">
        <title>The following picture well illustrates the structure of E :</title>
        <p>e1</p>
        <p>I</p>
        <p>R
e2
e3
We can get a V-structure G = (V (G); E(G)) equivalent to E as follows. Let H be the
equivalent classes of HeadHead and T the equivalent classes of TailTail, i.e. H =
ffe1; e3g; fe2gg and T = ffe1g; fe2g; fe3gg. Then we define G = (V (G); E(G)) as
follows. The set of vertices is V (G) = H T , and ((H1; T1); (H2; T2)) 2 E(G) if and
only if T1 \ H2 6= ;. It is depicted as follows.</p>
        <p>(;; fe1g)</p>
        <p>(fe1; e3g; fe2gI)</p>
        <p>R (fe2g; fe3g)
4</p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Vertex and edge representations and their logics</title>
      <p>In this section we will study the relation between the expressive power of logics
using vertex or edge vocabularies. We need the following definition. For a set A
STRUCT[V], we define EquivE(A) as the set of E-structures which are equivalent
to the structures in A. Formally,</p>
      <p>EquivE(A) = fE 2 STRUCT[E] j E is structurally equivalent to some G 2 Ag:</p>
      <sec id="sec-4-1">
        <title>Vice versa, for a set B</title>
        <p>STRUCT[E], we define
EquivV(B) = fG 2 STRUCT[V] j G is structurally equivalent to some E 2 Bg:</p>
      </sec>
      <sec id="sec-4-2">
        <title>By Proposition 1, it is immediate that for every sets A</title>
        <p>STRUCT[E],</p>
        <sec id="sec-4-2-1">
          <title>STRUCT[V] and B</title>
          <p>A = EquivV(EquivE(A)) and B = EquivE(EquivV(B))
From this we immediately get that A = EquivV(B) if and only if B = EquivE(A).</p>
          <p>Now we introduce the notion of (V; E)-equivalent, the logical version of
Defintion 1.</p>
          <p>Definition 2. A V-sentence ' and an E-sentence are (V; E)-equivalent if G(') =
EquivV(G( )), or equivalently, G( ) = EquivE(G(')).</p>
          <p>Using the notion of (V; E)-equivalent, we can now compare the expressive power
between vertex and edge representations. Our first proposition shows that the edge
representation is as least as expressive as the vertex representation:
Proposition 3. Let L in fFO; 9MSO; MSOg. Then, for every sentence ' 2 L[V], there
exists a sentence 2 L[E] such that ' and are (V; E)-equivalent
The proof is pretty straightforward, thus omitted.</p>
          <p>The natural question is whether the converse holds, that is, whether for every
sentence using the edge representation we can find an equivalent sentence using the vertex
representation. As we show below, it turns out that this is not true even for 9MSO
sentences, nor if the full power of MSO is allowed.</p>
          <p>Theorem 1. 1. There exists a sentence 2 9MSO[E] such that for all sentence ' 2
9MSO[V], and ' are not (V; E)-equivalent.
2. There exists a sentence 2 MSO[E] such that for all sentence ' 2 MSO[V],
and ' are not (V; E)-equivalent.</p>
        </sec>
      </sec>
      <sec id="sec-4-3">
        <title>Proof. We begin with the 9MSO case. The idea is to use the fact that (s; t)-reachability</title>
        <p>in directed graph is not expressible in 9MSO[V] (see, for example, [13, Theorem 7.16]).</p>
        <p>For this we need to add two constants s and t to both V- and E-vocabularies,
denoting the source and target vertices respectively. The interpretation of the constants s
and t in V-structures are the source and the target vertices, while their interpretation
in E-structures are two edges: one whose tail is the source vertex, and the other whose
head is the target vertex.</p>
        <p>We define the following class of V-structures consists of directed graphs in which
there is a path from s to t.</p>
        <p>RV =</p>
        <p>G 2 STRUCT[V] tfhoerreeaacrheiv=1; :1:;::;:v:k; ks.t. v11; (=vis;vain+d1)vk2=E(tGan)d</p>
        <p>It can be readily seen that the class EquivE(RV) is expressible in 9MSO[E] in the
following sentence. There exists a set P such that
– there is an edge y in P such that TailTail(y; s) holds;
– there is an edge y in P such that HeadHead(y; t) holds;
– for every edge y in P where :HeadHead(y; t), there is an edge z in P such that
HeadTail(y; z) holds.</p>
      </sec>
      <sec id="sec-4-4">
        <title>This immediately implies that 9MSO[E] is strictly more expressive than 9MSO[V].</title>
        <p>This proves the first case of the theorem.</p>
        <p>The proof for the second case goes along the same lines, this time using the fact that
directed graph hamiltonicity (i.e., whether a graph is hamiltonian) is not expressible in
MSO[V] (see, for example, [13, Corollary 7.24]). On the other hand, directed graph
hamiltonicity can be expressed in the following MSO[E] sentence. There exists a set U
such that
– every two edges in U are connected (can be expressed as in the proof above); and
– for every edge x, x is adjacent to some edge y in U (either HeadHead(x; y),
TailTail(x; y), or HeadTail(x; y) holds);
2</p>
        <p>Next, we compare the two representations for the case of first-order logic. It turns
out that the edge and vertex representations are equivalent if one disallows second-order
quantification. Moreover, we also show that this transformation involves only a slight
increase in quantifier rank.</p>
        <p>Proposition 4. For every sentence 2 FO[E], there exists a sentence ' 2 FO[V] such
that they are (V; E)-equivalent and qr(') = 2qr( ).</p>
        <p>With respect to the vertex to edge transformation, the following is immediate from
the proof of proposition 3
Corollary 1. For every sentence ' 2 FO[V], there exists a sentence
that ' and are (V; E)-equivalent and qr( ) = qr(') + 1.
2 FO[E] such
5</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>Graph pebble automata</title>
      <p>
        In this section we define pebble automata for directed graphs. It is based on the idea of
pebble automata (PA) for words over infinite alphabet [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ]. Let D be a set of infinite
symbols. We assume that the nodes in the directed graphs always come from D.
      </p>
      <p>Briefly the way graph PA with k pebbles works as follows. If G is a directed
graph, and (a1; b1); : : : ; (an; bn) are the edges in E(G), then we feed a sequence w =
ab11 abnn into graph k-PA. The pebbles are numbered from 1 to k. The automaton
starts the computation with only pebble k on the sequence w. The pebbles are placed
on/lifted from w in the stack discipline according to the strict order of the pebbles:
Pebble i can be placed only when pebbles i + 1; : : : ; k are above the sequence w. Each
pebble is intended to mark one position in w and the smallest numbered pebble on w,
or, equivalently the most recently placed pebble, serves as the head of the automaton.
The automaton moves from one state to another depending on whether the edges read
by the pebbles satisfy the HeadHead; TailTail; HeadTail relations.</p>
      <p>Definition 3. A two-way alternating graph k-pebble automaton, (in short graph k-PA)
is a system A = hQ; q0; F; i, where
– Q, q0 2 Q, U Q and F Q are a finite set of states, the initial state, the set of
universal states and the set of final states, respectively; and
– is a finite set of transitions of the form such that
!
is of the form</p>
      <p>(i; P; V00; V10; V01; V11; q)
, where i 2 f1; : : : ; kg, P; V00; V10; V01; V11
is of the form (q; act), where q 2 Q and
fi + 1; : : : ; kg, and
act 2 fleft; right; place-pebble; lift-pebbleg:</p>
      <p>Given a sequence of edges w = ab11 abnn , a configuration of A on /w. is a triple
[i; q; ], where i 2 f1; : : : ; kg, q 2 Q and : fi; i + 1; : : : ; kg ! f0; 1; : : : ; n; n + 1g.
The function defines the position of the pebbles and is called the pebble assignment.
The symbols in the positions 0 and n + 1 are / and ., respectively.</p>
      <p>The initial configuration is 0 = [k; q0; 0], where 0(k) = 0 is the initial pebble
assignment. A configuration [i; q; ] with q 2 F is called an accepting configuration.</p>
      <p>A transition (i; P; V00; V01; V10; V11; p) ! applies to a configuration [j; q; ], if
(1) i = j and p = q,
(2) P = fl &gt; i : (l) = (i)g,
(3:a) V00 = fl &gt; i : a (l) = a (i)g,
(3:b) V10 = fl &gt; i : b (l) = a (i)g,
(3:c) V10 = fl &gt; i : a (l) = b (i)g, and
(3:d) V11 = fl &gt; i : b (l) = b (i)g.</p>
      <p>A transition (i; P; V00; V01; V10; V11; p) ! applies to a configuration [j; q; ], if
conditions (1)–(3) above hold.</p>
      <p>We define the transition relation `A as follows: [i; q; ] `A [i0; q0; 0], if there is a
transition ! (p; act) 2 that applies to [i; q; ] such that q0 = p, for all j &gt; i,
0(j) = (j), and
- if act = left, then i0 = i and 0(i) = (i) 1,
- if act = right, then i0 = i and 0(i) = (i) + 1,
- if act = lift-pebble, then i0 = i + 1,
- if act = place-pebble, then i0 = i 1, 0(i
1) = 0 and 0(i) = (i).</p>
      <sec id="sec-5-1">
        <title>As usual, we denote the reflexive, transitive closure of `A by `A.</title>
        <p>The acceptance criteria is based on the notion of leads to acceptance below. For
every configuration = [i; q; ],
– if q 2 F , then leads to acceptance;
– if q 2 U , then leads to acceptance if and only if for all configurations 0 such that
` 0, 0 leads to acceptance;
– if q 2= F [ U , then leads to acceptance if and only if there is at least one
configuration 0 such that ` 0, and 0 leads to acceptance.</p>
        <p>A sequence of edges ab11 abnn is accepted by A, if the initial configuration 0 leads
to acceptance. The language L(A) consists of all sequence of edges accepted by A.
Obviously, the sequence w induces a set of directed edges Gw as explain in the beginning
of this section.</p>
        <p>We have presented here the notion of alternating graph PA, since it is easier to
work with for our purposes. However, it is not difficult to define instead the notion
of deterministic graph PA. The next theorem shows that this choice is without loss of
generality, as both models are equivalent.</p>
        <p>Theorem 2. 1. For each k 1, two-way non-deterministic graph k-PA and one-way
deterministic graph k-PA have the same recognition power.
2. For each k 1, graph k-PA languages are closed under boolean operation.</p>
        <p>
          Next, we introduce the relationship between graph PA and First Order logic.
Theorem 3. For every FO E-sentence , there exists a graph k-PA A
qr( ) and L(A) = G( )).
such that k =
Proof. The proof is an adaptation of similar result in [
          <xref ref-type="bibr" rid="ref19">19</xref>
          ]. First, by Theorem 2, PAk is
closed under boolean operations. Let ' = Qxk (xk) where Q 2 f8; 9g and (xk) is
of quantifier rank k 1.
        </p>
        <p>The proof is by straightforward induction on k. A k-PA A iterates pebble k through
all possible positions in the input. On each iteration, the automaton A recursively calls
a (k 1)-PA A0 that accepts the language L( (xk)), treating the position of pebble k
as the assignment value for xk.</p>
        <p>- If Q = 8, then A accepts w if and only if A0 accepts on all iterations.
- If Q = 9, then A accepts w if and only if A0 accepts on at least one iteration.
2</p>
        <p>
          Notice that Theorem 3 is optimal in the sense that all k pebbles are needed. More
precisely, it is possible to adapt the proof of [
          <xref ref-type="bibr" rid="ref19">19</xref>
          ] to show that for every k 2 there
exists an FO E-sentence , with k = qr( ), and such that L(A) 6= G( )) for every
graph PA A using less than k pebbles.
6
        </p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>When the edges are labeled with symbols from finite alphabet</title>
      <p>In the usual graph databases setting the edges are labeled with symbols from a fixed
finite alphabet. Each symbol can be viewed as a unary predicate on the edges.</p>
      <p>In this section we extend the vocabularies V and E with unary predicates on the
edges, which we called extended V and E vocabularies. We also extend the definition
of graph pebble automata for edges labeled with symbols from a fixed alphabet.</p>
      <p>In the following we let be a fixed finite alphabet.</p>
      <p>Extended V logic. The vocabulary for the extended V logic consists of for each</p>
      <sec id="sec-6-1">
        <title>2 , where each is a binary predicate on the domain. We denote by V the extended</title>
        <p>V logic.</p>
        <p>An extended V-structure is a tuple G = (V; f g 2 ) such that V is the domain of
nodes and the sets f g 2 are disjoints. Intuitively, each relation denotes the set of
edges which are labeled with the symbol 2 . Since no edge can be labeled with two
different symbols, the sets f g 2 are disjoint.</p>
        <p>Extended E logic. The vocabulary consists of HeadHead; HeadTail; TailTail; f g 2 ,
where each 2 is unary predicate on the domain. We denote by E the extended E
logic.</p>
        <p>An extended E-structure is a tuple E = (U; HeadHead; HeadTail; TailTail; f g 2 ),
where U is the domain of edges, the relations HeadHead; HeadTail; TailTail on U are
defined as before, and each 2 is a unary predicate on U .</p>
        <p>It is straightforward to show that all results on the vocabularies V and E still hold
for the extended logics V and E . In the following we will elaborate this point more
precisely.</p>
        <p>Definition 4. Let G be an V structure and E an E structure. We say that G and E are
structurally equivalent if there exists a 1-1 mapping : E(G) ! Dom(E ) such that for
all (v1; v2); (v2; v3); (v1; v3) 2 S 2 and e1; e2 2 Dom(E ),
1. for each 2 , (v1; v2) 2 if and only if (v1; v2) 2 ;
2. (v1; v2) = e1 and (v2; v3) = e2 if and only if HeadTail(e1; e2);
3. (v1; v2) = e1 and (v1; v3) = e2 if and only if TailTail(e1; e2); and
4. (v1; v3) = e1 and (v2; v3) = e2 if and only if HeadHead(e1; e2).</p>
        <p>The 1-1 mapping is called a (V ; E )-isomorphism.</p>
        <p>Theorem 4. 1. Let L in fFO; 9MSO; MSOg. Then, for every sentence ' 2 L[V ],
there exists a sentence 2 L[E ] such that ' and are (V ; E )-equivalent
2. There exists a sentence 2 9MSO[E ] such that for all sentence ' 2 9MSO[V ],
and ' are not (V ; E )-equivalent.
3. There exists a sentence 2 MSO[E ] such that for all sentence ' 2 MSO[V ],
and ' are not (V ; E )-equivalent.</p>
        <p>Next we define a graph pebble automata with unary predicates on the edges. It is
also pretty much straightforward extension of Definition 3. In this case the input is of
0 1 1 0 n 1
the form: @ a1 A @ an A 2 D D, where i 2 is the label of the edge
b1 bn
(ai; bi).</p>
        <p>The transitions are of the form: (i; ; P; V00; V10; V01; V11; p) ! (q; act). It is
straightforward to show that all the results in the previous section can be adapted for
such graph pebble automata. More precisely,
Theorem 5. 1. For PA with unary predicates, for each k 1, two-way non-deterministic
graph k-PA and one-way deterministic graph k-PA have the same recognition
power.
2. For each k 1, graph k-PA (with unary predicates) languages are closed under
boolean operation.
3. For every FO E -sentence , there exists a graph k-PA A with unary predicates
such that k = qr( ) and L(A) = G( )).</p>
      </sec>
    </sec>
    <sec id="sec-7">
      <title>Future directions</title>
      <p>We would like to apply our logics and graph pebble automata in a more application
oriented settings. Also, it is well known that the emptiness problem for graph pebble
automata is undecidable. One direction that we would like to pursue is to charaterize
a subclass of pebble automata, for which the emptiness problem is decidable. We also
would like to define and study similar logics for matroid and extend the graph pebble
automata for abstract matroid.</p>
      <p>Acknowledgments: We thank the anonymous referees for many helpful comments. Partial
support provided by EPSRC grant G049165 and FET-Open Project FoX, grant agreement 233599.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>S.</given-names>
            <surname>Abiteboul</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Buneman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Suciu</surname>
          </string-name>
          .
          <article-title>Data on the Web: From Relations to Semistructured Data and XML</article-title>
          . Morgan Kauffman,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>R.</given-names>
            <surname>Angles</surname>
          </string-name>
          ,
          <string-name>
            <surname>C.</surname>
          </string-name>
          <article-title>Gutie´rrez. Survey of graph database models</article-title>
          .
          <source>ACM Comput. Surv</source>
          .
          <volume>40</volume>
          (
          <issue>1</issue>
          )
          <string-name>
            <surname>:</surname>
          </string-name>
          (
          <year>2008</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3. P. Barcelo´,
          <string-name>
            <given-names>C.</given-names>
            <surname>Hurtado</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L.</given-names>
            <surname>Libkin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Wood</surname>
          </string-name>
          .
          <article-title>Expressive languages for path queries over graphstructured data</article-title>
          .
          <source>In PODS</source>
          <year>2010</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>D.</given-names>
            <surname>Berwanger</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Janin</surname>
          </string-name>
          . Automata on Directed Graphs:
          <article-title>Edge Versus Vertex Marking</article-title>
          .
          <source>In ICGT</source>
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>B.</given-names>
            <surname>Courcelle</surname>
          </string-name>
          .
          <article-title>The expression of graph properties and graph transformations in monadic second-order logic</article-title>
          .
          <source>In Handbook of Graph Grammars and Computing by Graph Transformations</source>
          , Volume
          <volume>1</volume>
          :
          <string-name>
            <surname>Foundations</surname>
          </string-name>
          ,
          <year>1997</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <given-names>I.</given-names>
            <surname>Cruz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Mendelzon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Wood</surname>
          </string-name>
          .
          <article-title>A graphical query language supporting recursion</article-title>
          .
          <source>In SIGMOD</source>
          <year>1987</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>R.</given-names>
            <surname>Fagin</surname>
          </string-name>
          ,
          <string-name>
            <given-names>L. J.</given-names>
            <surname>Stockmeyer</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M. Y.</given-names>
            <surname>Vardi</surname>
          </string-name>
          .
          <article-title>On monadic NP vs</article-title>
          .
          <source>monadic co-NP. Info. and Comp</source>
          .,
          <volume>120</volume>
          (
          <issue>1</issue>
          ):
          <fpage>78</fpage>
          -
          <lpage>92</lpage>
          ,
          <year>1995</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>N.</given-names>
            <surname>Globerman</surname>
          </string-name>
          and
          <string-name>
            <given-names>D.</given-names>
            <surname>Harel</surname>
          </string-name>
          .
          <article-title>Complexity results for multi-pebble automata and their logics</article-title>
          .
          <source>In ICALP</source>
          <year>1994</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>C.</given-names>
            <surname>Gutierrez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Hurtado</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Mendelzon</surname>
          </string-name>
          .
          <article-title>Foundations of semantic web databases</article-title>
          .
          <source>In PODS</source>
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10. P. Hlineˇny´.
          <article-title>Branch-width, parse trees, and monadic second-order logic for matroids</article-title>
          .
          <source>J. Comb. Theory, Ser. B</source>
          <volume>96</volume>
          (
          <issue>3</issue>
          ):
          <fpage>325</fpage>
          -
          <lpage>351</lpage>
          (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <given-names>R.</given-names>
            <surname>Ladner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Lipton</surname>
          </string-name>
          and
          <string-name>
            <given-names>L.</given-names>
            <surname>Stockmeyer</surname>
          </string-name>
          .
          <article-title>Alternating Pushdown and Stack Automata</article-title>
          .
          <source>SIAM Journal of Comp</source>
          .
          <volume>13</volume>
          (
          <issue>1</issue>
          ):
          <fpage>135</fpage>
          -
          <lpage>155</lpage>
          ,
          <year>1984</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <given-names>U.</given-names>
            <surname>Leser</surname>
          </string-name>
          .
          <article-title>A query language for biological networks</article-title>
          .
          <source>Bioinformatics 21 (suppl 2)</source>
          (
          <year>2005</year>
          ),
          <fpage>ii33</fpage>
          -
          <lpage>ii39</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <given-names>L.</given-names>
            <surname>Libkin</surname>
          </string-name>
          .
          <source>Elements of Finite Model Theory</source>
          . Springer,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14.
          <string-name>
            <surname>A. O. Mendelzon</surname>
            ,
            <given-names>P. T.</given-names>
          </string-name>
          <string-name>
            <surname>Wood</surname>
          </string-name>
          .
          <article-title>Finding regular simple paths in graph databases</article-title>
          .
          <source>SIAM J. Comput.</source>
          ,
          <volume>24</volume>
          (
          <issue>6</issue>
          ):
          <fpage>1235</fpage>
          -
          <lpage>1258</lpage>
          ,
          <year>1995</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <given-names>R.</given-names>
            <surname>Milo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Shen-Orr</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Itzkovitz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Kashtan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Chklovskii</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Alon</surname>
          </string-name>
          .
          <article-title>Network motifs: simple building blocks of complex networks</article-title>
          .
          <source>Science</source>
          <volume>298</volume>
          (
          <issue>5594</issue>
          ) (
          <year>2002</year>
          ),
          <fpage>824</fpage>
          -
          <lpage>827</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <given-names>F.</given-names>
            <surname>Neven</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Schwentick</surname>
          </string-name>
          , and
          <string-name>
            <given-names>V.</given-names>
            <surname>Vianu</surname>
          </string-name>
          .
          <article-title>Finite state machines for strings over infinite alphabets</article-title>
          .
          <source>ACM ToCL</source>
          ,
          <volume>5</volume>
          (
          <issue>3</issue>
          ):
          <fpage>403</fpage>
          -
          <lpage>435</lpage>
          ,
          <year>2004</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <given-names>R.</given-names>
            <surname>Ronen</surname>
          </string-name>
          and
          <string-name>
            <surname>O. Shmueli.</surname>
          </string-name>
          <article-title>SoQL: a language for querying and creating data in social networks</article-title>
          .
          <source>In ICDE</source>
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref18">
        <mixed-citation>
          18.
          <string-name>
            <given-names>T.</given-names>
            <surname>Schwentick</surname>
          </string-name>
          .
          <source>On Winning Ehrenfeucht Games and Monadic NP. Ann. Pure Appl. Logic</source>
          ,
          <volume>79</volume>
          (
          <issue>1</issue>
          ),
          <fpage>61</fpage>
          -
          <lpage>92</lpage>
          ,
          <year>1996</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref19">
        <mixed-citation>
          19.
          <string-name>
            <given-names>T.</given-names>
            <surname>Tan</surname>
          </string-name>
          .
          <article-title>Graph reachability and pebble automata over infinite alphabets</article-title>
          .
          <source>In LICS</source>
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref20">
        <mixed-citation>
          20. G.
          <article-title>Tura´n. On the definability of properties of finite graphs</article-title>
          .
          <source>Discrete Mathematics</source>
          ,
          <volume>49</volume>
          (
          <issue>3</issue>
          ):
          <fpage>291</fpage>
          -
          <lpage>302</lpage>
          ,
          <year>1984</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>