Semantic-Web
Ontology Languages
Part I: RDF
Pascal Hitzler, Markus Krötzsch, Sebastian Rudolph
Informatik 2009 Lübeck
[Link]
Outline
• A Brief Motivation
• RDF
• Simple Semantics for RDF
• RDF Schema
• Semantics for RDF(S)
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 2
Why Semantic Web Modelling?
• Initially, the Web was made for humans reading webpages.
• But there‘s too much information out there to be entirely
checked by a human with a specific information need.
• Machines can process large amounts of data.
• Normal Web data (such as HTML) is not suitable for
content-sensitive machine processing (ambiguous, relies on
background knowledge, etc.)
• Semantic Web is concerned with representing information
distributed across the Web in a machine-interpretable way.
• So, why not use XML?
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 3
Shortcomings of (Pure) XML
• Task: express ”The Book ‘Foundations of Semantic Web
Technologies’ is published by CRC Press.”
• Many options:
<published>
<publisher>CRC Press</publisher>
<book>Foundations of Semantic Web Technologies</book>
</published>
<publisher name="CRC Press">
<published book=”Foundations of Semantic Web Technologies/>
</publisher>
<book name="Foudations of Semantic Web Technologies">
<published publisher="CRC Press”/>
</book>
• ambiguity and tree structure inappropriate for intended
purpose
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 4
Web-Wide Linked Open Data –
The Vision Becoming True
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 5
RDF: Graphs instead of Trees
• Solution: representation by directed
graphs
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 6
RDF
• “Resource Description Framework”
• W3C Recommendation
([Link]
• RDF is a data model (not one specific syntax)
– originally designed for providing metadata for Web
resources, later used for more general purposes
– encodes structured information
– universal machine-readable exchange format
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 7
Building blocks for RDF Graphs
• URIs
• literals
• blank nodes (aka: empty nodes, bnodes)
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 8
URIs - Idea
• URI = Uniform Resource Identifier
• allow for denoting resources in a world-wide
unambiguous way
• resources can be any object that possesses a
clear identity (within the context of a given
application)
• Examples: books, cities, humans, publishers,
but also relations between those, abstract
concepts, etc.
• already realized in some domains: e.g., ISBN
for books
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 9
URIs - Syntax
• Builds on concept of URLs but not every URI
refers to a Web document
(but often the URL of a document is used as its
URI)
• URI starts with so-called URI schema separated
from the following part by ":”
(e.g, http, ftp, mailto)
• mostly hierarchically organized
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 10
Self-defined URIs
• necessary if no URI exists (yet) for a resource
(or it is not known)
• strategy for avoiding unwanted clashes: use
http URIs of webspace you control
• this also allows you to provide some
documentation about the URI
• How to distinguish URI of a resource from URI
of the associated documents describing it?
• Example: URI for "Othello”
– don’t use:
[Link]
– rather use:
[Link]
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 11
Literals
• used for representing data values
• written down as strings
• interpreted via assigned datatype
• literals without explicitly associated
datatype are treated like strings
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 12
Bnodes
• used to state existence of an entity the
reference of which is not known
• from a logic perspective: existentially
quantified variables
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 13
Graphs as Triple Sets
• there are several ways for representing
graphs
• in RDF we see graphs as set of vertex-
edge-vertex triples
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 14
Graphs as Triple Sets
• there are several ways for representing
graphs
• in RDF we see graphs as set of vertex-
edge-vertex triples
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 15
Graphs as Triple Sets
• there are several ways for representing
graphs
• in RDF we see graphs as set of vertex-
edge-vertex triples
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 16
RDF Triples
• constitutents of an RDF triple
subject predicate object
• terms inspired by linguistics but doesn’t always
coincide
• eligible instantiations:
subject : URI or bnode
predicate : URI
objekt : URI or bnode or literal
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 17
Turtle - An Easy Syntax for RDF
Turtle notation:
– unabbreviated URIs in <…>
– literals in “…”
– period at the end of each triple
– extra spaces and linebreaks outside of names irrelevant
<[Link] <[Link] <[Link] .
<[Link] <[Link] "Foundations of Semantic Web Technologies" .
<[Link] <[Link] "CRC Press" .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 18
Turtle - An Easy Syntax for RDF
Turtle notation:
– unabbreviated URIs in <…> but can be abbreviated by namespaces
– literals in “…”
– period at the end of each triple
– extra spaces and linebreaks outside of names irrelevant
@prefix book: <[Link] .
@prefix ex: <[Link] .
@prefix crc: <[Link] .
book:uri ex:publishedBy crc:uri .
book:uri ex:title "Foundations of Semantic Web Technologies" .
crc:uri ex:name "CRC Press" .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 19
Turtle - An Easy Syntax for RDF
Turtle notation:
– unabbreviated URIs in <…> but can be abbreviated by namespaces
– literals in “…”
– period at the end of each triple
– extra spaces and linebreaks outside of names irrelevant
@prefix book: <[Link] .
@prefix ex: <[Link] .
@prefix crc: <[Link] . repeated subjects may be le0 out
book:uri ex:publishedBy crc:uri ;
book:uri ex:title "Foundations of Semantic Web Technologies" .
crc:uri ex:name "CRC Press" .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 20
Turtle - An Easy Syntax for RDF
Turtle notation:
– unabbreviated URIs in <…> but can be abbreviated by namespaces
– literals in “…”
– period at the end of each triple
– extra spaces and linebreaks outside of names irrelevant
@prefix book: <[Link] .
@prefix ex: <[Link] .
@prefix crc: <[Link] . repeated subjects may be le0 out
book:uri ex:publishedBy crc:uri ;
book:uri ex:title "Foundations of Semantic Web Technologies“ ;
ex:author book:Hitzler, book:Krötzsch, book:Rudolph .
crc:uri ex:name "CRC Press" . several objects can be
assigned to the same
subject‐predicate pairs
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 21
XML-Syntax of RDF
• there is also an XML syntax for RDF
• it’s for machines, so we don’t deal with it here
<rdf:Description rdf:about="[Link]
<ex:title>Foundations of Semantic Web Technologies</ex:title>
<ex:publishedBy>
<rdf:Description rdf:about="[Link]
<ex:name>CRC Press</ex:name>
</rdf:Description>
</ex:publishedBy>
</rdf:Description>
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 22
Datatypes in RDF
• by now: literals were untyped, interpreted as strings
(making e.g. "02”, ”2”, ”2.0” all different)
• typing literals with datatypes allows for more adequate
(semantic = meaning-appropriate) treatment of values
• datatypes denoted by URIs and can be freely chosen
• frequently: xsd datatypes from XML
• syntax of typed literal:
"datavalue"^^datatype-URI
• rdf:XMLLiteral is the only datatype that is part of the
RDF standard
• denotes arbitrary balanced XML “snippets”
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 23
Datatypes – the Abstract View
• Example: xsd:decimal
lexical space value space
datatype mapping
"3.14"
"3.14000" 3,14
"+03.14"
-2,5
"-2.5"
100
"100.00"
"3.14"="+03.14" holds for xsd:decimal but not for
xsd:string
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 24
Datatypes in RDF – Example
• Graph:
• Turtle:
@prefix xsd: <[Link] ."
<[Link]
<[Link] "RDF Primer"^^xsd:string ;"
<[Link]
"2004-02-10"^^xsd:date .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 25
Language Settings and Datatypes
• language settings only applicable to untyped literals
<[Link] "
<[Link]
"Initiation à RDF"@fr, "RDF Primer"@en .
• distinct types or language settings – distinct literals
<[Link] <[Link] "
"CRC Press" ,"
"CRC Press"@en ,"
"CRC Press"^^xsd:string .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 26
n-ary Relationships
• Cooking with RDF:
“For the preparation of Chutney, we need the following:
1 lb green mango, 1 tsp. Cayenne pepper, ...”
dish ingredient amount
chutney green mango 1 lb
chutney cayenne pepper 1 tsp.
• solved by auxiliary nodes (may be blank)
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 27
n-ary Relationships
• Turtle version 1:
@prefix ex: <[Link] .
ex:Chutney ex:hasIngredient _:id1 .
_:id1 ex:ingredient ex:greenMango; ex:amount "1lb" .
• Turtle version 2:
@prefix ex: <[Link] .
ex:Chutney ex:hasIngredient
[ ex:ingredient ex:greenMango; ex:amount "1lb" ] .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 28
Special Datastructures in RDF
• open lists (containers)
• closed lists (collections)
• reified triples
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 29
Open Lists (Container)
• Graph:
• by rdf:type we assign a list type to the root node
– rdf:Seq – ordered liste (sequence)
– rdf:Bag – unordered list
– rdf:Alt – set of alternatives or choices
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 30
Closed Lists (Collections)
• Graph:
• Abbreviation for Turtle:
@prefix book: <[Link] .
book:uri <[Link]
( book:uri/Hitzler book:uri/Krötzsch book:uri/Rudolph ) .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 31
Reification
• How to model propositions about propositions such
as:
„The Detective supposes that the butler killed the
gardener.“
ex:supposes
Reification
• Solution: auxiliary node for nested proposition
ex:supposes
rdf:subject rdf:predicate rdf:object
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 33
Simple Semantics
• RDF is focused on information exchange and
interoperability
• answers of RDF tools to
entailment queries
should coincide
• therefore, formal
semantics needed
• defined in a model-
theoretic way, i.e. we
start by defining
interpretations
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 34
Simple Semantics
• Interpretations in RDF:
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 35
Simple Semantics
• when is a triple valid in
an interpretation?
• a graph is valid, if all
its triples are
• this settles the case
for „grounded“
graphs
• graph with blank nodes
is valid if they can be
mapped to elements
such that the condition
on the right is satisfied
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 36
Simple Entailment
• this model theory defines simple entailment
• this is essentially graph matching with bnodes being
wildcards (more precisely: graph homomorphism)
Example: the graph
simply entails the graph
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 37
Schema Knowledge with RDF(S)
• RDF allows for specification of factual data
• = propositions about single resources
(individuals) and their relationships
• desirable: propositions about generic groups of
individuals, such as the class of publishers, of
organizations, or of persons
• in database terminology: schema knowledge
• RDF Schema (RDFS): part of the RDF W3C
recommendation
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 38
Classes and Instances
book:uri rdf:type ex:Textbook .
– characterizes the specific book as an instance of
the (self-defined) class of textbooks
– class-membership not exclusive: "
book:uri rdf:type ex:Enjoyable .
– URIs can be typed as class-identifiers:"
ex:Textbook rdf:type rdfs:Class ."
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 39
Subclasses
• we want to express that every textbook is a book, e.g.,
that every instance of the class ex:Textbook is
“automatically” an instance of the class ex:Book
• realized by rdfs:subClassOf property:
ex:Textbook rdfs:subClassOf ex:Book ."
• rdfs:subClassOf is defined to be transitive and reflexive
• rule of thumb:
rdf:type means ∈
rdfs:subClassOf means ⊆
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 40
Properties
• technical term for Relations, Correspondencies
• Property names usually occur in predicate position
in factoid RDF triples
• characterize, how two resources are related
• mathematically: set of pairs:
married_with = {(Adam,Eva),(Brad,Angelina),...}
• URI can be marked as property name by typing it
accordingly:
ex:publishedBy rdf:type rdf:Property .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 41
Subproperties
• in analogy to subclass relationships
• representation in RDFS via rdfs:subPropertyOf e.g.:
ex:happilyMarriedWith rdf:subPropertyOf rdf:marriedWith .
• then, given
ex:Markus ex:happilyMarriedWith ex:Anja ."
we can deduce
ex:Markus ex:marriedWith ex:Anja ."
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 42
Property Restrictions
• properties may give hints what types the linked resources
have, e.g. we know that ex:publishedBy connects
publications with publishers
• i.e., for all URIs a, b where we know
a ex:publishedBy b .
we want to automatically follow:
a rdf:type ex:Publication ."
b rdf:type ex:Publisher ."
• this generic correspondency can be encoded in RDFS:
ex:publishedBy rdfs:domain ex:Publication ."
ex:publishedBy rdfs:range ex:Publisher .
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 43
Property Restrictions
• with property restrictions, semantic interdependencies
between properties and classes can be specified
• Caution: property restrictions are interpreted globally and
conjunctively, e.g.
ex:authorOf rdfs:range ex:Cookbook ."
ex:authorOf rdfs:range ex:Storybook . "
means: everything which is authored by somebody is
both a cookbook and a storybook
• thus: always use most generic classes for domain/range
statements
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 44
Additional Information
• used to add human-readable information (comments or
names)
• for compatibility reasons graph-based representation
recommended; set of properties for that purpose:
– rdfs:label assigns an alternative name (encoded as
literal) to an arbitrary ressource
– rdfs:comment assigns a more comprehensive comment
(also literal)
– rdfs:seeAlso, rdfs:definedBy refer to resources (URIs!)
containing further information about the subject
resource
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 45
RDFS Entailment
• RDFS interpretations take care of RDF(S)-specific
vocabulary by imposing additional conditions on
simple interpretations:
– all URIs and bnodes are of type rdf:Resource
– triple predicates are of type rdf:Property
– all well-typed and untyped literals are of type rdf:Literal
– types of triple subjects/objects correspond to
rdfs:domain/rdfs:range statements
– rdfs:subClassOf and rdfs:subPropertyOf are interpreted
reflexive and transitive and “inheriting“
– well-formed XML-Literals are mapped into LV, ill-formed
ones go somewhere else
– ...and many more
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 46
RDFS Entailment – Automation
• RDFS entailment can be decided via rule-like
deduction calculus (NP-complete)
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 47
Semantics of RDFS via Translation
into FOL
• other option for defining RDF(S)
semantics: embedding into first order logic
• 2 Problems:
– FOL doesn‘t provide literals/datatypes
• can be tackled by „built-in“ predicates
– straight forward translation s p o . p(s,o)
does not work, as p might also occur in subject
or object position
• solved by alternative translation with one ternary
predicate: s p o . triple(s,p,o)
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 48
Semantics of RDFS via Translation
into FOL
• RDF graph is translated into FOL theory by
introducing statement triple(s,p,o) for every triple
spo.
• for every blank node, one distinct variable is used
(whereas URIs and literals are treated as
constants)
• the final translation is obtained by conjunctively
combining all the obtained statements and then
existentially quantifying over all variables
Markus Krötzsch, Sebas=an Rudolph: Seman=c Web Modelling Languages, ESSLLI 2009, Bordeaux. [Link]=c‐web‐[Link] 49
Semantics of RDFS via Translation
into FOL
• RDFS semantics can then be implemented
by axiomatising the deduction calculus:
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 50
Deployment of RDF
• today there is a variety of RDF tools
• software libraries for virtually every
programming language
• freely available systems for handling large sets
of RDF data (so-called RDF stores or triple
stores)
• increasingly supported by commercial actors
(e.g. Oracle)
• basis for several data formats: RSS 1.0, XMP
(Adobe), SVG (vector graphics format)
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 51
RDF(S) as Ontology Language?
• RDFS language features allow for modeling
certain semantic aspects of a domain of
interest
• hence, RDFS can be seen as a lightweight
ontology language
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 52
RDF(S) as Ontology Language?
Shortcomings of RDF(S):
• “weak” semantics:
ex:speaksWith rdfs:domain ex:Homo ."
ex:Homo rdfs:subClassOf ex:Primates .
does not entail
ex:speaksWith rdfs:domain ex:Primates .
• expressivity: no negative information can be
specified, no cardinality, no disjunction…
P. Hitzler, M. Krötzsch, S. Rudolph: Seman=c Web Ontology Languages, Informa=k 2009, Lübeck. [Link]=c‐web‐[Link] 53
References
• W3C Specification: [Link]
• Pascal Hitzler, Markus Krötzsch,
Sebastian Rudolph, York Sure,
Semantic Web – Grundlagen.
Springer, 2008.
[Link]
(In German.)
• Pascal Hitzler, Markus Krötzsch,
Sebastian Rudolph,
Foundations of Semantic Web Technologies.
Chapman & Hall/CRC, 2009.
[Link]
(Grab a flyer from us.)