0% found this document useful (0 votes)
13 views77 pages

KG02 Basic Knowledge Graph Infrastructure

The document discusses the foundational aspects of Knowledge Graphs for Explainable AI, focusing on the basic infrastructure required to identify and represent resources using RDF. It covers topics such as URIs, RDF serialization formats, and the representation of simple facts through RDF triples. Additionally, it introduces concepts like HTTP content negotiation and the use of Turtle notation for RDF serialization.

Uploaded by

232559
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)
13 views77 pages

KG02 Basic Knowledge Graph Infrastructure

The document discusses the foundational aspects of Knowledge Graphs for Explainable AI, focusing on the basic infrastructure required to identify and represent resources using RDF. It covers topics such as URIs, RDF serialization formats, and the representation of simple facts through RDF triples. Additionally, it introduces concepts like HTTP content negotiation and the use of Turtle notation for RDF serialization.

Uploaded by

232559
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

Knowledge Graphs for Explainable AI

Knowledge Graphs for Explainable AI

02: Basic Knowledge Graph Infrastructure

1. How to Identify and Access Things?


2. How to Represent Simple Facts with RDF?
3. RDF Turtle Serialization
4. Vocabularies and Model Building with RDFS
5. RDF Complex Data Structures
Dr. Imran Ihsan
6. RDF Reification and RDF* Ph.D. in Knowledge Engineering
Associate Professor
7. Logical Inference with RDF(S)
Knowledge Graphs for Explainable AI
2

02-01
How to Identify and Access Things?
02: Basic Knowledge Graph Infrastructure
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
3

What is this?

‫یہ سیب نہیں ہے‬


Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
4

Semiotic Triangle

Shared
Concept

Concept is a substitute of

Symbolizes Refers to

“Apple” Symbol Object


Stands for
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
5

Uniform Resource Identifier


A Uniform Resource Identifier (URI) defines a simple and extensible schema for worldwide unique
identification of abstract or physical resources (RFC 3986).
An Internationalized Resource Identifier (IRI) extends the URI definition by expanding the set of
permitted characters to most Unicode characters (RFC 3987).

A Resource can be every object with a clear identity (according to the context of the application)
as e.g., web pages, books, locations, persons, relations among objects, abstract concepts, etc.

URI concept is already established in various domains, as e.g.,


the Web (URL),
Books and publications (ISBN, ISSN),
Digital Object Identifier (DOI)
https://data.example.org/fruits/apples#this
schema domain/host path fragment
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
6

URL vs URI

URL URI
Identifies Identifies
what exists on the web
on the web what exists
http://www.imranihsan.com http://www.au.edu.pk/faculty_foaf.rd#me
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
7

The Basic Architecture of the Web

HTML communication
HTTP

WEB
reference address

URI
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
8

Would this be an appropriate URI?

??

https://www.xyz.org/apple
https://www.xyz.org/‫سیب‬
https://www.xyz.org/pomme
https://www.xyz.org/苹果
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
9

Would this be an appropriate URI?

??
https://www.wikidata.org/entity/Q312

https://www.wikidata.org/entity/Q89
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
10

Identification vs Lexicalization

rdfs:label
wd:Q89 “apple”@en

rdfs:label

“‫@”سیب‬ur

rdfs:label

“pomme”@fr

rdfs:label

“苹果”@cn
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
11

HTTP Content Negotiation


Designator and Designatum
URI
are separate things.
https://www.wikidata.org/entity/Q89
Therefore, they should have different URIs.
“Apple” is identified
HTTP CONTENT NEGOTIATION
by a URI.

Identifies “Apple” is represented


Via HTML code.
Metadata:
“Apple” is described Designatum = Resource
Content-type: text/html
(designated) by a web page. Data:
Represents
Describes <!DOCTYPE html>
(stands for)
<html class="client-nojs" lang="en" dir="ltr">
<head>
Designator <meta charset="UTF-8"/>
<title>apple - Wikidata</title>
...
</html> Representation
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
12

HTTP Content Negotiation


Let’s try an example:
I want to have information about “the Apple” from Wikidata.

1 HTTP GET request 4 HTML Document


Accept Header: text/html
https://wikidata.org/entity/Q89
URI represents Designatum

2 HTTP/2 303 See Other 3 HTTP GET request


https://wikidata.org/wiki/Q89 Accept Header: text/html
URI represents Designator https://wikidata.org/wiki/Q89
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
13

HTTP Content Negotiation


Let’s try an example:
I want to have machine understandable information about “the Apple” from Wikidata.

1 HTTP GET request 4 RDF Document


Accept Header: text/turtle
https://wikidata.org/entity/Q89
URI represents Designatum

Turtle is the way


to encode RDF

