Graphical Conjunctive Queries A completeness theorem for Cartesian - - PowerPoint PPT Presentation

graphical conjunctive queries
SMART_READER_LITE
LIVE PREVIEW

Graphical Conjunctive Queries A completeness theorem for Cartesian - - PowerPoint PPT Presentation

Graphical Conjunctive Queries A completeness theorem for Cartesian bicategories Filippo Bonchi, Jens Seeber , Pawe l Soboci nski IMT School for Advanced Studies Lucca Birmingham - 21 st September, 2018 Contents 1 Cartesian bicategories 2


slide-1
SLIDE 1

Graphical Conjunctive Queries

A completeness theorem for Cartesian bicategories Filippo Bonchi, Jens Seeber, Pawe l Soboci´ nski

IMT School for Advanced Studies Lucca

Birmingham - 21st September, 2018

slide-2
SLIDE 2

Contents

1 Cartesian bicategories 2 Conjunctive queries 3 Completeness 4 Summary

slide-3
SLIDE 3

String diagrams

  • A graphical way of reasoning about monoidal categories
slide-4
SLIDE 4

String diagrams

  • A graphical way of reasoning about monoidal categories
  • 2-dimensional diagrams manipulated according to algebraic

rules – hot research topic

slide-5
SLIDE 5

String diagrams

  • A graphical way of reasoning about monoidal categories
  • 2-dimensional diagrams manipulated according to algebraic

rules – hot research topic

  • ZX calculus (Coecke, Duncan)
slide-6
SLIDE 6

String diagrams

  • A graphical way of reasoning about monoidal categories
  • 2-dimensional diagrams manipulated according to algebraic

rules – hot research topic

  • ZX calculus (Coecke, Duncan)
  • Signal flow graphs (Bonchi, Sobocinski, Zanasi)
slide-7
SLIDE 7

String diagrams

  • A graphical way of reasoning about monoidal categories
  • 2-dimensional diagrams manipulated according to algebraic

rules – hot research topic

  • ZX calculus (Coecke, Duncan)
  • Signal flow graphs (Bonchi, Sobocinski, Zanasi)
  • Monoidal computer (Pavlovic)
slide-8
SLIDE 8

String diagrams

  • A graphical way of reasoning about monoidal categories
  • 2-dimensional diagrams manipulated according to algebraic

rules – hot research topic

  • ZX calculus (Coecke, Duncan)
  • Signal flow graphs (Bonchi, Sobocinski, Zanasi)
  • Monoidal computer (Pavlovic)
  • . . .
slide-9
SLIDE 9

Relations with string diagrams

The category Rel of sets with relations as morphisms

slide-10
SLIDE 10

Relations with string diagrams

The category Rel of sets with relations as morphisms

  • forms a symmetric monoidal category:
slide-11
SLIDE 11

Relations with string diagrams

The category Rel of sets with relations as morphisms

  • forms a symmetric monoidal category:

R1 ⊗ R2 = {((a, b), (c, d)) | (a, c) ∈ R1, (b, d) ∈ R2}

R1

a c

R2

b d

slide-12
SLIDE 12

Relations with string diagrams

The category Rel of sets with relations as morphisms

  • forms a symmetric monoidal category:

R1 ⊗ R2 = {((a, b), (c, d)) | (a, c) ∈ R1, (b, d) ∈ R2}

R1

a c

R2

b d

  • Composition:

R1 ; R2 = {(x, z) | ∃y : (x, y) ∈ R1, (y, z) ∈ R2}

R1 R2

x y z

slide-13
SLIDE 13

Relations with string diagrams

  • Relations are ordered by inclusion
slide-14
SLIDE 14

Relations with string diagrams

  • Relations are ordered by inclusion
  • Every object:
slide-15
SLIDE 15

Relations with string diagrams

  • Relations are ordered by inclusion
  • Every object:
  • Copying and discarding
slide-16
SLIDE 16

Relations with string diagrams

  • Relations are ordered by inclusion
  • Every object:
  • Copying and discarding

,

slide-17
SLIDE 17

Relations with string diagrams

  • Relations are ordered by inclusion
  • Every object:
  • Copying and discarding

,

  • Equality and “spawn”
slide-18
SLIDE 18

Relations with string diagrams

  • Relations are ordered by inclusion
  • Every object:
  • Copying and discarding

