The Expressive Power of SPARQL Renzo Angles and Claudio Gutierrez - - PowerPoint PPT Presentation

the expressive power of sparql
SMART_READER_LITE
LIVE PREVIEW

The Expressive Power of SPARQL Renzo Angles and Claudio Gutierrez - - PowerPoint PPT Presentation

The Expressive Power of SPARQL Renzo Angles and Claudio Gutierrez Computer Science Department Universidad de Chile 1 / 3 Motivations Current definition of SPARQL semantics is non-standard and unnecesarily complex 2 / 3


slide-1
SLIDE 1

The Expressive Power of SPARQL

Renzo Angles and Claudio Gutierrez

Computer Science Department Universidad de Chile

– 1 / 3

slide-2
SLIDE 2

Motivations

◮ Current definition of SPARQL semantics is non-standard and

unnecesarily complex

– 2 / 3

slide-3
SLIDE 3

Motivations

◮ Current definition of SPARQL semantics is non-standard and

unnecesarily complex

This paper:

SPARQL has a simple compositional semantics (except very rare corner cases).

– 2 / 3

slide-4
SLIDE 4

Motivations

◮ Current definition of SPARQL semantics is non-standard and

unnecesarily complex

This paper:

SPARQL has a simple compositional semantics (except very rare corner cases).

◮ What is the expressive power of SPARQL?

For example, how does it compare to SQL?

– 2 / 3

slide-5
SLIDE 5

Motivations

◮ Current definition of SPARQL semantics is non-standard and

unnecesarily complex

This paper:

SPARQL has a simple compositional semantics (except very rare corner cases).

◮ What is the expressive power of SPARQL?

For example, how does it compare to SQL?

This paper:

SPARQL is equivalent in expressive power to Relational Algebra

– 2 / 3

slide-6
SLIDE 6

Outline

◮ Overview of current definition of SPARQL semantics

– 3 / 3

slide-7
SLIDE 7

Outline

◮ Overview of current definition of SPARQL semantics ◮ SPARQL is equivalent to SPARQL-S (a version of SPARQL

with safe filters)

– 3 / 3

slide-8
SLIDE 8

Outline

◮ Overview of current definition of SPARQL semantics ◮ SPARQL is equivalent to SPARQL-S (a version of SPARQL

with safe filters)

◮ SPARQL-S is equivalent to SPARQL-C, a version of SPARQL

with compositional semantics.

– 3 / 3

slide-9
SLIDE 9

Outline

◮ Overview of current definition of SPARQL semantics ◮ SPARQL is equivalent to SPARQL-S (a version of SPARQL

with safe filters)

◮ SPARQL-S is equivalent to SPARQL-C, a version of SPARQL

with compositional semantics.

◮ SPARQL-C is equivalent to Relational Algebra

– 3 / 3

slide-10
SLIDE 10

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics

SPARQL

slide-11
SLIDE 11

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns

SPARQL SPARQL-S

slide-12
SLIDE 12

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns

SPARQL SPARQL-S

slide-13
SLIDE 13

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics

SPARQL SPARQL-S SPARQL-C

slide-14
SLIDE 14

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics

SPARQL SPARQL-S SPARQL-C

slide-15
SLIDE 15

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics Datalog Non-recursive with negation

SPARQL SPARQL-S SPARQL-C DATALOG

slide-16
SLIDE 16

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics Datalog Non-recursive with negation

SPARQL SPARQL-S SPARQL-C DATALOG

slide-17
SLIDE 17

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics Datalog Non-recursive with negation Relational Algebra

SPARQL SPARQL-S SPARQL-C DATALOG SQL

slide-18
SLIDE 18

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics Datalog Non-recursive with negation Relational Algebra

SPARQL SPARQL-S SPARQL-C DATALOG SQL

slide-19
SLIDE 19

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics Datalog Non-recursive with negation Relational Algebra

