Fundamentos lógicos de bases de datos (Logical foundations of databases)

Size: px
Start display at page:

Download "Fundamentos lógicos de bases de datos (Logical foundations of databases)"

Transcription

1 20/7/2015 ECI 2015 Buenos Aires Fundamentos lógicos de bases de datos (Logical foundations of databases) Diego Figueira Gabriele Puppis CNRS LaBRI

2 About the speakers Gabriele Puppis PhD from Udine (Italy) post-docs in Oxford Works in LaBRI, Bordeaux CNRS researcher Diego Figueira PhD from ENS Cachan (France), post-docs in Warsaw, Edinburgh Works in LaBRI, Bordeaux CNRS researcher Alma Mater: UBA! 2

3 About the speakers Gabriele Puppis PhD from Udine (Italy) post-docs in Oxford Works in LaBRI, Bordeaux CNRS researcher Diego Figueira PhD from ENS Cachan (France), post-docs in Warsaw, Edinburgh Works in LaBRI, Bordeaux CNRS researcher Alma Mater: UBA! 2

4 About the speakers Gabriele Puppis PhD from Udine (Italy) post-docs in Oxford Works in LaBRI, Bordeaux CNRS researcher hermano del inigualable Diego Figueira PhD from ENS Cachan (France), post-docs in Warsaw, Edinburgh Works in LaBRI, Bordeaux CNRS researcher Alma Mater: UBA!!!! 2

5 First and foremost interrupt! ask! (in any language) 3

6 Organization Format: 45 min slots / 20 min breaks: Schedule: Relational Algebra First-Order logic EF games, 0-1 law, Locality Conjunctive Queries logic databases complexity Evaluation: A short test on Saturday Slides available at 4

7 Databases database = a collection of data, structured in some way + a way of defining, querying, updating the data inside mediate between humans, processes & data * * [Abitebou, Hull, Vianu Foundations of databases ] 5

8 Databases database = a collection of data, structured in some way + a way of defining, querying, updating the data inside mediate between humans, processes & data * Data model how the data is logically organized mathematical abstraction for representing data independent from physical organisation DBMS also implement: transactions, concurrency, access control, resiliency * [Abitebou, Hull, Vianu Foundations of databases ] 5

9 Relational databases Relational data model = data logically organised into relations ( tables ). What s a relation? a (finite) subset of the cartesian product of sets a table with rows and columns 6

10 Relational databases Relational data model = data logically organised into relations ( tables ). What s a relation? a (finite) subset of the cartesian product of sets a table with rows and columns like: { (1,a,2), (2,b,6), (2,a,1) } N {a,b} N 6

11 Relational databases Relational data model = data logically organised into relations ( tables ). What s a relation? a (finite) subset of the cartesian product of sets a table with rows and columns like: { (1,a,2), (2,b,6), (2,a,1) } N {a,b} N a tuple (a 3-tuple ) 6

12 Relational databases Relational data model = data logically organised into relations ( tables ). What s a relation? a (finite) subset of the cartesian product of sets a table with rows and columns like: { (1,a,2), (2,b,6), (2,a,1) } N {a,b} N a tuple (a 3-tuple ) () 0-tuple 6

13 Relational databases Relational data model = data logically organised into relations ( tables ). What s a relation? a (finite) subset of the cartesian product of sets a table with rows and columns like: { (1,a,2), (2,b,6), (2,a,1) } N {a,b} N like: 1 a 2 2 b 6 2 a 1 a tuple (a 3-tuple ) () 0-tuple 6

14 Relational databases Relational data model = data logically organised into relations ( tables ). What s a relation? a (finite) subset of the cartesian product of sets a table with rows and columns DB = A schema: names of tables and attributes An instance: data conforming to the schema 6

15 Relational databases Relational data model = data logically organised into relations ( tables ). What s a relation? a (finite) subset of the cartesian product of sets a table with rows and columns DB = A schema: names of tables and attributes Films (Title:string, Director:string, Actor:string) Schedule (Theatre:string, Title:string) An instance: data conforming to the schema 6

16 Relational databases Relational data model = data logically organised into relations ( tables ). What s a relation? a (finite) subset of the cartesian product of sets a table with rows and columns DB = A schema: names of tables and attributes Films (Title:string, Director:string, Actor:string) Schedule (Theatre:string, Title:string) An instance: data conforming to the schema Films Schedule Title Director Actor Theatre Title 8 1/2 Fellini Mastroianni Utopia Dr. Strangelove Shining Kubrick Nicholson Utopia 8 1/2 Dr. Strangelove Kubrick Sellers UGC Dr. Strangelove 8 femmes Ozon Ardant UGC 8 femmes 6

17 Relational databases Relational data model = data logically organised into relations ( tables ). We assume all elements come from a fixed set of constants or data values U. 7

18 Relational databases: queries What is a query q? A mapping that takes a database instance D returns a relation q(d) U r of fixed arity r 8

19 Relational databases: queries computable! What is a query q? A mapping that takes a database instance D returns a relation q(d) U r of fixed arity r 8

20 Relational databases: queries computable! What is a query q? A mapping that takes a database instance D returns a relation q(d) U r of fixed arity r generic! (order independent) 8

21 Relational databases: queries computable! What is a query q? A mapping that takes a database instance D returns a relation q(d) U r of fixed arity r generic! (order independent) Boolean query: r=0 Either yes { () } or no { } 8

22 Relational databases: queries What is a query q? A mapping that takes a database instance D returns a relation q(d) U r of fixed arity r What do we care about queries? expressive power evaluation static analysis 8

23 The fundamental questions: How to query the relational data model? How efficient/expressive is it? 9

24 The fundamental questions: How to query the relational data model? How efficient/expressive is it? expressiveness efficiency 9

25 Query languages Query Language Syntax + Semantics Expressions for querying the db, governed by syntactic rules Select X from Y y :- x (x y) Interpretation of symbols in terms of some structure Retrieves all strings in column X of table Y Returns the maximum element of the set. 10

26 Relational Algebra (RA) [Codd, 1970] Syntax: E := R,S, E E E \ E E E π M (E) σ ϴ (E) where M N ϴ N {=, } N 11

27 Relational Algebra (RA) [Codd, 1970] Syntax: E := R,S, E E E \ E E E π M (E) σ ϴ (E) where M N ϴ N {=, } N R 1 R 2 : Set union R 1 R 2 : Cartesian product R 1 \ R 2 : Set difference 11

28 Relational Algebra (RA) [Codd, 1970] Syntax: E := R,S, E E E \ E E E π M (E) σ ϴ (E) where M N ϴ N {=, } N R 1 R 2 : Set union R 1 R 2 : Cartesian product R 1 \ R 2 : Set difference σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} : Selection 11

29 Relational Algebra (RA) [Codd, 1970] Syntax: E := R,S, E E E \ E E E π M (E) σ ϴ (E) where M N ϴ N {=, } N R 1 R 2 : Set union R 1 R 2 : Cartesian product R 1 \ R 2 : Set difference σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} : Selection 11

30 Relational Algebra (RA) [Codd, 1970] Syntax: E := R,S, E E E \ E E E π M (E) σ ϴ (E) where M N ϴ N {=, } N R 1 R 2 : Set union R 1 R 2 : Cartesian product σ {1=3,1 2} ( {(1,2,1), A procedural (2,2,2)} query ) = language {(1,2,1)} R 1 \ R 2 : Set difference σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} : Selection 11

31 Relational Algebra (RA) [Codd, 1970] Syntax: E := R,S, E E E \ E E E π M (E) σ ϴ (E) where M N ϴ N {=, } N R 1 R 2 : Set union R 1 R 2 : Cartesian product σ {1=3,1 2} ( {(1,2,1), A procedural (2,2,2)} query ) = language {(1,2,1)} R 1 \ R 2 : Set difference σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} : Selection π {i1,,i n } (R) {(x i 1,,x in ) (x 1,, x m ) R} : Projection 11

32 Relational Algebra (RA) [Codd, 1970] Syntax: E := R,S, E E E \ E E E π M (E) σ ϴ (E) where M N ϴ N {=, } N R 1 R 2 : Set union R 1 R 2 : Cartesian product σ {1=3,1 2} ( {(1,2,1), A procedural (2,2,2)} query ) = language {(1,2,1)} π {1,3} ( {(1,2,1),(2,2,2)} ) = {(1,1), (2,2)} R 1 \ R 2 : Set difference σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} : Selection π {i1,,i n } (R) {(x i 1,,x in ) (x 1,, x m ) R} : Projection 11

33 Relational Algebra (RA) [Codd, 1970] R 1 R 2 : Set union R 1 R 2 : Cartesian product R 1 \ R 2 : Set difference σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} : Selection π {i1,,i n } (R) {(x i 1,,x in ) (x 1,, x m ) R} : Projection Question 1: What is the RA expression for { (v 1,v 2 ) there are w 1 w 2 so that (v 1,w 1 ) R 1 and (v 2,w 2 ) R 2 }? Question 2: π 2 (σ 1=3 (π 2 (σ 1=3 (R 1 R 2 )) R 2 ))=? R 1 R 2 a 3 a 4 b 2 b 1 c 4 b 2 b 3 a 1 a 2 b 3 12

34 Relational Algebra (RA) [Codd, 1970] R 1 R 2 : Set union R 1 R 2 : Cartesian product R 1 \ R 2 : Set difference σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} : Selection π {i1,,i n } (R) {(x i 1,,x in ) (x 1,, x m ) R} : Projection Question 1: What is the RA expression for { (v 1,v 2 ) there are w 1 w 2 so that (v 1,w 1 ) R 1 and (v 2,w 2 ) R 2 }? Answer: π {1,3} (σ 1 3 (R 1 R 2 )) Question 2: π 2 (σ 1=3 (π 2 (σ 1=3 (R 1 R 2 )) R 2 ))=? a b c c b a a b R 1 R 2 a 3 b 2 c 4 b 3 a 2 a 4 b 1 b 2 a 1 b 3 12

35 Relational Algebra (RA) [Codd, 1970] R 1 R 2 : Set union R 1 R 2 : Cartesian product R 1 \ R 2 : Set difference σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} : Selection π {i1,,i n } (R) {(x i 1,,x in ) (x 1,, x m ) R} : Projection Question 1: What is the RA expression for { (v 1,v 2 ) there are w 1 w 2 so that (v 1,w 1 ) R 1 and (v 2,w 2 ) R 2 }? Answer: π {1,3} (σ 1 3 (R 1 R 2 )) Question 2: π 2 (σ 1=3 (π 2 (σ 1=3 (R 1 R 2 )) R 2 ))=? Answer (only one element): b a b c c b a a b R 1 R 2 a 3 b 2 c 4 b 3 a 2 a 4 b 1 b 2 a 1 b 3 12

