0% found this document useful (0 votes)
17 views7 pages

Lec06 Rdfsquery

Uploaded by

Olfa Bouchaala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views7 pages

Lec06 Rdfsquery

Uploaded by

Olfa Bouchaala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

RDF and RDFS

axiomatic semantics

the meaning of the modeling primitives of RDF


and RDF Schema is being translated into first-
order logic

it provides a basis for reasoning support by


automated reasoners

lecture 6: rdf – axiomatic semantics and query

of#38# ece#627,#winter#‘13# 2# of#38#

RDF and RDFS RDF and RDFS


axiomatic semantics - approach axiomatic semantics - approach

language primitives are represented by constants:


Resource, Class, Property, subClassOf, etc. variable names begin with ?

a few predefined predicates are used as for all axioms are implicitly universally quantified
expressing relationships between the constants

ece#627,#winter#‘13# 3# of#38# ece#627,#winter#‘13# 4# of#38#

RDF and RDFS a.semantics RDF


basic predicates basic ideas – statements (from lecture 4)

PropVal(P, R, V) a triple:
object-attribute-value
! a predicate with 3 arguments, is used to or in other words:
represent an RDF statement with resource R, resource-property-value
property P and value V (values are resources or literals)
! an RDF statement (triple) (R, P, V) is or
represented as PropVal(P, R, V) subject-property-object

ece#627,#winter#‘13# 5# of#38# ece#627,#winter#‘13# 6# of#38#


RDF and RDFS a.semantics RDF and RDFS a.semantics
basic predicates classes

Type(R, T) constants: Class, Resource, Property, Literal


! all classes are instances of Class
! short for PropVal(type, R, T) Type(Class,Class)
! specifies that the resource R has the type T Type(Resource,Class)
Type(Property,Class)
Type(?r, ?t) ↔ PropVal(type, ?r, ?t) Type(Literal,Class)

ece#627,#winter#‘13# 7# of#38# ece#627,#winter#‘13# 8# of#38#

RDF and RDFS a.semantics RDF and RDFS a.semantics


classes (2) classes (3)

Resource is the most general class: every class the predicate in an RDF statement must be a
and every property is a resource property

Type(?p,Property) → Type(?p,Resource) PropVal(?p,?r,?v) → Type(?p,Property)


Type(?c,Class) → Type(?c,Resource)

ece#627,#winter#‘13# 9# of#38# ece#627,#winter#‘13# 10# of#38#

RDF and RDFS a.semantics RDF and RDFS a.semantics


type property type property (2)

type is a property type can be applied to resources (domain) and has


a class as its value (range)
Type(type, Property)
is equivalent to
Type(?r, ?c) →
PropVal(type, type, Property)
(Type(?r, Resource) ∧ Type(?c, Class))

ece#627,#winter#‘13# 11# of#38# ece#627,#winter#‘13# 12# of#38#


RDF and RDFS a.semantics RDF and RDFS a.semantics
subclass subclass

subClassOf is a property if a class C is a subclass of a class C', then all


instances of C are also instances of C':