SPARQL SPARQL-S SPARQL-C DATALOG SQL

slide-20
SLIDE 20

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics Datalog Non-recursive with negation Relational Algebra

SPARQL SPARQL-S SPARQL-C DATALOG SQL

slide-21
SLIDE 21

SPARQL Query (General structure)

SELECT ASK CONSTRUCT DESCRIBE

  • Triple

pattern

FROM FROM NAMED

Dataset FILTER OPTIONAL AND UNION

  • TRUE - FALSE

WHERE

GRAPH

SPARQL

slide-22
SLIDE 22

?X name “George”

SPARQL

Triple pattern (RDF triple + variables)

Syntax of SPARQL graph patterns

slide-23
SLIDE 23

{ P1 . P2 } ?X name “George”

SPARQL

Triple pattern (RDF triple + variables) Join of patterns

Syntax of SPARQL graph patterns

slide-24
SLIDE 24

{ P1 . P2 } ?X name “George”

SPARQL

Triple pattern (RDF triple + variables) Join of patterns { P1 OPTIONAL { P2 } } Optional patterns

Syntax of SPARQL graph patterns

slide-25
SLIDE 25

{ P1 . P2 } ?X name “George”

SPARQL

Triple pattern (RDF triple + variables) Join of patterns { P1 OPTIONAL { P2 } } { P1 } UNION { P2 } Optional patterns Union of patterns

Syntax of SPARQL graph patterns

slide-26
SLIDE 26

{ P1 . P2 } ?X name “George”

SPARQL

Triple pattern (RDF triple + variables) Join of patterns { P1 OPTIONAL { P2 } } { P1 } UNION { P2 } { P1 FILTER C } Optional patterns Union of patterns Filter conditions over patterns

Syntax of SPARQL graph patterns

slide-27
SLIDE 27

{ P1 . P2 } ?X name “George”

SPARQL

{ P1 OPTIONAL { P2 } } { P1 } UNION { P2 } { P1 FILTER C } ( P1 AND P2 ) ( P1 OPT P2 ) ( P1 UNION P2 ) ( P1 FILTER C ) ( ?X name “George”) Original SPARQL syntax Algebraic Syntax

SPARQL-C

Syntax of SPARQL graph patterns

slide-28
SLIDE 28

Example of SPARQL query

SELECT ?N, ?A, ?E

?E ?A ?N

(SELECT)

SPARQL

slide-29
SLIDE 29

Example of SPARQL query

SELECT ?N, ?A, ?E FROM G

?E ?A ?N

(FROM)

SPARQL

slide-30
SLIDE 30

Example of SPARQL query

SELECT ?N FROM G WHERE (?X name ?N)

(Triple pattern)

person1 person2 ?X person3 ?N “George” “John” “Mark”

SPARQL

slide-31
SLIDE 31

Example of SPARQL query

SELECT ?N, ?A FROM G WHERE ( (?X name ?N) AND (?X age ?A) )

(AND)

person1 person2 ?X ?N “George” “John” ?A 20 26

SPARQL

slide-32
SLIDE 32

Example of SPARQL query

SELECT ?N, ?A FROM G WHERE ( (?X name ?N) AND ( (?X age ?A) FILTER (?A < 25) ) )

(FILTER)

person1 ?X ?N “George” ?A 20

SPARQL

slide-33
SLIDE 33

Example of SPARQL query

SELECT ?N, ?E FROM G WHERE ( (?X,name,?N) AND ( (?X,age,?A) FILTER (?A < 25) ) ) ( (?X name ?N) OPT (?X email ?E) )

(OPTIONAL)

person1 person2 ?X person3 ?N “George” “John” “Mark” ?E “Mark@mark.com” person1 ?X ?N “George” ?A 20

SPARQL

slide-34
SLIDE 34

Example of SPARQL query

SELECT ?N, ?A, ?E FROM G WHERE ( ( (?X name ?N) AND ( (?X age ?A) FILTER (?A < 25) ) ) UNION ( (?X name ?N) OPT (?X email ?E) ) )

