Leif Harald Karlsen
Person
and our
understanding of the term “person”Student: A person taking a course at a university.
Person: A being that has certain capacities or attributes.
University: An institution focused on teaching and research in a wide range of domains.
Sonk: A dingu bolating a prosendu at a silidong.
Dingu: A bokinus that has junikal sonadages or pilonki.
Silidong: An inku pokusada on veleren and sokina in a hinduna range of kalindis.
L
is a mapping from
constructs/sentences over L
into some other
well-known language/structureL
into the well-known
language is known as interpretation type(x, y) . subClassOf(y, z) .
_____________________________________
type(x, z) .
or
type(x, y), subClassOf(y, z) -> type(x, z)
or for RDF
(?x rdf:type ?y) (?y rdfs:subClassOf ?z) -> (?x rdf:type ?z)
mother(x, y) -> parent(x, y);
Student(uid, sname, student_id, level, born)
Person(pid, pname, birthdate)
sname
s are also
pname
s”-- Relations:
Student(uid) Person(pid)
student_name(uid, sname) person_name(pid, pname)
student_id(uid, student_id) person_birthdate(pid, birthdate)
student_level(uid, level)
student_born(uid, born)
-- Rules:
Student(uid) -> Person(uid); -- All students are persons
student_name(uid, sname) -> person_name(uid, sname); -- snames are pnames
Student(uid)
is really the same as
uid rdf:type Student
student_name(uid, sname)
is really the same as
uid student_name sname
C(x), SubClassOf(C, D) -> D(x)
rdf:type
and rdfs:subClassOf
:
(?x rdf:type ?y) (?y rdfs:subClassOf ?z) -> (?x rdf:type ?z)
(?s ?p ?o) -> (?s ?p _:b)
where _:b
is a fresh blank node.
rdfs:Class
)rdf:type
) and subclassing
(rdfs:subClassOf
)rdf:Property
)rdfs:subPropertyOf
)rdfs:domain
) and range
(rdfs:range
)Data:
ex:leifhka ex:lectures ex:in5800 .
ex:martingi ex:lectures ex:in3060 .
ex:ole ex:takesCourse ex:in5800, ex:in2090 .
ex:mary ex:takesCourse ex:in3060 .
Ontology:
ex:Student rdf:type rdfs:Class .
ex:Employee rdf:type rdfs:Class .
ex:Lecturer rdf:type rdfs:Class .
ex:Person rdf:type rdfs:Class .
ex:Course rdf:type rdfs:Class .
ex:Student rdfs:subClassOf ex:Person .
ex:Lecturer rdfs:subClassOf ex:Employee .
ex:Employee rdfs:subClassOf ex:Person .
ex:takesCourse rdf:type rdfs:Property .
ex:lectures rdf:type rdfs:Property .
ex:takesCourse rdfs:domain ex:Student .
ex:takesCourse rdfs:range ex:Course .
ex:lectures rdfs:domain ex:Lecturer .
ex:lectures rdfs:range ex:Course .
(?x rdfs:subClassOf ?y) (?y rdfs:subClassOf ?z) -> (?x rdfs:subClassOf ?z)
(?x rdf:type ?y) (?y rdfs:subClassOf ?z) -> (?x rdf:type ?z)
(?r rdfs:subPropertyOf ?p) (?p rdfs:subPropertyOf ?q) -> (?p rdfs:subPropertyOf ?q)
(?x ?r ?y) (?r rdfs:subPropertyOf ?p) -> (?x ?p ?y)
(?x ?r ?y) (?r rdfs:domain ?d) -> (?x rdf:type ?d)
(?x ?r ?y) (?r rdfs:range ?d) -> (?y rdf:type ?d)
[sc-prop: (?x rdf:type ?y) (?y rdfs:subClassOf ?z) -> (?x rdf:type ?z) ]
where sc-prop
is the name of the rule.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
[sc-trans: (?x rdfs:subClassOf ?y) (?y rdfs:subClassOf ?z) -> (?x rdfs:subClassOf ?z) ]
[sc-prop: (?x rdf:type ?y) (?y rdfs:subClassOf ?z) -> (?x rdf:type ?z) ]
[sp-trans: (?r rdfs:subPropertyOf ?p) (?p rdfs:subPropertyOf ?q) -> (?p rdfs:subPropertyOf ?q) ]
[sp-prop: ?x ?r ?y) (?r rdfs:subPropertyOf ?p) -> (?x ?p ?y) ]
[domain: (?x ?r ?y) (?r rdfs:domain ?d) -> (?x rdf:type ?d) ]
[range: (?x ?r ?y) (?r rdfs:range ?d) -> (?y rdf:type ?d) ]
Could then apply these rules to the previous RDFS example with the JenaRuleReasoner.
rdf:type
,
rdfs:subClassOf
, rdfs:subPropertyOf
,
rdfs:domain
and rdfs:range
ex:Student rdfs:subClassOf
[ a owl:Class ;
owl:intersectionOf ( ex:Person
[ a owl:Restriction ;
owl:onProperty ex:takesCourse ;
owl:someValuesFrom ex:Course
]
)
] .
rdf:type
,
rdfs:subClassOf
, rdfs:subPropertyOf
,
rdfs:domain
and rdfs:range
?R owl:equivalentProperty ?P
: Equivalent properties
(?x ?R ?y) -> (?x ?P ?y)
and
(?x ?P ?y) -> (?x ?R ?y)
ex:hasSurename owl:equivalentProperty ex:hasLastname .
?R owl:inverseOf ?P
: Inverse properties
(?x ?R ?y) -> (?y ?P ?x)
and
(?x ?P ?y) -> (?y ?R ?x)
ex:hasParent owl:inverseOf ex:hasChild .
?R a owl:ReflexiveProperty
: Reflexive property
(?R rdfs:domain ?C) (?x rdf:type ?C) -> (?x ?R ?x)
ex:knows a owl:ReflexiveProperty .
?R a owl:SymmetricProperty
: Symmetric property
(?x ?R ?y) -> (?y ?R ?x)
ex:marriedTo a owl:SymmetricProperty .
?R a owl:TransitiveProperty
: Transitive property
(?x ?R ?y) (?y ?R ?z) -> (?x ?R ?z)
ex:hasAncestor a owl:TransitiveProperty .
[ owl:intersectionOf (?C1 ?C2 ... ?Ci ... ?Cn) ] rdfs:subClassOf ?C
:
Intersection subclass
(?x rdf:type ?C1), ..., (?x rdf:type ?Cn) -> (?x rdf:type ?C)
[ owl:intersectionOf (ex:Dog ex:Young) ] rdfs:subClassOf ex:Puppy .
?R owl:propertyChainAxiom (?P1 ?P2 ... ?Pn)
: Property
chains
(?x ?P1 ?x2) (?x2 ?P2 ?x3) ... (?xn ?Pn ?y) -> (?x ?R ?y)
ex:hasUncle owl:propertyChainAxiom ( ex:hasParent ex:hasBrother ) .
RDF:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.org/> .
ex:Person a owl:Class .
ex:Student a owl:Class ;
rdfs:subClassOf ex:Person .
ex:Employee a owl:Class ;
rdfs:subClassOf ex:Person .
ex:parent a owl:ObjectProperty ;
rdfs:range ex:Person ;
rdfs:domain ex:Person .
ex:mother a owl:ObjectProperty ;
rdfs:subPropertyOf ex:parent .
ex:name a owl:DatatypeProperty ;
rdfs:domain ex:Person ;
rdfs:range xsd:string .
ex:age a owl:DatatypeProperty ;
rdfs:domain ex:Person ;
rdfs:range xsd:integer .
ex:ola a ex:Student ;
ex:name "Ola" .
ex:kari ex:mother ex:ola ;
ex:age "35"^^xsd:integer .
Lore (simplified):
IMPORT 'http://leifhka.org/lore/library/prefix.lore';
prefix('xsd', 'http://www.w3.org/2001/XMLSchema#');
CREATE SCHEMA IF NOT EXISTS xsd;
prefix('rdfs', 'http://www.w3.org/2000/01/rdf-schema#');
CREATE SCHEMA IF NOT EXISTS rdfs;
prefix('ex', 'http://example.org/');
CREATE SCHEMA IF NOT EXISTS ex;
prefix('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
CREATE SCHEMA IF NOT EXISTS rdf;
prefix('owl', 'http://www.w3.org/2002/07/owl#');
CREATE SCHEMA IF NOT EXISTS owl;
CREATE RELATION owl.Class(individual text);
CREATE RELATION owl.DatatypeProperty(individual text);
CREATE RELATION owl.ObjectProperty(individual text);
CREATE RELATION ex.Employee(individual text);
CREATE RELATION ex.Person(individual text);
CREATE RELATION ex.Student(individual text);
CREATE RELATION ex.mother(subject text, object text);
CREATE RELATION ex.parent(subject text, object text);
CREATE RELATION ex.name(subject text, object text);
CREATE RELATION ex.age(subject text, object bigint);
ex.Employee(x) -> ex.Person(x);
ex.Student(x) -> ex.Person(x);
ex.mother(x, y) -> ex.parent(x, y);
ex.parent(x, y) -> ex.Person(y);
ex.parent(x, y) -> ex.Person(x);
ex.name(x, y) -> ex.Person(x);
ex.age(x, y) -> ex.Person(x);
owl.Class('http://example.org/Student');
owl.Class('http://example.org/Employee');
owl.Class('http://example.org/Person');
owl.DatatypeProperty('http://example.org/name');
owl.DatatypeProperty('http://example.org/age');
owl.ObjectProperty('http://example.org/mother');
owl.ObjectProperty('http://example.org/parent');
ex.Student('http://example.org/ola');
ex.name('http://example.org/ola', 'Ola');
ex.mother('http://example.org/kari', 'http://example.org/ola');
ex.age('http://example.org/kari', '35');
x rdf:type A
into
A(x)
s p o
into
p(s, o)
ex:A
can then be used as ex.A
prefix
)qn('ex', 'ole')
for ex:ole
ex:A rdfs:subClassOf ex:B
becomes
ex.A(x) -> ex.B(x)
-b
flag)owl:sameAs
, same as we showed
above)owl:ObjectProperty
or
owl:DatatypeProperty
owl:DatatypeProperty
s needs to have an
rdfs:range
-m r2rml
together with all the common DB-flagsCREATE RELATION triplelore_class(cname text);
CREATE RELATION triplelore_property(pname text, range text);
triplelore_class('ex.Employee');
triplelore_class('owl.DatatypeProperty');
triplelore_class('owl.Class');
triplelore_class('ex.Person');
triplelore_class('ex.Student');
triplelore_class('owl.ObjectProperty');
triplelore_property('ex.mother', NULL);
triplelore_property('ex.parent', NULL);
triplelore_property('ex.name', 'http://www.w3.org/2001/XMLSchema#string');
triplelore_property('ex.age', 'http://www.w3.org/2001/XMLSchema#integer');
-m r2rml
flag, e.g.:java -jar triplelore.jar \
-m r2rml \
-h dbpg-ifi-kurs03 \
-U leifhka \
-d in5800 \
-P pwd123 \
-o mappings.ttl
ontop query \
--db-driver=org.postgresql.Driver \
--db-url=jdbc:postgresql://dbpg-ifi-kurs03.uio.no/in5800 \
--db-user=leifhka \
--db-password=pwd123 \
-m mappings.ttl
-q query.sparql
Lets derive ancestor relationships from people.ttl via
Lets assume we are Bob (ex:bob
) and want to know our
ancestor’s occupations.
Bob managed to get a hold of:
people.ttl
) describing his closest relatives and
familypeople_ont.ttl
) defining family relationsHe can now simply use a reasoner (either Lore or Jena with the OWL rules or an OWL-reasoner) to do the integration and reasoning!
ex:takesCouse
)ex:in5800
)Note: Can use one standardized vocabulary to define another (e.g. OWL is used to define SKOS)
Via rules:
(?x ex:hasAncestor ?y) (?y ex:hasAncestor ?z) -> (?x ex:hasAncestor ?z)
Via OWL axiom:
ex:hasAncestor rdf:type owl:TransitiveProperty .