,

  • Equality and “spawn”

,

slide-19
SLIDE 19

Observations

Comonoid

= = = =

slide-20
SLIDE 20

Observations

Comonoid

= = = =

Monoid

= = = =

slide-21
SLIDE 21

Observations

Comonoid

= = = =

Monoid

= = = =

Frobenius

= =

slide-22
SLIDE 22

Observations

Comonoid

= = = =

Monoid

= = = =

Frobenius

= =

Adjointness

≤ ≤ ≤ ≤

slide-23
SLIDE 23

Observations

Comonoid

= = = =

Monoid

= = = =

Frobenius

= =

Adjointness

≤ ≤ ≤ ≤

Lax Comonoid homomorphism

R

R R R

slide-24
SLIDE 24

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory

slide-25
SLIDE 25

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered

slide-26
SLIDE 26

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category

slide-27
SLIDE 27

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

slide-28
SLIDE 28

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

  • a comonoid
slide-29
SLIDE 29

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

  • a comonoid
  • a monoid
slide-30
SLIDE 30

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

  • a comonoid
  • a monoid

satisfying coherence

slide-31
SLIDE 31

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

  • a comonoid
  • a monoid

satisfying coherence and the laws on the last slide.

slide-32
SLIDE 32

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

  • a comonoid
  • a monoid

satisfying coherence and the laws on the last slide. A morphism

slide-33
SLIDE 33

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

  • a comonoid
  • a monoid

satisfying coherence and the laws on the last slide. A morphism is a monoidal functor

slide-34
SLIDE 34

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

  • a comonoid
  • a monoid

satisfying coherence and the laws on the last slide. A morphism is a monoidal functor preserving the ordering, the comonoid and the monoid.

slide-35
SLIDE 35

Cartesian bicategories

Definition (Carboni & Walters)

A Cartesian bicategory is a locally ordered symmetric monoidal category where every object is equipped with

  • a comonoid
  • a monoid

satisfying coherence and the laws on the last slide. A morphism is a monoidal functor preserving the ordering, the comonoid and the monoid. Idea: Do categorical logic with Cartesian bicategories.

slide-36
SLIDE 36

Categorical logic with Cartesian bicategories

Definition

A model of B (in Rel) is a morphism M: B → Rel

slide-37
SLIDE 37

Categorical logic with Cartesian bicategories

Definition

A model of B (in Rel) is a morphism M: B → Rel

Problem (Completeness)

For morphisms x, y in B such that M(x) ⊆ M(y) for all models M, is x ≤ y?

slide-38
SLIDE 38

Categorical logic with Cartesian bicategories

Definition

A model of B (in Rel) is a morphism M: B → Rel

Problem (Completeness)

For morphisms x, y in B such that M(x) ⊆ M(y) for all models M, is x ≤ y? Not to be confused with “functional completeness”!

slide-39
SLIDE 39

The syntactic Cartesian bicategory

Signature Σ

slide-40
SLIDE 40

The syntactic Cartesian bicategory

Signature Σ, each R ∈ Σ equipped with arity and coarity R: n → m.

slide-41
SLIDE 41

The syntactic Cartesian bicategory

Signature Σ, each R ∈ Σ equipped with arity and coarity R: n → m. Freely generated (syntactic) Cartesian bicategory CBΣ has

  • bjects N and morphisms
slide-42
SLIDE 42

The syntactic Cartesian bicategory

Signature Σ, each R ∈ Σ equipped with arity and coarity R: n → m. Freely generated (syntactic) Cartesian bicategory CBΣ has

  • bjects N and morphisms

Mor(CBΣ) ::= ǫ

  • .

. . . . . S2 . . . . . . S1

  • .

. . . . . S1 . . . S2

slide-43
SLIDE 43

The syntactic Cartesian bicategory

Signature Σ, each R ∈ Σ equipped with arity and coarity R: n → m. Freely generated (syntactic) Cartesian bicategory CBΣ has

  • bjects N and morphisms

Mor(CBΣ) ::= ǫ

  • .

. . . . . S2 . . . . . . S1

  • .

. . . . . S1 . . . S2

  • .

. . . . . R

slide-44
SLIDE 44

The syntactic Cartesian bicategory