(UNION)

“John” “Mark” 20 ?A ?N “George” ?E “Mark@mark.com” “George”

SPARQL

person1 person2 ?X person3 ?N “George” “John” “Mark” ?E “Mark@mark.com” person1 ?X ?N “George” ?A 20 UNION

slide-35
SLIDE 35

W3C Semantics of SPARQL

slide-36
SLIDE 36

W3C Semantics of SPARQL

slide-37
SLIDE 37

W3C Semantics of SPARQL

slide-38
SLIDE 38

W3C Semantics of SPARQL

slide-39
SLIDE 39

W3C Semantics of SPARQL

slide-40
SLIDE 40

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns

SPARQL SPARQL-S

slide-41
SLIDE 41

Notion of Expressive Power

◮ A query is a function from the set of input data to the set of

  • utput data.

◮ The expressive power of a query language is given by the set

  • f queries it can express.

– 1 / 4

slide-42
SLIDE 42

Notion of Expressive Power

◮ A query is a function from the set of input data to the set of

  • utput data.

◮ The expressive power of a query language is given by the set

  • f queries it can express.

Definition (Equivalence of languages)

Two query languages L1 and L2 have the same expressive power if they can express the same queries.

– 1 / 4

slide-43
SLIDE 43

Notion of Expressive Power

◮ A query is a function from the set of input data to the set of

  • utput data.

◮ The expressive power of a query language is given by the set

  • f queries it can express.

Definition (Equivalence of languages)

Two query languages L1 and L2 have the same expressive power if they can express the same queries. (If the languages operate over different data inputs and outputs, have to normalize them before.)

– 1 / 4

slide-44
SLIDE 44

SPARQL-S: Accepting only Safe Patterns

What is the meaning of (P FILTER C) when var(C) ⊆ var(P) (non-safe filters)?

– 2 / 4

slide-45
SLIDE 45

SPARQL-S: Accepting only Safe Patterns

What is the meaning of (P FILTER C) when var(C) ⊆ var(P) (non-safe filters)?

Example

Possible meanings of (?X name ?Y) FILTER (?Z > 3)

– 2 / 4

slide-46
SLIDE 46

SPARQL-S: Accepting only Safe Patterns

What is the meaning of (P FILTER C) when var(C) ⊆ var(P) (non-safe filters)?

Example

Possible meanings of (?X name ?Y) FILTER (?Z > 3)

  • 1. Non-defined variable ?Z. (Error, False, empty set)

– 2 / 4

slide-47
SLIDE 47

SPARQL-S: Accepting only Safe Patterns

What is the meaning of (P FILTER C) when var(C) ⊆ var(P) (non-safe filters)?

Example

Possible meanings of (?X name ?Y) FILTER (?Z > 3)

  • 1. Non-defined variable ?Z. (Error, False, empty set)
  • 2. All values of ?X, ?Y, ?Z such that the expression matches.

– 2 / 4

slide-48
SLIDE 48

SPARQL-S: Accepting only Safe Patterns

What is the meaning of (P FILTER C) when var(C) ⊆ var(P) (non-safe filters)?

Example

Possible meanings of (?X name ?Y) FILTER (?Z > 3)

  • 1. Non-defined variable ?Z. (Error, False, empty set)
  • 2. All values of ?X, ?Y, ?Z such that the expression matches.
  • 3. W3C uses the following:

◮ IF the expression is inside an optional, e.g.

P OPT ( (?X name ?Y) FILTER (?Z >3) ) and variable ?Z occurs in P, THEN (2.)

◮ ELSE (1.) – 2 / 4

slide-49
SLIDE 49

SPARQL-S: Accepting only Safe Patterns

◮ Patterns with non-safe filter are rare cases.

– 3 / 4

slide-50
SLIDE 50

SPARQL-S: Accepting only Safe Patterns