2 HTTP/2 303 See Other 3 HTTP GET request


https://wikidata.org/wiki/Q89 Accept Header: text/turtle
URI represents Designator https://wikidata.org/wiki/Q89
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
14

Basic Architecture of the Web of Data

HTML communication
HTTP

WEB
reference address

URI
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
15

The Basic Architecture of the Web

RDF communication
HTTP

WEB
OF DATA
reference address

URI
Knowledge Graphs for Explainable AI
16

02-01
How to Represent Simple Facts with RDF?
02: Basic Knowledge Graph Infrastructure
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
17

Resource Description Framework


How do I represent the following fact:
“Spock’s home planet is Vulcan” in an intuitive way?

Subject Spock URI

Predicate Home Planet URI

Object Vulcan URI or Literal


Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
18

Resource Description Framework


RDF Statements (RDF-Triple): In RDF the predicate of a
statement is referred to
as “Property”.

Subject Property Object/Value


URI URI URI/Literal

N-Triple Serialization
<http://dbpedia.org/resource/Spock> <http://dbpedia.org/property/origin> <http://dbpedia.org/resource/Vulcan>

Graph Representation
http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
19

Resource Description Framework


http://dbpedia.org/ontology/creator http://dbpedia.org/resource/Gene_Roddenberry

http://dbpedia.org/property/affiliation
http://dbpedia.org/resource/Starfleet

http://www.w3.org/2000/01/rdf-schema#label
“Spock”@en

http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan_(Star_Trek)

http://dbpedia.org/resource/Lennord_Nimoy
http://dbpedia.org/ontology/portrayer

http://dbpedia.org/resource/Zachary_Quinto
http://dbpedia.org/ontology/portrayer

http://dbpedia.org/ontology/portrayer http://dbpedia.org/resource/Ethen_Peck
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
20

Resource Description Framework


URIs and Literals
URIs identify and reference resources uniquely.
Literals describe data values that don’t have a separate existence.

Literal
“Spock”@en

http://www.w3.org/2000/01/rdf-schema#label

http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan

Entity
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
21

RDF Literals and Datatypes


Typed literals can be expressed via XML Schema datatypes
Namespace for typed literals:
http://www.w3.org/2001/XMLSchema#

Examples:
“Semantics” ^ ^<http://www.w3.org/2001/XMLSchema#string>
“1161.00” ^ ^<http://www.w3.org/2001/XMLSchema#float>
“2015-08-02” ^ ^<http://www.w3.org/2001/XMLSchema#date>

Language Tags denote the (natural) language of the text:


Example:
“Semantik“@de , “Semantics“@en
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
22

Existential Assertions – Blank Nodes


denote existence of an individual with specific attributes,
but without providing an identification or reference

Blank Node
http://dbpedia.org/property/origin
http://dbpedia.org/resource/Vulcan_(Star_Trek)

Cannot be
referenced
externally http://dbpedia.org/resource/Lenord_Nimoy
http://dbpedia.org/ontology/portrayer
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
23

RDF Terms, RDF Triples, and RDF Graph


Definitions:
Let 𝐼 denote the set of IRIs, 𝐿 the set of RDF Literals and 𝐵 the set of RDF blank nodes.
The set of RDF terms is defined as 𝐼 ∪ 𝐿 ∪ 𝐵.

An RDF triple 𝑡: = (𝑠, 𝑝, 𝑜) is any element of the set (𝐼 ∪ 𝐵)⨉(𝐼)⨉(𝐼 ∪ 𝐵 ∪ 𝐿),


where 𝑠 ∈ (𝐼 ∪ 𝐵) is called the subject,
𝑝 ∈ 𝐼 is called the predicate and
𝑜 ∈ (𝐼 ∪ 𝐵 ∪ 𝐿) is called the object.

An RDF graph 𝐺 is a subset of (𝐼 ∪ 𝐵)⨉(𝐼)⨉(𝐼 ∪ 𝐵 ∪ 𝐿),


i.e. an RDF graph is a set of RDF triples.
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
24

RDF Serializations
RDF comes with several different serialization formats:
N-Triples, RDF/XML, JSON-LD, Turtle, N-Quads, RDFa, Notation3, HexTuples...

We will use RDF/Turtle

N-Triples Turtle N-Quads

RDF/XML Notation 3 HexTuples

HDT RDFa

JSON-LD

support for multiple graphs


Knowledge Graphs for Explainable AI
25

02-03
RDF Turtle Serialization
02: Basic Knowledge Graph Infrastructure
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
26

N-Triples Serialization
“Spock”@en

http://www.w3.org/2000/01/rdf-schema#label

http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan

