90 likes | 98 Views
This lecture discusses the complexity of conjunctive queries in finite model theory. Topics include the FO fragment, canonical form, complexity theorems, and tree decomposition.
E N D
Finite Model TheoryLecture 7 Complexity of FO (cont’d)
Outline • Complexity of conjunctive queries
Conjunctive Queries • The FO fragment consisting of:R(x,y,…) -- atomic formulasx=y -- equalityf1Æ phi2 -- conjunction9 x.f -- existential quantifiers • Canonical form:9 x1.9 x2… 9 xk.(G1Æ … Æ Gm)or, simply: G1, …, Gm
Complexity of Conjunctive Queries TheoremThe query complexity of CQ is NP-hard.The combined complexity of CQ is NP-complete. ProofNP membership. Let:f = 9 x1 … 9 xk G1Æ … Æ GmA = (A, R1A, …, RpA)Step 1: guess k values a1, …, ak2 AStep 2: check if G1Æ … Æ Gm is true after substituting x1 with a1, …, xk with ak
Proof (cont’d) Hardness: will design a structure A s.t. the set {f | A ²f} is NP-hard. • By reduction from 3 colorability A = ({0,1,2}, N), where N = {(i,j) | i ¹ j} Let G = (V, E) be a graph, |V| = k Define: f = 9 x1 … 9 xk (Æ(xi, xj) 2 E N(xi, xj))
Tree Decomposition • Note: a conjunctive query = a hypergraph • A tree decomposition of a conjunctive query (or hypergraph) with variables (nodes) V is a tree T, and a set Btµ V for each node t in T such that: • For every x 2 V, the set {t | x 2 Bt} is connected • Every hyperedge of the query (hypergraph) is contained in some Bt
Tree Decomposition Examples [in class]: f = R(x,y,z), R(z,u,v), S(v,w) f = R(x,y,z), R(z,u,v), R(v,w,x)
Tree Decomposition Definition A conjunctive query (or a hypergraph) is acyclic if there exists a tree decomposition such that 8 t, Bt is an hyperedge. I.e. there are no redundant variables on the tree nodes.
Tree Decomposition Theorem If f is an acyclic conjunctive query and A is a structure, then checking whether A²f can be done in timme O(|f| |A|) Note: |A| denotes the size of the entire structure, i.e. is more of the form n + n3 + n2 + n5 if the arities of the relations in A are 3, 2, 5. Proof [in class]