Signature Σ, each R ∈ Σ equipped with arity and coarity R: n → m. Freely generated (syntactic) Cartesian bicategory CBΣ has

  • bjects N and morphisms

Mor(CBΣ) ::= ǫ

  • .

. . . . . S2 . . . . . . S1

  • .

. . . . . S1 . . . S2

  • .

. . . . . R

modulo the laws of Cartesian bicategories.

slide-45
SLIDE 45

Cartesian bicategories and logic

CBΣ can emulate regular logic.

slide-46
SLIDE 46

Cartesian bicategories and logic

CBΣ can emulate regular logic.

Example

∃z0, z1 : R(x0, z0) ∧ R(x1, z0) ∧ R(x0, z1) ∧ R(x1, z1),

slide-47
SLIDE 47

Cartesian bicategories and logic

CBΣ can emulate regular logic.

Example

∃z0, z1 : R(x0, z0) ∧ R(x1, z0) ∧ R(x0, z1) ∧ R(x1, z1),

R R R R

slide-48
SLIDE 48

Cartesian bicategories and logic

CBΣ can emulate regular logic.

Example

∃z0, z1 : R(x0, z0) ∧ R(x1, z0) ∧ R(x0, z1) ∧ R(x1, z1),

R R R R

One-to-one correspondence between string diagrams and regular logic.

slide-49
SLIDE 49

Contents

1 Cartesian bicategories 2 Conjunctive queries 3 Completeness 4 Summary

slide-50
SLIDE 50

Conjunctive queries

  • Conjunctive queries: logical formulas made of ∃, ∧, ⊤, =

and symbols from the signature Σ.

slide-51
SLIDE 51

Conjunctive queries

  • Conjunctive queries: logical formulas made of ∃, ∧, ⊤, =

and symbols from the signature Σ.

  • Model: A set of discourse X and interpretation R ⊆ Xn

for every R ∈ Σ.

slide-52
SLIDE 52

Conjunctive queries

  • Conjunctive queries: logical formulas made of ∃, ∧, ⊤, =

and symbols from the signature Σ.

  • Model: A set of discourse X and interpretation R ⊆ Xn

for every R ∈ Σ.

  • Extends to a semantics function • in the obvious way.
slide-53
SLIDE 53

Conjunctive queries

  • Conjunctive queries: logical formulas made of ∃, ∧, ⊤, =

and symbols from the signature Σ.

  • Model: A set of discourse X and interpretation R ⊆ Xn

for every R ∈ Σ.

  • Extends to a semantics function • in the obvious way.
  • Model in this sense is the same thing as a morphism

CBΣ → Rel.

slide-54
SLIDE 54

Conjunctive queries

  • Conjunctive queries: logical formulas made of ∃, ∧, ⊤, =

and symbols from the signature Σ.

  • Model: A set of discourse X and interpretation R ⊆ Xn

for every R ∈ Σ.

  • Extends to a semantics function • in the obvious way.
  • Model in this sense is the same thing as a morphism

CBΣ → Rel.

  • Query inclusion: φ ≤ ψ iff M(φ) ⊆ M(ψ) in all models M.
slide-55
SLIDE 55

Query inclusion

Example

hasGrandson := ∃v, c : Parent(g, v) ∧ Parent(v, c) ∧ Male(c)

slide-56
SLIDE 56

Query inclusion

Example

hasGrandson := ∃v, c : Parent(g, v) ∧ Parent(v, c) ∧ Male(c) hasGrandson ≤ grandparent := ∃v, c : Parent(g, v) ∧ Parent(v, c)

slide-57
SLIDE 57

Query inclusion

Example

hasGrandson := ∃v, c : Parent(g, v) ∧ Parent(v, c) ∧ Male(c) hasGrandson ≤ grandparent := ∃v, c : Parent(g, v) ∧ Parent(v, c) φ = ∃z0 : (x0 = x1) ∧ R(x0, z0) ψ = ∃z0, z1 : R(x0, z0) ∧ R(x1, z0) ∧ R(x0, z1) ∧ R(x1, z1) φ ≤ ψ

slide-58
SLIDE 58

A dictionary

database theory logic category theory

slide-59
SLIDE 59

A dictionary

database theory logic category theory query logical formula morphism S in CBΣ

slide-60
SLIDE 60

A dictionary