N-Triples Notation
URIs/IRIs in angle brackets
Literals in quotation marks
Triple ends with a period
.
N-Triples Serialization
<http://dbpedia.org/resource/Spock> <http://www.w3.org/2000/01/rdf-schema#label> “Spock”@en .
<http://dbpedia.org/resource/Spock> <http://dbpedia.org/property/origin> <http://dbpedia.org/resource/Vulcan> .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
27

N-Triples Serialization
“Spock”@en

http://www.w3.org/2000/01/rdf-schema#label

http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan _(Star_Trek)

Turtle (Terse RDF Triple Language) Notation


is an extension of N-Triples.

@prefix dbp: <http://dbpedia.org/property/> .


@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . RDF/Turtle allows
@base <http://dbpedia.org/resource/> . shortcuts and
abbreviations for
<Spock> rdfs:label "Spock"@en . readability.
<Spock> dbp:origin <Vulcan_(Star_Trek)> .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
28

N-Triples Serialization
“Spock”@en

http://www.w3.org/2000/01/rdf-schema#label

http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan _(Star_Trek)

Turtle (Terse RDF Triple Language) Notation


is an extension of N-Triples.

@prefix dbp: <http://dbpedia.org/property/> .


@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix directive
@base <http://dbpedia.org/resource/> . associates prefix-label with URI

@base directive
<Spock> rdfs:label "Spock"@en . provides URI to complement all relative URIs
<Spock> dbp:origin <Vulcan_(Star_Trek)> .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
29

N-Triples Serialization
“Spock”@en

http://www.w3.org/2000/01/rdf-schema#label

http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan _(Star_Trek)

Further RDF abbreviations with Turtle

@prefix dbp: <http://dbpedia.org/property/> .


@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . semicolon
indicates that subsequent triples have the
@base <http://dbpedia.org/resource/> .
same subject (predicate list)

<Spock> rdfs:label "Spock"@en ;


dbp:origin <Vulcan_(Star_Trek)> .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
30

N-Triples Serialization
http://dbpedia.org/ontology/portrayer
http://dbpedia.org/resource/Lennord_Nimoy

http://dbpedia.org/ontology/portrayer
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Zachary_Quinto

http://dbpedia.org/ontology/portrayer
http://dbpedia.org/resource/Ethen_Peck
Further RDF abbreviations with Turtle

@prefix dbp: <http://dbpedia.org/property/> .


@base <http://dbpedia.org/resource/> . comma
indicates that subsequent triples have same
subject and property (object list)
<Spock> rdfs:portrayer <Zachary_Quinto> ,
<Leonard_Nimoy> ,
<Ethan_Peck> .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
31

N-Triples Serialization
http://dbpedia.org/ontology/birthdate http://www.w3.org/2000/01/rdf-schema#label
“1931-03-26” ^ ^xsd:date “Spock”@en

http://dbpedia.org/resource/Spock

“1951-01-01” ^ ^xsd:gYear “2” ^ ^xsd:integer


http://dbpedia.org/ontology/activeYearsStartYear http://dbpedia.org/property/children

@prefix dbo: <http://dbpedia.org/ontology/> .


@prefix dbr: <http://dbpedia.org/property/> . Typed Literals
@prefix xsd: <http://www.w3c.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://dbpedia.org/resource/> .

<Leonard_Nimoy> rdfs:label "Leonard Nimoy"@en ;


dbo:birthDate "1931-03-26"^^xsd:date ;
dbo:activeYearsStartYear "1951-01-01"^^xsd:gYear ;
dbr:children "2"^^xsd:integer .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
32

N-Triples Serialization
dbp:position
dbr:Spock “First Officer”@en

dbp:startDate
“2265-01-01” ^ ^xsd: gYear

dbp:startDate
“2287-01-01” ^ ^xsd:gYear

dbp:vessel
dbr:USS_Enterprise_(NCC-1701)

dbp:vessel
dbr:USS_Enterprise_(NCC-1701)-A

N-ary Relations
Spock had different deployments in the Star Trek universe
How to model this in RDF?
Problem: unique association
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
33

Anonymous Blank Nodes


dbp:position
“First Officer”@en

dbp:startDate
“2265-01-01” ^ ^xsd: gYear
dbp:deployment dbp:vessel
dbr:USS_Enterprise_(NCC-1701)
dbr:Spock
dbp:position
“First Officer”@en
dbp:deployment
dbp:startDate
“2287-01-01” ^ ^xsd: gYear

dbp:vessel
dbr:USS_Enterprise_(NCC-1701)-A
N-ary Relations
Blank Nodes (Bnodes) can be introduced to represent multivalued relationships.
Blank Nodes can be introduced for resources that don’t need a name (auxiliary nodes).
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
34