36 RA = Basic SQL no domain-specific features, aggregation, etc Select X From R 1,,R n Where Z or not in ( ) π X ( σ Z ( R 1 R n ) ) union difference 13

37 RA = Basic SQL no domain-specific features, aggregation, etc Select X From R 1,,R n Where Z or not in ( ) π X ( σ Z ( R 1 R n ) ) union difference π 2 (σ 1 3(R 1 R 2 )) a 3 R 1 R 2 b 2 c 4 b 3 a 2 a 4 b 1 b 2 a 1 b 3 13

38 RA = Basic SQL no domain-specific features, aggregation, etc Select X From R 1,,R n Where Z or not in ( ) π X ( σ Z ( R 1 R n ) ) union difference Select R 1.2 as foo π 2 (σ 1 3(R 1 R 2 )) From R 1, R 2 a 3 Where R 1.1 R 2.1 R 1 R 2 b 2 c 4 b 3 a 2 a 4 b 1 b 2 a 1 b 3 13

39 RA = Basic SQL no domain-specific features, aggregation, etc Select X From R 1,,R n Where Z or not in ( ) π X ( σ Z ( R 1 R n ) ) union difference π 2 (σ 1 3(R 1 R 2 )) From R 1, R 2 a 3 π 2 (σ 1=3 ( R 2 )) Select R 1.2 as foo Where R 1.1 R 2.1 R 1 R 2 b 2 c 4 b 3 a 2 a 4 b 1 b 2 a 1 b 3 13

40 RA = Basic SQL no domain-specific features, aggregation, etc Select X From R 1,,R n Where Z or not in ( ) π X ( σ Z ( R 1 R n ) ) union difference Select R 1.2 as foo R 1 R 2 π 2 (σ 1 3(R 1 R 2 )) From R 1, R 2 a 3 π 2 (σ 1=3 ( R 2 )) Where R 1.1 R 2.1 a 4 b 2 b 1 c 4 b 2 b 3 a 1 a 2 b 3 13

41 RA = Basic SQL no domain-specific features, aggregation, etc Select X From R 1,,R n Where Z or not in ( ) π X ( σ Z ( R 1 R n ) ) union difference Select R 1.2 as foo R 1 R 2 π 2 (σ 1 3(R 1 R 2 )) From R 1, R 2 a 3 π 2 (σ 1=3 ( R 2 )) Where R 1.1 R 2.1 Select foo From, R 2 Where foo = R 2.2 b 2 c 4 b 3 a 2 a 4 b 1 b 2 a 1 b 3 13

42 Denotational languages Procedural Algebra How to obtain the result Logics What is the property of the result Declarative 14

43 Denotational languages { Relational Algebra Procedural operations on tables Algebra How to obtain the result Logics What is the property of the result Declarative 14

44 Denotational languages { Relational Algebra Procedural operations on tables Algebra How to obtain the result Logics What is the property of the result { First Order logic properties on mathematical structures Declarative 14

45 Denotational languages { Relational Algebra Procedural operations on tables Algebra How to obtain the result Logics What is the property of the result { First Order logic properties on mathematical structures Declarative 14

46 FO = First-Order logic 15

47 Denotational languages A structure is: A = (D, R 1,, R n, f 1, f n ) D is a non-empty set, the domain R i is an m-ary relation for some m (ie, R i D m ) f i is an n-ary function for some n (ie, f i : D n D ) 16

48 Denotational languages A structure is: A = (D, R 1,, R n, f 1, f n ) D is a non-empty set, the domain R i is an m-ary relation for some m (ie, R i D m ) f i is an n-ary function for some n (ie, f i : D n D ) A graph G = (V,E) V: nodes E V 2 : edges (binary relation) (no functions) A group, like (N,+) N: natural numbers (no relations) +: N 2 N addition (binary function) 16

49 First-order logic 17

50 First-order logic FO variables x, y, z, quantifiers:, Boolean connectives:,, A language to talk about structures Variables range over the domain Atomic formulas: R(x 1,, x m ), x=y 17

51 First-order logic FO variables x, y, z, quantifiers:, Boolean connectives:,, A graph G = (V,E) V: nodes E V 2 : edges (binary relation) (no functions) A language to talk about structures Variables range over the domain Atomic formulas: R(x 1,, x m ), x=y Language to talk about graphs Variables range over nodes Atomic formulas: E(x,y), x = y 17

52 First-order logic FO variables x, y, z, quantifiers:, Boolean connectives:,, A graph G = (V,E) V: nodes E V 2 : edges (binary relation) (no functions) A language to talk about structures Variables range over the domain Atomic formulas: R(x 1,, x m ), x=y Language to talk about graphs Variables range over nodes Atomic formulas: E(x,y), x = y Formulas: Atomic formulas + connectives + quantifiers 17

53 The node x has at least two neighbours y z ( (y=z) E(x,y) E(x,z)) 18

54 The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) free x is free = not quantified (a property of a node in the graph) 18

55 The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) free x is free = not quantified (a property of a node in the graph) Each node has at least two neighbours x y z ( (y=z) E(x,y) E(x,z)) 18

56 The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) free x is free = not quantified (a property of a node in the graph) Each node has at least two neighbours ψ = x y z ( (y=z) E(x,y) E(x,z)) the formula is a sentence = no free variables (a property of the graph) 18

57 The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) free x is free = not quantified (a property of a node in the graph) Each node has at least two neighbours ψ = x y z ( (y=z) E(x,y) E(x,z)) the formula is a sentence = no free variables (a property of the graph) Question: How to express in FO Every two neighbours have a common neighbour? Does it have free variables? Is it a sentence? 18

58 The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) free x is free = not quantified (a property of a node in the graph) Each node has at least two neighbours ψ = x y z ( (y=z) E(x,y) E(x,z)) the formula is a sentence = no free variables (a property of the graph) Question: How to express in FO Every two neighbours have a common neighbour? Does it have free variables? Is it a sentence? Answer: x y ( E(x,y) z ( (E(x,z) E(z,x)) (E(y,z) E(z,y)) ) ) 18

59 Binding To evaluate a formula φ we need a graph G=(V,E) and a binding α that maps free variables of φ to nodes of G. G α φ(x 1,,x n ) α : {x 1,,x n } V assigns nodes to free variables 19

60 Binding To evaluate a formula φ we need a graph G=(V,E) and a binding α that maps free variables of φ to nodes of G. G,α satisfy φ φ is satisfiable G α φ(x 1,,x n ) α : {x 1,,x n } V assigns nodes to free variables 19

61 Binding To evaluate a formula φ we need a graph G=(V,E) and a binding α that maps free variables of φ to nodes of G. G,α satisfy φ φ is satisfiable G α φ(x 1,,x n ) α : {x 1,,x n } V assigns nodes to free variables The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) G α φ if α = {x v} v v' G v'' 19

62 Binding To evaluate a formula φ we need a graph G=(V,E) and a binding α that maps free variables of φ to nodes of G. G,α satisfy φ φ is satisfiable G α φ(x 1,,x n ) α : {x 1,,x n } V assigns nodes to free variables The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) G α φ if α = {x v} v v' Every node has at least two neighbours ψ = x y z ( (y=z) E(x,y) E(x,z)) G ψ G v'' 19

63 First-order logic Formal Semantics of FO G α x φ iff for some v V and α = α {x v} we have G α' φ G α x φ iff for every v V and α = α {x v} we have G α' φ G α φ ψ iff G α φ and G α ψ G α φ iff it is not true that G α φ G α x=y iff α(x)=α(y) G α E(x,y) iff (α(x),α(y)) E 20

64 Formulas as queries φ(x 1,, x n ) evaluated on G=(V,E) yields all the bindings that satisfy φ: φ(g) = { ( α(x 1 ),,α(x n ) ) G α φ, α: {x 1,,x n } V } 21

65 Formulas as queries φ(x 1,, x n ) evaluated on G=(V,E) yields all the bindings that satisfy φ: φ(g) = { ( α(x 1 ),,α(x n ) ) G α φ, α: {x 1,,x n } V } The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) Return all nodes with at least two neighbours 21

66 Formulas as queries φ(x 1,, x n ) evaluated on G=(V,E) yields all the bindings that satisfy φ: φ(g) = { ( α(x 1 ),,α(x n ) ) G α φ, α: {x 1,,x n } V } The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) φ(g) = {v, v', v''} φ(g') = {v, v'} Return all nodes with at least two neighbours v v' v v' v'' G v'' G' 21

67 Formulas as queries φ(x 1,, x n ) evaluated on G=(V,E) yields all the bindings that satisfy φ: φ(g) = { ( α(x 1 ),,α(x n ) ) G α φ, α: {x 1,,x n } V } The node x has at least two neighbours φ(x) = y z ( (y=z) E(x,y) E(x,z)) φ(g) = {v, v', v''} φ(g') = {v, v'} Return all nodes with at least two neighbours v v' v v' Every node has two neighbours ψ = x y z ( (y=z) E(x,y) E(x,z)) ψ(g) = {()} set with one element: the 0-tuple ψ(g') = {} empty set v'' G v'' G' 21

68 Question: Which bindings α verify G α φ for φ(x,y) = z (E(x,z) E(z,y)) v' and G = v? v'' 22

69 Question: Which bindings α verify G α φ for φ(x,y) = z (E(x,z) E(z,y)) v' and G = v? v'' Answer: α = { x v, y v }, α = { x v, y v }, φ(g) = {v,v', v''} {v,v', v''} α = { x v', y v }, and all the rest 22

70 Formulas as queries FO can serve as a declarative query language on relational databases : we express the properties of the answer Tables = Relations Queries = Formulas Rows = Tuples 23

71 Formulas as queries FO can serve as a declarative query language on relational databases : we express the properties of the answer Tables = Relations Queries = Formulas Rows = Tuples Particular to databases: Use of constants No functions Finite structure Quantification over active domain 23

72 Formulas as queries FO can serve as a declarative query language on relational databases : we express the properties of the answer Tables = Relations Queries = Formulas Rows = Tuples Particular to databases: Use of constants No functions Finite structure Quantification over active domain finite is different from 23

