SLIDE 1
Graphical Conjunctive Queries A completeness theorem for Cartesian - - PowerPoint PPT Presentation
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 2
SLIDE 3
String diagrams
- A graphical way of reasoning about monoidal categories
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
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
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
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
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
Relations with string diagrams
The category Rel of sets with relations as morphisms
SLIDE 10
Relations with string diagrams
The category Rel of sets with relations as morphisms
- forms a symmetric monoidal category:
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
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
Relations with string diagrams
- Relations are ordered by inclusion
SLIDE 14
Relations with string diagrams
- Relations are ordered by inclusion
- Every object:
SLIDE 15
Relations with string diagrams
- Relations are ordered by inclusion
- Every object:
- Copying and discarding
SLIDE 16
Relations with string diagrams
- Relations are ordered by inclusion
- Every object:
- Copying and discarding
,
SLIDE 17
Relations with string diagrams
- Relations are ordered by inclusion
- Every object:
- Copying and discarding
,
- Equality and “spawn”
SLIDE 18
Relations with string diagrams
- Relations are ordered by inclusion
- Every object:
- Copying and discarding
,
- Equality and “spawn”
,
SLIDE 19
Observations
Comonoid
= = = =
SLIDE 20
Observations
Comonoid
= = = =
Monoid
= = = =
SLIDE 21
Observations
Comonoid
= = = =
Monoid
= = = =
Frobenius
= =
SLIDE 22
Observations
Comonoid
= = = =
Monoid
= = = =
Frobenius
= =
Adjointness
≤ ≤ ≤ ≤
SLIDE 23
Observations
Comonoid
= = = =
Monoid
= = = =
Frobenius
= =
Adjointness
≤ ≤ ≤ ≤
Lax Comonoid homomorphism
R
≤
R R R
≤
SLIDE 24
Cartesian bicategories
Definition (Carboni & Walters)
A Cartesian bicategory
SLIDE 25
Cartesian bicategories
Definition (Carboni & Walters)
A Cartesian bicategory is a locally ordered
SLIDE 26
Cartesian bicategories
Definition (Carboni & Walters)
A Cartesian bicategory is a locally ordered symmetric monoidal category
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
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
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
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
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
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
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
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
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
Categorical logic with Cartesian bicategories
Definition
A model of B (in Rel) is a morphism M: B → Rel
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
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
The syntactic Cartesian bicategory
Signature Σ
SLIDE 40
The syntactic Cartesian bicategory
Signature Σ, each R ∈ Σ equipped with arity and coarity R: n → m.
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
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
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
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
Cartesian bicategories and logic
CBΣ can emulate regular logic.
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
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
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
Contents
1 Cartesian bicategories 2 Conjunctive queries 3 Completeness 4 Summary
SLIDE 50
Conjunctive queries
- Conjunctive queries: logical formulas made of ∃, ∧, ⊤, =
and symbols from the signature Σ.
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
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
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
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
Query inclusion
Example
hasGrandson := ∃v, c : Parent(g, v) ∧ Parent(v, c) ∧ Male(c)
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
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
A dictionary
database theory logic category theory
SLIDE 59
A dictionary
database theory logic category theory query logical formula morphism S in CBΣ
SLIDE 60
A dictionary
database theory logic category theory query logical formula morphism S in CBΣ database model morphism M: CBΣ → Rel
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
Using the dictionary
Theorem (Chandra, Merlin (1977))
Conjunctive queries can be translated into hypergraphs (with interfaces).
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
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
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
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
Cospans
Cartesian bicategory Cospan∼C:
SLIDE 68
Cospans
Cartesian bicategory Cospan∼C:
- Morphisms cospans X
G Y
SLIDE 69
Cospans
Cartesian bicategory Cospan∼C:
- Morphisms cospans X
G Y
- Chandra & Merlin ordering:
SLIDE 70
Cospans
Cartesian bicategory Cospan∼C:
- Morphisms cospans X
G Y
- Chandra & Merlin ordering:
X G Y ≤ X H Y
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
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
Contents
1 Cartesian bicategories 2 Conjunctive queries 3 Completeness 4 Summary
SLIDE 74
Graphical theorem
Theorem (Graphical theorem)
CBΣ ∼ = DiscCospan∼ HypΣ ⊆ Cospan∼ HypΣ
SLIDE 75
Graphical theorem
Theorem (Graphical theorem)
CBΣ ∼ = DiscCospan∼ HypΣ ⊆ Cospan∼ HypΣ
Lemma
Rel ∼ = Span∼ Set
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
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
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
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
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
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
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
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
Corollary from Completeness
Corollary
The laws of Cartesian bicategories are sound and complete for query inclusion.
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
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
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
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
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
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
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
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
Contents
1 Cartesian bicategories 2 Conjunctive queries 3 Completeness 4 Summary
SLIDE 94
Summary
Logical CCQ=GCQ
- Chandra and Merlin
- Completeness
- Combinatorial
hypergraphs with interfaces
- Graphical theorem
- Categorical
free cartesian bicategories
SLIDE 95