Anonymous Blank Nodes


dbp:position
“First Officer”@en

dbp:startDate
“2265-01-01” ^ ^xsd: gYear

dbp:vessel
dbr:USS_Enterprise_(NCC-1701)

@prefix dbo: <http://dbpedia.org/ontology/> .


@prefix dbr: <http://dbpedia.org/property/> .
@prefix xsd: <http://www.w3c.org/2001/XMLSchema#> .

[] dbp:position "First Officer/ Science Officer"@en ;


dbp:startDate "2265-01-01“ ^ ^xsd:gYear ;
dbp:vessel dbr:USS_Enterprise_(NCC-1701) .

anonymous blank node as subject


Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
35

Anonymous Blank Nodes


dbp:position
“First Officer”@en

dbp:startDate
“2265-01-01” ^ ^xsd: gYear

dbp:deployment dbp:vessel
dbr:USS_Enterprise_(NCC-1701)

@prefix dbo: <http://dbpedia.org/ontology/> . dbr:Spock


dbp:position
@prefix dbr: <http://dbpedia.org/property/> . “First Officer”@en
dbp:deployment
@prefix xsd: <http://www.w3c.org/2001/XMLSchema#> . dbp:startDate
“2287-01-01” ^ ^xsd: gYear

dbr:Spock dbp:deployment [ dbp:position "First Officer/ Science Officer"@en ; dbp:vessel


dbr:USS_Enterprise_(NCC-1701)-A
dbp:startDate "2265-01-01“ ^ ^xsd:gYear ;
dbp:vessel dbr:USS_Enterprise_(NCC-1701) .
],
[ dbp:position "First Officer/ Science Officer"@en ;
dbp:startDate "2287-01-01“ ^ ^xsd:gYear ;
nested anonymous
blank nodes dbp:vessel dbr:USS_Enterprise_(NCC-1701)-A .
].
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
36

Anonymous Blank Nodes


dbp:position
“First Officer”@en

dbp:startDate
_:ID1 “2265-01-01” ^ ^xsd: gYear

dbp:deployment dbp:vessel
@prefix dbo: <http://dbpedia.org/ontology/> . dbr:USS_Enterprise_(NCC-1701)

@prefix dbr: <http://dbpedia.org/property/> . dbr:Spock


dbp:position
@prefix xsd: <http://www.w3c.org/2001/XMLSchema#> . “First Officer”@en
dbp:deployment
dbp:startDate
dbr:Spock dbp:deployment _:ID1 , _:ID2 . _:ID2 “2287-01-01” ^ ^xsd: gYear

dbp:vessel
dbr:USS_Enterprise_(NCC-1701)-A
_:ID1 dbp:position "First Officer/ Science Officer"@en ;
dbp:startDate "2265-01-01“ ^ ^xsd:gYear ;
dbp:vessel dbr:USS_Enterprise_(NCC-1701) .
dereferenceable blank nodes
_:ID2 dbp:position "First Officer/ Science Officer"@en ; can only be referenced from
dbp:startDate "2287-01-01“ ^ ^xsd:gYear ; inside a document / graph
dbp:vessel dbr:USS_Enterprise_(NCC-1701)-A .
Knowledge Graphs for Explainable AI
37

02-04
Vocabularies and Model Building with RDFS
02: Basic Knowledge Graph Infrastructure
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
38

What does it really mean?

http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan_(Star_Trek)

something which can be uniquely identified via the URI something which can be uniquely identified via the URI
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/ Vulcan_(Star_Trek)

but the URI for the same resource could also be but the URI for the same resource could also be
http://wikidata.org/entity/Q16341 http://wikidata.org/entity/Q1088708

We need more semantic expressivity...


Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
39

The Semantic Web Technology Stack

RDF Schema
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
40

Terms, Vocabularies, and Schemata


Definitions:
A term t is a word, compound word, or multi-word expression that in specific contexts is
given specific meanings.

A terminology or vocabulary 𝑉 = {𝑡1 , … , 𝑡𝑛 } is a set of terms used to describe data in a


particular domain or set of domains.

A schema is a formal description of the high-level structure of a dataset that may be used
for a variety of purposes, including managing, storing, indexing, querying, validating, and/or
reasoning over a dataset.

A semantic schema is a schema that allows for defining the meaning of high-level terms
(aka vocabulary or terminology), which facilitates reasoning over graphs using those terms.
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
41

Classes, Properties, and Instances


Definitions:
Classes are abstract groups, sets, or collections of resources usually with some
conceptional similarities. Classes group resources (instances) of the same type.

Classes are characterized by attributes (properties)..