73 Formulas as queries FO can serve as a declarative query language on relational databases : we express the properties of the answer Tables = Relations Queries = Formulas Rows = Tuples Particular to databases: Use of constants No functions Finite structure Quantification over active domain finite is different from There are formulas φ that are satisfiable only on infinite structures. Like which? 23

74 Formulas as queries FO can serve as a declarative query language on relational databases : we express the properties of the answer Tables = Relations Queries = Formulas Rows = Tuples Particular to databases: Use of constants No functions Finite structure Quantification over active domain finite is different from There are formulas φ that are satisfiable only on infinite structures. Like which? φ = R(x,y) is an infinite linear order 23

75 Formulas as queries FO can serve as a declarative query language on relational databases : we express the properties of the answer Tables = Relations Queries = Formulas Rows = Tuples Particular to databases: Use of constants No functions Finite structure Quantification over active domain finite is different from There are formulas φ that are satisfiable only on infinite structures. Like which? φ = R(x,y) is an infinite linear order Finite model theory 23

76 Formulas as queries FO can serve as a declarative query language on relational databases : we express the properties of the answer Tables = Relations Queries = Formulas Rows = Tuples RA =* FO How = What RA and FO logic have roughly* the same expressive power! [E.F. Codd 1972] *FO without functions, with equality, on finite domains, 24

77 Formulas as queries RA FO R 1 R 2 R 1 (x 1,, x n ) R 2 (x n+1,, x m ) R 1 R 2 R 1 (x 1,, x n ) R 2 (x 1,, x n ) σ {i1 =j 1,,i n =j n } (R) R(x 1,, x m ) (x i1 =x j1 ) (x in =x jn ) π {i1,,i n } (R) ({x 1,,x m } \ {x i1,,x in }). R(x 1,, x m ) R 1 \ R 2 R 1 (x 1,, x n ) R 2 (x 1,, x n ) 25

78 Formulas as queries FO RA does not hold in general! 26

79 Formulas as queries FO RA does not hold in general! the complement of R RA FO : R(x) 26

80 Formulas as queries FO RA / the complement of R RA FO : R(x) 26

81 Formulas as queries FO RA / the complement of R RA FO : R(x) We restrict variables to range over active domain 26

82 Formulas as queries FO RA / the complement of R RA FO : R(x) We restrict variables to range over active domain elements in the relations FO act = FO restricted to active domain 26

83 Formulas as queries FO RA / the complement of R RA FO : R(x) We restrict variables to range over active domain elements in the relations FO act = FO restricted to active domain φ 1 (x,y) = E(x,y) φ 1 (G) = {(v 1,v 1 ),(v 3,v 1 )} φ 2 (x) = y E(y,x) φ 2 (G) = {v 2 } G = v 1 v 2 v 4 v 3 26

84 First-order logic restricted to active domain Formal Semantics of FO act G α x φ iff for some v ACT(G) and α = α {x v} we have G α' φ G α x φ iff for every v ACT(G) and α = α {x v} we have G α' φ G α φ ψ iff G α φ and G α ψ G α φ iff it is not true that G α φ G α x=y iff α(x)=α(y) G α E(x,y) iff (α(x),α(y)) E ACT(G) = {v for some v': (v,v') E or (v',v) E} 27

85 ` FO act RA 28

86 ` FO act RA Assume: 1. φ has variables x 1,,x n, 2. φ in normal form: ( * ( )*)* + quantifier-free ψ(x 1,,x n ) x 1,x 2 x 3 x 4. ( E(x 1,x 3 ) E(x 4,x 2 ) ) (x 1 =x 3 ) 28

87 ` FO act RA Assume: 1. φ has variables x 1,,x n, 2. φ in normal form: ( * ( )*)* + quantifier-free ψ(x 1,,x n ) x 1,x 2 x 3 x 4. ( E(x 1,x 3 ) E(x 4,x 2 ) ) (x 1 =x 3 ) Translation Adom = RA expression for active domain = π 1 (E) π 2 (E) ( x i φ(x i1,,x in ) ) π {i1,,i n }\{i} ( φ ) (x i = x j ) σ {i=j} ( Adom Adom ) (ψ 1 (x 1,,x n ) ψ 2 (x 1,,x n )) ψ 1 ψ 2 ( φ(x i1,,x in )) Adom Adom \ φ 28

88 ` FO act RA Assume: 1. φ has variables x 1,,x n, 2. φ in normal form: ( * ( )*)* + quantifier-free ψ(x 1,,x n ) x 1,x 2 x 3 x 4. ( E(x 1,x 3 ) E(x 4,x 2 ) ) (x 1 =x 3 ) Translation Adom = RA expression for active domain = π 1 (E) π 2 (E) ( x i φ(x i1,,x in ) ) π {i1,,i n }\{i} ( φ ) (x i = x j ) σ {i=j} ( Adom Adom ) A B = (A B) \ A \ B (ψ 1 (x 1,,x n ) ψ 2 (x 1,,x n )) ψ 1 ψ 2 ( φ(x i1,,x in )) Adom Adom \ φ 28

89 Corollary FO act is equivalent to RA 29

90 Question 1: How is π 2 (σ 1=3 (π 2 (σ 1=3 (R 1 R 2 )) R 2 )) expressed in FO? Remember: R 1,R 2 are binary Question 2: How is y,z. (R 1 (x,y) R 1 (y,z) x z ) expressed in RA? Remember: The signature is the same as before (R 1,R 2 binary) R 1 R 2 R 1 R 2 R 1 \ R 2 σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} π {i1,,i n } (R) {(x i 1,,x in ) (x 1,, x m ) R} 30

91 Question 1: How is π 2 (σ 1=3 (π 2 (σ 1=3 (R 1 R 2 )) R 2 )) expressed in FO? Remember: R 1,R 2 are binary Answer: x 2. ( x 1,x 4. (R 1 (x 1,x 2 ) R 2 (x 1,x 4 )) R 2 (x 2,x 5 ) ) Question 2: How is y,z. (R 1 (x,y) R 1 (y,z) x z ) expressed in RA? Remember: The signature is the same as before (R 1,R 2 binary) R 1 R 2 R 1 R 2 R 1 \ R 2 σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} π {i1,,i n } (R) {(x i 1,,x in ) (x 1,, x m ) R} 30

92 Question 1: How is π 2 (σ 1=3 (π 2 (σ 1=3 (R 1 R 2 )) R 2 )) expressed in FO? Remember: R 1,R 2 are binary Answer: x 2. ( x 1,x 4. (R 1 (x 1,x 2 ) R 2 (x 1,x 4 )) R 2 (x 2,x 5 ) ) Question 2: How is y,z. (R 1 (x,y) R 1 (y,z) x z ) expressed in RA? Remember: The signature is the same as before (R 1,R 2 binary) R 1 R 2 R 1 R 2 R 1 \ R 2 σ {i1 =j 1,,i n =j n } (R) {(x 1,, x m ) R (x i1 =x j1 ) (x in =x jn )} π {i1,,i n } (R) {(x i 1,,x in ) (x 1,, x m ) R} Answer: π 1 (σ {2=3,1 4} (R 1 R 1 )) 30

93 FO RA SQL = = Logic Algebra Programming language 31

94 over active domain on finite domains very basic FO RA SQL = = Logic Algebra Programming language 31

95 Algorithmic problems for query languages Evaluation problem: Given a query Q, a database instance db, and a tuple t, is t Q(db)? How hard is it to retrieve data? 32

96 Algorithmic problems for query languages Evaluation problem: Given a query Q, a database instance db, and a tuple t, is t Q(db)? How hard is it to retrieve data? Emptiness problem: Given a query Q, is there a database instance db so that Q(db)? Does Q make sense? Is it a contradiction? (Query optimization) 32

97 Algorithmic problems for query languages Evaluation problem: Given a query Q, a database instance db, and a tuple t, is t Q(db)? How hard is it to retrieve data? Emptiness problem: Given a query Q, is there a database instance db so that Q(db)? Does Q make sense? Is it a contradiction? (Query optimization) Equivalence problem: Given queries Q 1, Q 2, is Q 1 (db) = Q 2 (db) for all database instances db? Can we safely replace a query with another? (Query optimization) 32

98 Complexity theory What can be mechanized? decidable/undecidable How hard is it to mechanise? complexity classes 33

99 Complexity theory H s 10th Domino PCP What can be mechanized? decidable/undecidable How hard is it to mechanise? complexity classes K... 33

100 Complexity theory H s 10th Domino PCP What can be mechanized? decidable/undecidable How hard is it to mechanise? complexity classes K... usage of resources: time memory 33

101 Complexity theory H s 10th Domino PCP What can be mechanized? decidable/undecidable How hard is it to mechanise? complexity classes K... usage of resources: time memory Algorithm Alg is TIME-bounded by a function f : N N if Alg(input) uses less than f ( input ) units of TIME. 33

102 Complexity theory H s 10th Domino PCP What can be mechanized? decidable/undecidable How hard is it to mechanise? complexity classes K... usage of resources: time memory Algorithm Alg is TIME-bounded by a function f : N N if Alg(input) uses less than f ( input ) units of TIME. time input size f Alg 33

103 Complexity theory H s 10th Domino PCP What can be mechanized? decidable/undecidable How hard is it to mechanise? complexity classes K... usage of resources: time memory SPACE Algorithm Alg is TIME-bounded by a function f : N N if SPACE. Alg(input) uses less than f ( input ) units of TIME. time input size f Alg 33

104 Complexity theory H s 10th Domino PCP What can be mechanized? decidable/undecidable How hard is it to mechanise? complexity classes K... usage of resources: time memory SPACE Algorithm Alg is TIME-bounded by a function f : N N if SPACE. Alg(input) uses less than f ( input ) units of TIME. time input size f Alg LOGSPACE PTIME PSPACE EXPTIME 33

105 Complexity theory H s 10th Domino PCP What can be mechanized? decidable/undecidable How hard is it to mechanise? complexity classes K... usage of resources: time memory SPACE Algorithm Alg is TIME-bounded by a function f : N N if SPACE. Alg(input) uses less than f ( input ) units of TIME. time input size f Alg TIME-bounded by a polynomial LOGSPACE PTIME PSPACE EXPTIME SPACE-bounded by log(n) SPACE-bounded by a polynomial 33

106 Algorithmic problems for FO Evaluation problem: Given a FO formula φ(x 1,, x n ), a graph G, and a binding α, does G α φ? Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? 34