◮ Patterns with non-safe filter are rare cases. ◮ Patterns with non-safe filters are simulable with safe ones.

– 3 / 4

slide-51
SLIDE 51

SPARQL-S: Accepting only Safe Patterns

◮ Patterns with non-safe filter are rare cases. ◮ Patterns with non-safe filters are simulable with safe ones.

Why not avoid them?

– 3 / 4

slide-52
SLIDE 52

SPARQL-S: Accepting only Safe Patterns

◮ Patterns with non-safe filter are rare cases. ◮ Patterns with non-safe filters are simulable with safe ones.

Why not avoid them?

Theorem

SPARQL and SPARQL-S have the same expressive power.

– 3 / 4

slide-53
SLIDE 53

SPARQL-S: Accepting only Safe Patterns

◮ Patterns with non-safe filter are rare cases. ◮ Patterns with non-safe filters are simulable with safe ones.

Why not avoid them?

Theorem

SPARQL and SPARQL-S have the same expressive power.

Proof idea

◮ There is generic procedure to translate non-safe queries into

equivalent safe queries.

◮ It uses case-by-case W3C evaluation rules for non-safe queries.

– 3 / 4

slide-54
SLIDE 54

SPARQL-S: Schema of translation from SPARQL

Proof idea

Given pattern P, define filter-safe pattern s(P) recursively:

– 4 / 4

slide-55
SLIDE 55

SPARQL-S: Schema of translation from SPARQL

Proof idea

Given pattern P, define filter-safe pattern s(P) recursively:

◮ Works as the identity for most patterns

– 4 / 4

slide-56
SLIDE 56

SPARQL-S: Schema of translation from SPARQL

Proof idea

Given pattern P, define filter-safe pattern s(P) recursively:

◮ Works as the identity for most patterns ◮ Special Case 1: P is (P1 OPT(P2 FILTER C))

s(P) ← (s(P1) OPT((s(P1) AND s(P2)) FILTER C))

– 4 / 4

slide-57
SLIDE 57

SPARQL-S: Schema of translation from SPARQL

Proof idea

Given pattern P, define filter-safe pattern s(P) recursively:

◮ Works as the identity for most patterns ◮ Special Case 1: P is (P1 OPT(P2 FILTER C))

s(P) ← (s(P1) OPT((s(P1) AND s(P2)) FILTER C))

◮ Special Case 2: (P1 FILTER C) with var(C) ⊆ var(P1)

For each X ∈ var(C) and not in var(P1) replace:

◮ conditions (X = a) or (X = Y ) by error

(for ex. bound(d), for d constant.)

◮ condition bound(X) by false. – 4 / 4

slide-58
SLIDE 58

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics

SPARQL SPARQL-S SPARQL-C

slide-59
SLIDE 59

SPARQL-C: SPARQL with compositional semantics

Desiderata for semantics:

– 1 / 1

slide-60
SLIDE 60

SPARQL-C: SPARQL with compositional semantics

Desiderata for semantics:

◮ Compositional approach: The meaning of an expression is

determined by the meaning of its parts and the way they are combined.

– 1 / 1

slide-61
SLIDE 61

SPARQL-C: SPARQL with compositional semantics

Desiderata for semantics:

◮ Compositional approach: The meaning of an expression is

determined by the meaning of its parts and the way they are combined.

◮ Denotational approach: Meaning of expressions is formalized

by assigning mathematical objects which describe the meaning.

– 1 / 1

slide-62
SLIDE 62

SPARQL-C: SPARQL with compositional semantics

Desiderata for semantics:

◮ Compositional approach: The meaning of an expression is

determined by the meaning of its parts and the way they are combined.

◮ Denotational approach: Meaning of expressions is formalized

by assigning mathematical objects which describe the meaning. SPARQL-C has a denotational and compositional semantics.

– 1 / 1

slide-63
SLIDE 63

SPARQL-C Semantics Overview: Building blocks

Definition

