OWL Dr. Alexandra I. Cristea http://www.dcs.warwick.ac.uk/~acristea/ Once upon a time… “Wholly new forms of encyclopedias will appear, ready-made with a mesh of associative trails running through them, ready to be dropped into the memex and there amplified.” Vannevar Bush - As we may Think, July 1945 2 Semantic Web I have a dream for the Web [in which computers] become capable of analyzing all the data on the Web – the content, links, and transactions between people and computers. “a web of data can be this A "Semantic Web", which that should make possible, has yet to emerge, but and when it processed directly does, the day-to-day mechanisms of trade, indirectly machines” bureaucracy and our by daily lives will be handled by machines talking to machines. The "intelligent agents" people have touted for ages will finally materialize. 3 The SW stack (1.0, by TBL, 2000) 4 The SW stack (by Steve Bratt, 2007) 5 [W3.org] (reminder) • Extensible Markup Language (XML) is a simple, very flexible text format • Uniform Resource Identifiers (URIs, aka URLs) are short strings that identify resources in the web • The Resource Description Framework (RDF) is a general-purpose language for representing information in the Web. 6 [W3.org] • RDF Schema, is a semantic extension of RDF. • OWL facilitates: – greater machine interpretability of Web content than that supported by XML, RDF, and RDF Schema (RDF-S) – by providing additional vocabulary – along with a formal semantics. 7 What is OWL? • W3C Recommendation, February 2004. – – – • • • • • web standard Newest OWL 2 (W3C Recommendation 11 December 2012) http://www.w3.org/TR/owl2-overview/ Web Ontology Language originally built on top of RDF for processing information on the web designed to be interpreted by computers, not for being read by people OWL and a version of OWL2 are written in XML 8 9 Why OWL? • OWL is a part of the "Semantic Web Vision" - a future where: – Web information has exact meaning – Web information can be processed by computers – Computers can integrate information from the web • OWL was designed to – provide a common way to process the content of web information (instead of displaying it). – be read by computer applications (instead of humans). 10 What is an Ontology? (reminder) • formal specification of a certain domain • machine manipulable model • Ontology is about the exact description of things and their relationships and an inference mechanism for it. • For the web, ontology is about – the exact description of web information and – relationships between web information and – reasoning with it. • dictionary ⊂ taxonomy ⊂ ontology 11 History of OWL • Based on predecessors – (OWL DL = ¼ DAML+OIL) • A Web Language: Based on RDF(S) • An Ontology Language: Based on logic 12 OWL is Different from RDF • OWL , RDF similar • but OWL – stronger language – greater machine interpretability – larger vocabulary – stronger syntax. 13 OWL Sublanguages • OWL has three sublanguages: – OWL Lite • hierarchy + simple constraints + cardinality {0,1} – OWL DL (includes OWL Lite) • complete, decidable (part of FOL; extends ALC) • Type separations (class <> property <> individual) • OWL DL is the subset of OWL (Full) that is optimized for reasoning and knowledge modeling – OWL Full (includes OWL DL) • aug. meaning RDF. • Classes - individuals 14 OWL2 Profiles • OWL 2 EL – Polynomial time algorithms (standard reasoning) – For very large ontologies – Performance important; expressivity less • OWL 2 QL – Relat. Db. Queries in LogSpace (SQL) – Lightweight ontologies, many individuals • OWL 2 RL – Polynomial time algorithms (rule-extended db. technol.) – Lightweight ontologies; many individuals – Operating directly on RDF • All more restrictive than OWL DL 15 16 17 OWL can be written in XML • By using XML, OWL information can easily be exchanged between different types of computers using different types of operating system and application languages. • Oh yes, there is a namespace: xmlns:owl ="http://www.w3.org/2002/07/owl#" Note: OWL2 also written in the Manchester notation 18 OWL Use Cases • At least two different user groups – OWL used as data exchange language (define interfaces of services and agents) – OWL used for terminologies or knowledge models 19 OWL Example (Airport) • Example: http://www.cs.man.ac.uk/~rector/Modules/CS6462004/Labs/Thursday/Simple_University-01.owl • OWL Syntax converter: http://mowl-power.cs.man.ac.uk:8080/converter/ (offline currently) • Validators: RDF: http://www.w3.org/RDF/Validator/ (try it out) OWL: http://mowl-power.cs.man.ac.uk:8080/validator/ (offline currently) Protégé: http://protege.stanford.edu/products.php#desktop-protege • Semantic web search engine (for more OWL examples): http://swoogle.umbc.edu/ 20 21 22 Relationship OWL 2, OWL 1 • OWL 2 has a very similar overall structure to OWL 1. • backwards compatibility with OWL 1 is complete. • New features with new expressivity: – keys; property chains; richer datatypes, data ranges; qualified cardinality restrictions; – asymmetric, reflexive, and disjoint properties; and – enhanced annotation capabilities – Based on real applications, use cases and user experience 23 Modelling Knowledge: basics • OWL2: knowledge representation language • Axioms: statements expressed in OWL ontology • Entities: refer to real-world objects • Expressions: combinations/ descriptions of entities 24 OWL Ontologies • What’s inside an OWL ontology (entities) – Individuals – Properties (Slots) / values • Restrictions on properties (type, cardinality) • Characteristics of properties (transitive, …) – Classes + class-hierarchy • Relations between classes (inheritance, disjoints, equivalents) – Annotations • Reasoning tasks: classification, consistency checking 25 Last time: • We revisited: – the SW goals and – the SW stack and its components • discussed ontology languages in this context – Reminded ourselves about the ontology definition • Started OWL: – – – – – – – – why, history, OWL 1.1 vs. OWL2, OWL1.1 sub-languages, OWL2 Profiles, Use Cases, An Example, how OWL 2 models knowledge, OWL elements 26 Now: • OWL/XML – Starting with • header • elements (parts of the universe) • See also: http://www.w3.org/TR/2012/REC-owl2rdf-based-semantics-20121211/ 27 The OWL language • There are different syntactic forms of OWL: • – RDF/XML syntax see http://www.w3.org/TR/owl2-mapping-to-rdf/ (used for interchange: can be written and read by all conformant OWL 2 software) • – OWL/XML syntax that does not follow the RDF conventions (first of the languages) see http://www.w3.org/TR/owl2-xml-serialization/ • – functional syntax (used in the language specification document) (much more compact and readable) see http://www.w3.org/TR/owl2-syntax/ • – graphic syntax based on the conventions of UML (Unified Modelling Language) (an easy way for people to become familiar with OWL) • – Manchester syntax (used in the Protégé editor) see http://www.w3.org/TR/owl2-manchester-syntax/ 28 29 30 Parts of the Universe (OWL2) individuals data values ontologies classes datatypes properties rdfs:Resource rdfs:Literal owl:Ontology rdfs:Class rdfs:Datatype rdf:Property data properties owl:DatatypeProperty ontology properties owl:OntologyProperty annotation properties owl:AnnotationProperty 31 Structure of entities and literals in OWL2 32 OWL • Individuals (e.g., “FourSeasons”) • Properties – ObjectProperties (references) – DatatypeProperties (simple values) • Classes (e.g., “Hotel”) 33 Individuals 34 Individuals (Instances) • Represent objects in the domain • Specific things • Two names could represent the same “real-world” individual Sydney SydneysOlympicBeach BondiBeach 35 Example of Individuals <Region rdf:ID="CentralCoastRegion" /> equivalent to: <owl:Thing rdf:ID="CentralCoastRegion" /> <owl:Thing rdf:about="#CentralCoastRegion"> <rdf:type rdf:resource="#Region"/> </owl:Thing> 36 37 38 Homework task • Identify individuals in an ontology of your choice (either directly in OWL/RDF, or in Protégé) 39 Properties • Object Properties • Datatype Properties 40 ObjectProperties • Link two individuals together • Relationships (0..n, n..m) BondiBeach Sydney FourSeasons 41 Example Property <owl:ObjectProperty rdf:ID=“hasPart"> <rdfs:domain rdf:resource="#Destination" /> <rdfs:range rdf:resource="#Beaches" /> </owl:ObjectProperty> 42 Property Domain & Range • If a relation is: subject_individual hasProperty object_individual • The domain is the class of the subject individual • The range is the class of the object individual (or a datatype if hasProperty is a Datatype Property) DomainClass RangeClass 43 Properties, Range and Domain • Property characteristics – Domain: “left side of relation” (Destination) – Range: “right side” (Accomodation) Accomodation Destination BestWestern Sydney FourSeasons 44 Domains • Individuals can only take values of properties that have matching domain – “Only Destinations can have Accommodations” • Domain can contain multiple classes • Domain can be undefined: Property can be used everywhere 45 Property Restriction: Example Cardinality <owl:Class rdf:ID="Wine"> <rdfs:subClassOf rdf:resource="&food;PotableLiquid"/> <rdfs:subClassOf> <owl:Restriction> <owl:onProperty rdf:resource="#madeFromGrape"/> <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality> </owl:Restriction> </rdfs:subClassOf> ... </owl:Class> <owl:Restriction> <owl:onProperty rdf:resource="#madeFromGrape"/> <owl:minCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minCardinality </owl:Restriction> 46 OWL Extends Other Ontologies • extend existing ontology by saying things about terms in it: <owl:Class rdf:about="#Animal"> <rdfs:comment> Animals have exactly two parents, ie: If x is an animal, it has exactly 2 parents (but NOT anything that has 2 parents is an animal). </rdfs:comment> <rdfs:subClassOf> <owl:Restriction owl:cardinality="2"> <owl:onProperty rdf:resource="#hasParent"/> </owl:Restriction> </rdfs:subClassOf> </owl:Class> • If ontology is already published, you use the full URL. <owl:Class rdf:about="http://www.sample.com/ontologies/zoo#Animal"> 47 48 49 50 51 52 53 54 55 56 Restrictions (Overview) • Define a condition for property values – – – – – – allValuesFrom someValuesFrom hasValue minCardinality maxCardinality cardinality • An anonymous class consisting of all individuals that fulfill the condition 57 Inverse Properties • Represent bidirectional relationships • Adding a value to one property also adds a value to the inverse property (!) BondiBeach Sydney 58 Inverse Property Example <owl:ObjectProperty rdf:ID="hasPart"> <rdf:type rdf:resource="&owl;FunctionalProperty" /> </owl:ObjectProperty> <owl:ObjectProperty rdf:ID=“isPartOf"> <owl:inverseOf rdf:resource="#hasPart" /> </owl:ObjectProperty> 59 60 Transitive Properties • If A is related to B and B is related to C then A is also related to C • Often used for part-of relationships NewSouthWales Sydney BondiBeach hasPart (derived) 61 Transitive Property Example <owl:ObjectProperty rdf:ID="locatedIn"> <rdf:type rdf:resource="&owl;TransitiveProperty" /> <rdfs:domain rdf:resource="&owl;Thing" /> < Is this necessary? <rdfs:range rdf:resource="#Region" /> </owl:ObjectProperty> <Region rdf:ID="SantaCruzMountainsRegion"> <locatedIn rdf:resource="#CaliforniaRegion" /> </Region> What can be deduced? <Region rdf:ID="CaliforniaRegion"> <locatedIn rdf:resource="#USRegion" /> </Region> 62 • Previously: – Header of OWL – Individuals in OWL – Properties in OWL: • Domain, range, restrictions, inverse, transitive • Next: – More on Properties (sub-properties, datatype properties) – Classes 63 Sub-properties Example <owl:ObjectProperty rdf:ID="hasWineDescriptor"> <rdfs:domain rdf:resource="#Wine" /> <rdfs:range rdf:resource="#WineDescriptor" /> </owl:ObjectProperty> <owl:ObjectProperty rdf:ID="hasColor"> <rdfs:subPropertyOf rdf:resource="#hasWineDescriptor" /> <rdfs:range rdf:resource="#WineColor" /> ... </owl:ObjectProperty> What can we say about some instance that has a hasColor property? 64 Homework task • Identify different types of object properties in an ontology of your choice (either directly in OWL/XML, or in Protégé). Find out their type. 65 DatatypeProperties • Link individuals to primitive values (integers, floats, strings, Booleans etc) • Often: AnnotationProperties without formal “meaning” in OWL 1.1 Sydney hasSize = 4,500,000 isCapital = true rdfs:comment = “Don’t miss the opera house” 66 67 XML Schema Datatypes in OWL • OWL supports XML Schema primitive datatypes – E.g., integer, real, string, … • Strict separation between “object” classes and datatypes – Disjoint interpretation domain for datatypes – Disjoint “object” and datatype properties 68 Why Separate Classes and Datatypes? • Philosophical reasons: – Datatypes structured by built-in predicates – Not appropriate to form new datatypes using ontology language • Practical reasons: – Ontology language remains simple and compact – Semantic integrity of ontology language not compromised – Implementability not compromised — can use hybrid reasoner 69 Homework task • Identify datatype properties in an ontology of your choice (either directly in OWL/XML, or in Protégé) 70 Classes 71 Classes • Sets of individuals with common characteristics • Individuals are instances of at least one class Beach City Sydney Cairns BondiBeach CurrawongBeach 72 • Classes are defined using the owl:class element; • owl:class is a subclass of rdfs:class 73 Examples of Classes in OWL <owl:Class rdf:ID="Winery"/> <owl:Class rdf:ID="Region"/> <owl:Class rdf:ID="ConsumableThing"/> 74 Class membership • Adam is a Person. <Person rdf:ID="Adam"> <rdfs:label>Adam</rdfs:label> <rdfs:comment>Adam is a person. </rdfs:comment> <age><xsd:integer rdf:value="13"/></age> <shoesize><xsd:decimal rdf:value="9.5"/></shoesize> </Person> 75 Superclass Relationships • Classes can be organized in a hierarchy • Direct instances of subclass are also (indirect) instances of superclasses Cairns Sydney Canberra Coonabarabran 76 Example Subclasses <owl:Class rdf:ID="PotableLiquid"> <rdfs:subClassOf rdf:resource="#ConsumableThing" /> … </owl:Class> <owl:Class rdf:ID="Wine"> What can be said about wine here? <rdfs:subClassOf rdf:resource="&food;PotableLiquid"/> <rdfs:label xml:lang="en">wine</rdfs:label> <rdfs:label xml:lang="fr">vin</rdfs:label> ... </owl:Class> 77 Class Relationships • Classes can overlap arbitrarily RetireeDestination City Cairns BondiBeach Sydney 78 Class Disjointness • All classes could potentially overlap • In many cases we want to make sure they don’t share instances disjointWith UrbanArea Sydney Sydney City RuralArea Woomera CapeYork Destination 79 Example disjoint <owl:Class rdf:about="#Man"> <owl:disjointWith rdf:resource="#Woman"/> </owl:Class> not in OWL Lite! 80 How do we say: Lecturer is disjoint (different) from professor. 81 How do we say: Faculty is equivalent with academic staff. 82 83 84 85 86 87 You could also use owl:disjointWith here. 88 89 90 91 92 93 94 95 96 97 98 • Last time: – Last of OWL properties (sub-properties, datatype properties) – OWL classes: disjoint, union, intersection, equivalence, etc. • Next: – revisit reading OWL – OWL2 properties – Visualisation – Final OWL considerations 99 OWL Syntax What does this mean? <owl:Class> <owl:intersectionOf rdf:parseType="collection"> <owl:Class rdf:about="#Person"/> <owl:Restriction> <owl:onProperty rdf:resource="#hasChild"/> <owl:allValuesFrom> <owl:unionOf rdf:parseType="collection"> <owl:Class rdf:about="#Doctor"/> <owl:Restriction> <owl:onProperty rdf:resource="#hasChild"/> <owl:hasClass rdf:resource="#Doctor"/> </owl:Restriction> </owl:unionOf> </owl:allValuesFrom> </owl:Restriction> </owl:intersectionOf> </owl:Class> 100 Class Descriptions • Define the “meaning” of classes • Anonymous class expressions are used – “All national parks have campgrounds.” – “A backpackers destination is a destination that has budget accommodation and offers sports or adventure activities.” • Expressions mostly restrict property values (OWL Restrictions) 101 Restrictions (Reminder) • Define a condition for property values – – – – – – allValuesFrom someValuesFrom hasValue minCardinality maxCardinality cardinality • An anonymous class consisting of all individuals that fulfill the condition 102 Homework task • Identify different classes in an ontology of your choice (either directly in OWL/XML, or in Protégé); • Identify relations between classes; • Identify types of classes (including anonymous classes). 103 104 105 (reminder) 106 107 108 109 110 111 112 113 114 and after 115 Visualization of OWL ontologies 116 Protégé • http://protege.cim3.net/file/pub/ontologie s/travel/travel.owl 117 Visualization with OWLViz 118 Visualization in Ontograf 119 Tourism Semantic Web (2) OWL Metadata (Individuals) Tourism Ontology Destination Activity Accommodation Web Services 120 OWL File & import <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:travel="http://protege.stanford.edu/plugins/ owl/owl-library/travel.owl#" xml:base="http://protege.stanford.edu/plugins/owl/owllibrary/heli-bunjee.owl"> [. . .] </rdf:RDF> 121 OWL File: [. . .] OWL body in RDF wrap <owl:Ontology rdf:about=""> <owl:imports rdf:resource="http://protege.stanford.edu/ plugins/owl/owl-library/travel.owl"/> </owl:Ontology> <owl:Class rdf:ID="HeliBunjeeJumping"> <rdfs:subClassOf rdf:resource="http://protege.stanford. edu/plugins/owl/owl-library/travel.owl#BunjeeJumping"/> </owl:Class> <HeliBunjeeJumping rdf:ID="ManicSuperBunjee"> [***] </HeliBunjeeJumping> 122 OWL File [***] in HeliBunjeeJumping <travel:isPossibleIn> <rdf:Description rdf:about="http://protege.stanford.edu/plugins/owl/owllibrary/travel.owl#Sydney"> <travel:hasActivity rdf:resource="#ManicSuperBunjee"/> </rdf:Description> </travel:isPossibleIn> <travel:hasContact> [ +++ ] </travel:hasContact> <rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Manic super bunjee now offers nerve wrecking jumps from 300 feet right out of a helicopter. Satisfaction guaranteed. </rdfs:comment> 123 OWL File [+++] in travel:hasContact <travel:Contact rdf:ID="MSBInc"> <travel:hasEmail rdf:datatype="http://www.w3.org/2001/XMLSchema#string"> msb@manicsuperbunjee.com </travel:hasEmail> <travel:hasCity rdf:datatype="http://www.w3.org/2001/XMLSchema#string"> Sydney </travel:hasCity> <travel:hasStreet rdf:datatype="http://www.w3.org/2001/XMLSchema#string"> Queen Victoria St </travel:hasStreet> <travel:hasZipCode rdf:datatype="http://www.w3.org/2001/XMLSchema#int"> 1240 </travel:hasZipCode> </travel:Contact> 124 Problems with RDFS (reminder) RDFS too weak to describe resources in sufficient detail – No localised range and domain constraints • Can’t say that the range of hasChild is person when applied to persons and elephant when applied to elephants – No existence/cardinality constraints • Can’t say that all instances of person have a mother that is also a person, or that persons have exactly 2 parents – No transitive, inverse or symmetrical properties • Can’t say that isPartOf is a transitive property, that hasPart is the inverse of isPartOf or that touches is symmetrical Difficult to provide reasoning support – No “native” reasoners for non-standard semantics – May be possible to reason via FO axiomatisation 125 Homework 126 127 Web Ontology Language Requirements Desirable features identified for Web Ontology Language: Extends existing Web standards – Such as XML, RDF, RDFS • Easy to understand and use – Should be based on familiar KR idioms • Formally specified • Of “adequate” expressive power • Possible to provide automated reasoning support 128 From RDF to OWL (history) • Two languages developed to satisfy above requirements – OIL: developed by group of (largely) European researchers (several from EU OntoKnowledge project) – DAML-ONT: developed by group of (largely) US researchers (in DARPA DAML programme) • Efforts merged to produce DAML+OIL – Development was carried out by “Joint EU/US Committee on Agent Markup Languages” – Extends (“DL subset” of) RDF • DAML+OIL submitted to W3C as basis for standardisation – Web-Ontology (WebOnt) Working Group formed – WebOnt group developed OWL language based on DAML+OIL – OWL language became thus a W3C Proposed Recommendation 129 OWL Language • Three species of OWL – OWL full is union of OWL syntax and RDF – OWL DL restricted to FOL fragment (¼ DAML+OIL) – OWL Lite is “easier to implement” subset of OWL DL • Semantic layering – OWL DL ¼ OWL full within DL fragment – DL semantics officially definitive • OWL DL based on SHIQ Description Logic – In fact it is equivalent to SHOIN(Dn) DL • OWL DL Benefits from many years of DL research – – – – Well defined semantics Formal properties well understood (complexity, decidability) Known reasoning algorithms Implemented systems (highly optimised) 130 • Thus, OWL DL was used as basis of the OWL2 profiles: – OWL EL , – OWL QL , – OWL RL 131 OWL Lite Synopsis • • • • • • • • • • • • • • • • RDF Schema • Features: • Class (Thing, Nothing) • rdfs:subClassOf • rdf:Property rdfs:subPropertyOf • rdfs:domain • rdfs:range • Individual • (In)Equality: • equivalentClass • equivalentProperty • sameAs • differentFrom • AllDifferent • distinctMembers • • Property Characteristics: ObjectProperty DatatypeProperty inverseOf TransitiveProperty SymmetricProperty FunctionalProperty InverseFunctionalProperty Property Restrictions: Restriction onProperty allValuesFrom someValuesFrom Restricted Cardinality: minCardinality (only 0 or 1) maxCardinality (only 0 or 1) cardinality (only 0 or 1) • • • • • • • • • • • • • • • • • • • • • Header Information: Ontology imports Class Intersection: intersectionOf Versioning: versionInfo priorVersion backwardCompatibleW ith incompatibleWith DeprecatedClass DeprecatedProperty Annotation Properties: rdfs:label rdfs:comment rdfs:seeAlso rdfs:isDefinedBy AnnotationProperty OntologyProperty Datatypes xsd datatypes 132 OWL DL + Full • • • • • • • • • • • • • • • Class Axioms: oneOf, dataRange disjointWith equivalentClass (applied to class expressions) rdfs:subClassOf (applied to class expressions) Boolean Combinations of Class Expressions: unionOf complementOf intersectionOf Arbitrary Cardinality: minCardinality maxCardinality cardinality Filler Information: hasValue 133 OWL built-in classes • owl:FunctionalProperty, owl:InverseFunctionalProperty, owl:SymmetricProperty, owl:TransitiveProperty, owl:DeprecatedClass, owl:DeprecatedProperty 134 OWL built in properties • owl:equivalentClass, owl:disjointWith, owl:equivalentProperty, owl:inverseOf, owl:sameAs, owl:differentFrom, owl:complementOf, owl:unionOf, owl:intersectionOf, owl:oneOf, owl:allValuesFrom, owl:onProperty, owl:someValuesFrom, owl:hasValue, owl:minCardinality, owl:maxCardinality, owl:cardinality, owl:distinctMembers • annotation properties: owl:versionInfo, rdfs:label, rdfs:comment, rdfs:seeAlso, rdfs:isDefinedBy • ontology properties: owl:imports, owl:priorVersion, owl:backwardCompatibleWith, owl:incompatibleWith 135 OWL query language: OWL-QL • OWL Query Language (OWL-QL) is an updated version of the DAML Query Language (DQL). • It is intended to be a candidate standard language and protocol for queryanswering dialogues among Semantic Web computational agents. 136 OWL Class Constructors • XMLS datatypes as well as classes in • arbitrarily complex nesting of constructors 137 OWL Axioms 138 OWL Conclusion • We have learned: – OWL definition – OWL comparison with RDF – OWL classes and properties – Usage scenarios 139