Type(subClassOf, Property)
PropVal(subClassOf, ?c, ?c') ↔
= PropVal(type, subClassOf, Property) (Type(?c, Class) ∧ Type(?c', Class) ∧
∀?x (Type(?x, ?c) → Type(?x, ?c')))

ece#627,#winter#‘13# 13# of#38# ece#627,#winter#‘13# 14# of#38#

RDF and RDFS a.semantics RDF and RDFS a.semantics


subproperty subproperty

subPropertyOf is a property P is a subproperty of P', if P'(x,y) is true whenever


P(x,y) is true:

Type(subPropertyOf, Property)
PropVal(subPropertyOf, ?p, ?p') ↔
= PropVal(type, subPropertyOf, Property) (Type(?p, Property) ∧ Type(?p', Property) ∧
∀?r ∀?v (PropVal(?p, ?r, ?v) →
PropVal(?p', ?r, ?v)))

ece#627,#winter#‘13# 15# of#38# ece#627,#winter#‘13# 16# of#38#

RDF and RDFS a.semantics RDF and RDFS a.semantics


domain and range domain and range

if the domain of P is D, then for every P(x,y), x∈D if the range of P is R, then for every P(x,y), y∈R

PropVal(domain, ?p, ?d) → PropVal(range, ?p, ?r) →


∀?x ∀?y (PropVal(?p, ?x, ?y) → Type(?x, ?d)) ∀?x ∀?y (PropVal(?p, ?x, ?y) → Type(?y, ?r))

ece#627,#winter#‘13# 17# of#38# ece#627,#winter#‘13# 18# of#38#


RDF and RDFS a.semantics RDF and RDFS semantics
issues inference rules

semantics in terms of RDF triples instead of


can be used for automatic reasoning, but … restating RDF in terms of first-order logic
the inference system consists of inference rules:
it needs first-order logic proof system to do so
IF E contains certain triples
THEN add to E certain additional triples

where E is an arbitrary set of RDF triples

ece#627,#winter#‘13# 19# of#38# ece#627,#winter#‘13# 20# of#38#

RDF and RDFS semantics RDF and RDFS semantics


inference rules – examples inference rules – examples

IF E contains the triples


IF E contains the triple (?x, ?p, ?y) (?u, rdfs:subClassOf, ?v) and (?v, rdfs:subClassOf, ?w)
THEN E also contains (?p, rdf:type, rdf:Property)
THEN E also contains the triple (?u, rdfs:subClassOf, ?w)
any resource ?p used in the property position can be inferred to be
a member of the class rdf:Property encodes transitivity of the subclass relation

ece#627,#winter#‘13# 21# of#38# ece#627,#winter#‘13# 22# of#38#

RDF and RDFS semantics RDF and RDFS semantics


inference rules – examples inference rules – examples

IF E contains the triples IF E contains the triples


(?x, rdf:type, ?u) and (?u, rdfs:subClassOf, ?v) (?x, ?p, ?y) and (?p, rdfs:range, ?u)

THEN E also contains the triple (?x, rdf:type, ?v) THEN E also contains the triple (?y, rdf:type, ?u)

… any resource ?y which appears as the value of a property ?p can be


inferred to be a member of the range of ?p
(range definitions in RDF Schema are not used to restrict the range
of a property, but rather to infer the membership of the range)

ece#627,#winter#‘13# 23# of#38# ece#627,#winter#‘13# 24# of#38#


SPARQL SPARQL
a query language for RDF a query language for RDF

XML query language (XPath) not suitable the simplest graph pattern is the triple pattern:
like an RDF triple, but with the possibility of a
SPARQL variable instead of an RDF term in the subject,
predicate, or object positions (?x, ?p, ?y)
(SPARQL Protocol and RDF Query Language)
is based on matching graph patterns
combining triple patterns gives a basic graph pattern,
where an exact match to a graph is needed to fulfill
a pattern

ece#627,#winter#‘13# 25# of#38# ece#627,#winter#‘13# 26# of#38#

SPARQL SPARQL
example example (2)

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> to retrieve all instances of a particular class (e.g. course) :
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> (declaration of rdf, rdfs prefixes omitted for brevity)
SELECT ?c
WHERE
PREFIX uni: <http://www.mydomain.org/uni-ns#>
{
SELECT ?i
?c rdf:type rdfs:Class . WHERE
} {
?i rdf:type uni:course .
this query retrieves all triple patterns, where: }
-the property is rdf:type
-the object is rdfs:Class - it retrieves all classes

ece#627,#winter#‘13# 27# of#38# ece#627,#winter#‘13# 28# of#38#

SPARQL SPARQL
select-from-where – query structure select-from-where

SELECT retrieve all phone numbers of staff members


specifies the projection: the number and order of retrieved data
SELECT ?x ?y
WHERE
FROM {
is used to specify the source being queried (optional) ?x uni:phone ?y .
}
WHERE
imposes constraints on possible solutions in the form of graph here ?x and ?y are variables, and ?x uni:phone ?y represents a
pattern templates and boolean constraints resource-property-value triple pattern

ece#627,#winter#‘13# 29# of#38# ece#627,#winter#‘13# 30# of#38#


SPARQL SPARQL
implicit join implicit join (2)

we restrict the second pattern only to those triples, the resource of the previous query is equivalent to
which is in the variable ?x
(a semicolon indicates that the following triple shares its subject with the
previous one) SELECT ?x ?y
WHERE
retrieve all lecturers and their phone numbers: {
?x rdf:type uni:Lecturer .
SELECT ?x ?y
WHERE ?x uni:phone ?y .
}
{ ?x rdf:type uni:Lecturer ;
uni:phone ?y . }

ece#627,#winter#‘13# 31# of#38# ece#627,#winter#‘13# 32# of#38#

SPARQL SPARQL
explicit join optional patterns

retrieve the name of all courses taught by the lecturer with ID 949352 <uni:lecturer rdf:about= 949352 >
<uni:name>Mike Knight</uni:name>
</uni:lecturer>
SELECT ?n
WHERE <uni:professor rdf:about= 94318 >
{ <uni:name>John Smith</uni:name>
?x rdf:type uni:Course ; <uni:email>[email protected]</uni:email>
uni:isTaughtBy :949352 . </uni:professor>
?c uni:name ?n .
FILTER (?c = ?x) . one has only name, the other has name and email address
}

ece#627,#winter#‘13# 33# of#38# ece#627,#winter#‘13# 34# of#38#

SPARQL SPARQL
optional patterns (2) optional patterns (3)
if we ask for lecturers and their email addresses as a solution we can adapt the query to use an optional pattern

SELECT ?name ?email SELECT ?name ?email


WHERE WHERE
{ ?x rdf:type uni:Lecturer ;
{ ?x rdf:type uni:Lecturer ;
uni:name ?name .
uni:name ?name ;
OPTIONAL { x? uni:email ?email }
uni:email ?email . }
}
the result: Mike Knight, John Smith, [email protected]
the result: John Smith, [email protected]

ece#627,#winter#‘13# 35# of#38# ece#627,#winter#‘13# 36# of#38#


RDF RDFS
summary summary

! provides a foundation for representing and ! RDF Schema is a primitive ontology language
processing metadata (offers certain modelling primitives with fixed
meaning)
! has a graph-based data model
! key concepts of RDF Schema are class, subclass
! has an XML-based syntax relations, property, subproperty relations, and
! allows incremental building of knowledge, and its domain and range restrictions
sharing and reuse ! there arequery languages for RDF and RDFS,
! is domain independent including SPARQL

ece#627,#winter#‘13# 37# of#38# ece#627,#winter#‘13# 38# of#38#

You might also like