:firstName
:person xsd:string
semi-formal description
:familyName
Person xsd:string
• firstName <string> :birthDate
• familyName <string>
xsd:date
• birthDate <date> :birthPlace
• birthPlace <location>
• address <string> :location
• …
:address xsd:string
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
42

Classes, Properties, and Instances


Definitions:
An RDF Property 𝑃 is defined as a relation between subject resources 𝑆 and
object resources 𝑂, 𝑃 ⊆ 𝑆⨂𝑂.
Instances are individual members 𝑖1 , … , 𝑖𝑛 of a class 𝐶, 𝑖1 , … , 𝑖𝑛 ∈ 𝐶.
An instance can be member of multiple classes

rdf:type :firstName
:LeonardNimoy :person xsd:string
:familyName
xsd:string
:birthDate
xsd:date
:birthPlace

:location

:address xsd:string
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
43

RDF Schema – Classes, Instances


RDF Schema, officially called “RDF Vocabulary Description Language”

The class of all classes


RDF Schema allows:
Definition of classes via rdfs:Class
Class instantiation in RDF via rdf:type
A Property to relate an
instance to its class
Example:
:Person rdf:type rdfs:Class .
:LeonardNimoy rdf:type :Person .

LeonardNimoy ∈ Perosn
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
44

RDF Schema – Property


Definition of properties via rdf:Property
The class of all properties

Definition of property restrictions on domain and range via rdfs:domain and rdfs:range

Example
:Person rdf:type rdfs:Class .
:Occupation rdf:type rdfs:Class .
:profession rdf:type rdf:Property .
:profession rdfs:domain :Person .
:profession rdfs:range :Occupation .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
45

RDF Schema – Meta Classes


Everything in the RDF model is a resource:

rdfs:Class rdf:type rdfs:Resource .


rdf:Property rdf:type rdfs:Resource .
rdfs:Literal rdf:type rdfs:Resource .
rdfs:XMLLiteral rdf:type rdfs:Resource .
rdfs:Datatype rdf:type rdfs:Resource .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
46

RDF Schema – Hierarchical Relationships


Subclasses and Superclasses via rdfs:subClassOf

Example:
:Scientist rdfs:subClassOf :Occupation .

Scientist ⊆ Occupation
:occupation

:scientist
Semantics of rdfs:subClassOf (denoted as “⊆”):
x x
∀A,B: Classes, a: Instance,
A ⊆ B (a ∈ A → a ∈ B)
i.e., ∀a,A,B: T(a, rdf:type, A) ∧ T(A, rdfs:subClassOf, B) → T(a, rdf:type, B) :scienceOfficer
:scientificAssistant

:ScientificAssistant rdf:type :Scientist .


:ScienceOfficer rdf:type :Scientist .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
47

RDF Schema – Hierarchical Relationships


Subproperties and Superproperties via rdfs:subPropertyOf

Example:
:firstName rdfs:subPropertyOf :name .

subProperty superProperty

Semantics of rdfs:subPropertyOf (denoted as “⊆”):

∀A,B: Properties, a,b: Instances,


A ⊆ B ((a,b) ∈ A → (a,b) ∈ B)
i.e., ∀a,b,A,B: T(a, A, b) ∧ T(A, rdfs:subPropertyOf, B)→ T(a, B, b)
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
48

RDF Schema – Annotation Properties


to annotate resources with useful (human-readable) information.

rdfs:seeAlso
defines a relation of a resource to another, which explains it

rdfs:isDefinedBy
subproperty of rdfs:seeAlso, defines the relation of a resource to its definition

rdfs:comment
Semantics of rdfs:seeAlso, rdfs:isDefinedBy, rdfs:comment, rdfs:label
comment, usually as text
is only denoted via natural language definitions,

rdfs:label
“readable” name of a resource (contrary to ID)
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
49

RDF Schema
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix : <http://example.org/KG2023#> .
:Person rdf:type rdfs:Class .
:FictionalCharacter rdf:type rdfs:Class .
T – BOX

:Occupation rdf:type rdfs:Class . Class Definition


:Artist rdfs:subClassOf :Occupation .
:Scientist rdfs:subClassOf :Occupation .
:profession rdf:type rdf:Property ;
rdfs:domain :Person, FictionalCharacter ; Property Definition
rdfs:range :Occupation .
:Actor rdf:type :Artist .
:ScienceOfficer rdf:type :Scientist .
A – BOX

:LeonardNimoy rdf:type :Person ;


:profession :Actor ;
rdfs:label Leonard Nimoy”@en .
Instance Definition
:Spock rdf:type :FictionalCharacter ;
rdfs:label "Spock"@en .
profession :ScienceOfficer .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
50

RDF Schema - Essentials


RDF Classes and properties provide a high-level vocabulary – a set of RDF terms – for general use in
RDF descriptions.

