Knowledge Representation Part VII Protégé / RDFS / OWL / ++ Jan Pettersen Nytun, UiA
Outline Protégé example RDFS OWL Some W3C documents concerning OWL 2
The Semantic Web Language Stack Hierarchy of languages, where each layer exploits and uses capabilities of the layers below. / XML Schema
Individuals [4]
Setting Default Namespace Explicitly I found some problems like double #’s in the stored file when not explicitly stating the namespace. Explicitly stating the default namespace
Turle File @prefix : <http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix xml: <http://www.w3.org/XML/1998/namespace> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @base <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#> . <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#> rdf:type owl:Ontology .
Turle File Continues... ######################################################## # # Object Properties :hasSibling rdf:type owl:ObjectProperty . :livesIn rdf:type owl:ObjectProperty .
Turle File Continues... ################################################################# # # Individuals :England rdf:type owl:NamedIndividual , owl:Thing . :Gemma rdf:type owl:NamedIndividual , :Matthew rdf:type owl:NamedIndividual , owl:Thing ; :livesIn :England ; :hasSibling :Gemma .
Adding Classes
########################################################## # # Classes :Country rdf:type owl:Class . :Person rdf:type owl:Class .
# Individuals :England rdf:type :Country , owl:NamedIndividual # Individuals :England rdf:type :Country , owl:NamedIndividual . :Gemma rdf:type :Person , :Matthew rdf:type :Person , owl:NamedIndividual ; :livesIn :England ; :hasSibling :Gemma .
[4]: In OWL classes are built up of descriptions that specify the conditions that must be satisfied by an individual for it to be a member of the class.
Which Syntax Does Protégé Uses?
Protégé Uses The Manchester OWL Syntax in Dialog Windows The Manchester syntax [OWL 2 Manchester Syntax] is an OWL syntax that is designed to be easier for non-logicians to read.
Save Ontology Using The Manchester Syntax Prefix: : <http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#> Prefix: owl: <http://www.w3.org/2002/07/owl#> Prefix: rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> Prefix: xml: <http://www.w3.org/XML/1998/namespace> Prefix: xsd: <http://www.w3.org/2001/XMLSchema#> Prefix: rdfs: <http://www.w3.org/2000/01/rdf-schema#> Ontology: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#> ObjectProperty: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#livesIn> ObjectProperty: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#hasSibling> Class: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#Person> Class: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#Country>
Individual: Matthew Types: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#Person> Facts: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#livesIn> <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#England>, <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#hasSibling> <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#Gemma> Individual: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#Gemma> Individual: <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#England> <http://http://www.uia.no/IKT437/janpettersennytun/ontologies/lecture5#Country>
Outline Protégé example RDFS OWL Some W3C documents concerning OWL 2
RDFS Allows definition of (simple) ontologies. RDFS gives some fundamental concepts, e.g.: subClassOf subPropertyOf Domain and range …
rdfs:subClassOf The members of one class (the subclass) are also members of the other (the super class). Tools like reasoners “understands” the semantics of subClassOf. :Female rdf:type owl:Class ; rdfs:subClassOf :Human .
rdfs:subPropertyOf The pair related by one property (the sub property) are included in the other (the super property). :hasSon rdf:type owl:ObjectProperty ; rdfs:subPropertyOf :isParentTo .
Property Domains and Ranges Properties link individuals from the domain to individuals from the range (or to “data” if for instance type is String). Pizza ontology example: - the property hasTopping links individuals belonging to class Pizza (domain) to individuals belonging to the class of PizzaTopping (range). It is important to realize that in OWL domains and ranges should not be viewed as only constraints to be checked. They are used as `axioms' in reasoning.
Domain and Range can be used to describe a property Domain and Range can be used to describe a property. They determine the class membership of individuals related by the property. Given the 2 triples: :employer rdfs:domain :Person :employer rdfs:range :Organization Then triple: :John :employer :CompanyX Requires that: - :John is necessarily a :Person - :CompanyX is necessarily a :Organization From Wikipedia, the free encyclopedia Mention primitive values… litterals.
Multiple Classes As The Range For A Property This is interpreted as the intersection of the classes. For example, if the range of a property has the classes Man and Woman, the range of the property is interpreted as Man intersection Woman (this range would then be very small in number of individuals since not many are man and woman at the same time).
Did not work for me!
This Seems to Work Fine! somePizza and someTopping are individuals stated to be of type Thing
Limitations Of RDFS [5] …modelers often need even richer and more expressive primitives to specify the formal semantics of Web resources… For example, one cannot state in RDFS that “this class is equivalent to this other class”, and cannot specify cardinality constraints.
Outline Protégé example RDFS OWL Some W3C documents concerning OWL 2
OWL OWL extends the possibilities found in RDFS, e.g.: equivalentClass inverseOf transitiveProperty SymetricProperty …
Part Of OWL Metamodel [5]
Unique Name Assumption (UNA) in Logic UNA different names always refer to different entities in the world. Protégé-OWL is based on UNA. OWL is not based on UNA. OWL supplies explicit constructs: owl:sameAs (property) two given names or identifiers (e.g., URIs) refer to the same individual or entity. owl:differentFrom (property) two given names or identifiers (e.g., URIs) refer to different individuals or entities. Assume UNA “helps” reasoners and may be also the ontology developer. But it may violate the real world…
Knowledge Representation Part III, JPN, UiA Disjoint Classes OWL Classes are assumed to “overlap”, e.g., an individual may be of several classes. It is however possible to specify that two classes are disjoint. Knowledge Representation Part III, JPN, UiA
Knowledge Representation Part II, JPN, UiA OWL Property types There are two main types of properties: Object properties. Datatype properties. Additionally: Annotation properties can be used to add metadata (data about data). Knowledge Representation Part II, JPN, UiA
Property Characteristics OWL allows the meaning of properties to be enriched through the use of property characteristics. E.g., inverse property. Knowledge Representation Part III, JPN, UiA
Knowledge Representation Part III, JPN, UiA Inverse Property If some property links individual A to individual B then its inverse property will link individual B to individual A. For example, Figure 4.16 shows the property hasParent and its inverse property hasChild. If Matthew hasParent Jean, then because of the inverse property we can infer that Jean hasChild Matthew. Knowledge Representation Part III, JPN, UiA
Functional Properties A functional property connects only one object or literal to a subject. birth mother: One's biological mother E.g., it is only possible to have one birth mother Knowledge Representation Part III, JPN, UiA
Functional Properties Continues … Mapping functional property to UML: It is possible to define an association as functional by specifying the upper multiplicity of the navigable end as being 0..1 Person isBirthMotherTo * birth mother: One's biological mother 0..1 Female hasBirthMother Knowledge Representation Part III, JPN, UiA
Inverse Functional Properties If a property is inverse functional then it means that the inverse property is functional. birth mother: One's biological mother Knowledge Representation Part III, JPN, UiA
Functional / Inverse Functional Properties Inverse functional properties are similar, but in the reverse direction. Person isBirthMotherTo Inverse Functional Property * birth mother: One's biological mother Functional Property 0..1 Female hasBirthMother JPN, UiA
Functional / Inverse Functional Properties continues … Both object properties and datatype properties can be declared as "functional“ but not “functional inverse”. [http://stackoverflow.com/questions/21487939/what-is-the-difference-between-datatypeproperty-objectproperty-functionalpro]: we cannot have the equivalence between the conditions that p is an inverse functional property and that p-1 is a functional property because datatype properties cannot have inverses. RDF does not allow literal values as the subjects of triples. I seems this is why we need both???
More Property Characteristics If a property is transitive, and the property relates individual a to individual b, and also individual b to individual c, then we can infer that individual a is related to individual c via property P. E.g., subRegionOf JPN, UiA
More Property Characteristics If a property P is symmetric, and the property relates individual a to individual b then individual b is also related to individual a via property P. E.g., hasSibling JPN, UiA
More Property Characteristics If a property P is asymmetric, and the property relates individual a to individual b then individual b cannot be related to individual a via property P. E.g., isMotherTo JPN, UiA
More Property Characteristics A property P is said to be reflexive when the property must relate individual to itself. E.g., hasRelative (everybody has himself as a relative). This does not necessarily mean that every two individuals which are related by a reflexive property are identical. birth mother: One's biological mother JPN, UiA
More Property Characteristics parentOf More Property Characteristics Irreflexive, meaning that no individual can be related to itself by such a role. E.g., hasParent birth mother: One's biological mother Knowledge Representation Part III, JPN, UiA
OWL Restrictions Three main categories: Quantifier Restrictions existential restrictions universal restrictions Cardinality Restrictions hasValue Restrictions
New version of Protégé calls it “Subclass of”
Existential Restrictions A restriction containing an owl:someValuesFrom constraint describes a class of all individuals for which at least one value of the property concerned is an instance of the class description or a data value in the data range.
Cardinality in dialog window should be ignored (it is 1..*)
In Turtle Representation pizza:Pizza rdf:type owl:Class ; rdfs:label "Pizza"@en ; rdfs:subClassOf [ rdf:type owl:Restriction ; owl:onProperty pizza:hasBase ; owl:someValuesFrom pizza:PizzaBase ] ; … At least one pizza base!
pizza:Margherita rdf:type owl:Class ; rdfs:label "Margherita"@pt ; rdfs:subClassOf pizza:NamedPizza , [ rdf:type owl:Restriction ; owl:onProperty pizza:hasTopping ; owl:allValuesFrom [ rdf:type owl:Class ; owl:unionOf ( pizza:MozzarellaTopping pizza:TomatoTopping ) ] ] , … Only = owl:allValuesFrom
There is no “+” for adding; conditions comes from superclass!
Multiple Inheritance from Anonymous Classes :Pizza rdf:type owl:Class ; rdfs:subClassOf [ rdf:type owl:Restriction ; owl:onProperty :hasTopping ; owl:someValuesFrom :PizzaTopping ] , [ rdf:type owl:Restriction ; owl:onProperty :hasBase ; owl:someValuesFrom :PizzaBase ] .
Reasoner Finding Inconsistency The actual reason that ProbeInconsistentTopping has been detected to be inconsistent is because its superclasses VegetableTopping and CheeseTopping are disjoint from each other.
Difference Between subClassOf and equivalentClass # Red wine is a subclass of all things that have a red color. :RedWine a owl:Class ; rdfs:subClassOf [ a owl:Restriction ; owl:onProperty :color ; owl:hasValue red^^<http://www.w3.org/2001/XMLSchema#string> ]. # The set of red things is exactly the same as the class of things that have the value # "red" for its color property . :RedThing a owl:Class ; owl:equivalentClass owl:hasValue red^^<http://www.w3.org/2001/XMLSchema#string> ] Necessary Sufficient
Using Necessary AND Sufficient Conditions
Outline Protégé example RDFS OWL Some W3C documents concerning OWL 2
OWL Some Documents From W3C Where to start: OWL 2 Web Ontology Language Document Overview (Second Edition) (http://www.w3.org/TR/2012/REC-owl2-overview-20121211/)
OWL 2 Syntaxes [http://www.semantic-web-book.org/w/images/7/75/W2011-08-OWL-Syntax.pdf]:
Syntaxes [OWL 2 Web Ontology Language Document Overview ]: Name of Syntax Specification Status Purpose RDF/XML Mapping to RDF Graphs, RDF/XML Mandatory Interchange (can be written and read by all conformant OWL 2 software) OWL/XML XML Serialization Optional Easier to process using XML tools Functional Syntax Structural Specification Easier to see the formal structure of ontologies Manchester Syntax Easier to read/write DL Ontologies Turtle Mapping to RDF Graphs, Turtle Optional, Not from OWL-WG Easier to read/write RDF triples
Any OWL 2 ontology can also be viewed as an RDF graph Any OWL 2 ontology can also be viewed as an RDF graph ... The OWL 2 Quick Reference Guide [http://www.w3.org/TR/2012/REC-owl2-quick-reference-20121211/] provides a simple overview of these two views of OWL 2, laid out side by side.
The OWL 2 Quick Reference Guide - Example 8.2.2 Universal Quantification A universal class expression ObjectAllValuesFrom( OPE CE ) consists of an object property expression OPE and a class expression CE, and it contains all those individuals that are connected by OPE only to individuals that are instances of CE. Provided that OPE is simple according to the definition in Section 11, such a class expression can be seen as a syntactic shortcut for the class expression ObjectMaxCardinality( 0 OPE ObjectComplementOf( CE ) ). ObjectAllValuesFrom := 'ObjectAllValuesFrom' '(' ObjectPropertyExpression ClassExpression ')'
The OWL 2 Quick Reference Guide – Example Continues… Consider the ontology consisting of the following axioms. ObjectPropertyAssertion( a:hasPet a:Peter a:Brian ) Brian is a pet of Peter. ClassAssertion( a:Dog a:Brian ) Brian is a dog. ClassAssertion( ObjectMaxCardinality( 1 a:hasPet ) a:Peter ) Peter has at most one pet. Language Feature Functional Syntax RDF Syntax class assertion ClassAssertion(C a) a rdf:type C. positive object property assertion ObjectPropertyAssertion( PN a1 a2 ) a1 PN a2. _:x rdf:type owl:Restriction. _:x owl:onProperty P. _:x owl:maxCardinality n. maximum cardinality ObjectMaxCardinality(n P)
Semantics [OWL 2 Web Ontology Language Document Overview ]: The OWL 2 Structural Specification document defines the abstract structure of OWL 2 ontologies, but it does not define their meaning. The Direct Semantics [OWL 2 Direct Semantics] and the RDF-Based Semantics [OWL 2 RDF-Based Semantics] provide two alternative ways of assigning meaning to OWL 2 ontologies, with a correspondence theorem providing a link between the two. These two semantics are used by reasoners and other tools, e.g., to answer class consistency, subsumption and instance retrieval queries.
Semantics [OWL 2 Web Ontology Language Document Overview ]: The Direct Semantics assigns meaning directly to ontology structures, resulting in a semantics compatible with the model theoretic semantics of the SROIQ description logic—a fragment of first order logic with useful computational properties. The advantage of this close connection is that the extensive description logic literature and implementation experience can be directly exploited by OWL 2 tools. ... Ontologies that satisfy these syntactic conditions are called OWL 2 DL ontologies.
OWL 2 Web Ontology Language Direct Semantics (http://www. w3 This document provides the direct model-theoretic semantics for OWL 2, which is compatible with the description logic SROIQ. Furthermore, this document defines the most common inference problems for OWL 2. (Paper about SROIQ: The Even More Irresistible SROIQ. IanHorrocks and OliverKutz and UlrikeSattler , The University of Manchester , http://www.cs.man.ac.uk/~sattler/publications/KR-06-SROIQ.pdf )
Sematic Description – Example [OWL 2 Web Ontology Language Direct Semantics ]: ObjectMaxCardinality( n OPE ) { x | #{ y | ( x , y ) ∈ (OPE)OP } ≤ n } (For S a set, #S denotes the number of elements in S.)
The Manchester OWL Syntax [http://webont.org/owled/2006/acceptedLong/submission_9.pdf] :
The Manchester OWL Syntax Continues… [http://webont.org/owled/2006/acceptedLong/submission_9.pdf] :
References [1] Book: David Poole and Alan Mackworth, Artificial Intelligence: Foundations of Computational Agents, Cambridge University Press, 2010, http://artint.info/ [2] http://www.w3.org/TR/swbp-n-aryRelations/ [3] RDF 1.1 Primer, W3C Working Group Note, 24 June 2014 [4] A Practical Guide To Building OWL Ontologies Using Protégé 4 and CO-ODE Tools Edition 1.3, Matthew Horridge [5] http://www.w3.org/TR/2009/REC-owl2-syntax-20091027/