the power of tarski’s relation algebra on treesjhellings.nl/files/foiks2018_1_slides.pdf1/35 the...
TRANSCRIPT
1/35
The Power of Tarski’s Relation Algebra on Trees
Jelle Hellings1
Yuqing Wu2 Marc Gyssens1 Dirk Van Gucht3
1 Hasselt University2 Pomona College
3 Indiana University
2/35
Relation algebra: graphs and queries
Alice
Bob
Carol
ParentOfParentOf
Dan
ParentOf
Faythe
ParentOf
Grace
ParentOf
PeggyFriendOf FriendOf
Victor
FriendOf
WorksWith
WendyFriendOf
FriendsOfGgp = π1[ParentOf ◦ ParentOf ◦ ParentOf ] ◦ FriendOf
2/35
Relation algebra: graphs and queries
Alice
Bob
Carol
ParentOfParentOf
Dan
ParentOf
Faythe
ParentOf
Grace
ParentOf
PeggyFriendOf FriendOf
Victor
FriendOf
WorksWith
WendyFriendOf
FriendsOfGgp = π1[ParentOf ◦ ParentOf ◦ ParentOf ] ◦ FriendOf
2/35
Relation algebra: graphs and queries
Alice
Bob
Carol
ParentOfParentOf
Dan
ParentOf
Faythe
ParentOf
Grace
ParentOf
PeggyFriendOf FriendOf
Victor
FriendOf
WorksWith
WendyFriendOf
FriendsOfGgp = π1[ParentOf ◦ ParentOf ◦ ParentOf ] ◦ FriendOf
2/35
Relation algebra: graphs and queries
Alice
Bob
Carol
ParentOfParentOf
Dan
ParentOf
Faythe
ParentOf
Grace
ParentOf
PeggyFriendOf FriendOf
Victor
FriendOf
WorksWith
WendyFriendOf
FriendsOfGgp = π1[ParentOf ◦ ParentOf ◦ ParentOf ] ◦ FriendOf
2/35
Relation algebra: graphs and queries
Alice
Bob
Carol
ParentOfParentOf
Dan
ParentOf
Faythe
ParentOf
Grace
ParentOf
PeggyFriendOf FriendOf
Victor
FriendOf
WorksWith
WendyFriendOf
FriendsOfGgp = π1[ParentOf ◦ ParentOf ◦ ParentOf ] ◦ FriendOf
3/35
Relation algebra: other operators
ChildOf = ParentOf −1
AcquaintanceOf = FriendOf ∪WorksWith
WorkFriendOf = FriendOf ∩WorksWith
NonWorkFriend = FriendOf −WorksWith
Parent = π1[ParentOf ]
NonParent = π 1[ParentOf ]
GrandParentOf = ParentOf ◦ ParentOf
Also: constants ∅, id, di.
4/35
Relation algebra and query languages
∅ id ∪ ◦ −1 π π ∩ − di
Tarski’s Relation Algebra, FO[3]
I On graphs: RPQs, 2RPQs, Nested RPQs, Graph XPath.I XPath of Benedikt et al.I Path+ of Wu et al.I Downward queries of Hellings et al.I Conditional and Navigational XPath.
5/35
�estions about the relation algebra
�estions
I Are all these operators necessary?I What does each operator add?
What is the expressive power of fragments of the relation algebra?
5/35
�estions about the relation algebra
�estions
I Are all these operators necessary?I What does each operator add?
What is the expressive power of fragments of the relation algebra?
6/35
Expressive power of relation algebra
7/35
Background: when are queries equivalent?
Two types of queries and equivalences
Path-queries. The exact query result is important:
FriendOf ∩WorksWith ≡path FriendOf − (FriendOf −WorksWith).
Boolean-queries. The existence of a query result is important:
FriendOf −1 ◦ ParentOf ≡bool π1[FriendOf ] ∩ π1[ParentOf ].
DefinitionLanguage L1 is z-subsumed by L2 if every query in L1 isz-equivalent to a query in L2 (denoted by L1 �z L2).
8/35
Background: query fragments
Let F ⊆ {di, −1,π ,π ,∩,−}.I We write N(F): only allows ∅, id, `, ◦, ∪, and all operators in F.I We write N(F) to represent all operators expressible in N(F)
using the following basic rewrite rules:
π1[e] = π j[π 1[e]] = (e ◦ e−1) ∩ id = (e ◦ (id ∪ di)) ∩ id;π2[e] = π j[π 2[e]] = (e−1 ◦ e) ∩ id = ((id ∪ di) ◦ e) ∩ id;π i[e] = id − πi[e];
e1 ∩ e2 = e1 − (e1 − e2).
Examples
I N(π ) = N(π ,π ).I N(−1,−) = N(−1,π ,π ,∩,−).
9/35
Results on graphs
Previous work by Fletcher et al.Relative expressive power of relation algebra fragments on graphs:I Path queries: each operator adds expressive power.I Boolean queries: −1 sometimes does not add expressive power.
Example: strong Boolean separationsConsider (E ◦ E) ∩ E:
G3,3: G4:
Without ∩ (or −): no query distinguishes G3,3 and G4.
9/35
Results on graphs
Previous work by Fletcher et al.Relative expressive power of relation algebra fragments on graphs:I Path queries: each operator adds expressive power.I Boolean queries: −1 sometimes does not add expressive power.
Example: strong Boolean separationsConsider (E ◦ E) ∩ E:
G3,3: G4:
Without ∩ (or −): no query distinguishes G3,3 and G4.
10/35
Our work: studying trees
GoalImprove understanding of the relation algebra by studying theexpressive power in restricted se�ings.
Trees
AdviserOf AdviserOf
AdviserOf AdviserOf
I Trees are hierarchical/nested structures.E.g. taxonomies, organizational charts, documents, file systems.
I Tree-based formal data models and query languagesE.g. XML data with XPath, JSON data, nested relational data.
11/35
Initial classification
1-subtreereducible
2-subtreereducible
3-subtreereducible
downward non-downward
local
non-local
monotone
non-monotone
monotone
non-monotone
N(∩,−)
N(π ,∩)
N(π ,π ,∩,−) N(−1,π ,π ,∩)
N(−1,π ,∩)
N(di, −1,π )
N(di, −1,π ,π )
N(−1,π ,π ,∩,−)
N(di, −1,π ,∩)
N
I N(π ,π ,∩,−) studied by Hellings et al.I N(−1,π ) studied by Benedikt et al.I N(−1,π ,∩) studied by Wu et al.
11/35
Initial classification
1-subtreereducible
2-subtreereducible
3-subtreereducible
downward non-downward
local
non-local
monotone
non-monotone
monotone
non-monotone
N(∩,−)
N(π ,∩)
N(π ,π ,∩,−) N(−1,π ,π ,∩)
N(−1,π ,∩)
N(di, −1,π )
N(di, −1,π ,π )
N(−1,π ,π ,∩,−)
N(di, −1,π ,∩)
N
I N(π ,π ,∩,−) studied by Hellings et al.
I N(−1,π ) studied by Benedikt et al.I N(−1,π ,∩) studied by Wu et al.
11/35
Initial classification
1-subtreereducible
2-subtreereducible
3-subtreereducible
downward non-downward
local
non-local
monotone
non-monotone
monotone
non-monotone
N(∩,−)
N(π ,∩)
N(π ,π ,∩,−) N(−1,π ,π ,∩)
N(−1,π ,∩)
N(di, −1,π )
N(di, −1,π ,π )
N(−1,π ,π ,∩,−)
N(di, −1,π ,∩)
N
I N(π ,π ,∩,−) studied by Hellings et al.I N(−1,π ) studied by Benedikt et al.I N(−1,π ,∩) studied by Wu et al.
12/35
Downward queries: Boolean and path queries
N()
N(π )
N(π )
N(∩,−)
N(π ,∩)
N(π ,π ,∩,−)
I N(π ,π ,∩,−) is downward.I −1 and di are not downward.
Theorem (Hellings et al.)Let F ⊆ {π ,π ,∩,−}.We have N(F) �path N(F − {∩,−}).
13/35
Local queries
14/35
Locality
DefinitionA query q is local if there exists k ≥ 0 such that, for every tree T , andfor all nodes m and n, (m, n) ∈ [[q]]T if and only if (m, n) ∈ [[q]]T′ , withT ′ the smallest subtree of T containing all nodes at distance at mostk from the nearest common ancestor of m and n.
I N(−1,π ,π ,∩,−) is local.I di is not local.
15/35
Local queries: main resultsPath queries Boolean queries
N()
N(π )
N(π )
N(−1)
N(−1,π )
N(−1,π )
N(−1,−)
N(∩,−)
N(π ,∩)
N(π ,π ,∩,−)
N(−1,π ,∩)
N(−1,π ,π ,∩)
N(−1,π ,π ,∩,−)
N()
N(π ) = N(−1)
N(π )
N(−1,−)
N(∩,−)
N(π ,∩)N(−1,π ,∩)
N(π ,π ,∩,−)N(−1,π ,π ,∩)
N(−1,π ,π ,∩,−)
16/35
Condition tree queries
DefinitionIf an expression always evaluates to a subset of id then it is called anode expression.
DefinitionA condition tree query Q is a tuple Q = (T ,C, s, t,γ ) withI T = (V, Σ,E) a labeled tree,I C is a set of node expressions,I s ∈ V is the source node,I t ∈ V is the target node,I γ ⊆ V × C is the node-condition relation.
γ (n) denotes the set {e1, . . . , ek} of conditions related to node n ∈ V .γ (n) also denotes the expression e1 ◦ . . . ◦ ek (≡path e1 ∩ . . . ∩ ek ).
17/35
A condition tree query example
Consider the union-free expression
`−11 ◦ `
−12 ◦ π 2[`3] ◦ `3 ◦ `3 ◦ π1[`1] ◦ π1[`2].
This expression is path-equivalent to
`2 `3
`1 `3
`1 `2
s t
{π 2[`3]}
`3
`2 `3
`1 `3 `3
`1 `2
`1
`2 `3
`1
`4
`3
`1 `2
17/35
A condition tree query example
Consider the union-free expression
`−11 ◦ `
−12 ◦ π 2[`3] ◦ `3 ◦ `3 ◦ π1[`1] ◦ π1[`2].
This expression is path-equivalent to
`2 `3
`1 `3
`1 `2
s t
{π 2[`3]}
`3
`2 `3
`1 `3 `3
`1 `2
`1
`2 `3
`1
`4
`3
`1 `2
17/35
A condition tree query example
Consider the union-free expression
`−11 ◦ `
−12 ◦ π 2[`3] ◦ `3 ◦ `3 ◦ π1[`1] ◦ π1[`2].
This expression is path-equivalent to
`2 `3
`1 `3
`1 `2
s t
{π 2[`3]}
`3
`2 `3
`1 `3 `3
`1 `2
`1
`2 `3
`1
`4
`3
`1 `2
17/35
A condition tree query example
Consider the union-free expression
`−11 ◦ `
−12 ◦ π 2[`3] ◦ `3 ◦ `3 ◦ π1[`1] ◦ π1[`2].
This expression is path-equivalent to
`2 `3
`1 `3
`1 `2
s t
{π 2[`3]}
`3
`2 `3
`1 `3 `3
`1 `2
`1
`2 `3
`1
`4
`3
`1 `2
18/35
Condition tree queries and local queries
Qtree(F) are the condition tree queries in which node conditions arerestricted to union-free expressions in N(F).
ClaimLet {−1,π } ⊆ F ⊆ {−1,π ,π }.Qtree(F) and union-free N(F) path-subsume each other.
PropositionLet F ⊆ {−1,π ,π } and Q be a condition tree query in Qtree(F).There exists a union-free expression e in N(F) such that e ≡path Q.
19/35
Basic manipulations on condition tree queries
`
n
m
leaf-prune mγ (n) ◦ π1[` ◦ γ (m)]
`
n
m
root-prune mγ (n) ◦ π2[γ (m) ◦ `]
19/35
Basic manipulations on condition tree queries
`
n
m
leaf-prune mγ (n) ◦ π1[` ◦ γ (m)]
`
n
m
root-prune mγ (n) ◦ π2[γ (m) ◦ `]
20/35
Up-down queries
DefinitionA condition tree query Q = (T ,C, s, t,γ ) is an up-down query if alledges of T are on the unique path from s to t not taking into accountthe direction of the edges.
`3
`1
`2
`2
`1`2
s
tπ 2[`3]
pruning`1 `2
`1
s
t
π2[`3]
π1[`2]π1[`2 ◦ π 2[`3]]
LemmaLet {π } ⊆ F ⊆ {−1,π ,π }, and Q be a condition tree query in Qtree(F).There exists an up-down query Q ′ in Qtree(F) such that Q ≡path Q
′.
21/35
Up-down queries and local queriesClaimLet {−1,π } ⊆ F ⊆ {−1,π ,π }.Qtree(F) and union-free N(F) path-subsume each other.
PropositionLet F ⊆ {−1,π ,π } and e be a union-free expression in N(F).There exists a condition tree query Q in Qtree(F) such that e ≡path Q.
Proof.
`1 `′1
r
n1
s
m1
t
direct rewrite γ (s) ◦ . . . ◦ γ (n1) ◦ `−11 ◦ γ (r)
◦ `′1 ◦ γ (m1) ◦ . . . ◦ γ (t)
21/35
Up-down queries and local queriesClaimLet {−1,π } ⊆ F ⊆ {−1,π ,π }.Qtree(F) and union-free N(F) path-subsume each other.
PropositionLet F ⊆ {−1,π ,π } and e be a union-free expression in N(F).There exists a condition tree query Q in Qtree(F) such that e ≡path Q.
Proof.
`1 `′1
r
n1
s
m1
t
direct rewrite γ (s) ◦ . . . ◦ γ (n1) ◦ `−11 ◦ γ (r)
◦ `′1 ◦ γ (m1) ◦ . . . ◦ γ (t)
22/35
Path-queries: eliminate intersection
TheoremLet {−1,π } ⊆ F ⊆ {−1,π ,π ,∩}.We have N(F) �path N(F − {∩}).
Proof.
`1 `2
`3
r1
s1 n1
t1
Q1 ∩
` `
`1 `2
`3
r2
m1 m2
s2 m3
t2
Q2
merge ``1 `2
`3
r1
s1 n1
t1
Q1 ∩
`1 `2
`3
s2 m3
t2
Q ′2
π2[γ (r2) ◦ `]
22/35
Path-queries: eliminate intersection
TheoremLet {−1,π } ⊆ F ⊆ {−1,π ,π ,∩}.We have N(F) �path N(F − {∩}).
Proof.
`1 `2
`3
r1
s1 n1
t1
Q1 ∩
` `
`1 `2
`3
r2
m1 m2
s2 m3
t2
Q2
merge ``1 `2
`3
r1
s1 n1
t1
Q1 ∩
`1 `2
`3
s2 m3
t2
Q ′2
π2[γ (r2) ◦ `]
22/35
Path-queries: eliminate intersection
TheoremLet {−1,π } ⊆ F ⊆ {−1,π ,π ,∩}.We have N(F) �path N(F − {∩}).
Proof.
`1 `2
`3
r1
s1 n1
t1
Q1 ∩
`1 `2
`3
s2 m3
t2
Q ′2
π2[γ (r2) ◦ `]
merge nodes`1 `2
`3
γ (s1) ◦ γ (s2) γ (n1) ◦ γ (m3)
γ (t1) ◦ γ (t2)
γ (r1) ◦ π2[γ (r2) ◦ `]
Q1 ∩ Q2
23/35
Boolean queries: eliminate projection or converse
PropositionN(π ) �bool N(
−1) and N(−1) �bool N(π ).
Proof.Wu et al.: union-free N(π ) is path-equivalence to Qtree().
`
s
tn
m
reset s, t
`
n
m
s, t
leaf-prune m s, t
π1[`]` ◦ `−1
23/35
Boolean queries: eliminate projection or converse
PropositionN(π ) �bool N(
−1) and N(−1) �bool N(π ).
Proof.Wu et al.: union-free N(π ) is path-equivalence to Qtree().
`
s
tn
m
reset s, t
`
n
m
s, t
leaf-prune m s, t
π1[`]` ◦ `−1
23/35
Boolean queries: eliminate projection or converse
PropositionN(π ) �bool N(
−1) and N(−1) �bool N(π ).
Proof.Wu et al.: union-free N(π ) is path-equivalence to Qtree().
`
s
tn
m
reset s, t
`
n
m
s, t
leaf-prune m s, t
π1[`]` ◦ `−1
24/35
Bonus: condition tree queries on chains
DefinitionA condition tree query is a chain query if it is up-down and Tconsists of a single path.
` `
`′
r
s n
t
merge ``
`′
r
sγ (s) ◦ γ (n)
t
pruning `
`′sγ (s) ◦ γ (n) ◦ π2[γ (r) ◦ `]
t
LemmaLet {π } ⊆ F ⊆ {−1,π ,π }, and Q be a condition tree query in Qtree(F).There exists a chain query Q ′ in Qtree(F) such that Q ≡path Q
′.
24/35
Bonus: condition tree queries on chains
DefinitionA condition tree query is a chain query if it is up-down and Tconsists of a single path.
` `
`′
r
s n
t
merge ``
`′
r
sγ (s) ◦ γ (n)
t
pruning `
`′sγ (s) ◦ γ (n) ◦ π2[γ (r) ◦ `]
t
LemmaLet {π } ⊆ F ⊆ {−1,π ,π }, and Q be a condition tree query in Qtree(F).There exists a chain query Q ′ in Qtree(F) such that Q ≡path Q
′.
24/35
Bonus: condition tree queries on chains
DefinitionA condition tree query is a chain query if it is up-down and Tconsists of a single path.
` `
`′
r
s n
t
merge ``
`′
r
sγ (s) ◦ γ (n)
t
pruning `
`′sγ (s) ◦ γ (n) ◦ π2[γ (r) ◦ `]
t
LemmaLet {π } ⊆ F ⊆ {−1,π ,π }, and Q be a condition tree query in Qtree(F).There exists a chain query Q ′ in Qtree(F) such that Q ≡path Q
′.
25/35
Bonus: eliminate di�erence on chains
TheoremLet {−1,π } ⊆ F ⊆ {−1,π ,π ,∩,−}.On chains, we have N(F) ≡path N(
−1,π ).
Proof.
`
`′
s1
t1
n
Q1 −
`
`′
s2
t2
m
Q2
di�erence `
`′
s
tγ (t1) ◦ γ (t2)
γ (n)
γ (s1)
`
`′
s
tγ (t1)
γ (n) ◦ γ (m)
γ (s1)
`
`′
s
tγ (t1)
γ (n)
γ (s1) ◦ γ (s2)
25/35
Bonus: eliminate di�erence on chains
TheoremLet {−1,π } ⊆ F ⊆ {−1,π ,π ,∩,−}.On chains, we have N(F) ≡path N(
−1,π ).
Proof.
`
`′
s1
t1
n
Q1 −
`
`′
s2
t2
m
Q2
di�erence `
`′
s
tγ (t1) ◦ γ (t2)
γ (n)
γ (s1)
`
`′
s
tγ (t1)
γ (n) ◦ γ (m)
γ (s1)
`
`′
s
tγ (t1)
γ (n)
γ (s1) ◦ γ (s2)
26/35
Separation results
27/35
Recognizing branches
DefinitionA k-subtree-reduction step on tree T consists of removing a subtreerooted at a node n with parent m, given that parent m has at least kother children isomorphic to n.
Theorem
1. N(di,∩) and N(−1,−) are closed under 3-subtree-reductions.
2. N(di, −1,π ,π ) is closed under 2-subtree-reductions.
3. N(−1,π ,π ,∩) is closed under 1-subtree-reductions.
28/35
The subtree-reductions classification is strict
PropositionAlready on unlabeled trees, we have
1. N(di) �bool N(−1,π ,π ,∩),
2. N(−1,−) �bool N(−1,π ,π ,∩),
3. N(di,∩) �bool N(di, −1,π ,π ).
Proof.
1. e1 = E ◦ di ◦ di ◦ E.
2. e2 = (E−1 ◦ E) − id.
3. e3 = (((di ◦ E) ∩ di) ◦ ((di ◦ E) ∩ di)) ∩ di.
29/35
Diversity and jumping in trees
PropositionAlready on unlabeled trees, N(di,∩) �bool N(
−1,π ,π ,∩,−).
Proof.e = P2,¬r ◦ di ◦ P2,¬r
P2,¬r = π2[E] ◦ P2
P2 = π1[S2]
S2 = (E ◦ di) ∩ E .
T1: T2:
r
m n
r′
m′ n′
30/35
Diversity and jumping in chains
PropositionAlready on chains, we have
1. N(di, −1) �bool N(−1,π ,π ,∩,−);
2. N(di,π ) �bool N(−1,π ,π ,∩,−).
Proof.
1. e1 = (` ◦ `−1) ◦ di ◦ (` ◦ `−1).
2. e2 = π1[`] ◦ di ◦ π1[`].
C1: `` `′`′`′
nm
C2: ` `′`′
31/35
Brute-force: path queries
PropositionAlready on unlabeled trees, we have
1. N(−1) �path N(di,π ,π ),2. N(π ) �path N(
−1).
Proof.
1. e1 = E−1
2. e2 = π1[E] ◦ π2[E]
32/35
Brute-force: Boolean queries
PropositionAlready on unlabeled trees, we have
1. N(di, −1) �bool N(di) and N(di,π ) �bool N(di),2. N(di, −1,∩) �bool N(di,π ,π ,∩,−),3. N(di,π ) �bool N(di, −1).
Proof.
T1: T2: T3:
T ′1 : T ′2 : T ′3 :
33/35
Conclusion and discussion
34/35
Overview of resultsBoolean queries Path queries
di −1 π π ∩ − di −1 π π ∩ −
Localq
ueries
Dow
nwardqu
eries N() 7 7• 7• 7• 3• 3• 7• 7• 7• 7• 3• 3•
N(∩) 7 7• 7• 7• 3• 7• 7• 7• 7• 3•
N(∩,−) 7• 7• 7• 7• 7• 7• 7• 7•
N(π ) 7 3• 7• 3• 7• 7• 7• 7• 3• 7•
N(π ,∩) 7 3 7• 7• 7• 7• 7• 7•
N(π ,π ) 7 3• 3• 3• 7• 7• 3• 3•
N(π ,π ,∩) 7 3 3• 7• 7• 3•
N(π ,π ,∩,−) 7 7 7• 7•
N(−1) 7 3 7• 3 7• 7• 7• 7• 7 7•
N(−1,π ) 7 7• 3• 7• 7• 7• 3• 7•
N(−1,π ,∩) 7 7• 7• 7• 7• 7•
N(−1,π ,π ) 7 3 7 7• 3 7
N(−1,π ,π ,∩) 7 7 7• 7
N(−1,π ,π ,∩,−) 7 7•
N(di) 7 7 7• 7 7• 7 7 7• 7 7•
N(di,π ) 3• 7• 7 7• 7 7• 7 7•
N(di,π ,∩) 7 7• 7• 7 7• 7•
N(di,π ,π ) 3• 7 7 7 7 7
N(di,π ,π ,∩) 7 ? 7 ?N(di,π ,π ,∩,−) 7 7
N(di, −1) 7 7• 7 7• 7 7• 7 7•
N(di, −1,π ) 7• 7 7• 7• 7 7•
N(di, −1,π ,∩) 7• 7• 7• 7•
N(di, −1,π ,π ) 7 7 7 7
N(di, −1,π ,π ,∩) ? ?N(di, −1,π ,π ,∩,−)
35/35
Conclusion
We fully established relationships between the local fragments.
Open problemLet {di,π ,∩} ⊆ F ⊆ {di, −1,π ,π ,∩} and let z ∈ {bool, path}.Do we have a collapse N(F ∪ {−}) �z N(F) or not?
LemmaOn unlabeled chains, we have N(di, −1,π ,π ,∩,−) �bool N(π ).
35/35
Conclusion
We fully established relationships between the local fragments.
Open problemLet {di,π ,∩} ⊆ F ⊆ {di, −1,π ,π ,∩} and let z ∈ {bool, path}.Do we have a collapse N(F ∪ {−}) �z N(F) or not?
LemmaOn unlabeled chains, we have N(di, −1,π ,π ,∩,−) �bool N(π ).