107 Algorithmic problems for FO Evaluation problem: Given a FO formula φ(x 1,, x n ), a graph G, and a binding α, does G α φ? DECIDABLE foundations of the database industry Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? 34

108 Algorithmic problems for FO Evaluation problem: Given a FO formula φ(x 1,, x n ), a graph G, and a binding α, does G α φ? DECIDABLE foundations of the database industry Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? UNDECIDABLE both for and finite Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? 34

109 Algorithmic problems for FO Evaluation problem: Given a FO formula φ(x 1,, x n ), a graph G, and a binding α, does G α φ? DECIDABLE foundations of the database industry Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? UNDECIDABLE both for and finite Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? UNDECIDABLE by reduction to the satisfiability problem 34

110 Algorithmic problems for FO Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? UNDECIDABLE both for and finite [Trakhtenbrot 50] 35

111 Algorithmic problems for FO Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? UNDECIDABLE both for and finite [Trakhtenbrot 50] Proof: By reduction from the Domino (aka Tiling) problem. 35

112 Algorithmic problems for FO Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? UNDECIDABLE both for and finite [Trakhtenbrot 50] Proof: By reduction from the Domino (aka Tiling) problem. Reduction from P to P': Algorithm that solves P using a O(1) procedure P'(x) that returns the truth value of P'(x). 35

113 The (undecidable) Domino problem Domino Input: 4-sided dominos:

114 The (undecidable) Domino problem Domino Input: 4-sided dominos: Output: Is it possible to form a white-bordered rectangle? (of any size)

115 The (undecidable) Domino problem Domino Input: 4-sided dominos: Output: Is it possible to form a white-bordered rectangle? (of any size) Rules: sides must match, you can t rotate the dominos, but you can clone them.

116 The (undecidable) Domino problem Domino - Why is it undecidable? It can easily encode halting computations of Turing machines: q 0 q q 0 0 l l l l 0 1 r r 0 0 r r 0 q q q 0 q 0 0 l l l l 1 r r r r s s

117 The (undecidable) Domino problem Domino - Why is it undecidable? It can easily encode halting computations of Turing machines: (head is elsewhere, symbol is not modified) q 0 q q 0 0 l l l l 0 1 r r 0 0 r r 0 q q q 0 q 0 0 l l l l 1 r r r r s s

118 The (undecidable) Domino problem Domino - Why is it undecidable? It can easily encode halting computations of Turing machines: r 2 r r q (head is elsewhere, symbol is not modified) 2 (head is here, symbol is rewritten, head moves right) 0 0 q 0 q q 0 0 l l l l 0 1 r r 0 0 r r 0 q q q 0 q 0 0 l l l l 1 r r r r s s

119 The (undecidable) Domino problem Domino - Why is it undecidable? It can easily encode halting computations of Turing machines: r 2 r r q 0 2 l 2 l 1 l l 2 q 0 2 (head is elsewhere, symbol is not modified) 2 (head is here, symbol is rewritten, head moves right) (head is here, symbol is rewritten, head moves left) 0 0 q 0 q q 0 0 l l l l 0 1 r r 0 0 r r 0 q q q 0 q 0 0 l l l l 1 r r r r s s

120 The (undecidable) Domino problem Domino - Why is it undecidable? It can easily encode halting computations of Turing machines: r 2 r r q 0 2 l 2 l 1 l l 2 q 0 2 (head is elsewhere, symbol is not modified) 2 s (head is here, symbol is rewritten, head moves right) (head is here, symbol is rewritten, head moves left) (initial configuration) 0 0 q 0 q q 0 0 l l l l 0 1 r r 0 0 r r 0 q q q 0 q 0 0 l l l l 1 r r r r s s

121 The (undecidable) Domino problem Domino - Why is it undecidable? It can easily encode halting computations of Turing machines: r 2 r r q 0 2 l 2 l 1 l l 2 q 0 2 (head is elsewhere, symbol is not modified) 2 s h (head is here, symbol is rewritten, head moves right) (head is here, symbol is rewritten, head moves left) (initial configuration) (halting configuration) 0 0 q 0 q q 0 0 l l l l 0 1 r r 0 0 r r 0 q q q 0 q 0 0 l l l l 1 r r r r s s

122 Domino Sat-FO (domino has a solution iff φ satisfiable) 1. There is a grid: H(, ) and V(, ) are relations representing bijections such that

123 Domino Sat-FO (domino has a solution iff φ satisfiable) 1. There is a grid: H(, ) and V(, ) are relations representing bijections such that V H

124 Domino Sat-FO (domino has a solution iff φ satisfiable) 1. There is a grid: H(, ) and V(, ) are relations representing bijections such that H V H V

125 Domino Sat-FO (domino has a solution iff φ satisfiable) 1. There is a grid: H(, ) and V(, ) are relations representing bijections such that H H H H V V V V V H V H V H H V... V V V V H H H H... V H V H V H... H V

126 Domino Sat-FO (domino has a solution iff φ satisfiable) 1. There is a grid: H(, ) and V(, ) are relations representing bijections such that H H H H V V V H H H V V V V V H V H V H H V... V V V V H H H H V H 2. Assign one domino to each node: a unary relation D ( x ) for each domino

127 Domino Sat-FO (domino has a solution iff φ satisfiable) 1. There is a grid: H(, ) and V(, ) are relations representing bijections such that H H H H V V V H H H V V V V V H V H V H H V... V V V V H H H H V H 2. Assign one domino to each node: a unary relation D ( x ) for each domino 3. Match the sides x,y if H(x,y), then D a (x) D b (y) for some dominos a,b that match horizontally (Idem vertically)

128 Domino Sat-FO (domino has a solution iff φ satisfiable) 1. There is a grid: H(, ) and V(, ) are relations representing bijections such that H H H H V V V V V V V H H H... V H V H V H H V... V V V V H H H H 4. Borders are white V H 2. Assign one domino to each node: a unary relation D ( x ) for each domino 3. Match the sides x,y if H(x,y), then D a (x) D b (y) for some dominos a,b that match horizontally (Idem vertically)

129 Algorithmic problems for FO Evaluation problem: Given a FO formula φ(x 1,, x n ), a graph G, and a binding α, does G α φ? DECIDABLE foundations of the database industry Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? UNDECIDABLE both for and finite Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? UNDECIDABLE by reduction to the satisfiability problem 39

130 Algorithmic problems for FO Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? UNDECIDABLE by reduction to the satisfiability problem 40

131 Algorithmic problems for FO φ is satisfiable iff φ is not equivalent to Satisfiability problem undecidable Equivalence problem undecidable Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? UNDECIDABLE by reduction to the satisfiability problem 40

132 Algorithmic problems for FO φ is satisfiable iff φ is not equivalent to Satisfiability problem undecidable Equivalence problem undecidable Actually, there are reductions in both senses: φ(x 1,,x n ) and ψ(y 1,,y m ) are equivalent iff n=m (x 1 =y 1 ) (x n =y n ) φ(x 1,,x n ) ψ(y 1,,y n ) is unsatisfiable (x 1 =y 1 ) (x n =y n ) ψ(x 1,,x n ) φ(y 1,,y n ) is unsatisfiable Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? UNDECIDABLE by reduction to the satisfiability problem 40

133 Algorithmic problems for FO Evaluation problem: Given a FO formula φ(x 1,, x n ), a graph G, and a binding α, does G α φ? DECIDABLE foundations of the database industry Satisfiability problem: Given a FO formula φ, is there a graph G and binding α, such that G α φ? UNDECIDABLE both for and finite Equivalence problem: Given FO formulae φ,ψ, is G α φ iff G α ψ for all graphs G and bindings α? UNDECIDABLE by reduction to the satisfiability problem 41

134 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V 42

135 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V Encoding of G = (V, E) each node is coded with a bit string of size log( V ), edge set is encoded by its tuples, e.g. (100,101), (010, 010), Cost of coding: G = E 2 log( V ) V (mod a polynomial) 42

136 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V Encoding of G = (V, E) each node is coded with a bit string of size log( V ), edge set is encoded by its tuples, e.g. (100,101), (010, 010), Cost of coding: G = E 2 log( V ) V (mod a polynomial) Encoding of α = {x 1,,x n } V each node is coded with a bit string of size log( V ), Cost of coding: α = n log( V ) 42

137 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V 43

138 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V If φ(x 1,,x n ) = E(x i,x j ): answer YES iff (α(x i ),α(x j )) E If φ(x 1,,x n ) = ψ(x 1,,x n ) ψ'(x 1,,x n ): answer YES iff G α ψ and G α ψ' If φ(x 1,,x n ) = ψ(x 1,,x n ): answer NO iff G α ψ If φ(x 1,,x n ) = y. ψ(x 1,,x n,y): answer YES iff for some v V and α'= α {y v} we have G α' ψ. 43

139 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V If φ(x 1,,x n ) = E(x i,x j ): answer YES iff (α(x i ),α(x j )) E If φ(x 1,,x n ) = ψ(x 1,,x n ) ψ'(x 1,,x n ): answer YES iff G α ψ and G α ψ' If φ(x 1,,x n ) = ψ(x 1,,x n ): answer NO iff G α ψ If φ(x 1,,x n ) = y. ψ(x 1,,x n,y): answer YES iff for some v V and α'= α {y v} we have G α' ψ. Question: How much space does it take? 43

140 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V If φ(x 1,,x n ) = E(x i,x j ): answer YES iff (α(x i ),α(x j )) E use 4 pointers LOGSPACE If φ(x 1,,x n ) = ψ(x 1,,x n ) ψ'(x 1,,x n ): answer YES iff G α ψ and G α ψ' If φ(x 1,,x n ) = ψ(x 1,,x n ): answer NO iff G α ψ If φ(x 1,,x n ) = y. ψ(x 1,,x n,y): answer YES iff for some v V and α'= α {y v} we have G α' ψ. Question: How much space does it take? 43