Vocabularies can be easily reused across different independent RDF sources.

Datasets that agree on vocabularies are better integrable since they “speak the same language”.

Naming convention:
Classes are given upper case singular names
(:Occupation, :Person, :FictionalCharacter, …)
Properties are given lower case singular names
(:profession, :birthPlace, :birthDate, …)
Knowledge Graphs for Explainable AI
51

02-05
RDF Complex Data Structures
02: Basic Knowledge Graph Infrastructure
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
52

RDF Complex Data Structures


An RDF graph is an unordered set of RDF triples.

RDF Lists
General data structures to enumerate any resources or literals and to introduce an
ordering. No new semantics, just “syntactic sugar”.

Distinguish between:
Container open list, i.e. extension (new entries) possible
Collection closed list, i.e. no extension possible
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
53

RDF Container – Open Lists


rdf:_1
:TheOriginalSeries

rdf:_2
defines the type of container, e.g. :starTrekTVSeriee :TheAnimatdSeries
Bag - unordered set
:contains rdf:_3
Seq - ordered set :TheNextGeneration
Alt - alternatives

:DeepSpace9
rdf:type rdf:_4

rdf:Bag
:Voyager
rdf:_5

rdf:_1 ... rdf:_n


relates a container to :Enterprise
rdf:_6
one of its elements.
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
54

RDF Container – Open Lists


rdf:_1
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . :TheOriginalSeries

@prefix : <http://example.org/KG2024#> .
rdf:_2
:starTrekTVSeriee :TheAnimatdSeries
:StarTrekTVSeries :contains [
:contains rdf:_3
a rdf:Bag ; :TheNextGeneration
rdf:_1 :TheOriginalSeries ;
rdf:_2 :TheAnimatedSeries ; :DeepSpace9
rdf:type rdf:_4
rdf:_3 :TheNextGeneration ;
rdf:_4 :DeepSpace9 ; rdf:Bag
:Voyager
rdf:_5 :Voyager ; rdf:_5

rdf:_6 :Enterprise rdf:_1 ... rdf:_n


relates a container to :Enterprise
]. rdf:_6
one of its elements.
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
55

RDF Container – Close Lists


@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . Head
@prefix : <http://example.org/KG2023#> . :starTrekTVSeriee :TheOriginalSeries
:StarTrekTVSeries :contains [ :contains
rdf:first
rdf:first :TheOriginalSeries ; rdf:rest [
rdf:first :TheAnimatedSeries ; rdf:rest [ :TheAnimatdSeries Tail
rdf:first :TheNextGeneration ; rdf:rest [ rdf:rest rdf:first

rdf:first :DeepSpace9 ; rdf:rest [


rdf:rest :TheNextGeneration
rdf:first :Voyager ; rdf:rest [
rdf:first
rdf:first :Enterprise ; rdf:rest
rdf:rest rdf:nil :DeepSpace9
rdf:first
] in short rdf:rest
]
rdf:rest :Voyager
] :StarTrekTVSeries :contains ( rdf:first
] :TheOriginalSeries :TheAnimatedSeries
] :TheNextGeneration :DeepSpace9 :Voyager rdf:nil rdf:rest :Enterprise
:Enterprise ) . rdf:first
].
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
56

RDF Datasets
Sometimes it is beneficial to keep data in separate RDF graphs, e.g.,
data from different sources (of different trustworthiness or accuracy),
the same data, but from different points in time,
etc.

An RDF dataset is a dictionary of RDF graphs, consisting of:


one default graph: an RDF graph (that may be empty),
zero or more named graphs: pairs consisting of
i. a name that can be a URI/IRI or a blank node, and
ii. an RDF graph (that may be empty)
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
57

RDF Datasets – Example


st1:GeneRoddenberry st1:TheOriginalSeries 3
st1:executiveProducer st1:seasons

st1:StarTeckSeries st1:birthPlace “1966-09-08”xsd:date


st1:releaseDate

st1:distributor
st1:ElPaso st1:MBC

:portrayer st2:createdBy
:Spock :LeonardNimoy st2:USEnterprise st2:MattJeffries
st2:lengthInMeters
:birthDate :deathDate
288.6
st2:massInMetricTons
“1931-03-26”xsd:date “2015-02-27”xsd:date st2:constHeavyCrusier 190,000

Default Graph st2:StarTeckSpaceShips


Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
58

RDF Datasets – Example


In practical scenarios quadruples (quads)
( s, p, o, g )
are used to serialize RDF datasets.

For Example:
st2:GeneRoddenberry st2:birthPlace st2:ElPaso .

from the graph st1:StarTrekTVSeries can be represented with


