Finite Model Theory Lecture 7

9
1 Finite Model Theory Lecture 7 Complexity of FO (cont’d)

description

Finite Model Theory Lecture 7. Complexity of FO (cont’d). Outline. Complexity of conjunctive queries. Conjunctive Queries. - PowerPoint PPT Presentation

Transcript of Finite Model Theory Lecture 7

Page 1: Finite Model Theory Lecture 7

1

Finite Model TheoryLecture 7

Complexity of FO (cont’d)

Page 2: Finite Model Theory Lecture 7

2

Outline

• Complexity of conjunctive queries

Page 3: Finite Model Theory Lecture 7

3

Conjunctive Queries

• The FO fragment consisting of:

R(x,y,…) -- atomic formulasx=y -- equality1 Æ phi2 -- conjunction9 x. -- existential quantifiers

• Canonical form:9 x1.9 x2… 9 xk.(G1 Æ … Æ Gm)or, simply: G1, …, Gm

Page 4: Finite Model Theory Lecture 7

4

Complexity of Conjunctive Queries

Theorem The query complexity of CQ is NP-hard.The combined complexity of CQ is NP-complete.

ProofNP membership. Let:

= 9 x1 … 9 xk G1 Æ … Æ Gm

A = (A, R1A, …, Rp

A)Step 1: guess k values a1, …, ak 2 AStep 2: check if G1 Æ … Æ Gm is true after substituting x1 with a1, …, xk with ak

Page 5: Finite Model Theory Lecture 7

5

Proof (cont’d)

Hardness: will design a structure A s.t. the set { | A ² } 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: = 9 x1 … 9 xk (Æ(xi, xj) 2 E N(xi, xj))

Page 6: Finite Model Theory Lecture 7

6

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

Page 7: Finite Model Theory Lecture 7

7

Tree Decomposition

Examples [in class]:

= R(x,y,z), R(z,u,v), S(v,w)

= R(x,y,z), R(z,u,v), R(v,w,x)

Page 8: Finite Model Theory Lecture 7

8

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.

Page 9: Finite Model Theory Lecture 7

9

Tree Decomposition

Theorem If is an acyclic conjunctive query and A is a structure, then checking whether A ² can be done in timme O(|| |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]