141 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V If φ(x 1,,x n ) = E(x i,x j ): answer YES iff (α(x i ),α(x j )) E If φ(x 1,,x n ) = ψ(x 1,,x n ) ψ'(x 1,,x n ): answer YES iff G α ψ and G α ψ' use 4 pointers LOGSPACE MAX( SPACE(G α ψ)), SPACE(G α ψ')) ) If φ(x 1,,x n ) = ψ(x 1,,x n ): answer NO iff G α ψ If φ(x 1,,x n ) = y. ψ(x 1,,x n,y): answer YES iff for some v V and α'= α {y v} we have G α' ψ. Question: How much space does it take? 43

142 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V If φ(x 1,,x n ) = E(x i,x j ): answer YES iff (α(x i ),α(x j )) E If φ(x 1,,x n ) = ψ(x 1,,x n ) ψ'(x 1,,x n ): answer YES iff G α ψ and G α ψ' If φ(x 1,,x n ) = ψ(x 1,,x n ): answer NO iff G α ψ use 4 pointers LOGSPACE MAX( SPACE(G α ψ)), SPACE(G α ψ')) ) SPACE(G α ψ)) If φ(x 1,,x n ) = y. ψ(x 1,,x n,y): answer YES iff for some v V and α'= α {y v} we have G α' ψ. Question: How much space does it take? 43

143 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V If φ(x 1,,x n ) = E(x i,x j ): answer YES iff (α(x i ),α(x j )) E If φ(x 1,,x n ) = ψ(x 1,,x n ) ψ'(x 1,,x n ): answer YES iff G α ψ and G α ψ' If φ(x 1,,x n ) = ψ(x 1,,x n ): answer NO iff G α ψ use 4 pointers LOGSPACE MAX( SPACE(G α ψ)), SPACE(G α ψ')) ) SPACE(G α ψ)) If φ(x 1,,x n ) = y. ψ(x 1,,x n,y): answer YES iff for some v V and α'= α {y v} we have G α' ψ. 2 log( G ) + SPACE(G α' ψ ) Question: How much space does it take? 43

144 Evaluation problem for FO φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V If φ(x 1,,x n ) = E(x i,x j ): answer YES iff (α(x i ),α(x j )) E If φ(x 1,,x n ) = ψ(x 1,,x n ) ψ'(x 1,,x n ): answer YES iff G α ψ and G α ψ' If φ(x 1,,x n ) = ψ(x 1,,x n ): answer NO iff G α ψ use 4 pointers LOGSPACE MAX( SPACE(G α ψ)), SPACE(G α ψ')) ) SPACE(G α ψ)) If φ(x 1,,x n ) = y. ψ(x 1,,x n,y): answer YES iff for some v V and α'= α {y v} we have G α' ψ. 2 log( G ) + SPACE(G α' ψ ) Question: 2 log( G ) log( G ) + k log( α + G ) space How much space does it take? φ times 43

145 Evaluation problem for FO in PSPACE φ(x 1,,x n ) Input: G = (V,E) Output: G α φ? α = {x 1,,x n } V If φ(x 1,,x n ) = E(x i,x j ): answer YES iff (α(x i ),α(x j )) E If φ(x 1,,x n ) = ψ(x 1,,x n ) ψ'(x 1,,x n ): answer YES iff G α ψ and G α ψ' If φ(x 1,,x n ) = ψ(x 1,,x n ): answer NO iff G α ψ use 4 pointers LOGSPACE MAX( SPACE(G α ψ)), SPACE(G α ψ')) ) SPACE(G α ψ)) If φ(x 1,,x n ) = y. ψ(x 1,,x n,y): answer YES iff for some v V and α'= α {y v} we have G α' ψ. 2 log( G ) + SPACE(G α' ψ ) Question: 2 log( G ) log( G ) + k log( α + G ) space How much space does it take? φ times 43

146 Combined, Query, and Data complexities [Vardi, 1982] Problem: Usual scenario in database A database of size 10 6 A query of size

147 Combined, Query, and Data complexities [Vardi, 1982] Problem: Usual scenario in database A database of size 10 6 A query of size 100 Input: database + query 44

148 Combined, Query, and Data complexities [Vardi, 1982] Problem: Usual scenario in database A database of size 10 6 A query of size 100 Input: database + query TIME(2 query + data ) But we don t distinguish this in the analysis: = TIME( query + 2 data ) 44

149 Combined, Query, and Data complexities [Vardi, 1982] Query and data play very different roles. Separation of concerns: How the resources grow with respect to the size of the data the query size 45

150 Combined, Query, and Data complexities Combined complexity: input size is query + data Query complexity ( data fixed): input size is query Data complexity ( query fixed): input size is data 46

151 Combined, Query, and Data complexities Combined complexity: input size is query + data Query complexity ( data fixed): input size is query Data complexity ( query fixed): input size is data O(2 query + data ) is O( query + 2 data ) is exponential in combined complexity exponential in query complexity linear in data complexity exponential in combined complexity linear in query complexity exponential in data complexity 46

152 Question What is the data, query and combined complexity for the evaluation problem for FO? Remember: data complexity, input size: data query complexity, input size: query combined complexity, input size: data + query φ 2 log( G ) + k log( α + G ) space 47

153 Question What is the data, query and combined complexity for the evaluation problem for FO? Remember: data complexity, input size: data query complexity, input size: query combined complexity, input size: data + query φ 2 log( G ) + k log( α + G ) space query data O(log( data ) query ) space PSPACE combined and query complexity LOGSPACE data complexity 47

154 Evaluation pb for FO is PSPACE-complete (combined complexity) PSPACE-complete problem: QBF (satisfaction of Quantified Boolean Formulas) QBF = a boolean formula with quantification over the truth values (T,F) 48

155 Evaluation pb for FO is PSPACE-complete (combined complexity) PSPACE-complete problem: QBF (satisfaction of Quantified Boolean Formulas) QBF = a boolean formula with quantification over the truth values (T,F) p q. (p q) where p,q range over {T,F} 48

156 Evaluation pb for FO is PSPACE-complete (combined complexity) PSPACE-complete problem: QBF (satisfaction of Quantified Boolean Formulas) QBF = a boolean formula with quantification over the truth values (T,F) p q. (p q) where p,q range over {T,F} Theorem: Evaluation for FO is PSPACE-complete (combined c.) 48

157 Evaluation pb for FO is PSPACE-complete (combined complexity) PSPACE-complete problem: QBF (satisfaction of Quantified Boolean Formulas) QBF = a boolean formula with quantification over the truth values (T,F) p q. (p q) where p,q range over {T,F} Theorem: Evaluation for FO is PSPACE-complete (combined c.) Polynomial reduction QBF FO : 1. Given ψ QBF, let ψ (x) be the replacement of each p with p=x in ψ. 2. Note: x ψ' holds in a 2-element graph iff ψ is QBF-satisfiable 3. Test if G ψ' for G=({v,v'},{}) 48

158 Evaluation pb for FO is PSPACE-complete (combined complexity) PSPACE-complete problem: QBF (satisfaction of Quantified Boolean Formulas) QBF = a boolean formula with quantification over the truth values (T,F) p q. (p q) where p,q range over {T,F} Theorem: Evaluation for FO is PSPACE-complete (combined c.) Polynomial reduction QBF FO : ψ'(x)= p q. ( (p=x) (q=x) ) 1. Given ψ QBF, let ψ (x) be the replacement of each p with p=x in ψ. 2. Note: x ψ' holds in a 2-element graph iff ψ is QBF-satisfiable 3. Test if G ψ' for G=({v,v'},{}) 48

159 Evaluation pb for FO is PSPACE-complete (combined complexity) PSPACE-complete problem: QBF (satisfaction of Quantified Boolean Formulas) QBF = a boolean formula with quantification over the truth values (T,F) p q. (p q) where p,q range over {T,F} Theorem: Evaluation for FO is PSPACE-complete (combined c.) Polynomial reduction QBF FO : ψ'(x)= p q. ( (p=x) (q=x) ) x p q. ( (p=x) (q=x) ) 1. Given ψ QBF, let ψ (x) be the replacement of each p with p=x in ψ. 2. Note: x ψ' holds in a 2-element graph iff ψ is QBF-satisfiable 3. Test if G ψ' for G=({v,v'},{}) 48

160 Recap Equivalence-RA Equivalence-SQL Domino Equivalence-FO Sat-FO Eval-FO (combined) QBF Eval-FO (data) UNDECIDABLE PSPACE LOGSPACE 49

