Introduction RDF Semantics Querying RDF
RDF Data Model and Query Languages
Sergio Tessaris
April 21, 2006
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
FOAF example
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF Site Summary (RSS) 1.0
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF Site Summary (RSS) 1.0
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Building Blocks RDF Abstract Syntax RDF Vocabulary RDF Semantics RDF model theory Entailment Casting RDF into FOL Querying RDF Introduction Graph Patterns Query languages SPARQL
Sergio Tessaris RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Basic Concepts
RDF: language for representing information about resources (e.g. Metadata)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Basic Concepts
RDF: language for representing information about resources (e.g. Metadata) information about things identied on the Web
identiable doesnt mean retrievable e.g. goods from an eShop, prices, availability, etc.
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Basic Concepts
RDF: language for representing information about resources (e.g. Metadata) information about things identied on the Web
identiable doesnt mean retrievable e.g. goods from an eShop, prices, availability, etc.
information processed by applications, not human beings
Semantic Web
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Digression: Semantic Web
The Semantic Web is an extension of the current web in which information is given well-dened meaning, better enabling computers and people to work in cooperation. Tim Berners-Lee, James Hendler, Ora Lassila, The Semantic Web, Scientic American, May 2001
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Design Goals
having a simple data model having formal semantics and provable inference using an extensible URI-based vocabulary using an XML-based syntax supporting use of XML schema datatypes allowing anyone to make statements about any resource
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF Statements
RDF is about making statements about resources E.g. Sergio Tessaris is the author of the web page http://www.inf.unibz.it/tessaris/index.html This can be stated as a property of the web page http://www.inf.unibz.it/tessaris/index.html has an author whose value is "Sergio Tessaris" RDF statements
subject: e.g. URL http://www.inf.unibz.it/tessaris/index.html predicate: e.g. property author object: e.g. string "Sergio Tessaris"
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Identifying Resources
RDF identiers: Uniform Resource Identiers (URI) URIs, URLs, and URNs URL identies resources via a representation of their primary access mechanism URN URIs that are required to remain globally unique and persistent Example ftp://ftp.is.co.za/rfc/rfc1808.txt http://www.math.uio.no/faq/compression-faq/part1.html news:comp.infosystems.www.servers.unix telnet://melvyl.ucop.edu/ mailto:someone@example.com
Sergio Tessaris RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Literals
RDF allows the use of values
strings numbers booleans
Literals are basically UNICODE strings plain just strings (w optional language tag) typed have associated datatype URI RDF literals and typing literals are not URIs
e.g. http://www.unicode.org and http://www.unicode.org are dierent
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Triples and Graphs
RDF triples basic element of RDF model
subject predicate object
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Triples and Graphs
RDF triples basic element of RDF model
subject predicate object
triple: two nodes (subject, object) connected by a labelled edge (predicate)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Triples and Graphs
RDF triples basic element of RDF model
subject predicate object
triple: two nodes (subject, object) connected by a labelled edge (predicate) set of triples: a labelled directed graph
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Blank Nodes
RDF graphs may contain additional nodes arbitrary set of blank nodes (bnodes)
innite disjoint from URIs and literals
given two blank nodes it is possible to determine whether or not they are the same
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Blank Nodes
RDF graphs may contain additional nodes arbitrary set of blank nodes (bnodes)
innite disjoint from URIs and literals
given two blank nodes it is possible to determine whether or not they are the same intuition: a bnode represents the existence of something
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Scope of RDF Terms
URIs and Literals have a global scope two equal URIs (Literals) always represent the same object
equal means that the two unicode strings are the same there are not contextual to the graph
bnodes are contextual to the graph in which they appear
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Scope of RDF Terms
URIs and Literals have a global scope two equal URIs (Literals) always represent the same object
equal means that the two unicode strings are the same there are not contextual to the graph
bnodes are contextual to the graph in which they appear . . . more to came on the role of bnodes
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF Graphs
RDF triple
subject: RDF URI reference or a bnode predicate: RDF URI reference object: literal, RDF URI reference or a bnode
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF Graphs
RDF triple
subject: RDF URI reference or a bnode predicate: RDF URI reference object: literal, RDF URI reference or a bnode
RDF graph: set of RDF triples
nodes of an RDF graph are subjects and objects in the triples
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF Graphs (cont.)
no literals as subject predicates are just URIs URIs are used for both resources (nodes) and predicates (edges) literals can be non well formed datatypes no complete information about any resource
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
On Bnodes
bnodes are dierent from other RDF terms starting from the syntax
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
On Bnodes
bnodes are dierent from other RDF terms starting from the syntax Graph equivalence Denition G , G are equivalent if there is a bijection M between the nodes of the two graphs, s.t.:
1 2 3 4
M maps bnodes to bnodes. M(lit) = lit for literals lit in G . M(uri) = uri for URI in G . s, p, o in G i the triple M(s), p, M(o) in G .
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
On Bnodes
bnodes are dierent from other RDF terms starting from the syntax Graph equivalence Denition G , G are equivalent if there is a bijection M between the nodes of the two graphs, s.t.:
1 2 3 4
M maps bnodes to bnodes. M(lit) = lit for literals lit in G . M(uri) = uri for URI in G . s, p, o in G i the triple M(s), p, M(o) in G .
I.e. a sort of graph isomorphism
Sergio Tessaris RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Syntax vs. Semantics
still talking about (abstract) syntax nothing has been said on the actual semantics of RDF
introduced with an RDF vocabulary given by means of a Model Theory
how do you write/exchange RDF? in particular bnodes and literals several possibilities
N-Triples RDF/XML (normative) Turtle notation (subset of N3)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
N-Triples
documents contain a set of assertions subject predicate object . URI references written out completely: <http://example.org/resource30> Literals as strings: plain "chat"@fr typed "<a></a>"^^<http://www.w3.org/2000/01/ rdf-schema#XMLLiteral> Bnodes: :anon
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
N-Triples Example
<http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://xmlns.com/foaf/0.1/title> "Dr" . <http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> . <http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://xmlns.com/foaf/0.1/workplaceHomepage> <http://www.unibz.it/inf> . <http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://xmlns.com/foaf/0.1/homepage> <http://www.inf.unibz.it/~tessaris> . <http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://xmlns.com/foaf/0.1/mbox_sha1sum> "758128cdae69fd0fd9e880921d9f4b25259edbf5" . <http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://xmlns.com/foaf/0.1/name> "Sergio Tessaris" . <http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://xmlns.com/foaf/0.1/family_name> "Tessaris" . <http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://xmlns.com/foaf/0.1/givenname> "Sergio" . <http://www.inf.unibz.it/~tessaris/myfoaf.xml#me> <http://xmlns.com/foaf/0.1/phone> <tel:+39-0471-016-125> .
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF/XML
Normative XML serialisation for RDF documents Use namespace abbreviations: e.g.
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:myfoaf="http://www.inf.unibz.it/~tessaris/myfoaf.xml">
Encode paths of the RDF graph There are several ways of encoding the same graph!
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF/XML
document root is rdf:RDF rdf:Description to represent nodes predicates use the corresponding URI
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar"> <dc:title>RDF/XML Syntax Specification (Revised)</dc:title> </rdf:Description>
bnodes can be omitted
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF/XML Example
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/"> <foaf:Person rdf:ID="me"> <foaf:name>Sergio Tessaris</foaf:name> <foaf:title>Dr</foaf:title> <foaf:givenname>Sergio</foaf:givenname> <foaf:family_name>Tessaris</foaf:family_name> <foaf:mbox_sha1sum> 758128cdae69fd0fd9e880921d9f4b25259edbf5</foaf:mbox_sha1sum> <foaf:homepage rdf:resource="http://www.inf.unibz.it/~tessaris"/> <foaf:phone rdf:resource="tel:+39-0471-016-125"/> <foaf:workplaceHomepage rdf:resource="http://www.unibz.it/inf"/> </foaf:Person> </rdf:RDF>
Sergio Tessaris RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Turtle Notation
Extension of N-Triples Compact representation of graphs
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Turtle Notation
Extension of N-Triples Compact representation of graphs I will use this notation, explaining it on the way
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
Turtle Example
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix foaf: <http://xmlns.com/foaf/0.1/> . @prefix : <http://www.inf.unibz.it/~tessaris/myfoaf.xm#> . :me rdf:type foaf:Person ; foaf:family_name "Tessaris" ; foaf:givenname "Sergio" ; foaf:homepage <http://www.inf.unibz.it/~tessaris> ; foaf:mbox_sha1sum "758128cdae69fd0fd9e880921d9f4b25259edbf5" ; foaf:name "Sergio Tessaris" ; foaf:phone <tel:+39-0471-016-125> ; foaf:title "Dr" ; foaf:workplaceHomepage <http://www.unibz.it/inf> .
Sergio Tessaris RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF Data Model
up till now we have
abstract syntax for graphs a way to exchange these graphs
wheres the semantics? how to express rich semantic constructs?
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF Data Model
up till now we have
abstract syntax for graphs a way to exchange these graphs
wheres the semantics? how to express rich semantic constructs? everything is going to be in RDF itself
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF Data Model
up till now we have
abstract syntax for graphs a way to exchange these graphs
wheres the semantics? how to express rich semantic constructs? everything is going to be in RDF itself URIs are global: RDF prescribes the meaning of same URIs
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF, RDF Schema, and more
RDF: basic vocabulary, e.g.
class membership
RDFS: extends the basic vocabulary, e.g.
subclass relation domain and range for predicates
OWL family: extends to a full edged ontology language
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF, RDF Schema, and more
RDF: basic vocabulary, e.g.
class membership
RDFS: extends the basic vocabulary, e.g.
subclass relation domain and range for predicates
OWL family: extends to a full edged ontology language
we wont discuss OWL
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDF Vocabulary
Classes
rdf:Property rdf:XMLLiteral
Properties
rdf:type
Reication
rdf:Statement rdf:subject, rdf:predicate, rdf:object
Collections and Containers
rdf:Bag, rdf:Seq, rdf:Alt rdf:List, rdf:first, rdf:rest, rdf:nil rdf: 1, rdf: 2, rdf: 3,. . . etc.
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Building Blocks RDF Abstract Syntax RDF Vocabulary
RDFS Vocabulary
Classes
rdfs:Resource rdfs:Class rdfs:Literal rdfs:Datatype
Properties
rdfs:range, rdfs:domain rdfs:subClassOf rdfs:subPropertyOf rdfs:label, rdfs:comment
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Meaning and Semantics
the meaning of an RDF document is context dependent
mostly not machine accessible
we are interested in the semantics of RDF(S) as a formal language
implications of the asserted statements entailment as the basic tool (query answering) inference rules to decide entailment between two graphs
semantics provided by means of a model theory (normative)
over the abstract syntax already described
monotonic
no closed-world assumptions no defaults
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDF Interpretations
Consider a set of terms T (URIs and Literals in a graph) Denition (Simple Interpretation) a simple interpretation I over T is composed by non-empty set of resources (domain of I)
set P (properties of I) PL , which contains all the plain literals in T
mapping V from URI references in T into P mapping L from typed literals in T into mapping E from P into the powerset of
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDF Interpretations
double level interpretation the key is in E literals are in the domain no bnodes in T
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Triples Satisability
interpretation I(t) of a term t T
I(t) = t if t is a plain literal I(t) = L(t) if t is a typed literal I(t) = V(t) if t is a URI reference
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Triples Satisability
interpretation I(t) of a term t T
I(t) = t if t is a plain literal I(t) = L(t) if t is a typed literal I(t) = V(t) if t is a URI reference
a triple s p o . is satised by I i
I(s), I(o) E(I(p))
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Triples Satisability
interpretation I(t) of a term t T
I(t) = t if t is a plain literal I(t) = L(t) if t is a typed literal I(t) = V(t) if t is a URI reference
a triple s p o . is satised by I i
I(s), I(o) E(I(p))
Bnodes
B(G ) is the set of bnodes in G A a mapping from B(G ) to IA is the extension of I with A (i.e. IA (b) = A(b))
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Models of RDF Graphs
Ground graphs (without bnodes) Denition (Ground Satisability) I is a model of a ground RDF graph G i satises all the triples in G
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Models of RDF Graphs
Ground graphs (without bnodes) Denition (Ground Satisability) I is a model of a ground RDF graph G i satises all the triples in G Graphs with bnodes Denition (Satisability) I is a model of an RDF graph G i there is a mapping A from B(G ) to s.t. IA satises all the triples in G
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Simple Entailment
Entailment is dened in terms of models G entails G i every model of G is a model of G
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Simple Entailment
Entailment is dened in terms of models G entails G i every model of G is a model of G bnodes are existential variables
I model of G if exists A s.t. IA satises all the triples in G I model of G if exists A s.t. IA satises all the triples in G
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Simple Entailment
Entailment is dened in terms of models G entails G i every model of G is a model of G bnodes are existential variables
I model of G if exists A s.t. IA satises all the triples in G I model of G if exists A s.t. IA satises all the triples in G
What about RDF and RDFS?
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDF(S) Vocabulary
additional semantic conditions over the vocabulary e.g. rdf:type
restrict the set of models derived from the intended meaning (RDF data model) e.g. rdf:type is a rdf:Property
Semantic conditions e.g. x P i x, V(rdf:Property) E(V(rdf:type)) Axiomatic triples e.g. rdf:type rdf:type rdf:Property . RDF-MT doesnt cover reication, containers and collections
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDFS Semantic Conditions
RDFS introduces classes and their properties still based on rdf:type macro C() for unary predicates x C(y ) i x, y E(V(rdf:type))
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDFS Semantic Conditions
RDFS introduces classes and their properties still based on rdf:type macro C() for unary predicates x C(y ) i x, y E(V(rdf:type)) Semantic conditions
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDFS Semantic Conditions
RDFS introduces classes and their properties still based on rdf:type macro C() for unary predicates x C(y ) i x, y E(V(rdf:type)) Semantic conditions
Subclass: if x, y E(V(rdfs:subClassOf)) then C(x) C(y ) E (V (rdfs:subClassOf)) is transitive and reexive
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDFS Semantic Conditions
RDFS introduces classes and their properties still based on rdf:type macro C() for unary predicates x C(y ) i x, y E(V(rdf:type)) Semantic conditions
Subclass: if x, y E(V(rdfs:subClassOf)) then C(x) C(y ) E (V (rdfs:subClassOf)) is transitive and reexive Domain: if x, y E(V(rdfs:range)) then u, v E(x) implies v C(y )
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDFS Semantic Conditions
RDFS introduces classes and their properties still based on rdf:type macro C() for unary predicates x C(y ) i x, y E(V(rdf:type)) Semantic conditions
Subclass: if x, y E(V(rdfs:subClassOf)) then C(x) C(y ) E (V (rdfs:subClassOf)) is transitive and reexive Domain: if x, y E(V(rdfs:range)) then u, v E(x) implies v C(y )
somethings wrong here?
Sergio Tessaris RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Extensional Semantic Conditions
One direction (only if) is missing! Semantic conditions revised
Subclass: x, y E(V(rdfs:subClassOf)) i C(x) C(y ) Domain: x, y E(V(rdfs:range)) i u, v E(x) implies v C(y )
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Extensional Semantic Conditions
One direction (only if) is missing! Semantic conditions revised
Subclass: x, y E(V(rdfs:subClassOf)) i C(x) C(y ) Domain: x, y E(V(rdfs:range)) i u, v E(x) implies v C(y )
:p1 rdfs:range :c1 . :p2 rdfs:range :c2 . :p1 rdfs:subPropertyOf :p2 .
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Extensional Semantic Conditions
One direction (only if) is missing! Semantic conditions revised
Subclass: x, y E(V(rdfs:subClassOf)) i C(x) C(y ) Domain: x, y E(V(rdfs:range)) i u, v E(x) implies v C(y )
:p1 rdfs:range :c1 . :p2 rdfs:range :c2 . :p1 rdfs:subPropertyOf :p2 . implies? :c1 rdfs:subClassOf :c2 .
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Extensional Semantic Conditions
One direction (only if) is missing! Semantic conditions revised
Subclass: x, y E(V(rdfs:subClassOf)) i C(x) C(y ) Domain: x, y E(V(rdfs:range)) i u, v E(x) implies v C(y )
:p1 rdfs:range :c1 . :p2 rdfs:range :c2 . :p1 rdfs:subPropertyOf :p2 . implies? :c1 rdfs:subClassOf :c2 . only with extensional semantic conditions (not normative)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDFS Semantic Conditions
x C(y ) i x, y E(V(rdf:type)) x, y E(V(rdfs:subClassOf)) x, y E(V(rdfs:subPropertyOf)) x, y E(V(rdfs:range)) x, y E(V(rdfs:domain)) i i i i C(x) C(y ) E(x) E(y ) u, v E(x) v C(y ) u, v E(x) u C(y )
if x C(V(rdfs:Class)) if x C(V(rdfs:Datatype))
then then
C(x) C(V(rdfs:Resource)) C(x) C(V(rdfs:Literal))
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDF(S) Literals
Plain literals (RDFS) PL = C(V(rdfs:Literal))
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDF(S) Literals
Plain literals (RDFS) PL = C(V(rdfs:Literal)) aects logical implication :myself foaf:name "Sergio Tessaris" . entails :myself foaf:name :b1 . :b2 rdf:type rdfs:Literal .
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDF(S) Literals
Plain literals (RDFS) PL = C(V(rdfs:Literal)) aects logical implication :myself foaf:name "Sergio Tessaris" . entails :myself foaf:name :b1 . :b2 rdf:type rdfs:Literal . Note "Sergio Tessaris" rdf:type rdfs:Literal . is not a valid RDF(S) triple!
Sergio Tessaris RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Entailment Rules
a set of inference rules to capture RDF(S)-entailment rules complete an RDF graph add a triple if there is some pattern
rules application terminates in a polynomial number of steps
set of rules for RDF and RDFS (informative)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Entailment Rules
Lemma (Entailment Lemma) G rdf(s)-entails E i exists G derived from G with axiomatic triples using the entailment rules s.t. G simply entails E . simple entailment is enough eective procedure (needs simple entailment)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Grounding RDF Graphs
Grounding a graph G Def completed: added axiomatic triples and applied entailment rules Def Herbrand model: each bnode replaced by an URIs or Literal Def Canonical model (G ): bnodes replaced with fresh URIs
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Graph entailment
Theorem RDF graphs entailment: G entails E i some herbrand model of E is a subgraph of the canonical model of G Connects our denition to W3C normative semantics Complexity of entailment
1 2 3
NP-complete in the size of the RDF graphs PTIME in the size of the entailing graph G PTIME if E is acyclic or ground
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
RDFS and FOL
RDF has an high order avour
URIs can play dierent roles ex:o, rdf:type, ex:o
Introduce a dierent model theoretic semantics for RDF
Compatible with FOL Extensibility to more expressive languages (e.g. OWL) Use standard technologies (e.g. databases or theorem provers)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
FO Compatible Model Theory
key idea: polymorphic interpretation of URIs (contextual PC)
abstract domain u IO : individual + function mapping valid literals to datavalues u IC : class u IR : binary relation
E.g. ex:o, rdf:type, ex:o leads to ex:oIO ex:oIC
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
RDF model theory Entailment Casting RDF into FOL
Classical Logic Interoperability
Def non-high order graph: no blank nodes as objects of rdf:type Def The classical logic translation FO(G ) of a non-high order graph G
URIs and literals are constants blank nodes are existentially quantied variables binary atomic formulas in correspondence with triples in G u1 , rdf:type, u2 triples introduce u2 (u1 ) atomic formulae
Theorem Given an RDF graph G and a non-high order graph E , G entails E i FO(G ) |=C FO(E )
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Querying RDF documents
How do we get informations out of an RDF document? RDF graphs can be stored in a variety of means
RDF/XML documents databases dedicated RDF service providers (e.g. RSS 1.0) generated on the y; e.g. from web pages (Gleaning Resource Descriptions from Dialects of Languages [GRDDL])
Often retrieving the whole graph is not feasible/desirable
too big lot of uninteresting parts dynamic
Solution: a (standard) protocol for querying RDF graphs
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Entailment and Querying
entailment and query answering are strictly related an answer to a query is a set of entailed facts
tuples representing variable bindings complex structures like RDF graphs or XML documents it depends on the query language
RDF aims at big volumes of data
look out for eciency (i.e. low data complexity)
two main factors
representational language (RDF) query language
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Querying RDF
RDF(S) is a simple language
entailment can be checked on a single canonical model see entailment rules and lemma
more freedom on the query language
truly graph based query language (e.g. a la XQuery) WilburQL simple language based on graph entailment
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Querying RDF
RDF(S) is a simple language
entailment can be checked on a single canonical model see entailment rules and lemma
more freedom on the query language
truly graph based query language (e.g. a la XQuery) WilburQL simple language based on graph entailment
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Graph Patterns
Dataset: graph to be queried dene a new kind of graphs: RDF graph patterns
RDF graphs with variables
?x
foaf:nick
"Alice" .
patterns may contain bnodes :b foaf:nick "Alice" .
Query Answering Find all the assignments for the variables that make the pattern a logical consequence of the Dataset
Sergio Tessaris RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Subgraph Matching
can we query in an ecient way?
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Subgraph Matching
can we query in an ecient way? entailment lemma: simple entailment is subgraph matching
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Subgraph Matching
can we query in an ecient way? entailment lemma: simple entailment is subgraph matching subgraph matching is conjunctive query answering
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Subgraph Matching
can we query in an ecient way? entailment lemma: simple entailment is subgraph matching subgraph matching is conjunctive query answering Dataset can be stored in a relational database
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Subgraph Matching
can we query in an ecient way? entailment lemma: simple entailment is subgraph matching subgraph matching is conjunctive query answering Dataset can be stored in a relational database the answer is yes!
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Subgraph Matching
can we query in an ecient way? entailment lemma: simple entailment is subgraph matching subgraph matching is conjunctive query answering Dataset can be stored in a relational database the answer is yes! nothing more than conjunctive queries using a single ternary predicate (e.g. triple(x, foaf:nick, "Alice"))
e.g. Oracle supports RDF and an extension to SQL most SPARQL implementations rely on a database back-end
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
ORACLE SQL Extension
SELECT t.r reviewer, e.emailid emailid FROM TABLE(RDF_MATCH( (?r ReviewerOf ?c) (?r rdf:type Faculty), RDFModels(reviewers), NULL, NULL)) t, employees e WHERE t.r = e.name;
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
SPARQL
query language for RDF becoming a W3C recommendation based on Graph Patterns
patterns extract a set of variable bindings (tuples)
results from dierent graph patterns can be combined using an algebra
union of answersets left outer join ltering based on XQuery operators optionally, an RDF graph can be returned (using a template)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
SPARQL Example
BASE <http://example.org/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX ex: <properties/1.0#> SELECT DISTINCT ?person ?name ?age FROM <http://rdf.example.org/people.rdf> WHERE { ?person a foaf:Person ; foaf:name ?name. OPTIONAL { ?person ex:age ?age } . FILTER ! REGEX(?name, "Bob") } LIMIT 3 ORDER BY ASC[?name]
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
SPARQL Semantics
Semantics for pattern matching: entailment regime
kind of entailment: simple, RDF, RDFS, . . .
Answer set is a set of mappings from variables in Q to terms occurring in G Given an entailment |=E , a query pattern Q, an RDF graph G , then Q E -matches graph G with answer S if:
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
SPARQL Semantics
Semantics for pattern matching: entailment regime
kind of entailment: simple, RDF, RDFS, . . .
Answer set is a set of mappings from variables in Q to terms occurring in G Given an entailment |=E , a query pattern Q, an RDF graph G , then Q E -matches graph G with answer S if:
1
Q graph equivalent to Q (isomorphic to Q)
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
SPARQL Semantics
Semantics for pattern matching: entailment regime
kind of entailment: simple, RDF, RDFS, . . .
Answer set is a set of mappings from variables in Q to terms occurring in G Given an entailment |=E , a query pattern Q, an RDF graph G , then Q E -matches graph G with answer S if:
1 2
Q graph equivalent to Q (isomorphic to Q) G S(Q ) well-formed graph
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
SPARQL Semantics
Semantics for pattern matching: entailment regime
kind of entailment: simple, RDF, RDFS, . . .
Answer set is a set of mappings from variables in Q to terms occurring in G Given an entailment |=E , a query pattern Q, an RDF graph G , then Q E -matches graph G with answer S if:
1 2 3
Q graph equivalent to Q (isomorphic to Q) G S(Q ) well-formed graph G |=E (G S(Q ))
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
SPARQL Semantics
Semantics for pattern matching: entailment regime
kind of entailment: simple, RDF, RDFS, . . .
Answer set is a set of mappings from variables in Q to terms occurring in G Given an entailment |=E , a query pattern Q, an RDF graph G , then Q E -matches graph G with answer S if:
1 2 3
Q graph equivalent to Q (isomorphic to Q) G S(Q ) well-formed graph G |=E (G S(Q ))
Backward compatible with subgraph homomorphism
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
BNodes in Query Answers
Wheres the problem? why not G |=E S(Q )
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
BNodes in Query Answers
Wheres the problem? why not G |=E S(Q ) bnodes in answer sets
graph: :myself foaf:homepage "http://www.inf.unibz.it/" query: :b foaf:homepage ?x
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
BNodes in Query Answers
Wheres the problem? why not G |=E S(Q ) bnodes in answer sets
graph: :myself foaf:homepage "http://www.inf.unibz.it/" query: :b foaf:homepage ?x answers: [ ?x/"http://www.inf.unibz.it/" ], [ ?x/ :myself]
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
BNodes and Literals
which bnodes in answers? graph :myself foaf:name "Sergio Tessaris" . query ?x rdf:type rdfs:Literal answer
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
BNodes and Literals
which bnodes in answers? graph :myself foaf:name "Sergio Tessaris" . query ?x rdf:type rdfs:Literal answer querying precompleted graph graph :myself foaf:name "Sergio Tessaris" . :b rdf:type rdfs:Literal answer {[ ?x/ :b ]}
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
BNodes and Literals
which bnodes in answers? graph :myself foaf:name "Sergio Tessaris" . query ?x rdf:type rdfs:Literal answer querying precompleted graph graph :myself foaf:name "Sergio Tessaris" . :b rdf:type rdfs:Literal answer {[ ?x/ :b ]} in both cases :w rdf:type rdfs:Literal is a logical consequence
Sergio Tessaris
RDF Data Model and Query Languages
Introduction RDF Semantics Querying RDF
Introduction Graph Patterns Query languages SPARQL
Conclusions
RDF has a precise (model theoretic) semantics Several drawbacks, but its a standard we have to deal with it! Strange semantics but relatively easy to deal with (up to RDFS) Extensions (e.g. OWL) require a more careful rethinking of the whole framework
Keeping backward compatibility Interoperability via SPARQL Higher order style semantics (cfg HiLog)
Sergio Tessaris
RDF Data Model and Query Languages