Conjunctive Queries
Conjunctive Queries
Conjunctive Queries
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Three Problems:<br />
CQs and Structural Methods<br />
HOM: The homomorphism problem<br />
BCQ: Boolean conjunctive query evaluation<br />
CSP: Constraint satisfaction problem<br />
Bertinoro International Spring School 2009, 2-13 March 2009<br />
1<br />
Important problems in different areas.<br />
All these problems are hypergraph based.<br />
But actually: HOM = BCQ = CSP<br />
The Homomorphism Problem<br />
Given two relational structures<br />
A ( U , R1,<br />
R<br />
B ( V , S<br />
1<br />
,<br />
S<br />
2<br />
2<br />
,..., R<br />
,...,<br />
S<br />
k<br />
k<br />
)<br />
)<br />
Decide whether there exists a homomorphism h from A to B<br />
h :<br />
U<br />
such<br />
x R<br />
<br />
that<br />
<br />
V<br />
x,<br />
i<br />
h(<br />
x)<br />
<br />
i Si<br />
The Homomorphism Problem<br />
Given two relational structures<br />
A ( U , R1,<br />
R<br />
B ( V , S<br />
1<br />
,<br />
S<br />
2<br />
2<br />
,..., R<br />
,...,<br />
S<br />
k<br />
k<br />
)<br />
)<br />
Decide whether there exists a homomorphism h from A to B<br />
h :<br />
U<br />
such<br />
x R<br />
<br />
that<br />
<br />
V<br />
x,<br />
i<br />
h(<br />
x)<br />
<br />
i Si<br />
Feder & Vardi 93: Relationship to CSP, restrictions on B<br />
Kolaitis & Vardi, 98: Relationship to Query Containment, restrictions on A, B
(well-known)<br />
HOM is NP-complete<br />
Membership: Obvious, guess h.<br />
Hardness: Transformation from 3COL.<br />
(well-known)<br />
HOM is NP-complete<br />
Membership: Obvious, guess h.<br />
Hardness: Transformation from 3COL.<br />
1<br />
3<br />
6<br />
2<br />
4<br />
5<br />
A<br />
1 2<br />
1 3<br />
2 3<br />
3 4<br />
2 5<br />
4 5<br />
3 6<br />
B<br />
red<br />
red<br />
green<br />
green<br />
blue<br />
blue<br />
green<br />
blue<br />
red<br />
blue<br />
red<br />
green<br />
1<br />
3<br />
6<br />
2<br />
4<br />
h<br />
5<br />
A<br />
1 2<br />
1 3<br />
2 3<br />
3 4<br />
2 5<br />
4 5<br />
3 6<br />
h<br />
B<br />
red<br />
red<br />
green<br />
green<br />
blue<br />
blue<br />
green<br />
blue<br />
red<br />
blue<br />
red<br />
green<br />
Graph 3-colourable iff HOM(A,B ) yes-instance.<br />
Graph 3-colourable iff HOM(A,B ) yes-instance.<br />
DATABASE:<br />
Boolean <strong>Conjunctive</strong> Query<br />
Enrolled Teaches Parent<br />
John Algebra 2003<br />
Robert Logic 2003<br />
Mary DB 2002<br />
Lisa DB 2003<br />
……… ….. …….<br />
McLane Algebra March<br />
Kolaitis Logic May<br />
Lausen DB June<br />
Rahm DB May<br />
……… ….. …….<br />
McLane Lisa<br />
Kolaitis Robert<br />
Rahm Mary<br />
……… …..<br />
QUERY: Is there any teacher having a child<br />
enrolled in his/her course<br />
ans Enrolled(S,C,R) Teaches(P,C,A) <br />
Parent(P,S)<br />
Boolean <strong>Conjunctive</strong> Query (2)<br />
• Database schema:<br />
– Enrolled (Pers#, Course, Reg-Date)<br />
– Teaches (Pers#, Course, Assigned)<br />
– Parent (Pers1, Pers2)<br />
• Is there any teacher whose child attend some<br />
course<br />
ans Enrolled(S,C’,R) Teaches(P,C,A) <br />
Parent(P,S)
Boolean <strong>Conjunctive</strong> <strong>Queries</strong><br />
The problem BCQ:<br />
Instance: < DB, Q><br />
Question: Does Q evaluate to true over DB<br />
<strong>Conjunctive</strong> Query with Output<br />
• Database schema:<br />
– Enrolled (Pers#, Course, Reg-Date)<br />
– Teaches (Pers#, Course, Assigned)<br />
– Parent (Pers1, Pers2)<br />
• Output all students x enrolled in a course<br />
taught by a parent of x<br />
ans(S) Enrolled(S,C,R) Teaches(P,C,A) <br />
Parent(P,S)<br />
<strong>Conjunctive</strong><strong>Queries</strong>andRA,SQL<br />
Logical View of CQs<br />
<strong>Conjunctive</strong> queries correspond to Select-Project-Join queries,and to simple<br />
“SELECT-FROM-WHERE SQL statements with a conjunctive WHERE<br />
clause.<br />
–Enrolled (Pers#, Course, Reg-Date)<br />
–Teaches (Pers#, Course, Assigned)<br />
–Parent (Pers1, Pers2)<br />
Q: Ans(S) Enrolled(S,C,R) Teaches(P,C,A) Parent(P,S)<br />
SELECT Enrolled.Pers#<br />
FROM Enrolled Teaches Parent<br />
WHERE Enrolled Pers# = Parent.Pers2<br />
and Enrolled.Course = Teaches.Course<br />
11<br />
and Teaches.Pers# = Parent.Pers1<br />
AconjunctivequeryisaFOqueryoftheform<br />
{r(x) |y (r 1 (x 1 ,y 1 ) r2(x 2 ,y 2 ) … r2(x k ,y k ))}<br />
Where:<br />
x,y aredisjointlistsofvariables,<br />
allvariablesofxoccurfreeintheformulay (r 1 (x 1 ,y 1 ) r2(x 2 ,y 2 ) … r2(x k ,y k ))<br />
eachx i isalistofvariablesfromx,<br />
eachy i iscontainediny<br />
Written:r(x) r 1 (x 1 ,y 1 ) r2(x 2 ,y 2 ) … r2(x k ,y k ).<br />
12
BCQ = HOM<br />
View query Q as a relational structure<br />
Universe: Variables of the query<br />
Relations: sets of query-atoms for<br />
each database relation.<br />
Non-Boolean CQs<br />
Q:r(x) r 1 (x 1 ) r 2 (x 2 )… r m (x m )<br />
The database D is itself a relational structure.<br />
By the definition of the semantics of FO queries, the<br />
Boolean conjunctive query evaluates to true iff there is a<br />
homomorphism h: QD.<br />
R1<br />
R1<br />
DatabaseD<br />
…..<br />
R1<br />
D=QiffHOM(Q,D)<br />
HowdoweformallydefineQ(D)<br />
Vive-versa, every HOM instance can be reformulated as a Boolean conjunctive query. 14<br />
Non-Boolean CQs<br />
head(Q)<br />
body(Q)<br />
r(x) r 1 (x 1 ) r 2 (x 2 )… r m (x m )<br />
h<br />
h homomorphismh h<br />
R1<br />
R1 ….. R1<br />
DatabaseD<br />
Problems Equivalent to BCQ<br />
• <strong>Conjunctive</strong> Query Containment<br />
Q<br />
( 1<br />
Q2<br />
db<br />
Q1 db)<br />
Q2<br />
( db)<br />
• Query of Tuple Problem<br />
t Q(db) <br />
• Constraint Satisfaction in AI<br />
CSP BCQ<br />
• Clause Subsumption in Theorem Proving<br />
Q(D)={h(head(Q))|h HOM(body(Q),D)}<br />
<br />
s.t.<br />
C<br />
D<br />
<br />
15
Combinatorial Crossword Puzzle<br />
All known general<br />
solution algorithms<br />
rely on backtracking<br />
Combinatorial Crossword Puzzle<br />
All known general<br />
solution algorithms<br />
rely on backtracking<br />
1h: P A R I S 1v: L I M B O<br />
P A N D A<br />
L I N G O<br />
L A U R A<br />
P E T R A<br />
A N I T A<br />
P A M P A<br />
P E T E R<br />
We are looking for a<br />
homomorphism<br />
f:[1..26][A..Z]<br />
that translates<br />
1H ={}<br />
into 1h, and so on.<br />
and so on<br />
1h: P A R I S 1v: L I M B O<br />
P A N D A<br />
L I N G O<br />
L A U R A<br />
P E T R A<br />
A N I T A<br />
P A M P A<br />
P E T E R<br />
We are looking for a<br />
homomorphism<br />
f:[1..26][A..Z]<br />
that translates<br />
1H ={}<br />
into 1h, and so on.<br />
and so on<br />
ContainmentofCQ’s<br />
• GivenconjunctivequeriesQ1andQ2,wesay<br />
thatQ1iscontainedinQ2,denotedasQ1 Q2,<br />
iff forall databasesD,Q1(D) Q2(D).<br />
• Example:<br />
–Q1:p(X,Y) arc(X,Z),arc(Z,Y)<br />
–Q2:p(X,Y) arc(X,Z),arc(W,Y)<br />
•DBisagraph;Q1producespathsoflength2,<br />
Q2producespairsofnodeswithanarcoutand<br />
in,respectively.<br />
19<br />
WhyCQContainment<br />
Containmenttestsusedforequivalencetests.<br />
<br />
<br />
<br />
Q1=Q2iffQ1 Q2andQ2 Q1<br />
Equivalenceisfundamentaltoqueryoptimization<br />
Answeringqueriesusingviews.<br />
Dataintegration:collectingdatafromdifferentsources<br />
(e.g.onInternet),answeringyourspecificquery need<br />
toknowwhetherthesourcescan(fully,orpartially)<br />
answeryourquery.<br />
20
QueryHomomorphisms<br />
(akaContainmentMappings)<br />
Example<br />
Amappingfromthevariables ofCQQ2to<br />
thevariablesofCQQ1,suchthat:<br />
TheheadofQ2ismappedtotheheadofQ1.<br />
Q1:p(X,Y) r(X,Z),g(Z,Z),r(Z,Y)<br />
Q2:p(A,B) r(A,C),g(C,D),r(D,B)<br />
Eachsubgoal (=bodyatom)ofQ2ismappedto<br />
somesubgoal ofQ1withthesamepredicate.<br />
HomomorphismTheorem:<br />
ThereisahomomorphismfromQ2toQ1if<br />
andonlyifQ1 Q2.<br />
21<br />
Q1looksfor:<br />
X<br />
Q2looksfor:<br />
A<br />
Z<br />
C<br />
Y<br />
D<br />
SinceC=Dispossible,<br />
expectQ1 Q2.<br />
B<br />
22<br />
Example Continued<br />
• WheneverthereisapathfromX toY,it<br />
mustbethatX hasanarcout,andY an<br />
arcin.<br />
• Thus,everyfact(tuple)producedbyQ1is<br />
alsoproducedbyQ2.<br />
•Thatis,Q1 Q2.<br />
Example Continued<br />
Q1: p(X,Y) r(X,Z) , g(Z,Z) , r(Z,Y)<br />
Q2: p(A,B) r(A,C) , g(C,D) , r(D,B)<br />
Homomorphism:h(A)=X;h(B)=Y;h(C)=h(D)=Z.<br />
23<br />
24
ExampleConcluded<br />
Q1: p(X,Y) r(X,Z) , g(Z,Z) , r(Z,Y)<br />
Q2: p(A,B) r(A,C) , g(C,D) , r(D,B)<br />
•NocontainmentmappingfromQ1toQ2.<br />
– g(Z,Z)canonlybemappedtog(C,D).<br />
•Nootherg subgoals inQ2.<br />
–ButthenZmustmaptobothCandD impossible.<br />
• Thus,Q1properlycontainedinQ2.<br />
25<br />
ProofoftheHomomorphismTheorem Hom(Q2,Q1) iff Q1 Q2.<br />
a) hHOM(Q2,Q1) Q1 Q2(thisistheonlyif direction)<br />
LetDbeadatabaseandAQ1(D).<br />
Then gHOM(body(Q1),D),suchthatA=g(head(Q1)).<br />
Q2:head(Q2) body(Q2)<br />
h<br />
h<br />
Q1:head(Q1) body(Q1) A<br />
g<br />
g<br />
AD<br />
Buttheng hisahomomorphisminHOM(body(Q2),D),<br />
andg h(head(Q2))=g(h(head(Q2))=g(head(Q1))=A<br />
ThusA Q2(D).<br />
Insummary,AQ1(D),AQ2(D),thusQ1 Q2.<br />
26<br />
ProofoftheHomomorphismTheorem Hom(Q2,Q1) iff Q1 Q2.<br />
b)Q1 Q2 hHOM(Q2,Q1)(thisistheif direction)<br />
a) hHOM(Q2,Q1) Q1 Q2(thisistheonlyif direction)<br />
LetDbeadatabaseandAQ1(D).<br />
Then gHOM(body(Q1),D),suchthatA=g(head(Q1)).<br />
Q2:head(Q2) body(Q2)<br />
g h<br />
h<br />
h<br />
g h<br />
Q1:head(Q1) body(Q1) A<br />
g<br />
g<br />
AD<br />
Buttheng hisahomomorphisminHOM(body(Q2,D)),<br />
andg h(head(Q2))=g(h(head(Q2))=g(head(Q1))=A<br />
ThusA Q2(D).<br />
Insummary,AQ1(D),AQ2(D),thusQ1 Q2.<br />
27<br />
Q2: p(A,B) r(A,C) , g(C,D) , r(D,B)<br />
Q1: p(X,Y) r(X,Z) , g(Z,Z) , r(Z,Y)<br />
CanonicalDatabaseCan Q1 :<br />
Generateanewconstantf(U)=U foreachvariable U<br />
Can Q1 =f(atoms(body(Q)))={r(X,Z), g(Z,Z), r(Z,Y)}<br />
dom(Can Q1 )={X,Y,Z}<br />
Note:Themappingf:var(Q1) {newconstants}isanisomorphism where<br />
f(atoms(body(Q1)))=Can Q1 and f 1 (Can Q1 )=atoms(body(Q1)<br />
28
Q2: p(A,B) r(A,C) , g(C,D) , r(D,B)<br />
Q2: p(A,B) r(A,C) , g(C,D) , r(D,B)<br />
Q1: p(X,Y) r(X,Z) , g(Z,Z) , r(Z,Y)<br />
Q1: p(X,Y) r(X,Z) , g(Z,Z) , r(Z,Y)<br />
f<br />
f 1 f f 1 f f 1<br />
f f 1<br />
f<br />
f 1 f f 1 f f 1<br />
{r(X,Z) , g(Z,Z) , r(Z,Y)}= Can Q1 :<br />
A=p(X,Z) {r(X,Z) , g(Z,Z) , r(Z,Y)}= Can Q1 :<br />
Sincefmapsbody(Q)intoCan Q1’<br />
AnewfactA=f(head(Q1)) isgenerated<br />
A=f(head(Q1))Q1(Can Q1 ).<br />
SinceQ1 Q2,A Q2(Can Q1 ).<br />
Therefore hHom(Q2,Can Q1 {A}).<br />
29<br />
30<br />
Q2: p(A,B) r(A,C) , g(C,D) , r(D,B)<br />
h<br />
h h h<br />
Q1: p(X,Y) r(X,Z) , g(Z,Z) , r(Z,Y)<br />
f f 1 f f 1 f f 1 f f 1<br />
AnotherExample<br />
Q1: p(X,Y) r(X,Y) , g(Y,Z)<br />
Q2: p(A,B) r(A,B) , r(A,C)<br />
A=p(X,Z) {r(X,Z) , g(Z,Z) , r(Z,Y)}= Can Q1 :<br />
Q1looksfor:<br />
X<br />
Y<br />
Z<br />
A=f(head(Q1))Q1(Can Q1 ).<br />
Q2looksfor:<br />
SinceQ1 Q2,A Q2(Can Q1 ).<br />
Therefore hHom(Q2,Can Q1 {A}).<br />
A<br />
B<br />
Thenf 1 h HOM(Q2,Q1)isthedesiredhomomorphism.<br />
C<br />
QED<br />
31<br />
32
Example Continued<br />
Q1: p(X,Y) r(X,Y) , g(Y,Z)<br />
Q2: p(A,B) r(A,B) , r(A,C)<br />
Andnot<br />
everysubgoal<br />
needbea<br />
target.<br />
Noticetwo<br />
subgoals can<br />
maptoone.<br />
ExampleConcluded<br />
Q1: p(X,Y):-r(X,Y) & g(Y,Z)<br />
Q2: p(A,B):-r(A,B) & r(A,C)<br />
•NocontainmentmappingfromQ1toQ2.<br />
– g(Y,Z)cannotmapanywhere,sincethereisnog<br />
subgoal inQ2.<br />
Containmentmapping:m(A)=X;m(B)=m(C)=Y.<br />
33<br />
• Thus,Q1properlycontainedinQ2.<br />
34<br />
LetCan + Q1<br />
Query Containment BCQ<br />
=Can + Q1 f(head(Q1))<br />
LetQ2 + =Q2 head(Q2)(Q2 + isaBoolenquery)<br />
Then,<br />
Q1 Q2iffCan + Q1 =Q2 +<br />
i.e.,iffQ2 + evaluatestotrueover Can + Q1<br />
Therefore,allcomplexityresultsforBCQalsoholdfor<br />
(Boolean)<strong>Conjunctive</strong>Query<br />
evaluation<br />
•{enc(I),enc()|I² }<br />
–if isaconjunctivequery,combined<br />
complexity<br />
– n =|I|,m =||<br />
– n m possibleassignmentsforvars()<br />
– Givenanassignment,thetestingisin<br />
polynomialtime<br />
–InNP<br />
thequerycontainmentproblem.<br />
35<br />
36
<strong>Conjunctive</strong>Queryevaluation<br />
CQminimization<br />
THEOREM:BCQisNPComplete(combinedcomplexity)<br />
Proof:FollowsfromtheNPcompletenessofHOM<br />
Exercise: AsanalternativeproofofNPhardness,givea<br />
reductionfrom3SAT.<br />
COROLLARY: <strong>Conjunctive</strong>QueryContainmentisNPcomplete<br />
COROLLARY: <strong>Conjunctive</strong>QueryEquivalenceisNPcomplete<br />
•AconjunctivequeryQisminimal,ifitcontains<br />
minimalnumberofsubgoals –<br />
(subgoal=bodyatom)<br />
Thismeans:whenewerwedropanatom<br />
fromthebodyofQ,wegetaqueryQ’Q<br />
•ThetaskoftheCQminimization:minimizethe<br />
numberofsubgoals ofagivenCQ.<br />
Note:ThelatterproblemsareundecidableforFO 37<br />
38<br />
Cores<br />
Cores<br />
endomorphism h: {Y b}<br />
BCQ:<br />
Pp(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d)<br />
B= { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d)}<br />
{ p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
Logical meaning<br />
X, Y, U, V:<br />
p(X,Y) & p(X,b) &<br />
p(a,b) & p(U,c) & p(U,V) & q(a,c,d)<br />
39<br />
40
Cores<br />
endomorphism h: {Y b}<br />
B = { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
Cores<br />
endomorphism h: {Y b}<br />
B = { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
{ p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
{ p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
REDUNDANT!<br />
X,Y p(X,Y) & P(X,b)<br />
<br />
X p(X,b)<br />
41<br />
REDUNDANT!<br />
X,Y p(X,Y)<br />
<br />
X p(X,b)<br />
42<br />
Cores<br />
endomorphism h: {Y b}<br />
B = { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
<br />
Cores<br />
endomorphism h: {Y b}<br />
B = { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
<br />
h(B) =<br />
{ p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
h(B) =<br />
{ p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
X a<br />
V c<br />
h(B) can be further reduced by endomorphism g: {X a, V c}<br />
43<br />
44
Cores<br />
Cores<br />
endomorphism h: {Y b}<br />
B = { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
<br />
B = { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
<br />
h(B) =<br />
{ p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
h(B) =<br />
{ p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
{ p(a,b), p(U,c), q(a,c,d) }<br />
<br />
f(B)=g(h(B))=gh(B)=<br />
{ p(a,b), p(U,c), q(a,c,d) }<br />
h(B) can be further reduced by endomorphism g: {X a, V c}<br />
endomorphism f: {X a, Yb, V c}<br />
45<br />
46<br />
Cores<br />
Cores<br />
B = { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
<br />
B = { p(X,Y), p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
<br />
h(B) =<br />
{ p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
h(B) =<br />
{ p(X,b), p(a,b), p(U,c), p(U,V), q(a,c,d) }<br />
<br />
f(B)=g(h(B))=gh(B)= { p(a,b), p(U,c), q(a,c,d) }<br />
no refinement by endomorphisms possible !<br />
endomorphism f: {X a, Yb, V c}<br />
<br />
f(B)=g(h(B))=gh(B)=<br />
{ p(a,b), p(U,c), q(a,c,d) }<br />
Core(I)<br />
unique up to variable-renaming!<br />
47<br />
endomorphism f: {X a, Yb, V c}<br />
48
CQminimization<br />
Ans(X,Y,Z) R(X 2 ,Y 1 ,Z),<br />
R(X,Y 1 ,Z 1 ),<br />
R(X 1 ,Y,Z 1 ),<br />
R(X,Y 2 ,Z 2 ),<br />
R(X 2 ,Y 2 ,Z)<br />
Observations<br />
•Thegoal:minimizethenumberofrowsin<br />
thetableau.<br />
Theheadatomcannotbeeliminated!<br />
–Canwejustcheckthesubgoals onebyone(if<br />
onesubgoal cannotberemovedatcontain<br />
moment,coulditberemovedatalater<br />
moment)<br />
– Doesthesequenceoftheeliminationcount<br />
(or,istheminimizedqueryunique)<br />
49<br />
50<br />
Minimizationalgorithm<br />
•Canwejustchecktherowsonebyone<br />
Yes.Takethesubgoal u i ,inaCQQ1,check<br />
whetherthereisahomomorphismh,suchthat<br />
h(Q1) (Q1 u i ).Ifthereexistssucha<br />
homomorphism,thenu i canberemoved.<br />
Otherwise,u i cannotberemovedforever.<br />
BecauseQ1isgettingsmaller.<br />
THEOREM: The Core is Unique up to isomorphism<br />
Isomorphism here means: bijective variable renaming<br />
PROOF: Homework.<br />
•Doesthesequenceoftheeliminationcount(or,<br />
istheminimizedqueryunique)<br />
51<br />
52<br />
homework
CQContainmentvs.<br />
BCQevaluation<br />
• BothareNPcomplete,but:<br />
– thepotentialnumberofmappingsisdifferent:<br />
n m :wheren is<br />
•thesizeofQ1forCQcontainment(small,and<br />
normallydoesnothurt)<br />
•isthesizeofadatabaseforBCQevaluation(couldbe<br />
huge)<br />
• Highlydesirable:IdentifyfragmentsofBCQ,<br />
whoseevaluationproblemistractable(inP).<br />
53<br />
BCQevaluation<br />
• Intuition:theproblemwithcyclesinthequery:<br />
– Considerthequeries:<br />
•Q1:ans e(A,B),e(B,C),e(C,D),e(D,A)<br />
•Q2:ans e(A,B),e(B,C),e(C,D),e(D,E)<br />
•InprocessingQ1,maintainintermediatejoin<br />
resultse’(A,B,C,D) e(D,A)<br />
•InprocessingQ2,allthejoinoperationsareonly<br />
betweentwopredicates(locally)<br />
54<br />
Hypergraph of Crossword Puzzle<br />
<strong>Queries</strong>, CSPs, and<br />
Hypergraphs<br />
ans Enrolled(S,C,R) Teaches(P,C,A) Parent(P,S)<br />
C<br />
R<br />
A<br />
Theorem:Theevilisinthecycles.<br />
S<br />
P
Acyclic CSP<br />
Acyclic queries or CSPs<br />
ans Enrolled(S,C’,R) Teaches(P,C,A) Parent(P,S)<br />
ans Enrolled(S,C’,R) Teaches(P,C,A) Parent(P,S)<br />
C’<br />
C<br />
C’<br />
C<br />
Parent(P,S)<br />
R<br />
A<br />
R<br />
A<br />
Teaches(P,C,A)<br />
Enrolled(S,C’,R)<br />
S<br />
P<br />
S<br />
P<br />
Join Tree<br />
Join Tree<br />
Definition: AJointreeofaBCQisanorganisationof<br />
itsatomsintoatreeTsuchthatforeachvariableX,<br />
thenodesinwhichXoccursspanaconnected<br />
subtree ofT.(ConnectednessCondition)<br />
Definition: ACQisatreequery iffithasajointree.<br />
Example:Q=R(Y,Z,U)&s(Z,U,W)&d(Y,P)&t(V,Z)<br />
d(Y,P)<br />
r(Y,Z,U)<br />
Acyclicity<br />
GYO-Reduction (Graham, Yu, and Ozsoyoglu):<br />
Input: Hypergraph H<br />
Output: GYO-reduct of H<br />
Apply the following rules as long as possible:<br />
• Eliminate vertices that are contained in at<br />
most one hyperedge (ear vertices)<br />
• Eliminate hyperedges that are empty or<br />
contained in other hyperedges<br />
Definition: H is acyclic iff GYO-reduct(H)=(,).<br />
s(Z,U,W)<br />
t(V,Z)<br />
59<br />
Definition: Q is acyclic iff its hypergraph H(Q) is acyclic.
H<br />
Y<br />
Z<br />
U<br />
P<br />
V<br />
W<br />
Y<br />
Z<br />
rule 1<br />
U<br />
rule 2<br />
Y<br />
Z<br />
U<br />
rule 1<br />
0<br />
7<br />
9<br />
8<br />
6<br />
5<br />
0<br />
9<br />
6<br />
GYO-irreducible<br />
2 3 4<br />
H*= (ø,ø)<br />
GYO reduct<br />
rule 2<br />
1<br />
AternativeProcedure<br />
Definition: Anearedge(short: ear) ofahypergraph (V,E)isa<br />
hyperedge e Esuchthatoneofthefollowingconditionsholds:<br />
Hypergraph ofBCQs<br />
(1)Thereisawitnesse’ E,suchthate’ e andeach<br />
vertexfrome iseitheronlyine orine’,or<br />
(2)ehasnointersectionwithanyotherhyperedge.<br />
(C,D,E)is<br />
anear<br />
Ears<br />
Ears<br />
63<br />
64
GYO’ algorithm– removingears<br />
Algorithm(GYO’ Algorithm)<br />
Input:Hypergraph H =(V,E)<br />
Output: GYO’reductofH<br />
H<br />
P<br />
Y<br />
Z V<br />
U<br />
W<br />
HowdoesGYO’ workhere<br />
DountilEhasnoears:<br />
ChooseanyeareofE.<br />
SetH:=(V’ ,E {e}),whereV’ =vertices(E {e}).<br />
65<br />
Acyclicity Theorems<br />
Lemma: AhypergraphGisaGYOreductof<br />
HiffitisaGYO’reductofH.<br />
THEOREM: Ahypergraphisacycliciff<br />
itsonlyGYO’reductis(,).<br />
THEOREM: Aqueryhasajointreeiff<br />
itisacyclic.<br />
Summary<br />
•TheGYO(andGYO’)algorithmtakeslineartime<br />
•Thehypergraph isacycliciff theoutputofGYO<br />
(orequivalently,GYO’)algorithmisempty<br />
•ABCQisacyclicifitshypergraph isacyclic<br />
•IfaBCQisacyclic,thenthereisajointree,<br />
obtainedfromthesequenceoftheearremoving<br />
oftheGYOalgorithm.<br />
Easyalgorithmsexistfortcheckingwhether<br />
Itremainstoshow: Thequeryevaluationof<br />
acyclicBCQisinpolynomialtime<br />
Aqueryisacyclicandforcomputingajointree. 67<br />
68
Theacyclicqueryevaluation<br />
•ans d(Y,P),t(V,Z),s(Y,Z,U),s(Z,U,W)<br />
•ThepolynomialalgorithmofacyclicBCQ<br />
evaluation:<br />
• Bottomup<br />
•Semijoin<br />
Boolean conjunctive queries<br />
CSPs<br />
The Homomorphism Problem….<br />
….polynomialloy solvable for on instances<br />
having acyclic hypergraphs<br />
69<br />
Semijoin Operation<br />
Employee<br />
Employee Name Employee Salary Department Name<br />
Ackman 5000 Car<br />
Baker 4500 Car<br />
Carson 4800 Toy<br />
Davis 5100 Toy<br />
Temp=<br />
Employee semijoin (DepartmentName=DepartmentName)<br />
Department<br />
Employee<br />
Employee Name Employee Salary Department Name<br />
Ackman 5000 Car<br />
Baker 4500 Car<br />
Department<br />
Department Name Department Budget<br />
Car 450000000<br />
Figure by Dr. James A.<br />
Larson<br />
Emp A=B Dept= attr(Emp) (Emp A=B Dept)<br />
71<br />
n 2 log n
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
…<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
…<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
s(Z,U,W)<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
t(V,Z)<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
s(Z,U,W)<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
t(V,Z)<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
…<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s:<br />
…<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
<br />
d(Y,P)<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
…<br />
…<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
<br />
d(Y,P)<br />
<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5
…<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
<br />
d(Y,P)<br />
<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
<br />
d(Y,P)<br />
<br />
r(Y,Z,U)<br />
<br />
r:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
s(Z,U,W)<br />
t(V,Z)<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
s:<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
d:<br />
3 8<br />
3 7<br />
5 7<br />
6 7<br />
<br />
s(Z,U,W)<br />
d(Y,P)<br />
<br />
r(Y,Z,U)<br />
<br />
r:<br />
t(V,Z)<br />
3 8 9<br />
9 3 8<br />
8 3 8<br />
3 8 4<br />
3 8 3<br />
8 9 4<br />
9 4 7<br />
t:<br />
9 8<br />
9 3<br />
9 5<br />
A solution: Y=3, P=7, Z=8, U=9, W=4, V=9<br />
Computing the result<br />
• The result size can be exponential (even in case of ACQs).<br />
• Even when the result is of polynomial size, it is in general<br />
hard to compute.<br />
• In case of acyclic queries, the result can be computed in time<br />
polynomial in the result size (i.e., in output-polynomial time).<br />
• This will remain true for the subsequent generalizations of ACQs.<br />
• The result of ACQs can be computed by adding a top-down<br />
phase to Yannakakis’ algorithm for ABCQs and by joining the<br />
partial results.
Precise complexity of acyclic Boolean queries <br />
•CanbedonebetterParallelalgorithm<br />
Theorem:AnsweringacyclicBCQs isLOGCFL<br />
complete<br />
AC0 NC1 L NL LOGCFL NC2<br />
Theorem [GLS99]: Acyclic CSP-solvability is LOGCFL-complete.<br />
Answering acyclic BCQs is LOGCFL-complete<br />
LOGCFL: class of problems/languages that are logspace-reducible to a CFL<br />
AC 0 NL <br />
LOGCFL SAC1<br />
AC1<br />
NC<br />
2<br />
NC AC P NP<br />
LOCFL:Classofallproblemsthatare<br />
logspacereducibletoacontextfree<br />
language.<br />
93<br />
Characterization of LOGCFL [Ruzzo80]:<br />
LOGCFL = Class of all problems solvable with a logspace ATM<br />
with polynomial tree-size<br />
ABCQ is in LOGCFL<br />
ABCQ is in LOGCFL<br />
p(x,y)<br />
<br />
p(x,y)<br />
p<br />
<br />
…<br />
q(x,z)<br />
h(y,v,w)<br />
<br />
q(x,z)<br />
<br />
…<br />
q<br />
<br />
h(y,v,w)<br />
<br />
…<br />
h<br />
q(z,t) p(y,v) q(v,w) p(w,u)<br />
<br />
q(z,t)<br />
q<br />
p(y,v) q(v,w) p(w,u)<br />
…<br />
p<br />
q<br />
p<br />
…<br />
…<br />
…
p(x,y)<br />
<br />
q<br />
q(x,z)<br />
…<br />
<br />
ABCQ is in LOGCFL<br />
p<br />
…<br />
<br />
h<br />
h(y,v,w)<br />
…<br />
<br />
q(z,t)<br />
q<br />
p(y,v) q(v,w) p(w,u)<br />
…<br />
p<br />
q<br />
p<br />
…<br />
…<br />
…<br />
Is this query hard<br />
ans a(<br />
S,<br />
X , X ', C,<br />
F)<br />
b(<br />
S,<br />
Y,<br />
Y ', C',<br />
F')<br />
c(<br />
C,<br />
C',<br />
Z)<br />
d(<br />
X , Z)<br />
<br />
e(<br />
Y,<br />
Z)<br />
f ( F,<br />
F',<br />
Z')<br />
g(<br />
X ', Z')<br />
h(<br />
Y ', Z')<br />
<br />
j(<br />
J,<br />
X , Y,<br />
X ', Y ') p(<br />
B,<br />
X ', F)<br />
q(<br />
B',<br />
X ', F)<br />
n size of the database<br />
m number of atoms in the query m = 11 !<br />
• Classical methods worst-case complexity: O(n m )<br />
• Despite its apparence, this query is nearly acyclic<br />
It can be evaluated in O(m·n 2· logn)<br />
HardandEasyInstancesand • ThegeneralproblemisNPHard<br />
• Techniquesforidentifyingtractablecases<br />
• Twomainkindoftechniques:<br />
– Basedonthevaluesinthedatabaserelations<br />
e.g., g, [FederandVardi,1993]<br />
[Jeavons,Cohen,andGyssens, 1997]<br />
– Basedonthestructureofthequery<br />
e.g., g, [Freuder,1985],<br />
[DechterandPearl,1989],<br />
[Gyssens,Jeavons,andCohen,1994],<br />
[Gottlob,Leone,andS.,2002]<br />
Nearly Acyclic <strong>Queries</strong><br />
Inpractice,manyqueriesareacyclic,<br />
Butmanyothersare“nearlyacyclic”.<br />
Canwemakethisconceptprecise<br />
Canwedevelopefficientalgorithmsfor<br />
Nearlyacyclicqueries<br />
99
ans a(<br />
S,<br />
X , X ', C,<br />
F)<br />
b(<br />
S,<br />
Y,<br />
Y ', C',<br />
F')<br />
c(<br />
C,<br />
C',<br />
Z)<br />
d(<br />
X , Z)<br />
<br />
e(<br />
Y,<br />
Z)<br />
f ( F,<br />
F',<br />
Z')<br />
g(<br />
X ', Z')<br />
h(<br />
Y ', Z')<br />
<br />
j(<br />
J,<br />
X , Y,<br />
X ', Y ') p(<br />
B,<br />
X ', F)<br />
q(<br />
B',<br />
X ', F)<br />
B B’<br />
X X’ C F<br />
J Z Z’<br />
S<br />
Y Y’ C’ F’<br />
Nearly Acyclic <strong>Queries</strong> & CSPs<br />
• Bounded Treewidth (tw)<br />
– a measure of the cyclicity of graphs<br />
– for queries: tw(Q) = tw(G(Q))<br />
• For fixed k:<br />
– checking tw(Q) k<br />
– Computing a tree decomposition<br />
linear time<br />
(Bodlaender’96)<br />
Deciding CSP of treewidth k:<br />
It can be evaluated in O(m·n 2· logn)<br />
O(n k log n) [Dechter; Chekuri & Rajaraman’97; Kolaitis & Vardi, 98]<br />
LOGCFL-complete (G.L.S.’98)<br />
Primal graphs of<br />
CSPs/<strong>Queries</strong><br />
ans Enrolled(S,C,R) Teaches(P,C,A) Parent(P,S)<br />
S<br />
R<br />
C<br />
A<br />
Hypergraph H(Q)<br />
P<br />
R<br />
S<br />
C<br />
P<br />
A<br />
Primal graph G(Q)<br />
FurtherGraphRepresentations<br />
S<br />
X1<br />
2<br />
S 1<br />
Decther, 92<br />
X 2<br />
S 2<br />
Dual Graph<br />
X 2 S 3<br />
X 1<br />
X 3 X 2<br />
S<br />
S 4 1<br />
X 2 X 4 X 1<br />
S<br />
S 1<br />
3<br />
X 2<br />
S<br />
X 2<br />
5 X S4<br />
3<br />
Seidel, 81 S 3<br />
X 4<br />
S 4<br />
Incidence Graph<br />
X 5<br />
(Hidden variable encoding)
NearlyAcyclicGraphs<br />
y Example: a cyclic graph<br />
q<br />
g<br />
a<br />
b<br />
c<br />
e<br />
d<br />
f<br />
p<br />
k<br />
l<br />
o<br />
h<br />
i<br />
m<br />
j<br />
n<br />
A tree decomposition of width 2<br />
Connectedness condition for h<br />
ah<br />
ah<br />
ahq<br />
hkl<br />
ahq<br />
hkl<br />
hij<br />
abc<br />
hkp<br />
klo<br />
hij<br />
abc<br />
hkp<br />
klo<br />
mno<br />
mno<br />
ag<br />
cef<br />
bcd<br />
ag<br />
cef<br />
bcd
Logical characterization of Treewidth<br />
LogicL<br />
: FO based on ,<br />
( ,<br />
,<br />
disallowed )<br />
k <br />
L FO ,<br />
Basic Querying Logic<br />
TW[k] <br />
k 1<br />
L <br />
L 1<br />
[Kolaitis & Vardi ’98]<br />
: L with at most k <br />
1<br />
vars.<br />
LogicalcharacterizationofTreewidth<br />
A generalization:<br />
NRS- DATALOG - TW[<br />
k<br />
]<br />
FO<br />
(Flum, Frick, and Grohe ‘01)<br />
k1<br />
Game characterization of Treewidth<br />
• A robber and k cops play the game on a graph<br />
• The cops have to capture the robber<br />
• Each cop controls a vertex of the graph<br />
• Each cop, at any time, can fly to any vertex of the<br />
graph<br />
• The robber tries to elude her capture, by running<br />
arbitrarily fast on the vertices of the graph,<br />
but on those vertices controlled by cops<br />
Playing the game<br />
q<br />
b<br />
a<br />
d<br />
g<br />
c<br />
f<br />
e<br />
p<br />
h<br />
l<br />
k<br />
j<br />
i<br />
o<br />
n<br />
m
Playing the game<br />
Playing the game<br />
q<br />
g<br />
a<br />
b<br />
c<br />
e<br />
d<br />
f<br />
q<br />
g<br />
a<br />
b<br />
c<br />
e<br />
d<br />
f<br />
p<br />
k<br />
l<br />
o<br />
h<br />
i<br />
m<br />
j<br />
n<br />
p<br />
k<br />
l<br />
o<br />
h<br />
i<br />
m<br />
j<br />
n<br />
Playing the game<br />
Whenistheevaluationofconjunctive<br />
queriestractable<br />
q<br />
g<br />
p<br />
k<br />
l<br />
a<br />
o<br />
b<br />
c<br />
h<br />
i<br />
m<br />
e<br />
d<br />
j<br />
n<br />
f<br />
Incasetheyarecharacterizedbygraphs<br />
e.g.,throughprimalorGaifmangraphs:<br />
or graphs:<br />
G<br />
:<br />
class of<br />
graphs<br />
Q(<br />
G<br />
)<br />
:<br />
all<br />
queries characterized by graphs inG<br />
G<br />
Q( G<br />
)<br />
tractablet iff<br />
G<br />
unless P = W[1] or other collapses occur<br />
(Grohe, Schwentick, and Segoufin, ’01)<br />
has<br />
bounded<br />
dtreewidth
Hypergraphs vs Graphs (1)<br />
Hypergraphs vs Graphs (2)<br />
C’<br />
R<br />
C<br />
A<br />
R<br />
C’<br />
C<br />
A<br />
C’<br />
R<br />
C<br />
A<br />
R<br />
C’<br />
C<br />
A<br />
S<br />
P<br />
S<br />
P<br />
S<br />
P<br />
S<br />
P<br />
An acyclic hypergraph<br />
Its cyclic primal graph<br />
There are two cliques.<br />
We cannot know where they come from<br />
Drawbacks of treewidth<br />
Acyclic queries may have unbounded TW!<br />
Example:<br />
q p 1 (X 1 , X 2 ,…, X n ,Y 1 ) … p n (X 1 , X 2 ,…, X n ,Y n )<br />
is acyclic, obviously polynomial,<br />
but has treewidth n-1<br />
Acounterexample<br />
• LetQQ 1 betheclassofconjunctivequeriesconsistingofa<br />
conjunctive consisting a<br />
singleatom(withanarbitrarynumberofvariables)<br />
• EvaluatinganyqueryinQ 1 istrivial<br />
• LetGG 1 bethesetoftheprimalgraphsofqueriesinQ in Q 1<br />
• G 1 isthesetofallcliques<br />
• But…Q(G 1 ) Q 1 ,e.g.,Q(G 1 )containsCLIQUE m :<br />
• Thus,ingeneral,classesofqueriescannotbedefined<br />
, fromtheclassesoftheirprimalgraphs<br />
• Forgeneral(nonbinary)queriestheabovetheoremdoes<br />
nothelp<br />
• Boundedtreewidthisnotnecessaryfortractability
Beyond treewidth<br />
Bounded Degree of Cyclicity (Hinges)<br />
[Gyssens & Paredaens ’84, Gyssens, Jeavons, Cohen’94]<br />
Does not generalize bounded treewidth.<br />
Query Decomposition<br />
q p 1 (X 1 , X 2 ,…, Y m ) … p m (X 1 , X 2 ,…, Y n )<br />
Query width = 1 = acyclicity<br />
Bounded Query width<br />
[Chekuri & Rajaraman ’97]<br />
Group together query atoms<br />
(hyperedges) instead of variables<br />
p 1 (X 1 ,..., X n ,Y 1 )<br />
p 2 (X 1 ,..., X n ,Y 2 ) p 3 (X 1 ,..., X n , Y 3 ) p n (X 1 ,..., X 2 , Y n )<br />
• Every atom/hyperarc appears in some node<br />
• Connectedness conditions for variables and atoms<br />
Decomposition of cyclic queries<br />
q s(Y,Z,U) g(X,Y) t(Z,X) s(Z,W,X) t(Y,Z)<br />
Transform a query of bounded width into<br />
an acyclic query over a modified database<br />
q s(Y,Z,U) g(X,Y) t(Z,X) s(Z,W,X) t(Y,Z)<br />
Query width = 2<br />
g(X,Y), t(Y,Z)<br />
g(X,Y), t(Y,Z)<br />
gt(X,Y,Z)<br />
t(Z,X)<br />
s(Y,Z,U)<br />
t(Z,X)<br />
s(Y,Z,U)<br />
t(Z,X)<br />
s(Y,Z,U)<br />
s(Z,W,X)<br />
s(Z,W,X)<br />
s(Z,W,X)<br />
Relations:<br />
Relations:<br />
BCQ is polynomial for queries of bounded<br />
query width, if a query decomposition is given<br />
g t s<br />
t<br />
gt= g t<br />
s
Problems by Chekuri &<br />
Rajaraman ‘97<br />
A negative answer (G.L.S. ’99)<br />
Are the following problems solvable in<br />
polynomial time for fixed k <br />
– Decide whether Q has query width at most k<br />
– Compute a query decomposition of Q of<br />
width k<br />
Theorem:<br />
Proof:<br />
Deciding whether a query has<br />
query width at most k is<br />
NP-complete<br />
Very involved reduction from<br />
EXACT COVERING BY 3-SETS<br />
Important Observation<br />
Important Observation<br />
NP-hardness id due to an overly strong condition<br />
in the definition of query decomposition<br />
But the reuse of p(X,Y,Z) is harmless here:<br />
we can have added an atom p(X,Y,Z’) without changing the query<br />
p(X,Y,Z), q(U,V,Z)<br />
a(X,U,W), b(Y,V,W)<br />
p(X,Y,Z), q(U,V,Z)<br />
a(X,U,W), b(Y,V,W)<br />
Forbidden !<br />
p(X,Y,Z), c(T,W)<br />
p(X,Y,Z’), p(X,Y,Z), c(T,W)<br />
d(X,T)<br />
c(Y,T)<br />
d(X,T)<br />
c(Y,T)
Hypertree Decompositions<br />
Grouping and Reusing Atoms<br />
Query atoms can be used “partially”<br />
as long as the full atom appears<br />
somewhere else<br />
We group atoms<br />
We use p(X,Y,Z) partially<br />
p(X,Y,Z), q(U,V,Z)<br />
a(X,U,W), b(Y,V,W)<br />
p(X,Y,_), c(T,W)<br />
More liberal than query decomposition<br />
d(X,T)<br />
c(Y,T)<br />
Reusing atoms<br />
ans a(<br />
S,<br />
X , X ', C,<br />
F)<br />
b(<br />
S,<br />
Y,<br />
Y ', C',<br />
F')<br />
c(<br />
C,<br />
C',<br />
Z)<br />
d(<br />
X , Z)<br />
<br />
e(<br />
Y,<br />
Z)<br />
f ( F,<br />
F',<br />
Z')<br />
g(<br />
X ', Z')<br />
h(<br />
Y ', Z')<br />
<br />
j(<br />
J,<br />
X , Y,<br />
X ', Y ') p(<br />
B,<br />
X ', F)<br />
q(<br />
B',<br />
X ', F)<br />
p(X,Y,Z), q(U,V,Z)<br />
a(X,U,W), b(Y,V,W)<br />
j(J,X,Y,X’,Y’)<br />
a(S,X,X’,C,F), b(S,Y,Y’,C’,F’)<br />
We use p(X,Y,Z) partially<br />
p(X,Y,_), c(T,W)<br />
j(_,X,Y,_,_), c(C,C’,Z)<br />
j(_,_,_,X’,Y’), f(F,F’,Z’)<br />
d(X,T)<br />
c(Y,T)<br />
d(X,Z) e(Y,Z) g(X’,Z’), f(F,_,Z’) h(Y’,Z’)<br />
p(B,X’,F)<br />
q(B’,X’,F)<br />
Hypertree of width 2
Generalized Hypertree decomposition<br />
= Hypertree + Connectedness condition<br />
j(_,X,Y,_,_), c(C,C’,Z)<br />
j(J,X,Y,X’,Y’)<br />
a(S,X,X’,C,F), b(S,Y,Y’,C’,F’)<br />
j(_,_,_,X’,Y’), f(F,F’,Z’)<br />
d(X,Z) e(Y,Z) g(X’,Z’), f(F,_,Z’) h(Y’,Z’)<br />
Alternative view and<br />
generalized HT-Decompositions:<br />
GHD = tree decomp + set covering<br />
p(B,X’,F)<br />
q(B’,X’,F)<br />
Tree decomposition of hypergraph<br />
11<br />
H<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
12 13 19 4 h7<br />
h9<br />
h6<br />
h11<br />
17 7 5 h4<br />
16<br />
18<br />
14 15 8 9 6<br />
h14 h12 h13<br />
h5 10<br />
3<br />
Tree decomp of G(H)<br />
1,2,3,4,5,6<br />
5,6,7,8,9<br />
1,11,17,19<br />
11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19<br />
12<br />
h9<br />
h14<br />
18<br />
11<br />
Hypergraph and the tree<br />
decomposition<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
3<br />
1,2,3,4,5,6<br />
5,6,7,8,9<br />
1,11,17,19<br />
11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19
Hypergraph and the tree<br />
decomposition<br />
Hypergraph and the tree<br />
decomposition<br />
11<br />
h8<br />
h1<br />
1 2<br />
3<br />
1,11,17,19<br />
11<br />
h8<br />
h1<br />
1 2<br />
3<br />
1,11,17,19<br />
12<br />
h9<br />
h14<br />
18<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h12<br />
h5<br />
h13 10<br />
1,2,3,4,5,6 11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
5,6,7,8,9<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19<br />
12<br />
h9<br />
h14<br />
18<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h12<br />
h5<br />
h13 10<br />
1,2,3,4,5,6 11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
5,6,7,8,9<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19<br />
Hypergraph and the tree<br />
decomposition<br />
Hypergraph and the tree<br />
decomposition<br />
11<br />
h8<br />
h1<br />
1 2<br />
3<br />
1,11,17,19<br />
11<br />
h8<br />
h1<br />
1 2<br />
3<br />
1,11,17,19<br />
12<br />
h9<br />
h14<br />
18<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
1,2,3,4,5,6 11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
5,6,7,8,9<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19<br />
12<br />
h9<br />
h14<br />
18<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
1,2,3,4,5,6 11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
5,6,7,8,9<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19
Hypergraph and the tree<br />
decomposition<br />
Hypergraph and the tree<br />
decomposition<br />
11<br />
h8<br />
h1<br />
1 2<br />
3<br />
1,11,17,19<br />
11<br />
h8<br />
h1<br />
1 2<br />
3<br />
1,11,17,19<br />
12<br />
h9<br />
h14<br />
18<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h12<br />
h5<br />
h13 10<br />
1,2,3,4,5,6 11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
5,6,7,8,9<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19<br />
12<br />
h9<br />
h14<br />
18<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h12<br />
h5<br />
h13 10<br />
1,2,3,4,5,6 11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
5,6,7,8,9<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19<br />
Hypergraph and the tree<br />
decomposition<br />
Generalized hypertree<br />
decomposition<br />
11<br />
h8<br />
h1<br />
1 2<br />
3<br />
1,11,17,19<br />
11<br />
h8<br />
h1<br />
1 2<br />
3<br />
h8(1,11), h15(1,17,19)<br />
12<br />
h9<br />
h14<br />
18<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
1,2,3,4,5,6 11,12,17,18,19<br />
3,4,5,6,7,8 12,16,17,18,19<br />
5,6,7,8,9<br />
7,9,10<br />
12,15,16,18,19<br />
12,13,14,15,18,19<br />
12<br />
h9<br />
h14<br />
18<br />
h15<br />
h10 h2<br />
13 19 4<br />
h6<br />
h11<br />
17 7<br />
16<br />
14 15 8 9<br />
h12 h13<br />
h5<br />
h3<br />
5<br />
h7<br />
6<br />
10<br />
h4<br />
h1(1,2,3), h2(1,4,5,6)<br />
h2(_,4,5,6), h3(3,4,7,8)<br />
h4(5,7), h5(6,8,9)<br />
h6(7,9,10)<br />
h9(11,12,18), h15(_,17,19)<br />
h10(12,_,19), h14(16,17,18)<br />
h9(_,12,18), h13(15,16,19)<br />
h10(12,13,19), h12(14,15,18)<br />
Generalized hypetree decomposition of width 2
QUESTION:<br />
Hypertree Decomposition<br />
= Generalized HTD +Special Condition<br />
Can we determine in polynomial time<br />
Whether ghw(H) < k for constant k<br />
j(J,X,Y,X’,Y’)<br />
a(S,X,X’,C,F), b(S,Y,Y’,C’,F’)<br />
Each variable<br />
that disappeared<br />
at some vertex v<br />
Theorem: ghw(H) < 4 NP-complete<br />
j(_,X,Y,_,_), c(C,C’,Z)<br />
j(_,_,_,X’,Y’), JXY f(F,F’,Z’)<br />
[G., Miklos, Schwentick et. al. 06]<br />
d(X,Z) e(Y,Z) g(X’,Z’), f(F,_,Z’) h(Y’,Z’)<br />
Does not reappear in<br />
the subtrees rooted<br />
at v<br />
p(B,X’,F)<br />
q(B’,X’,F)<br />
Special Condition<br />
Generalized hypertree<br />
decomposition<br />
j(_,X,Y,_,_), c(C,C’,Z)<br />
j(J,X,Y,X’,Y’)<br />
a(S,X,X’,C,F), b(S,Y,Y’,C’,F’)<br />
j(_,_,_,X’,Y’), JXY f(F,F’,Z’)<br />
d(X,Z) e(Y,Z) g(X’,Z’), f(F,_,Z’) h(Y’,Z’)<br />
Does not appear in<br />
the subtrees rooted<br />
at v<br />
p(B,X’,F)<br />
q(B’,X’,F)<br />
Each variable<br />
that disappeared<br />
at some vertex v<br />
11<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
12 13 19 4 h7<br />
h9<br />
h6<br />
h11<br />
17 7 5 h4<br />
16<br />
18<br />
8 9 6<br />
14 15<br />
h14 h12 h13<br />
h5 10<br />
3<br />
Special condition violated<br />
h8(1,11), h15(1,17,19)<br />
h1(1,2,3), h2(1,4,5,6) h9(11,12,18), h15(_,17,19)<br />
h2(_,4,5,6), h3(3,4,7,8) h10(12,_,19), h14(16,17,18)<br />
h4(5,7), h5(6,8,9) h9(_,12,18), h13(15,16,19)<br />
h6(7,9,10)<br />
h10(12,13,19), h12(14,15,18)<br />
Generalized hypetree decomposition of width 2
Hypertree decomposition<br />
Hypertree decomposition<br />
12<br />
h9<br />
h14<br />
18<br />
11<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6<br />
h7<br />
h11<br />
17 7 5 h4<br />
16<br />
8 9 6<br />
14 15<br />
h5<br />
h12 h13 10<br />
3<br />
h10(12,13,19), h12(14,15,18), h14(16,17,18)<br />
h9(11,12,18), h15(1,17,19)<br />
h2(1,4,5,6), h3(3,4,7,8)<br />
h4(5,7), h5(6,8,9) h1(1,2,3)<br />
h6(7,9,10)<br />
12<br />
h9<br />
h14<br />
18<br />
11<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
3<br />
h10(12,13,19), h12(14,15,18), h14(16,17,18)<br />
h9(11,12,18), h15(1,17,19)<br />
h2(1,4,5,6), h3(3,4,7,8)<br />
h4(5,7), h5(6,8,9)<br />
h6(7,9,10)<br />
h1(1,2,3)<br />
Hypertee decomposition of width 3<br />
Hypertee decomposition of width 3<br />
Hypertree decomposition<br />
Hypertree decomposition<br />
12<br />
h9<br />
h14<br />
18<br />
11<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
3<br />
h10(12,13,19), h12(14,15,18), h14(16,17,18)<br />
h9(11,12,18), h15(1,17,19)<br />
h2(1,4,5,6), h3(3,4,7,8)<br />
h4(5,7), h5(6,8,9)<br />
h6(7,9,10)<br />
h1(1,2,3)<br />
12<br />
h9<br />
h14<br />
18<br />
11<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
3<br />
h10(12,13,19), h12(14,15,18), h14(16,17,18)<br />
h9(11,12,18), h15(1,17,19)<br />
h2(1,4,5,6), h3(3,4,7,8)<br />
h4(5,7), h5(6,8,9)<br />
h6(7,9,10)<br />
h1(1,2,3)<br />
Hypertee decomposition of width 3<br />
Hypertee decomposition of width 3
Hypertree decomposition<br />
Hypertree decomposition<br />
12<br />
h9<br />
h14<br />
18<br />
11<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
3<br />
h10(12,13,19), h12(14,15,18), h14(16,17,18)<br />
h9(11,12,18), h15(1,17,19)<br />
h2(1,4,5,6), h3(3,4,7,8)<br />
h4(5,7), h5(6,8,9)<br />
h6(7,9,10)<br />
h1(1,2,3)<br />
12<br />
h9<br />
h14<br />
18<br />
11<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
3<br />
h10(12,13,19), h12(14,15,18), h14(16,17,18)<br />
h9(11,12,18), h15(1,17,19)<br />
h2(1,4,5,6), h3(3,4,7,8)<br />
h4(5,7), h5(6,8,9)<br />
h6(7,9,10)<br />
h1(1,2,3)<br />
Hypertee decomposition of width 3<br />
Hypertee decomposition of width 3<br />
Hypertree decomposition<br />
Positive Results on<br />
Hypertree Decompositions<br />
12<br />
h9<br />
h14<br />
18<br />
11<br />
h8<br />
h1<br />
1 2<br />
h15<br />
h10 h2 h3<br />
13 19 4<br />
h6 h7<br />
h11<br />
17 7 5 h4<br />
16<br />
14 15 8 9 6<br />
h5<br />
h12 h13 10<br />
3<br />
h10(12,13,19), h12(14,15,18), h14(16,17,18)<br />
h9(11,12,18), h15(1,17,19)<br />
h2(1,4,5,6), h3(3,4,7,8)<br />
h4(5,7), h5(6,8,9)<br />
h6(7,9,10)<br />
h1(1,2,3)<br />
Hypertee decomposition of width 3<br />
• For each query Q, hw(Q) qw(Q)<br />
• In some cases, hw(Q) < qw(Q)<br />
• For fixed k, deciding whether<br />
hw(Q) k is in polynomial time (LOGCFL)<br />
• Computing hypertree decompositions is<br />
feasible in polynomial time (for fixed k).<br />
But: FP-intractable wrt k: W[2]-hard.
Evaluating CSP’s having bounded<br />
(gen.) hypertree width<br />
k fixed<br />
Given:<br />
a database db of relations<br />
a CSP Q over db such that hw(Q) k or ghw k<br />
a width k hypertree decomposition of Q<br />
• Deciding whether (Q,db) solvable is in<br />
O(n k+1 log n) and complete for LOGCFL<br />
• Computing Q(db) is feasible in<br />
output-polynomial time<br />
Observation: If H has n vertices, then<br />
HW(H)n/2+1<br />
Does not hold for TW: TW(K n )=n-1<br />
Often HW < TW. H-Decomps are interesting<br />
In case of bounded arity, too.<br />
ComparingDecompositionMethods<br />
We compare these methods according to<br />
their ability in indentifying tractable classes of<br />
CSP instances:<br />
Comparison results<br />
Hypertree Decomposition<br />
• D1 D2 (D2generalizes D1):<br />
0suchthat, k>0,C(D1,k) C(D2,k+)<br />
everyclassofCSPstractableaccordingtoD1istractableaccordingtoD2,<br />
according to is according to D2<br />
with(almost)thesamecost.<br />
• D2<br />
D1 (D2beats D1):thereexistsanintegerksuchthat<br />
exists integer such that<br />
m,C(D2,k) C(D1,m)<br />
thereareclassesofCSPstractableaccordingtoD2butnottractable<br />
accordingtoD1.<br />
• D1
Relationship GHW vs. HW:<br />
Observation:<br />
ghw(H) = hw(H*)<br />
where H* = H {E´| E in edges(H): E´ E}<br />
Exponential!<br />
Q: Are there other<br />
approximations to<br />
GHW <br />
Hypertree Decomposition<br />
Hinge Decomposition<br />
+<br />
Tree Clustering<br />
GHD<br />
Cycle Hypercutset<br />
Approximation Theorem [Adler,G.,Grohe 05] :<br />
Hinge<br />
Decomposition<br />
Tree Clustering<br />
w* treewidth<br />
ghw(H)
Open Question:<br />
Are there approximations<br />
of GHW better than HW<br />
GHD<br />
k<br />
Question:<br />
Are all tractable classes<br />
of CSPs of bounded GHW<br />
GHD<br />
Can we get closer<br />
Explore this area!<br />
Hypertree Decomposition 3k+1 Hypertree Decomposition<br />
Hinge Decomposition<br />
+<br />
Tree Clustering<br />
Cycle Hypercutset<br />
Hinge Decomposition<br />
+<br />
Tree Clustering<br />
Cycle Hypercutset<br />
Hinge<br />
Decomposition<br />
Tree Clustering<br />
w* treewidth<br />
Hinge<br />
Decomposition<br />
Tree Clustering<br />
w* treewidth<br />
Biconnected Components<br />
Cycle Cutset<br />
Biconnected Components<br />
Cycle Cutset<br />
No!<br />
Fractional HT-Decompositions<br />
[Grohe,Marx ’05]<br />
Fractional HD +<br />
GHD<br />
Open Question:<br />
What is the best<br />
“tractable” measure<br />
of hypergraph cyclicity<br />
Explore this area!<br />
GHD<br />
Hypertree Decomposition<br />
[Chen&Dalmau,…]<br />
Hypertree Decomposition<br />
Hinge Decomposition<br />
+<br />
Tree Clustering<br />
Cycle Hypercutset<br />
Hinge Decomposition<br />
+<br />
Tree Clustering<br />
Cycle Hypercutset<br />
Hinge<br />
Decomposition<br />
Tree Clustering<br />
w* treewidth<br />
Hinge<br />
Decomposition<br />
Tree Clustering<br />
w* treewidth<br />
Biconnected Components<br />
Cycle Cutset<br />
Biconnected Components<br />
Cycle Cutset