161 Bibliography Abiteboul, Hull, Vianu, Foundations of Databases, Addison-Wesley, (freely available at Chapters 1, 2, 3 50

CMPS 277 Principles of Database Systems. Lecture #9

CMPS 277 Principles of Database Systems.  Lecture #9 CMPS 277 Principles of Database Systems http://www.soe.classes.edu/cmps277/winter10 Lecture #9 1 Summary The Query Evaluation Problem for Relational Calculus is PSPACEcomplete. The Query Equivalence Problem

More information

Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler

Database Theory VU , SS Complexity of Query Evaluation. Reinhard Pichler Database Theory Database Theory VU 181.140, SS 2018 5. Complexity of Query Evaluation Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 17 April, 2018 Pichler

More information

Computational Logic. Relational Query Languages with Negation. Free University of Bozen-Bolzano, Werner Nutt

Computational Logic. Relational Query Languages with Negation. Free University of Bozen-Bolzano, Werner Nutt Computational Logic Free University of Bozen-Bolzano, 2010 Werner Nutt (Slides adapted from Thomas Eiter and Leonid Libkin) Computational Logic 1 Queries with All Who are the directors whose movies are

More information

1 First-order logic. 1 Syntax of first-order logic. 2 Semantics of first-order logic. 3 First-order logic queries. 2 First-order query evaluation

1 First-order logic. 1 Syntax of first-order logic. 2 Semantics of first-order logic. 3 First-order logic queries. 2 First-order query evaluation Knowledge Bases and Databases Part 1: First-Order Queries Diego Calvanese Faculty of Computer Science Master of Science in Computer Science A.Y. 2007/2008 Overview of Part 1: First-order queries 1 First-order

More information

Classical First-Order Logic

Classical First-Order Logic Classical First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2008/2009 Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2008/09

More information

Overview of Topics. Finite Model Theory. Finite Model Theory. Connections to Database Theory. Qing Wang

Overview of Topics. Finite Model Theory. Finite Model Theory. Connections to Database Theory. Qing Wang Overview of Topics Finite Model Theory Part 1: Introduction 1 What is finite model theory? 2 Connections to some areas in CS Qing Wang qing.wang@anu.edu.au Database theory Complexity theory 3 Basic definitions

More information

Query answering using views

Query answering using views Query answering using views General setting: database relations R 1,...,R n. Several views V 1,...,V k are defined as results of queries over the R i s. We have a query Q over R 1,...,R n. Question: Can

More information

GAV-sound with conjunctive queries

GAV-sound with conjunctive queries GAV-sound with conjunctive queries Source and global schema as before: source R 1 (A, B),R 2 (B,C) Global schema: T 1 (A, C), T 2 (B,C) GAV mappings become sound: T 1 {x, y, z R 1 (x,y) R 2 (y,z)} T 2

More information

1 PSPACE-Completeness

1 PSPACE-Completeness CS 6743 Lecture 14 1 Fall 2007 1 PSPACE-Completeness Recall the NP-complete problem SAT: Is a given Boolean formula φ(x 1,..., x n ) satisfiable? The same question can be stated equivalently as: Is the

More information

Finite Model Theory: First-Order Logic on the Class of Finite Models

Finite Model Theory: First-Order Logic on the Class of Finite Models 1 Finite Model Theory: First-Order Logic on the Class of Finite Models Anuj Dawar University of Cambridge Modnet Tutorial, La Roche, 21 April 2008 2 Finite Model Theory In the 1980s, the term finite model

More information

About the relationship between formal logic and complexity classes

About the relationship between formal logic and complexity classes About the relationship between formal logic and complexity classes Working paper Comments welcome; my email: armandobcm@yahoo.com Armando B. Matos October 20, 2013 1 Introduction We analyze a particular

More information

From Constructibility and Absoluteness to Computability and Domain Independence

From Constructibility and Absoluteness to Computability and Domain Independence From Constructibility and Absoluteness to Computability and Domain Independence Arnon Avron School of Computer Science Tel Aviv University, Tel Aviv 69978, Israel aa@math.tau.ac.il Abstract. Gödel s main

More information

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms

First-Order Logic. 1 Syntax. Domain of Discourse. FO Vocabulary. Terms First-Order Logic 1 Syntax Domain of Discourse The domain of discourse for first order logic is FO structures or models. A FO structure contains Relations Functions Constants (functions of arity 0) FO

More information

The Query Containment Problem: Set Semantics vs. Bag Semantics. Phokion G. Kolaitis University of California Santa Cruz & IBM Research - Almaden

The Query Containment Problem: Set Semantics vs. Bag Semantics. Phokion G. Kolaitis University of California Santa Cruz & IBM Research - Almaden The Query Containment Problem: Set Semantics vs. Bag Semantics Phokion G. Kolaitis University of California Santa Cruz & IBM Research - Almaden PROBLEMS Problems worthy of attack prove their worth by hitting

More information

Foundations of Query Languages

Foundations of Query Languages Foundations of Query Languages SS 2011 2. 2. Foundations of Query Languages Dr. Fang Wei Lehrstuhl für Datenbanken und Informationssysteme Universität Freiburg SS 2011 Dr. Fang Wei 30. Mai 2011 Seite 1

More information

Classical First-Order Logic

Classical First-Order Logic Classical First-Order Logic Software Formal Verification Maria João Frade Departmento de Informática Universidade do Minho 2009/2010 Maria João Frade (DI-UM) First-Order Logic (Classical) MFES 2009/10

More information

Logics with Counting. Ian Pratt-Hartmann School of Computer Science University of Manchester Manchester M13 9PL, UK

Logics with Counting. Ian Pratt-Hartmann School of Computer Science University of Manchester Manchester M13 9PL, UK Logics with Counting Ian Pratt-Hartmann School of Computer Science University of Manchester Manchester M13 9PL, UK 2 Chapter 1 Introduction It is well-known that first-order logic is able to express facts

More information

Database Theory VU , SS Ehrenfeucht-Fraïssé Games. Reinhard Pichler

Database Theory VU , SS Ehrenfeucht-Fraïssé Games. Reinhard Pichler Database Theory Database Theory VU 181.140, SS 2018 7. Ehrenfeucht-Fraïssé Games Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 15 May, 2018 Pichler 15

More information

Algorithmic Model Theory SS 2016

Algorithmic Model Theory SS 2016 Algorithmic Model Theory SS 2016 Prof. Dr. Erich Grädel and Dr. Wied Pakusa Mathematische Grundlagen der Informatik RWTH Aachen cbnd This work is licensed under: http://creativecommons.org/licenses/by-nc-nd/3.0/de/

More information

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65 Undecidable Problems Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, 2018 1/ 65 Algorithmically Solvable Problems Let us assume we have a problem P. If there is an algorithm solving

More information

Finite Model Theory and Descriptive Complexity

Finite Model Theory and Descriptive Complexity 3 Finite Model Theory and Descriptive Complexity Erich Grädel This chapter deals with the relationship between logical definability and computational complexity on finite structures. Particular emphasis

More information

if t 1,...,t k Terms and P k is a k-ary predicate, then P k (t 1,...,t k ) Formulas (atomic formulas)

if t 1,...,t k Terms and P k is a k-ary predicate, then P k (t 1,...,t k ) Formulas (atomic formulas) FOL Query Evaluation Giuseppe De Giacomo Università di Roma La Sapienza Corso di Seminari di Ingegneria del Software: Data and Service Integration Laurea Specialistica in Ingegneria Informatica Università

More information

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas.

3. Only sequences that were formed by using finitely many applications of rules 1 and 2, are propositional formulas. 1 Chapter 1 Propositional Logic Mathematical logic studies correct thinking, correct deductions of statements from other statements. Let us make it more precise. A fundamental property of a statement is

More information

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler Complexity Theory Complexity Theory VU 181.142, SS 2018 6. The Polynomial Hierarchy Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität Wien 15 May, 2018 Reinhard

More information

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181. Complexity Theory Complexity Theory Outline Complexity Theory VU 181.142, SS 2018 6. The Polynomial Hierarchy Reinhard Pichler Institut für Informationssysteme Arbeitsbereich DBAI Technische Universität

More information

A Little Logic. Propositional Logic. Satisfiability Problems. Solving Sudokus. First Order Logic. Logic Programming

A Little Logic. Propositional Logic. Satisfiability Problems. Solving Sudokus. First Order Logic. Logic Programming A Little Logic International Center for Computational Logic Technische Universität Dresden Germany Propositional Logic Satisfiability Problems Solving Sudokus First Order Logic Logic Programming A Little

More information

Bounded Query Rewriting Using Views

Bounded Query Rewriting Using Views Bounded Query Rewriting Using Views Yang Cao 1,3 Wenfei Fan 1,3 Floris Geerts 2 Ping Lu 3 1 University of Edinburgh 2 University of Antwerp 3 Beihang University {wenfei@inf, Y.Cao-17@sms}.ed.ac.uk, floris.geerts@uantwerpen.be,

More information

CMPS 217 Logic in Computer Science. Lecture #17

CMPS 217 Logic in Computer Science.   Lecture #17 CMPS 217 Logic in Computer Science https://courses.soe.ucsc.edu/courses/cmps217/spring13/01 Lecture #17 1 The Complexity of FO-Truth on a Structure Structure A Complexity of Th(A) Structure of the natural

More information

Predicate Calculus. Formal Methods in Verification of Computer Systems Jeremy Johnson

Predicate Calculus. Formal Methods in Verification of Computer Systems Jeremy Johnson Predicate Calculus Formal Methods in Verification of Computer Systems Jeremy Johnson Outline 1. Motivation 1. Variables, quantifiers and predicates 2. Syntax 1. Terms and formulas 2. Quantifiers, scope

More information

Infinite and Finite Model Theory Part II

Infinite and Finite Model Theory Part II Infinite and Finite Model Theory Part II Anuj Dawar Computer Laboratory University of Cambridge Lent 2002 3/2002 0 Finite Model Theory Finite Model Theory motivated by computational issues; relationship

More information

An introduction to Parameterized Complexity Theory

An introduction to Parameterized Complexity Theory An introduction to Parameterized Complexity Theory May 15, 2012 A motivation to parametrize Definitions Standard Complexity Theory does not distinguish between the distinct parts of the input. It categorizes

More information

Predicate Calculus. CS 270 Math Foundations of Computer Science Jeremy Johnson

Predicate Calculus. CS 270 Math Foundations of Computer Science Jeremy Johnson Predicate Calculus CS 270 Math Foundations of Computer Science Jeremy Johnson Presentation uses material from Huth and Ryan, Logic in Computer Science: Modelling and Reasoning about Systems, 2nd Edition

More information

The semijoin algebra and the guarded fragment

The semijoin algebra and the guarded fragment The semijoin algebra and the guarded fragment Dirk Leinders (dirk.leinders@luc.ac.be) Limburgs Universitair Centrum, Universitaire Campus, Diepenbeek, Belgium Maarten Marx (marx@science.uva.nl) Informatics

More information

Logarithmic space. Evgenij Thorstensen V18. Evgenij Thorstensen Logarithmic space V18 1 / 18

Logarithmic space. Evgenij Thorstensen V18. Evgenij Thorstensen Logarithmic space V18 1 / 18 Logarithmic space Evgenij Thorstensen V18 Evgenij Thorstensen Logarithmic space V18 1 / 18 Journey below Unlike for time, it makes sense to talk about sublinear space. This models computations on input

More information

Lecturecise 22 Weak monadic second-order theory of one successor (WS1S)

Lecturecise 22 Weak monadic second-order theory of one successor (WS1S) Lecturecise 22 Weak monadic second-order theory of one successor (WS1S) 2013 Reachability in the Heap Many programs manipulate linked data structures (lists, trees). To express many important properties

More information

Finite Model Theory and CSPs

Finite Model Theory and CSPs Finite Model Theory and CSPs Albert Atserias Universitat Politècnica de Catalunya Barcelona, Spain June 19, 2007 Part I FIRST-ORDER LOGIC, TYPES AND GAMES Relational Structures vs. Functional Structures

More information

7 RC Simulates RA. Lemma: For every RA expression E(A 1... A k ) there exists a DRC formula F with F V (F ) = {A 1,..., A k } and

7 RC Simulates RA. Lemma: For every RA expression E(A 1... A k ) there exists a DRC formula F with F V (F ) = {A 1,..., A k } and 7 RC Simulates RA. We now show that DRC (and hence TRC) is at least as expressive as RA. That is, given an RA expression E that mentions at most C, there is an equivalent DRC expression E that mentions

More information

Lecture 8: Complete Problems for Other Complexity Classes

Lecture 8: Complete Problems for Other Complexity Classes IAS/PCMI Summer Session 2000 Clay Mathematics Undergraduate Program Basic Course on Computational Complexity Lecture 8: Complete Problems for Other Complexity Classes David Mix Barrington and Alexis Maciel

More information

Theory of Computation

Theory of Computation Theory of Computation Dr. Sarmad Abbasi Dr. Sarmad Abbasi () Theory of Computation / Lecture 3: Overview Decidability of Logical Theories Presburger arithmetic Decidability of Presburger Arithmetic Dr.

More information

Propositional and Predicate Logic - VII

Propositional and Predicate Logic - VII Propositional and Predicate Logic - VII Petr Gregor KTIML MFF UK WS 2015/2016 Petr Gregor (KTIML MFF UK) Propositional and Predicate Logic - VII WS 2015/2016 1 / 11 Theory Validity in a theory A theory

More information

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k.

P is the class of problems for which there are algorithms that solve the problem in time O(n k ) for some constant k. Complexity Theory Problems are divided into complexity classes. Informally: So far in this course, almost all algorithms had polynomial running time, i.e., on inputs of size n, worst-case running time

More information

Umans Complexity Theory Lectures

Umans Complexity Theory Lectures Umans Complexity Theory Lectures Lecture 12: The Polynomial-Time Hierarchy Oracle Turing Machines Oracle Turing Machine (OTM): Deterministic multitape TM M with special query tape special states q?, q

More information

Abstract model theory for extensions of modal logic

Abstract model theory for extensions of modal logic Abstract model theory for extensions of modal logic Balder ten Cate Stanford, May 13, 2008 Largely based on joint work with Johan van Benthem and Jouko Väänänen Balder ten Cate Abstract model theory for

More information

Friendly Logics, Fall 2015, Lecture Notes 1

Friendly Logics, Fall 2015, Lecture Notes 1 Friendly Logics, Fall 2015, Lecture Notes 1 Val Tannen 1 Some references Course Web Page: http://www.cis.upenn.edu/~val/cis682. I have posted there the remarkable On the Unusual Effectiveness of Logic

More information

COMP 409: Logic Homework 5

COMP 409: Logic Homework 5 COMP 409: Logic Homework 5 Note: The pages below refer to the text from the book by Enderton. 1. Exercises 1-6 on p. 78. 1. Translate into this language the English sentences listed below. If the English

More information

On the Satisfiability of Two-Variable Logic over Data Words

On the Satisfiability of Two-Variable Logic over Data Words On the Satisfiability of Two-Variable Logic over Data Words Claire David, Leonid Libkin, and Tony Tan School of Informatics, University of Edinburgh Abstract. Data trees and data words have been studied

More information

Preliminaries. Introduction to EF-games. Inexpressivity results for first-order logic. Normal forms for first-order logic

Preliminaries. Introduction to EF-games. Inexpressivity results for first-order logic. Normal forms for first-order logic Introduction to EF-games Inexpressivity results for first-order logic Normal forms for first-order logic Algorithms and complexity for specific classes of structures General complexity bounds Preliminaries

More information

Lecture 12: Mapping Reductions

Lecture 12: Mapping Reductions Lecture 12: Mapping Reductions October 18, 2016 CS 1010 Theory of Computation Topics Covered 1. The Language EQ T M 2. Mapping Reducibility 3. The Post Correspondence Problem 1 The Language EQ T M The

More information

Handbook of Logic and Proof Techniques for Computer Science

Handbook of Logic and Proof Techniques for Computer Science Steven G. Krantz Handbook of Logic and Proof Techniques for Computer Science With 16 Figures BIRKHAUSER SPRINGER BOSTON * NEW YORK Preface xvii 1 Notation and First-Order Logic 1 1.1 The Use of Connectives

More information

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem.

an efficient procedure for the decision problem. We illustrate this phenomenon for the Satisfiability problem. 1 More on NP In this set of lecture notes, we examine the class NP in more detail. We give a characterization of NP which justifies the guess and verify paradigm, and study the complexity of solving search

More information

CS154, Lecture 17: conp, Oracles again, Space Complexity

CS154, Lecture 17: conp, Oracles again, Space Complexity CS154, Lecture 17: conp, Oracles again, Space Complexity Definition: conp = { L L NP } What does a conp computation look like? In NP algorithms, we can use a guess instruction in pseudocode: Guess string

More information

Linear-time Temporal Logic

Linear-time Temporal Logic Linear-time Temporal Logic Pedro Cabalar Department of Computer Science University of Corunna, SPAIN cabalar@udc.es 2015/2016 P. Cabalar ( Department Linear oftemporal Computer Logic Science University

More information

Comp487/587 - Boolean Formulas

Comp487/587 - Boolean Formulas Comp487/587 - Boolean Formulas 1 Logic and SAT 1.1 What is a Boolean Formula Logic is a way through which we can analyze and reason about simple or complicated events. In particular, we are interested

More information

Peter Wood. Department of Computer Science and Information Systems Birkbeck, University of London Automata and Formal Languages

Peter Wood. Department of Computer Science and Information Systems Birkbeck, University of London Automata and Formal Languages and and Department of Computer Science and Information Systems Birkbeck, University of London ptw@dcs.bbk.ac.uk Outline and Doing and analysing problems/languages computability/solvability/decidability

More information

The Complexity of Computing the Behaviour of Lattice Automata on Infinite Trees

The Complexity of Computing the Behaviour of Lattice Automata on Infinite Trees The Complexity of Computing the Behaviour of Lattice Automata on Infinite Trees Karsten Lehmann a, Rafael Peñaloza b a Optimisation Research Group, NICTA Artificial Intelligence Group, Australian National

More information

Notes on Satisfiability-Based Problem Solving. First Order Logic. David Mitchell October 23, 2013

Notes on Satisfiability-Based Problem Solving. First Order Logic. David Mitchell October 23, 2013 Notes on Satisfiability-Based Problem Solving First Order Logic David Mitchell mitchell@cs.sfu.ca October 23, 2013 Preliminary draft. Please do not distribute. Corrections and suggestions welcome. In this

More information

Overview. CS389L: Automated Logical Reasoning. Lecture 7: Validity Proofs and Properties of FOL. Motivation for semantic argument method

Overview. CS389L: Automated Logical Reasoning. Lecture 7: Validity Proofs and Properties of FOL. Motivation for semantic argument method Overview CS389L: Automated Logical Reasoning Lecture 7: Validity Proofs and Properties of FOL Agenda for today: Semantic argument method for proving FOL validity Işıl Dillig Important properties of FOL

More information

A Dichotomy. in in Probabilistic Databases. Joint work with Robert Fink. for Non-Repeating Queries with Negation Queries with Negation

A Dichotomy. in in Probabilistic Databases. Joint work with Robert Fink. for Non-Repeating Queries with Negation Queries with Negation Dichotomy for Non-Repeating Queries with Negation Queries with Negation in in Probabilistic Databases Robert Dan Olteanu Fink and Dan Olteanu Joint work with Robert Fink Uncertainty in Computation Simons

More information

CHAPTER 2. FIRST ORDER LOGIC

CHAPTER 2. FIRST ORDER LOGIC CHAPTER 2. FIRST ORDER LOGIC 1. Introduction First order logic is a much richer system than sentential logic. Its interpretations include the usual structures of mathematics, and its sentences enable us

More information

Non-Approximability Results (2 nd part) 1/19

Non-Approximability Results (2 nd part) 1/19 Non-Approximability Results (2 nd part) 1/19 Summary - The PCP theorem - Application: Non-approximability of MAXIMUM 3-SAT 2/19 Non deterministic TM - A TM where it is possible to associate more than one

More information

A.Antonopoulos 18/1/2010

A.Antonopoulos 18/1/2010 Class DP Basic orems 18/1/2010 Class DP Basic orems 1 Class DP 2 Basic orems Class DP Basic orems TSP Versions 1 TSP (D) 2 EXACT TSP 3 TSP COST 4 TSP (1) P (2) P (3) P (4) DP Class Class DP Basic orems

More information

CSE200: Computability and complexity Space Complexity

CSE200: Computability and complexity Space Complexity CSE200: Computability and complexity Space Complexity Shachar Lovett January 29, 2018 1 Space complexity We would like to discuss languages that may be determined in sub-linear space. Lets first recall

More information

6.5.3 An NP-complete domino game

6.5.3 An NP-complete domino game 26 Chapter 6. Complexity Theory 3SAT NP. We know from Theorem 6.5.7 that this is true. A P 3SAT, for every language A NP. Hence, we have to show this for languages A such as kcolor, HC, SOS, NPrim, KS,

More information

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P.

Syntax. Notation Throughout, and when not otherwise said, we assume a vocabulary V = C F P. First-Order Logic Syntax The alphabet of a first-order language is organised into the following categories. Logical connectives:,,,,, and. Auxiliary symbols:.,,, ( and ). Variables: we assume a countable

More information

JASS 06 Report Summary. Circuit Complexity. Konstantin S. Ushakov. May 14, 2006

JASS 06 Report Summary. Circuit Complexity. Konstantin S. Ushakov. May 14, 2006 JASS 06 Report Summary Circuit Complexity Konstantin S. Ushakov May 14, 2006 Abstract Computer science deals with many computational models. In real life we have normal computers that are constructed using,

More information

Tecniche di Verifica. Introduction to Propositional Logic

Tecniche di Verifica. Introduction to Propositional Logic Tecniche di Verifica Introduction to Propositional Logic 1 Logic A formal logic is defined by its syntax and semantics. Syntax An alphabet is a set of symbols. A finite sequence of these symbols is called

More information

University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter

University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter University of Aberdeen, Computing Science CS2013 Predicate Logic 4 Kees van Deemter 01/11/16 Kees van Deemter 1 First-Order Predicate Logic (FOPL) Lecture 4 Making numerical statements: >0, 1,>2,1,2

More information

Lecture 2: Syntax. January 24, 2018

Lecture 2: Syntax. January 24, 2018 Lecture 2: Syntax January 24, 2018 We now review the basic definitions of first-order logic in more detail. Recall that a language consists of a collection of symbols {P i }, each of which has some specified

More information

Logic: The Big Picture

Logic: The Big Picture Logic: The Big Picture A typical logic is described in terms of syntax: what are the legitimate formulas semantics: under what circumstances is a formula true proof theory/ axiomatization: rules for proving

More information

uring Reducibility Dept. of Computer Sc. & Engg., IIT Kharagpur 1 Turing Reducibility

uring Reducibility Dept. of Computer Sc. & Engg., IIT Kharagpur 1 Turing Reducibility uring Reducibility Dept. of Computer Sc. & Engg., IIT Kharagpur 1 Turing Reducibility uring Reducibility Dept. of Computer Sc. & Engg., IIT Kharagpur 2 FINITE We have already seen that the language FINITE

More information

Complete problems for classes in PH, The Polynomial-Time Hierarchy (PH) oracle is like a subroutine, or function in

Complete problems for classes in PH, The Polynomial-Time Hierarchy (PH) oracle is like a subroutine, or function in Oracle Turing Machines Nondeterministic OTM defined in the same way (transition relation, rather than function) oracle is like a subroutine, or function in your favorite PL but each call counts as single

More information

MTAT Complexity Theory October 13th-14th, Lecture 6

MTAT Complexity Theory October 13th-14th, Lecture 6 MTAT.07.004 Complexity Theory October 13th-14th, 2011 Lecturer: Peeter Laud Lecture 6 Scribe(s): Riivo Talviste 1 Logarithmic memory Turing machines working in logarithmic space become interesting when

More information

Algorithmic Meta-Theorems

Algorithmic Meta-Theorems Algorithmic Meta-Theorems Stephan Kreutzer Oxford University Computing Laboratory stephan.kreutzer@comlab.ox.ac.uk Abstract. Algorithmic meta-theorems are general algorithmic results applying to a whole

More information

First-Order Logic (FOL)

First-Order Logic (FOL) First-Order Logic (FOL) Also called Predicate Logic or Predicate Calculus 2. First-Order Logic (FOL) FOL Syntax variables x, y, z, constants a, b, c, functions f, g, h, terms variables, constants or n-ary

More information

Expressiveness of predicate logic: Some motivation

Expressiveness of predicate logic: Some motivation Expressiveness of predicate logic: Some motivation In computer science the analysis of the expressiveness of predicate logic (a.k.a. first-order logic) is of particular importance, for instance In database

More information

CS154, Lecture 10: Rice s Theorem, Oracle Machines

CS154, Lecture 10: Rice s Theorem, Oracle Machines CS154, Lecture 10: Rice s Theorem, Oracle Machines Moral: Analyzing Programs is Really, Really Hard But can we more easily tell when some program analysis problem is undecidable? Problem 1 Undecidable

More information

SOLUTION: SOLUTION: SOLUTION:

SOLUTION: SOLUTION: SOLUTION: Convert R and S into nondeterministic finite automata N1 and N2. Given a string s, if we know the states N1 and N2 may reach when s[1...i] has been read, we are able to derive the states N1 and N2 may

More information

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel

Propositional Logic. Testing, Quality Assurance, and Maintenance Winter Prof. Arie Gurfinkel Propositional Logic Testing, Quality Assurance, and Maintenance Winter 2018 Prof. Arie Gurfinkel References Chpater 1 of Logic for Computer Scientists http://www.springerlink.com/content/978-0-8176-4762-9/

More information

03 Review of First-Order Logic

03 Review of First-Order Logic CAS 734 Winter 2014 03 Review of First-Order Logic William M. Farmer Department of Computing and Software McMaster University 18 January 2014 What is First-Order Logic? First-order logic is the study of

More information

1 CHAPTER 1 INTRODUCTION 1.1 Background One branch of the study of descriptive complexity aims at characterizing complexity classes according to the l

1 CHAPTER 1 INTRODUCTION 1.1 Background One branch of the study of descriptive complexity aims at characterizing complexity classes according to the l viii CONTENTS ABSTRACT IN ENGLISH ABSTRACT IN TAMIL LIST OF TABLES LIST OF FIGURES iii v ix x 1 INTRODUCTION 1 1.1 Background : : : : : : : : : : : : : : : : : : : : : : : : : : : : 1 1.2 Preliminaries

More information

PREDICATE LOGIC: UNDECIDABILITY AND INCOMPLETENESS HUTH AND RYAN 2.5, SUPPLEMENTARY NOTES 2

PREDICATE LOGIC: UNDECIDABILITY AND INCOMPLETENESS HUTH AND RYAN 2.5, SUPPLEMENTARY NOTES 2 PREDICATE LOGIC: UNDECIDABILITY AND INCOMPLETENESS HUTH AND RYAN 2.5, SUPPLEMENTARY NOTES 2 Neil D. Jones DIKU 2005 14 September, 2005 Some slides today new, some based on logic 2004 (Nils Andersen) OUTLINE,

More information

Computability and Complexity Theory

Computability and Complexity Theory Discrete Math for Bioinformatics WS 09/10:, by A Bockmayr/K Reinert, January 27, 2010, 18:39 9001 Computability and Complexity Theory Computability and complexity Computability theory What problems can

More information

CS6901: review of Theory of Computation and Algorithms

CS6901: review of Theory of Computation and Algorithms CS6901: review of Theory of Computation and Algorithms Any mechanically (automatically) discretely computation of problem solving contains at least three components: - problem description - computational

More information

Finite and Algorithmic Model Theory II: Automata-Based Methods

Finite and Algorithmic Model Theory II: Automata-Based Methods Finite and Algorithmic Model Theory II: Automata-Based Methods Anuj Dawar University of Cambridge Computer Laboratory Simons Institute, 30 August 2016 Review We aim to develop tools for studying the expressive

More information

Complexity. Complexity Theory Lecture 3. Decidability and Complexity. Complexity Classes

Complexity. Complexity Theory Lecture 3. Decidability and Complexity. Complexity Classes Complexity Theory 1 Complexity Theory 2 Complexity Theory Lecture 3 Complexity For any function f : IN IN, we say that a language L is in TIME(f(n)) if there is a machine M = (Q, Σ, s, δ), such that: L

More information

Locality of Counting Logics

Locality of Counting Logics Locality of Counting Logics Dietrich Kuske Technische Universität Ilmenau 1/22 Example 1 Can a first-order formula distinguish the following two graphs? vs. no, but why? Hanf (1965): every single-centered

More information

INAPPROX APPROX PTAS. FPTAS Knapsack P

INAPPROX APPROX PTAS. FPTAS Knapsack P CMPSCI 61: Recall From Last Time Lecture 22 Clique TSP INAPPROX exists P approx alg for no ε < 1 VertexCover MAX SAT APPROX TSP some but not all ε< 1 PTAS all ε < 1 ETSP FPTAS Knapsack P poly in n, 1/ε

More information

Model Theory on Finite Structures

Model Theory on Finite Structures Model Theory on Finite Structures Anuj Dawar Department of Computer Science University of Wales Swansea Swansea, SA2 8PP, U.K. e-mail: a.dawar@swansea.ac.uk 1 Introduction In mathematical logic, the notions

More information

Parameterized Regular Expressions and Their Languages

Parameterized Regular Expressions and Their Languages Parameterized Regular Expressions and Their Languages Pablo Barceló a, Juan Reutter b, Leonid Libkin b a Department of Computer Science, University of Chile b School of Informatics, University of Edinburgh

More information

Relational Calculus. Dr Paolo Guagliardo. University of Edinburgh. Fall 2016

Relational Calculus. Dr Paolo Guagliardo. University of Edinburgh. Fall 2016 Relational Calculus Dr Paolo Guagliardo University of Edinburgh Fall 2016 First-order logic term t := x (variable) c (constant) f(t 1,..., t n ) (function application) formula ϕ := P (t 1,..., t n ) t

More information

Datalog and Constraint Satisfaction with Infinite Templates

Datalog and Constraint Satisfaction with Infinite Templates Datalog and Constraint Satisfaction with Infinite Templates Manuel Bodirsky 1 and Víctor Dalmau 2 1 CNRS/LIX, École Polytechnique, bodirsky@lix.polytechnique.fr 2 Universitat Pompeu Fabra, victor.dalmau@upf.edu

More information

Chapter 4: Classical Propositional Semantics

Chapter 4: Classical Propositional Semantics Chapter 4: Classical Propositional Semantics Language : L {,,, }. Classical Semantics assumptions: TWO VALUES: there are only two logical values: truth (T) and false (F), and EXTENSIONALITY: the logical

More information

Relations to first order logic

Relations to first order logic An Introduction to Description Logic IV Relations to first order logic Marco Cerami Palacký University in Olomouc Department of Computer Science Olomouc, Czech Republic Olomouc, November 6 th 2014 Marco

More information

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19

PROPOSITIONAL LOGIC. VL Logik: WS 2018/19 PROPOSITIONAL LOGIC VL Logik: WS 2018/19 (Version 2018.2) Martina Seidl (martina.seidl@jku.at), Armin Biere (biere@jku.at) Institut für Formale Modelle und Verifikation BOX Game: Rules 1. The game board

More information

Lecture Notes: The Halting Problem; Reductions

Lecture Notes: The Halting Problem; Reductions Lecture Notes: The Halting Problem; Reductions COMS W3261 Columbia University 20 Mar 2012 1 Review Key point. Turing machines can be encoded as strings, and other Turing machines can read those strings

More information

THE problem of updating a database through a set

THE problem of updating a database through a set FULL VERSION WITH COMPLETE PROOFS 1 Lossless Selection Views under Conditional Domain Constraints Ingo Feinerer, Enrico Franconi and Paolo Guagliardo name suggests, prescribes how a database relation can

More information

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch

6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch 6.045: Automata, Computability, and Complexity (GITCS) Class 15 Nancy Lynch Today: More Complexity Theory Polynomial-time reducibility, NP-completeness, and the Satisfiability (SAT) problem Topics: Introduction

More information

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete

9. PSPACE. PSPACE complexity class quantified satisfiability planning problem PSPACE-complete 9. PSPACE PSPACE complexity class quantified satisfiability planning problem PSPACE-complete Lecture slides by Kevin Wayne Copyright 2005 Pearson-Addison Wesley Copyright 2013 Kevin Wayne http://www.cs.princeton.edu/~wayne/kleinberg-tardos

More information

Automata Theory CS Complexity Theory I: Polynomial Time

Automata Theory CS Complexity Theory I: Polynomial Time Automata Theory CS411-2015-17 Complexity Theory I: Polynomial Time David Galles Department of Computer Science University of San Francisco 17-0: Tractable vs. Intractable If a problem is recursive, then

More information

CS 6505, Complexity and Algorithms Week 7: NP Completeness

CS 6505, Complexity and Algorithms Week 7: NP Completeness CS 6505, Complexity and Algorithms Week 7: NP Completeness Reductions We have seen some problems in P and NP, and we ve talked about space complexity. The Space Hierarchy Theorem showed us that there are

More information