database theory logic category theory query logical formula morphism S in CBΣ database model morphism M: CBΣ → Rel

slide-61
SLIDE 61

A dictionary

database theory logic category theory query logical formula morphism S in CBΣ database model morphism M: CBΣ → Rel answer to query semantics M(S)

slide-62
SLIDE 62

Using the dictionary

Theorem (Chandra, Merlin (1977))

Conjunctive queries can be translated into hypergraphs (with interfaces).

slide-63
SLIDE 63

Using the dictionary

Theorem (Chandra, Merlin (1977))

Conjunctive queries can be translated into hypergraphs (with interfaces). Query inclusion reduces to the existence of an (interface-preserving) hypergraph homomorphism.

slide-64
SLIDE 64

Using the dictionary

Theorem (Chandra, Merlin (1977))

Conjunctive queries can be translated into hypergraphs (with interfaces). Query inclusion reduces to the existence of an (interface-preserving) hypergraph homomorphism.

Example

∃z0,z1 : R(x0,z0)∧R(x1,z0)∧R(x0,z1)∧R(x1,z1) ∃z0 : (x0=x1)∧R(x0,z0)

slide-65
SLIDE 65

Using the dictionary

Theorem (Chandra, Merlin (1977))

Conjunctive queries can be translated into hypergraphs (with interfaces). Query inclusion reduces to the existence of an (interface-preserving) hypergraph homomorphism.

Example

∃z0,z1 : R(x0,z0)∧R(x1,z0)∧R(x0,z1)∧R(x1,z1) ∃z0 : (x0=x1)∧R(x0,z0) R R R R

1

slide-66
SLIDE 66

Using the dictionary

Theorem (Chandra, Merlin (1977))

Conjunctive queries can be translated into hypergraphs (with interfaces). Query inclusion reduces to the existence of an (interface-preserving) hypergraph homomorphism.

Example

∃z0,z1 : R(x0,z0)∧R(x1,z0)∧R(x0,z1)∧R(x1,z1) ∃z0 : (x0=x1)∧R(x0,z0) R R R R

1

R

1

slide-67
SLIDE 67

Cospans

Cartesian bicategory Cospan∼C:

slide-68
SLIDE 68

Cospans

Cartesian bicategory Cospan∼C:

  • Morphisms cospans X

G Y

slide-69
SLIDE 69

Cospans

Cartesian bicategory Cospan∼C:

  • Morphisms cospans X

G Y

  • Chandra & Merlin ordering:
slide-70
SLIDE 70

Cospans

Cartesian bicategory Cospan∼C:

  • Morphisms cospans X

G Y

  • Chandra & Merlin ordering:

X G Y ≤ X H Y

slide-71
SLIDE 71

Cospans

Cartesian bicategory Cospan∼C:

  • Morphisms cospans X

G Y

  • Chandra & Merlin ordering:

X G Y ≤ X H Y iff H X Y G

slide-72
SLIDE 72

Cospans

Cartesian bicategory Cospan∼C:

  • Morphisms cospans X

G Y

  • Chandra & Merlin ordering:

X G Y ≤ X H Y iff H X Y G

Dually define Span∼C with all arrows reversed.

slide-73
SLIDE 73

Contents

1 Cartesian bicategories 2 Conjunctive queries 3 Completeness 4 Summary

slide-74
SLIDE 74

Graphical theorem

Theorem (Graphical theorem)

CBΣ ∼ = DiscCospan∼ HypΣ ⊆ Cospan∼ HypΣ

slide-75
SLIDE 75

Graphical theorem

Theorem (Graphical theorem)

CBΣ ∼ = DiscCospan∼ HypΣ ⊆ Cospan∼ HypΣ

Lemma

Rel ∼ = Span∼ Set

slide-76
SLIDE 76

Graphical theorem

Theorem (Graphical theorem)

CBΣ ∼ = DiscCospan∼ HypΣ ⊆ Cospan∼ HypΣ

Lemma

Rel ∼ = Span∼ Set

Theorem (Completeness for CBΣ)

φ, ψ morphisms in CBΣ such that M(φ) ⊆ M(ψ) for all morphisms M: CBΣ → Rel. Then φ ≤ ψ.

slide-77
SLIDE 77

Graphical theorem

Theorem (Graphical theorem)

CBΣ ∼ = DiscCospan∼ HypΣ ⊆ Cospan∼ HypΣ

