1 / 75

Hypertree Decompositions

Hypertree Decompositions. G. Gottlob Technical University of Vienna, Austria N. Leone and F. Scarcello University of Calabria, Italy For papers and further material see: http://ulisse.deis.unical.it/~frank/Hypertrees/. Three Problems:. HOM: The homomorphism problem.

morrisa
Télécharger la présentation

Hypertree Decompositions

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Hypertree Decompositions G. Gottlob Technical University of Vienna, Austria N. Leone and F. Scarcello University of Calabria, Italy For papers and further material see: http://ulisse.deis.unical.it/~frank/Hypertrees/

  2. Three Problems: HOM: The homomorphism problem BCQ: Boolean conjunctive query evaluation CSP: Constraint satisfaction problem Important problems in different areas. All these problems are hypergraph based. But actually: HOM = BCQ = CSP

  3. The Homomorphism Problem Given two relational structures Decide whether there exists a homomorphism h from A to B

  4. HOM is NP-complete (well-known) Membership: Obvious, guess h. Hardness: Transformation from 3COL. 1 2 A 5 B 3 4 1 2 red green 1 3 red blue 6 2 3 green red 3 4 green blue 2 5 blue red 4 5 3 6 blue green Graph 3-colourable iff HOM(A,B ) yes-instance.

  5. HOM is NP-complete (well-known, independently proved in various contexts) Membership: Obvious, guess h. Hardness: Transformation from 3COL. 1 2 A 5 B h 3 4 1 2 red green h 1 3 red blue 6 2 3 green red 3 4 green blue 2 5 blue red 4 5 3 6 blue green Graph 3-colourable iff HOM(A,B ) yes-instance.

  6. Conjunctive Queries, CSPs • Database schema (scopes): • Enrolled (Pers#, Course, Reg-Date) • Teaches (Pers#, Course, Assigned) • Parent (Pers1, Pers2) • Is there any teacher having a child enrolled in her course? ans  Enrolled(S,C,R)  Teaches(P,C,A)  Parent(P,S)

  7. Conjunctive Queries, CSPs (2) • Database schema (scopes): • Enrolled (Pers#, Course, Reg-Date) • Teaches (Pers#, Course, Assigned) • Parent (Pers1, Pers2) • Is there any teacher whose child attend some course? ans  Enrolled(S,C’,R)  Teaches(P,C,A)  Parent(P,S)

  8. BCQ = HOM View query Q (=scopes)as a relational structure Universe: Variables of the query Relations: sets of query-atoms for each database relation. The database D is itself a relational structure. The Boolean conjunctive query (CSP) is equivalen to the HOM instance HOM(Q,D ). Vive-versa, every HOM instance can be reformulated as a Boolean Conjunctive Query (CSP). This talk will mainly concentrate on BCQ

  9. Queries, CSPs, and Hypergraphs • ans  Enrolled(S,C,R)  Teaches(P,C,A)  Parent(P,S) C R A S P

  10. Queries, CSPs, and Hypergraphs • ans  Enrolled(S,C’,R)  Teaches(P,C,A)  Parent(P,S) C’ C R A S P

  11. Boolean Conjunctive Queries The problem BCQ ( = constraint satisiability) Instance: < DB, Q> (= <Relations, Scope>) Question: Has Q a nonempty result over DB? Combined Complexity(Vardi ’82)

  12. Problems Equivalent to BCQ • Conjunctive Query Containment • Query of Tuple Problem • Constraint Satisfaction in AI • Clause Subsumption in Theorem Proving

  13. Example of CSP: Crossword Puzzle

  14. Complexity of BCQ • NP-complete in the general case (Chandra and Merlin ’77)NP-hard even for fixed database • Polynomial if Q has an acyclic hypergraph(Yannakakis ’81)LOGCFL-complete (in NC2) (G.L.S. ’98) Interest in larger tractable classes of CQS

  15. C’ C R A S P Acyclic queries or CSPs • ans  Enrolled(S,C’,R)  Teaches(P,C,A)  Parent(P,S) Parent(P,S) Teaches(P,C,A) Enrolled(S,C’,R) Join Tree

  16. Theorem [GLS99]: Answering acyclic BCQs is LOGCFL-complete LOGCFL: class of problems/languages that are logspace-reducible to a CFL LOGCFL Characterization of LOGCFL [Ruzzo80]: LOGCFL = Class of all problems solvable with a logspace ATM with polynomial tree-size

  17. Is this query hard? n size of the database m number of atoms in the query m = 11 ! O(n m) • Classical methods worst-case complexity: • Despite its apparence, this query is nearly acyclic It can be evaluated in O(m·n 2·logn)

  18. B B’ X X’ C F S Z Z’ J Y Y’ C’ F’ It can be evaluated in O(m·n 2·logn)

  19. Nearly Acyclic Queries & CSPs • Bounded Treewidth (tw) • a measure of the cyclicity of graphs • for queries: tw(Q) = tw(G(Q)) • For fixed k: • checking tw(Q) k • Computing a tree decomposition linear time (Bodlaender’96) • Answering BCQ of treewidth k: O(nk log n) (Chekuri & Rajaraman’97, Kolaitis & Vardi, 98) LOGCFL-complete (G.L.S.’98)

  20. Primal graphs of Queries • ans  Enrolled(S,C,R)  Teaches(P,C,A)  Parent(P,S) C C A R R A P S S P Primal graph G(Q) Hypergraph H(Q)

  21. Example: a cyclic graph q b a d g c f e p h j l i k o n m

  22. A tree decomposition of width 2 ah ahq hkl hkp klo hij abc mno ag cef bcd

  23. Connectedness condition for h ah ahq hkl hkp klo hij abc mno ag cef bcd

  24. Game characterization of Treewidth • A robber and k cops play the game on a graph • The cops have to capture the robber • Each cop controls a vertex of the graph • Each cop, at any time, can fly to any vertex of the graph • The robber tries to elude her capture, by running arbitrarily fast on the vertices of the graph,but on those vertices controlled by cops

  25. Playing the game q b a d g c f e p h j l i k o n m

  26. Playing the game q b a d g c f e p h j l i k o n m

  27. Playing the game q b a d g c f e p h j l i k o n m

  28. Playing the game q b a d g c f e p h j l i k o n m

  29. Logical characterization of Treewidth (Kolaitis & Vardi ’98)

  30. Hypergraphs vs Graphs (1) C C’ C’ C A R R A P S S P An acyclic hypergraph Its cyclic primal graph

  31. Hypergraphs vs Graphs (1) C C’ C’ C A R R A P S S P There are two cliques. We cannot know where they come from

  32. Drawbacks of treewidth Acyclic queries may have unbounded TW! Example: q p1(X1, X2,…, Xn)  … pm(X1, X2,…, Xn) is acyclic, obviously polynomial, but has treewidth n-1

  33. Beyond treewidth Bounded Degree of Cyclicity (Gyssens & Paredaens ’84) Bounded Query width (Chekuri & Rajaraman ’97) Group together query atoms (hyperedges) instead of variables

  34. p1(X1, X2,…, Xn) p1(X1, X2,…, Xn) p2(X1, X2,…, Xn) pm(X1, X2,…, Xn) Query Decomposition q  p1(X1, X2,…, Xn)  … pm(X1, X2,…, Xn) Query width = 1 • Every atom appears in some node • Connectedness conditions for variables and atoms

  35. g(X,Y), t(Y,Z) t(Z,X) s(Y,Z,U) s(Z,W,X) Decomposition of cyclic queries q  s(Y,Z,U)  g(X,Y)  t(Z,X)  s(Z,W,X)  t(Y,Z) Query width = 2 BCQ is polynomial for queries of bounded query width,if a query decomposition is given

  36. Open Problems by Chekuri & Rajaraman ‘97 Are the following problems solvable in polynomial time for fixed k ? • Decide whether Q has query width at most k • Compute a query decomposition of Q of width k

  37. A negative answer (G.L.S. ’99) Theorem: Deciding whether a query has query width at most k isNP-complete Proof: Very involved reduction fromEXACT COVERING BY 3-SETS

  38. Important Observation NP-hardness id due to an overly strong conditionin the definition of query decomposition p(X,Y,Z), q(U,V,Z) a(X,U,W), b(Y,V,W) p(X,Y,Z), c(T,W) Forbidden ! d(X,T) c(Y,T)

  39. Important Observation But the reuse of p(X,Y,Z) is harmless here:we could added an atom p(X,Y,Z’) without changing the query p(X,Y,Z), q(U,V,Z) p(X,Y,Z), q(U,V,Z) a(X,U,W), b(Y,V,W) p(X,Y,Z), c(T,W) p(X,Y,Z’), c(T,W) d(X,T) c(Y,T)

  40. Hypertree Decompositions Query atoms can be used “partially”as long as the full atom appearssomewhere else More liberal than query decomposition

  41. Grouping and Reusing Atoms p(X,Y,Z), q(U,V,Z) p(X,Y,Z), q(U,V,Z) We group atoms a(X,U,W), b(Y,V,W) p(X,Y,_), c(T,W) p(X,Y,_), c(T,W) We use p(X,Y,Z) partially d(X,T) c(Y,T)

  42. Reusing atoms p(X,Y,Z), q(U,V,Z) a(X,U,W), b(Y,V,W) p(X,Y,_), c(T,W) p(X,Y,_), c(T,W) We use p(X,Y,Z) partially d(X,T) c(Y,T)

  43. j(J,X,Y,X’,Y’) a(S,X,X’,C,F), b(S,Y,Y’,C’,F’) j(_,X,Y,_,_), c(C,C’,Z) j(_,_,_,X’,Y’), f(F,F’,Z’) d(X,Z) e(Y,Z) g(X’,Z’), f(F,_,Z’) h(Y’,Z’) p(B,X’,F) q(B’,X’,F)

  44. Connectedness Condition j(J,X,Y,X’,Y’) a(S,X,X’,C,F), b(S,Y,Y’,C’,F’) j(_,X,Y,_,_), c(C,C’,Z) j(_,_,_,X’,Y’), f(F,F’,Z’) d(X,Z) e(Y,Z) g(X’,Z’), f(F,_,Z’) h(Y’,Z’) p(B,X’,F) q(B’,X’,F)

  45. Special Condition Each variable that disappeared at some vertex v j(J,X,Y,X’,Y’) a(S,X,X’,C,F), b(S,Y,Y’,C’,F’) j(_,X,Y,_,_), c(C,C’,Z) j(_,_,_,X’,Y’), f(F,F’,Z’) J X Y d(X,Z) e(Y,Z) g(X’,Z’), f(F,_,Z’) h(Y’,Z’) Does not reappear inthe subtrees rootedat v p(B,X’,F) q(B’,X’,F)

  46. Special Condition Each variable that disappeared at some vertex v j(J,X,Y,X’,Y’) a(S,X,X’,C,F), b(S,Y,Y’,C’,F’) j(_,X,Y,_,_), c(C,C’,Z) j(_,_,_,X’,Y’), f(F,F’,Z’) J X Y d(X,Z) e(Y,Z) g(X’,Z’), f(F,_,Z’) h(Y’,Z’) Does not appear inthe subtrees rootedat v p(B,X’,F) q(B’,X’,F)

  47. Positive Results onHypertree Decompositions • For each query Q, hw(Q)  qw(Q) • In some cases, hw(Q) < qw(Q) • For fixed k, deciding whether hw(Q)  k is in polynomial time (LOGCFL) • Computing hypertree decompositions is feasible in polynomial time (for fixed k)

  48. Evaluating queries having bounded hypertree width k fixed Given: a database db a query Q over db such that hw(Q)  k a width k hypertree decomposition of Q • Deciding whether Q(db) is not empty is in O(n k+1log n) and complete for LOGCFL • Computing Q(db) is feasible in output-polynomial time

  49. Comparison results Hypertree Decomposition Hinge Decomposition + Tree Clustering Cycle Hypercutset HingeDecomposition Tree Clusteringw*  treewidth Biconnected Components Cycle Cutset

More Related