st2:GeneRoddenberry st2:birthPlace st2:ElPaso st1:StarTrekTVSeries .
Knowledge Graphs for Explainable AI
59

02-06
Reification and RDF
02: Basic Knowledge Graph Infrastructure
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
60

Let’s Ask ChatGPT


You
Who might be a literary role model for Spock, the science officer of the USS Enterprise?

ChatGPT

One literary role model for Spock, the science officer of the USS Enterprise, could be Sherlock Homes.
Both characters are known for their logical and analytical thinking, as well as their ability to remain calm
and rational in difficult situations. Additionally, both characters have a strong sense of duty and
commitment to solving problems, whether they be scientific or criminal nature.
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
61

RDF Reification
RDF also permits the interleaving of statements,
i.e. to make statements about statements.

Example:

ChatGPT states that Sherlock Holmes is a role model for Mr. Spock

Part 1: Sherlock Holmes is a role model for Mr. Spock


:SherlockHolmes :roleModel :Spock .

Part 2: stated by ChatGPT


??? :statedBy :ChatGPT .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
62

RDF Statement
rdf:Statment defines an RDF statement consisting of subject, predicate, object.

rdf:subject - the described resource

rdf:predicate - the original property

rdf:object - the value of the property

Sherlock Homes is a role model for Mr. Spock rdf:Statment

rdf:subject rdf:predicate rdf:object


Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
63

RDF Statement

“ChatGPT states that Sherlock Holmes is a role model for Mr. Spock”.

rdf:subject
:ChatGPT :SherlockHomes
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <http://example.org/KG2023#> . :statedBy

rdf:predicate
:Statement :roleModel
:statement1 a rdf:Statement ;
rdf:subject :SherlockHolmes ;
rdf:type
rdf:predicate :roleModel ;
rdf:object :Spock . rdf:Statement :Spock
rdf:object

:statement1 :statedBy :ChatGPT


Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
64

Alternative Representations – Singleton Properties


“ChatGPT states that Sherlock Holmes is a role model for Mr. Spock”.

:SherlockHomes :roleModel :Spock

:statedBy rdf:singletonPropertyOf

:ChatGPT :roleModel

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .


@prefix : <http://example.org/KG2023#> .
:SherlockHolmes :roleModel#1 :Spock .
:roleModel#1 rdf:singletonPropertyOf :roleModel ;
:statedBy :ChatGPT .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
65

Alternative Representations – RDF*


RDF* allows to consider RDF graphs either as subjects or objects of RDF triples.
RDF* syntax allows to recursively embed graphs into graphs.

“ChatGPT states that Sherlock Holmes is a role model for Mr. Spock”.

:roleModel
:SherlockHomes :Spock

:statedBy

:ChatGPT

@prefix : <http://example.org/KG2023#> .
<< :SherlockHolmes :roleModel :Spock >> :statedBy :ChatGPT .
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
66

RDF Reification
What is the use of reification?
Modeling data provenance
Formalizing statements about reliability and trust
Define metadata about statements

But you should be careful…


Relations and classes can be transformed into instances potentially resulting in type conflicts
Risk to define infinite recursions and cycles
Knowledge Graphs for Explainable AI
67

02-07
Logical Inference with RDF(S)
02: Basic Knowledge Graph Infrastructure
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
68

What does it really mean?

http://dbpedia.org/property/origin
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/Vulcan_(Star_Trek)

something which can be uniquely identified via the URI something which can be uniquely identified via the URI
http://dbpedia.org/resource/Spock http://dbpedia.org/resource/ Vulcan_(Star_Trek)

but the URI for the same resource could also be but the URI for the same resource could also be
http://wikidata.org/entity/Q16341 http://wikidata.org/entity/Q1088708

We need more semantic expressivity...


Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
69

Induction, Deduction, Abduction


The terms infer/inference are often used almost interchangeably with entail/entailment.
“entail” refers conceptually to what follows as a consequence,
“infer” refers to a process of computing entailments and is very similar to “reason/reasoning”.

Deductive reasoning involves applying rules over premises to derive conclusions


and is the main subject of Logic.

Inductive reasoning involves learning patterns from lots of examples and is the
main subject of Machine Learning.

Abductive reasoning involves deriving a likely explanation for an observation


based on a rule.
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
70

RDF(S) Semantics
In contrast to other data definition languages, RDF(S) is based on formal semantics.

Formal semantics enables RDF(S) to draw valid and sound logical inferences.

Examples:
:Spock rdf:type :FictionalCharacter .
:FictionalCharacter rdfs:subClassOf :Character .
:birthPlace rdfs:subPropertyOf :origin .

:Spock ∈ :FictionalCharacter
:FictionalCharacter ⊆ :Character
:birthPlace ⊆ :origin