Lemma

Rel ∼ = Span∼ Set

Theorem (Completeness for Cospan∼C)

φ, ψ morphisms in Cospan∼C such that M(φ) ≤ M(ψ) for all morphisms M: Cospan∼C → Span∼ Set. Then φ ≤ ψ.

slide-78
SLIDE 78

Yoneda argument

Theorem (Completeness for Cospan∼C)

φ, ψ morphisms in Cospan∼C such that M(φ) ≤ M(ψ) for all morphisms M: Cospan∼C → Span∼ Set. Then φ ≤ ψ.

slide-79
SLIDE 79

Yoneda argument

Theorem (Completeness for Cospan∼C)

φ, ψ morphisms in Cospan∼C such that M(φ) ≤ M(ψ) for all morphisms M: Cospan∼C → Span∼ Set. Then φ ≤ ψ.

Proof.

slide-80
SLIDE 80

Yoneda argument

Theorem (Completeness for Cospan∼C)

φ, ψ morphisms in Cospan∼C such that M(φ) ≤ M(ψ) for all morphisms M: Cospan∼C → Span∼ Set. Then φ ≤ ψ.

Proof.

H X Y G

slide-81
SLIDE 81

Yoneda argument

Theorem (Completeness for Cospan∼C)

φ, ψ morphisms in Cospan∼C such that M(φ) ≤ M(ψ) for all morphisms M: Cospan∼C → Span∼ Set. Then φ ≤ ψ.

Proof.

H X Y G

Hom( ,G)

  • Hom(H, G)

Hom(X, G) Hom(Y, G) Hom(G, G)

slide-82
SLIDE 82

Yoneda argument

Theorem (Completeness for Cospan∼C)

φ, ψ morphisms in Cospan∼C such that M(φ) ≤ M(ψ) for all morphisms M: Cospan∼C → Span∼ Set. Then φ ≤ ψ.

Proof.

H X Y G

Hom( ,G)

  • Hom(H, G)

Hom(X, G) Hom(Y, G) Hom(G, G)

α

slide-83
SLIDE 83

Yoneda argument

Theorem (Completeness for Cospan∼C)

φ, ψ morphisms in Cospan∼C such that M(φ) ≤ M(ψ) for all morphisms M: Cospan∼C → Span∼ Set. Then φ ≤ ψ.

Proof.

H X Y G

α(id) Hom( ,G)

  • Hom(H, G)

Hom(X, G) Hom(Y, G) Hom(G, G)

α

slide-84
SLIDE 84

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion.

slide-85
SLIDE 85

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion. CBΣ is an algebra for conjunctive queries.

slide-86
SLIDE 86

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion. CBΣ is an algebra for conjunctive queries.

Example

R R R R

slide-87
SLIDE 87

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion. CBΣ is an algebra for conjunctive queries.

Example

R R R R

R R

slide-88
SLIDE 88

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion. CBΣ is an algebra for conjunctive queries.

Example

R R R R

R R

=

R R

slide-89
SLIDE 89

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion. CBΣ is an algebra for conjunctive queries.

Example

R R R R

R R

=

R R

R R

slide-90
SLIDE 90

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion. CBΣ is an algebra for conjunctive queries.

Example

R R R R

R R

=

R R

R R

R

slide-91
SLIDE 91

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion. CBΣ is an algebra for conjunctive queries.

Example

R R R R

R R

=

R R

R R

R

=

R

slide-92
SLIDE 92

Corollary from Completeness

Corollary

The laws of Cartesian bicategories are sound and complete for query inclusion. CBΣ is an algebra for conjunctive queries.

Example

R R R R

R R

=

R R

R R

R

=

R

=

R

slide-93
SLIDE 93

Contents

1 Cartesian bicategories 2 Conjunctive queries 3 Completeness 4 Summary

slide-94
SLIDE 94

Summary

Logical CCQ=GCQ

  • Chandra and Merlin
  • Completeness
  • Combinatorial

hypergraphs with interfaces

  • Graphical theorem
  • Categorical

free cartesian bicategories

slide-95
SLIDE 95

Next step

Theorem (hopefully coming soon)

Given morphisms x, y in B such that M(x) ⊆ M(y) for all M: B → Rel. Then x ≤ y