◮ A mapping is a partial function from variables to RDF terms. ◮ The evaluation of a triple t is the set of mappings that make t

to match the graph

– 2 / 1

slide-64
SLIDE 64

SPARQL-C Semantics Overview: Building blocks

Definition

◮ A mapping is a partial function from variables to RDF terms. ◮ The evaluation of a triple t is the set of mappings that make t

to match the graph

Bag Semantics

◮ Multisets (bags) instead of set of mappings ◮ SPARQL uses bag semantics ◮ Not well understood from a theoretical point of view

– 2 / 1

slide-65
SLIDE 65

SPARQL-C Semantics Overview: Building blocks

Definition

◮ A mapping is a partial function from variables to RDF terms. ◮ The evaluation of a triple t is the set of mappings that make t

to match the graph

Bag Semantics

◮ Multisets (bags) instead of set of mappings ◮ SPARQL uses bag semantics ◮ Not well understood from a theoretical point of view

In this talk will avoid bag semantics details.

– 2 / 1

slide-66
SLIDE 66

SPARQL-C Semantics Overview: Operations

Let M1 and M2 be sets of mappings:

Definition

Join : M1 M2 Difference : M1 M2 Union : M1 ∪ M2 Left Outer Join : M1 M2 = (M1 M2) ∪ (M1 M2)

– 3 / 1

slide-67
SLIDE 67

SPARQL-C Semantics Overview: Operations

Let M1 and M2 be sets of mappings:

Definition

Join : M1 M2 Difference : M1 M2 Union : M1 ∪ M2 Left Outer Join : M1 M2 = (M1 M2) ∪ (M1 M2)

Definition

Given P1, P2 graph patterns and D an RDF graph: [ [P1 AND P2] ]D → [ [P1] ]D [ [P2] ]D [ [P1 UNION P2] ]D → [ [P1] ]D ∪ [ [P2] ]D [ [P1 OPT P2] ]D → [ [P1] ]D [ [P2] ]D

– 3 / 1

slide-68
SLIDE 68

SPARQL-C Semantics Overview: FILTERs

In a pattern (P FILTER C), the filter expression C is a Boolean combination of atoms.

Definition

[ [P FILTER C] ] = { µ ∈ [ [P] ] : µ | = C} = Set of mappings in [ [P] ] that satisfy C. Makes sense only if var(C) ⊆ var(P) (safe filters).

– 4 / 1

slide-69
SLIDE 69

SPARQL-S is equivalent to SPARQL-C

Theorem

SPARQL-S and SPARQL-C have the same expressive power.

– 5 / 1

slide-70
SLIDE 70

SPARQL-S is equivalent to SPARQL-C

Theorem

SPARQL-S and SPARQL-C have the same expressive power.

Proof idea

◮ Check case by case both semantics coincide (the algorithmic

for SPARQL-S and the compositional for SPARQL-C).

◮ The only non-trivial case is the semantics of patterns of the