Model-theoretic Semantics
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
71

Which Conclusions can we draw with RDF(S)?


:Character

rdfs:subClassOf

:FictionalCharacter

rdf:type

:birthPlace
:Spock :Vulcan
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
72

Which Conclusions can we draw with RDF(S)?


:Character

rdfs:subClassOf

rdf:type :FictionalCharacter

rdf:type

:birthPlace
:Spock :Vulcan

1) Deduction of new facts from a class hierarchy


∀𝑖, 𝑐1, 𝑐2: 𝑇(𝑖, 𝑟𝑑𝑓: 𝑡𝑦𝑝𝑒, 𝑐1) ∧ 𝑇(𝑐1, 𝑟𝑑𝑓𝑠: 𝑠𝑢𝑏𝐶𝑙𝑎𝑠𝑠𝑜𝑓, 𝑐2) → 𝑇(𝑖, 𝑟𝑑𝑓: 𝑡𝑦𝑝𝑒, 𝑐2)
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
73

Which Conclusions can we draw with RDF(S)?


:FictionalCharacter

rdf:type

rdfs:domain rdfs:range
:Character :birthPalace :Location

:birthPlace
:Spock :Vulcan
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
74

Which Conclusions can we draw with RDF(S)?


:FictionalCharacter

rdf:type

rdfs:domain rdfs:range
:Character :birthPalace :Location

rdf:type rdf:type

:birthPlace
:Spock :Vulcan

2) Deduction of entity class membership from the domain of one of its properties
∀𝑖1 , 𝑖2 , 𝑐1 , 𝑐2 , 𝑝: 𝑇(𝑖1 , 𝑝, 𝑖2 ) ∧ 𝑇(𝑝, 𝑟𝑑𝑓𝑠: 𝑑𝑜𝑚𝑎𝑖𝑛, 𝑐1 ) ∧ 𝑇(𝑝, 𝑟𝑑𝑓𝑠: 𝑟𝑎𝑛𝑔𝑒, 𝑐2 )
→ 𝑇(𝑖1 , 𝑟𝑑𝑓: 𝑡𝑦𝑝𝑒, 𝑐1 ) ∧ 𝑇(𝑖2 , 𝑟𝑑𝑓: 𝑡𝑦𝑝𝑒, 𝑐2 )
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
75

Which Conclusions can we draw with RDF(S)?


:FictionalCharacter

rdf:type

rdfs:domain rdfs:range
:Character :birthPalace :Location

rdf:type rdf:type

:birthPlace
:Spock :Vulcan

3) Deduction of entity class membership from the range of one of its properties
∀𝑖1 , 𝑖2 , 𝑐1 , 𝑐2 , 𝑝: 𝑇(𝑖1 , 𝑝, 𝑖2 ) ∧ 𝑇(𝑝, 𝑟𝑑𝑓𝑠: 𝑑𝑜𝑚𝑎𝑖𝑛, 𝑐1 ) ∧ 𝑇(𝑝, 𝑟𝑑𝑓𝑠: 𝑟𝑎𝑛𝑔𝑒, 𝑐2 ) →
𝑇(𝑖1 , 𝑟𝑑𝑓: 𝑡𝑦𝑝𝑒, 𝑐1 ) ∧ 𝑇(𝑖2 , 𝑟𝑑𝑓: 𝑡𝑦𝑝𝑒, 𝑐2 )
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
76

Which Conclusions can we draw with RDF(S)?


rdfs:domain rdfs:range
:Thing :origin :Thing
rdf:type
rdf:Property rdfs:subPropertyOf

rdf:type
rdfs:domain rdfs:range
:Character :birthPalace :Location

rdf:type rdf:type

:birthPlace
:Spock :Vulcan
Knowledge Graphs for Explainable AI 02: Basic Knowledge Graph Infrastructure
77

Which Conclusions can we draw with RDF(S)?


rdfs:domain rdfs:range
:Thing :origin :Thing
rdf:type
rdf:Property rdfs:subPropertyOf

rdf:type
rdfs:domain rdfs:range
:Character :birthPalace :Location

rdf:type :origin rdf:type

:birthPlace
:Spock :Vulcan

4) Deduction of new facts from subProperty relationships


∀𝑖1 , 𝑖2 , 𝑝1 , 𝑝2 : 𝑇(𝑖1 , 𝑝1 , 𝑖2 ) ∧ 𝑇(𝑝1 , 𝑟𝑑𝑓𝑠: 𝑠𝑢𝑏𝑃𝑟𝑜𝑝𝑒𝑟𝑡𝑦𝑂𝑓, 𝑝2 ) → 𝑇(𝑖1 , 𝑝2 , 𝑖2 )

You might also like