form (P1 OPT(P2 FILTER C).

– 5 / 1

slide-71
SLIDE 71

SPARQL-S is equivalent to SPARQL-C

Theorem

SPARQL-S and SPARQL-C have the same expressive power.

Proof idea

◮ Check case by case both semantics coincide (the algorithmic

for SPARQL-S and the compositional for SPARQL-C).

◮ The only non-trivial case is the semantics of patterns of the

form (P1 OPT(P2 FILTER C).

Corollary

SPARQL-S has compositional semantics.

– 5 / 1

slide-72
SLIDE 72

Expressive power of SPARQL : Tour

SPARQL W3C Syntax and Semantics SPARQL-S Only safe-filter patterns SPARQL-C Compositional Semantics Datalog Non-recursive with negation

SPARQL SPARQL-S SPARQL-C DATALOG

slide-73
SLIDE 73

SPARQL-C to Datalog

(Already known in the literature; cf. A. Polleres)

◮ Represent RDF triples and terms as Datalog facts. ◮ Represent SPARQL mappings as Datalog substitutions

In particular, represent the unbounded value in a mapping by the null value.

◮ Represent each graph pattern as Datalog rules.

– 1 / 14

slide-74
SLIDE 74

SPARQL-C to Datalog

Example (Transformation of AND)

Given the graph pattern (?X name ?N) AND (?X age ?A), it is transformed in the set of rules

  • 1. P1(?X, ?N) ← triple(g, ?X, name, ?N)
  • 2. P2(?X, ?A) ← triple(g, ?X, age, ?A)
  • 3. P(?X, ?N, ?A) ←

P1(?X1, ?N) ∧ P2(?X2, ?N) ∧ comp(?X1, ?X2, ?X)

– 2 / 14

slide-75
SLIDE 75

SPARQL-C to Datalog

Example (Transformation of AND)

Given the graph pattern (?X name ?N) AND (?X age ?A), it can be transformed in the set of rules

  • 1. P1(?X, ?N) ← triple(g, ?X, name, ?N)
  • 2. P2(?X, ?A) ← triple(g, ?X, age, ?A)
  • 3. P(?X, ?N, ?A) ←

P1(?X1, ?N) ∧ P2(?X2, ?N) ∧ comp(?X1, ?X2, ?X)

– 3 / 14

slide-76
SLIDE 76

SPARQL-C to Datalog

Example (Transformation of AND)

Given the graph pattern (?X name ?N) AND (?X age ?A), it can be transformed in the set of rules

  • 1. P1(?X, ?N) ← triple(g, ?X, name, ?N)
  • 2. P2(?X, ?A) ← triple(g, ?X, age, ?A)
  • 3. P(?X, ?N, ?A) ←

P1(?X1, ?N) ∧ P2(?X2, ?N) ∧ comp(?X1, ?X2, ?X)

– 4 / 14

slide-77
SLIDE 77

SPARQL-C to Datalog

Example (Transformation of AND)

Given the graph pattern (?X name ?N) AND (?X age ?A), it can be transformed in the set of rules

  • 1. P1(?X, ?N) ← triple(g, ?X, name, ?N)
  • 2. P2(?X, ?A) ← triple(g, ?X, age, ?A)
  • 3. P(?X, ?N, ?A) ←

P1(?X1, ?N) ∧ P2(?X2, ?N) ∧ comp(?X1, ?X2, ?X)

Rules for modeling compatible mappings.

comp(X, X, X) ← term(X) comp(X, null, X) ← term(X) comp(X, X, X) ← Null(X) comp(null, X, X) ← term(X)

– 5 / 14

slide-78
SLIDE 78

Datalog to SPARQL-C

◮ Represent Datalog facts using RDF triples.

Example

A Datalog fact p(c1, . . . , cn) is described by the set of RDF triples {(b, predicate, p), (b, rdf: 1, c1), . . . , (b, rdf: n, cn)}

◮ Direct representation of SPARQL mappings as Datalog

subsitutions.

– 6 / 14

slide-79
SLIDE 79

Datalog to SPARQL-C

Given a Datalog rule of the form L ← L1 ∧ · · · ∧ Ls ∧ ¬Ls+1 ∧ · · · ∧ ¬Lt ∧ Leq

1 ∧ · · · ∧ Leq u ,

(1) define a function g(L) returning a graph pattern of the form (((· · · ((g(L1) AND · · · AND g(Ls)) MINUS g(Ls+1)) · · · ) MINUS g(Lt)) FILTER(Leq

1 ∧ · · · ∧ Leq u ))

– 7 / 14

slide-80
SLIDE 80

Datalog to SPARQL-C

Example (Transformation of a Datalog rule)

Given a Datalog rule Q(?N, ?L) ← name(?X, ?N, ?L) ∧ ¬email(?X, ?E), it can be transformed in the SPARQL query SELECT ?N,?L FROM g WHERE ( ( (?Y predicate name) AND (?Y rdf: 1 ?X) AND (?Y rdf: 2 ?N) AND (?Y rdf 3 ?L) ) MINUS ( (?Z predicate email) AND (?Z rdf: 1 ?X) AND (?Z rdf: 2 ?E) ) )

– 8 / 14

slide-81
SLIDE 81

Datalog to SPARQL-C

Example (Transformation of a Datalog rule)

Given a Datalog rule Q(?N, ?L) ← name(?X, ?N, ?L) ∧ ¬email(?X, ?E), it can be transformed in the SPARQL query SELECT ?N,?L FROM g WHERE ( ( (?Y predicate name) AND (?Y rdf: 1 ?X) AND (?Y rdf: 2 ?N) AND (?Y rdf 3 ?L) ) MINUS ( (?Z predicate email) AND (?Z rdf: 1 ?X) AND (?Z rdf: 2 ?E) ) )

– 9 / 14

slide-82
SLIDE 82

Datalog to SPARQL-C

Example (Transformation of a Datalog rule)

Given a Datalog rule Q(?N, ?L) ← name(?X, ?N, ?L) ∧ ¬email(?X, ?E), it can be transformed in the SPARQL query SELECT ?N,?L FROM g WHERE ( ( (?Y predicate name) AND (?Y rdf: 1 ?X) AND (?Y rdf: 2 ?N) AND (?Y rdf 3 ?L) ) MINUS ( (?Z predicate email) AND (?Z rdf: 1 ?X) AND (?Z rdf: 2 ?E) ) )

– 10 / 14

slide-83
SLIDE 83

Datalog to SPARQL-C

Example (Transformation of a Datalog rule)

Given a Datalog rule Q(?N, ?L) ← name(?X, ?N, ?L) ∧ ¬email(?X, ?E), it can be transformed in the SPARQL query SELECT ?N,?L FROM g WHERE ( ( (?Y predicate name) AND (?Y rdf: 1 ?X) AND (?Y rdf: 2 ?N) AND (?Y rdf 3 ?L) ) MINUS ( (?Z predicate email) AND (?Z rdf: 1 ?X) AND (?Z rdf: 2 ?E) ) )

– 11 / 14

slide-84
SLIDE 84

Datalog to SPARQL-C

Example (Transformation of a Datalog rule)

Given a Datalog rule Q(?N, ?L) ← name(?X, ?N, ?L) ∧ ¬email(?X, ?E), it can be transformed in the SPARQL query SELECT ?N,?L FROM g WHERE ( ( (?Y predicate name) AND (?Y rdf: 1 ?X) AND (?Y rdf: 2 ?N) AND (?Y rdf 3 ?L) ) MINUS ( (?Z predicate email) AND (?Z rdf: 1 ?X) AND (?Z rdf: 2 ?E) ) )

– 12 / 14

slide-85
SLIDE 85

Conclusions

Theorem

SPARQL-C and Datalog have the same expressive power.

– 13 / 14

slide-86
SLIDE 86

Conclusions

Theorem

SPARQL-C and Datalog have the same expressive power. Considering that:

  • 1. SPARQL is equivalent to SPARQL-S;
  • 2. SPARQL-S is equivalent to SPARQL-C;
  • 3. SPARQL-C is equivalent to Datalog; and
  • 4. Datalog is equivalent to Relational Algebra.

– 13 / 14

slide-87
SLIDE 87

Conclusions

Theorem

SPARQL-C and Datalog have the same expressive power. Considering that:

  • 1. SPARQL is equivalent to SPARQL-S;
  • 2. SPARQL-S is equivalent to SPARQL-C;
  • 3. SPARQL-C is equivalent to Datalog; and
  • 4. Datalog is equivalent to Relational Algebra.

Theorem

SPARQL and Relational Algebra have the same expressive power.

◮ Results hold for bag and set semantics.

– 13 / 14

slide-88
SLIDE 88

Thank you!

Questions?

– 14 / 14