www.ontoknowledge.org/oil Ontologies in Semantic Web Based on tutorials and presentations: D. Lee, F. Harmelen, M. Arumugam, C. Goble, I. Horrocks, N. F. Noy, D.L. McGuinness, J. Broekstra, M. Klein, S. Decker, D. Fensel, DERI Group, H. Knublauch, N. Drummond, M. Horridge 1 Communication between people 2 The More or Less Global Agreement about Standard Terminology and Conceptual Hierarchy for a Domain Description is Necessary for the Interoperability in the Intelligent Web 3 Contents Introduction to Ontologies Ontology Engineering OWL: Web Ontology Language 4 5 What are ontologies? Ontologies are content theories about the sorts of objects, properties of objects, and relations between objects that are possible in a specified domain of knowledge. 6 What are ontologies? (3) Studer(98): Formal, explicit specification of a shared conceptualization Machine readable Concepts, properties, functions, axioms are explicitly defined Consensual knowledge Abstract model of some phenomena in the world 7 9 What Is “Ontology Engineering”? Ontology Engineering: Defining terms in the domain and relations among them Defining concepts in the domain (classes) Arranging the concepts in a hierarchy (subclasssuperclass hierarchy) Defining which attributes and properties (slots) classes can have and constraints on their values Defining individuals and filling in slot values 10 Tool for Ontology Engineering Screenshots in further examples are from Protégé-2000, which: is a graphical ontology-development tool supports a rich knowledge model is open-source and freely available (http://protege.stanford.edu/index.shtml) 11 Determine Domain and Scope What is the domain that the ontology will cover? For what we are going to use the ontology? For what types of questions the information in the ontology should provide answers (competency questions)? Answers to these questions may change during the lifecycle 12 Example Ontology Which wine should I serve with seafood today? French wines and wine regions A shared ONTOLOGY of wine and food California wines and wine regions 13 Competency Questions Which wine characteristics should I consider when choosing a wine? Is Bordeaux a red or white wine? Does Cabernet Sauvignon go well with seafood? What is the best choice of wine for grilled meat? Which characteristics of a wine affect its appropriateness for a dish? Does a flavor or body of a specific wine change with vintage year? 14 Enumerating Terms - The Wine Ontology wine, grape, winery, location,... wine color, wine body, wine flavor, sugar content,... white wine, red wine, Bordeaux wine,... food, seafood, fish, meat, vegetables, cheese,... 15 Define Classes and the Class Hierarchy A class is a concept in the domain a class of wines a class of wineries a class of red wines … A class is a collection of elements (instances of classes) with similar properties 16 Class Inheritance Classes usually constitute a taxonomic hierarchy (a subclass-superclass hierarchy) A class hierarchy is usually an IS-A hierarchy: an instance of a subclass is an instance of a superclass If you think of a class as a set of elements, a subclass is a subset 17 Class Inheritance - Example Apple is a subclass of Fruit Every apple is a fruit Red wines is a subclass of Wine Every red wine is a wine Chianti wine is a subclass of Red wine Every Chianti wine is a red wine 18 Modes of Development top-down – define the most general concepts first and then specialize them bottom-up – define the most specific concepts and then organize them in more general classes combination – define the more salient concepts first and then generalize and specialize them 19 Documentation Classes (and slots) usually have documentation Describing the class in natural language Listing domain assumptions relevant to the class definition Listing synonyms Documenting classes and slots is as important as documenting computer code! 20 Define Properties of Classes – Slots Slots in a class definition describe attributes of instances of the class and relations to other instances Each wine will have color, sugar content, producer, etc 21 Properties (Slots) Types of properties “intrinsic” properties: flavor and color of wine “extrinsic” properties: name and price of wine parts: ingredients in a dish relations to other objects: producer of wine (winery) Simple and complex properties simple properties (attributes): contain primitive values (strings, numbers) complex properties: contain (or point to) other objects (e.g., a winery instance) 22 Slots for the Class Wine (in Protégé-2000) 23 Slot and Class Inheritance A subclass inherits all the slots from the superclass If a wine has a name and flavor, a red wine also has a name and flavor If a class has multiple superclasses, it inherits slots from all of them Port is both a dessert wine and a red wine. It inherits “sugar content: high” from the former and “color:red” from the latter 24 Property Constraints Property constraints (facets) describe or limit the set of possible values for a slot The name of a wine is a string The wine producer is an instance of Winery A winery has exactly one location 25 Common Facets Slot cardinality – the number of values a slot has Slot value type – the type of values a slot has Minimum and maximum value – a range of values for a numeric slot Default value – the value a slot has unless explicitly specified otherwise 26 Common Facets: Slot Cardinality Minimum cardinality Minimum cardinality 1 means that the slot must have a value (required) Minimum cardinality 0 means that the slot value is optional Maximum cardinality Maximum cardinality 1 means that the slot can have at most one value (single-valued slot) Maximum cardinality greater than 1 means that the slot can have more than one value (multiple-valued slot) 27 Common Facets: Value Type String: a string of characters (“Château Lafite”) Number: an integer or a float (15, 4.5) Boolean: a true/false flag Enumerated type: a list of allowed values (high, medium, low) Complex type: an instance of another class Specify the class to which the instances belong The Wine class is the value type for the slot “produces” at the Winery class 28 Domain and Range of Slot Domain of a slot – the class (or classes) that have the slot More precisely: class (or classes) instances of which can have the slot Range of a slot – the class (or classes) to which slot values belong 29 Facets and Class Inheritance A subclass inherits all the slots from the superclass A subclass can override the facets to “narrow” the list of allowed values Make the cardinality range smaller Replace a class in the range with a subclass Wine producer is-a French wine Winery is-a producer French winery 30 Create Instances Create an instance of a class The class becomes a direct type of the instance Any superclass of the direct type is a type of the instance Assign slot values for the instance frame Slot values should conform to the facet constraints Knowledge-acquisition tools often check that 31 Creating an Instance: Example 32 Multiple Inheritance A class can have more than one superclass A subclass inherits slots and facet restrictions from all the parents Different systems resolve conflicts differently 33 Disjoint Classes Classes are disjoint if they cannot have common instances Disjoint classes cannot have any common subclasses either Port Wine Dessert wine Red wine, White wine, Rosé wine are disjoint Dessert wine and Red wine are not disjoint Red wine White wine Rosé wine 34 The Perfect Family Size (1) If a class has only one child, there may be a modeling problem If the only Red Burgundy we have is Côtes d’Or, why introduce the subhierarchy? Compare to bullets in a bulleted list 35 The Perfect Family Size (2) If a class has more than a dozen children, additional subcategories may be necessary However, if no natural classification exists, the long list may be more natural 36 Single and Plural Class Names A “wine” is not a kind-of “wines” A wine is an instance of the class Wines Class instance-of Instance 37 Classes and Their Names Classes represent concepts in the domain, not their names The class name can change, but it will still refer to the same concept Synonym names for the same concept are not different classes Many systems allow listing synonyms as part of the class definition 38 A Completed Hierarchy of Wines 39 Inverse Slots Maker and Producer are inverse slots 40 41 Semantic Web “Layered Cake” (2001) ??? ??? Reasoning Semantics+inference OWL Relational Data Data Exchange 42 Semantic Web “Layered Cake” (refreshed) 43 OWL-RDFS Relationship Both use the same data model: page.html hasAuthor “Dieter Fensel“ Resource Property Value (subject) (predicate) (object) OWL extends vocabulary and adds axioms 44 Description Logic Family DLs are a family of logic based KR formalisms Particular languages mainly characterized by: Set of constructors for building complex concepts and roles from simpler ones Set of axioms for asserting facts about concepts, roles and individuals Examples: “Female persons” • Person ⊓ Female “Non-female persons” • Person ⊓ Female “Persons that have a child” • Person ⊓ hasChild.Person “Persons all of whose children are female” • Person ⊓ hasChild.Female “Persons that are employed or self-eployed” • Person ⊓ (Employee ⊔ SelfEmployed) “Persons that have at most one father“ • Person ⊓ ≤1.hasFather 45 Description Logic Family Necessary and sufficient conditions Inclusion axioms provide necessary conditions: concept ⊑ definition Equivalence axioms provide necessary and sufficient conditions: concept ≡ definition { concept ⊑ definition and definition ⊑ concept 46 Complex Classes Union of Classes Instances of the Union of two Classes are either the instance of one or both classes Person ≡ Man ⊔ Woman <owl:Class rdf:ID=“Person"> <owl:unionOf rdf:parseType="Collection"> <owl:Class rdf:about="#Woman" /> <owl:Class rdf:about="#Man" /> </owl:unionOf> </owl:Class> 47 Complex Classes Intersection of Classes Instances of the Intersection of two Classes are simultaneously instances of both class Man ≡ Person ⊓ Male <owl:Class rdf:ID=“Man"> <owl:intersectionOf rdf:parseType="Collection"> <owl:Class rdf:about="#Person" /> <owl:Class rdf:about="#Male" /> </owl:intersectionOf> </owl:Class> 48 one of: Enumerated Classes Specify a class via a direct enumeration of its members: WhineColor ≡ {White, Rose, Red} <owl:Class rdf:ID="WineColor"> <rdfs:subClassOf rdf:resource="#WineDescriptor"/> <owl:oneOf rdf:parseType="Collection"> <owl:Thing rdf:about="#White"/> <owl:Thing rdf:about="#Rose"/> <owl:Thing rdf:about="#Red"/> </owl:oneOf> </owl:Class> 49 Complex Classes Property Restrictions Defining a Class by restricting its possible instances via their property values OWL distinguishes between the following two: Value constraint • (Mother ≡ Woman ⊓ hasChild.Person) Cardinality constraint • (MotherWithManyChildren ≡ Mother ⊓ ≥3hasChild) Property restrictions are local remember RDFS allows only global properties 50 Complex Classes - Property Restrictions someValuesFrom A Mother is a Woman that has a child (some Person) Mother ⊑ Woman ⊓ hasChild.Person <owl:Class rdf:ID=“Mother"> <rdfs:subClassOf rdf:resource="#Woman" /> <rdfs:subClassOf> <owl:Restriction> <owl:onProperty rdf:resource="#hasChild" /> <owl:someValuesFrom rdf:resource="#Person" /> </owl:Restriction> </rdfs:subClassOf> </owl:Class> 51 Complex Classes - Property Restrictions allValuesFrom To express the set of parents that only have female children (daughters) you would write: ParentsWithOnlyDaughters ⊑ Person ⊓ hasChild.Woman <owl:Class rdf:ID=“ParentsWithOnlyDaughters"> <rdfs:subClassOf rdf:resource="#Person" /> <rdfs:subClassOf> <owl:Restriction> <owl:onProperty rdf:resource="#hasChild" /> <owl:allValuesFrom rdf:resource="#Woman" /> </owl:Restriction> </rdfs:subClassOf> ... </owl:Class> 52 Complex Classes - Property Restrictions hasValue hasValue allows to define classes based on the existence of particular property values, their must be at least one matching property value The set of all childs of the woman MARY would be expressed like following: MarysChildren ⊑ Person П hasParent.{MARY} <owl:Class rdf:ID=“MarysChildren"> <rdfs:subClassOf rdf:resource="#Person" /> <rdfs:subClassOf> <owl:Restriction> <owl:onProperty rdf:resource="#hasParent" /> <owl:hasValue rdf:resource="#MARRY" /> </owl:Restriction> </rdfs:subClassOf> </rdfs:subClassOf> ... </owl:Class> 53 Complex Classes - Property Restrictions cardinality Definition of cardinality: the number of occurrences, either maximum (maxCardinality) or minimum (minCardinality) or exact (cardinality) based upon the context (class) in which it is used To define a half-orphan (Halbwaise) you would write the following: HalfOrphan ⊑ Person П =1hasParent.Person <owl:Class rdf:ID=“HalfOrphan"> <rdfs:subClassOf rdf:resource="#Person" /> <rdfs:subClassOf> <owl:Restriction> <owl:onProperty rdf:resource="#hasParent"/> <owl:cardinality rdf:datatype="&xsd;NonNegativeInteger">1</owl:cardinality> </owl:Restriction> </rdfs:subClassOf> </rdfs:subClassOf> … 54 </owl:Class> Properties OWL vs. RDF RDF Schema provides a couple of pre defined properties: rdfs:range used to indicate the range of values for a property. rdfs:domain used to associate a property with a class. rdfs:subPropertyOf used to specialize a property. OWL provides additional poperty classes, which allow reasoning and inferencing, i.e. owl:functionalProperty owl:transitiveProperty owl:symetricProperty 55 Properties OWL vs. RDF OWL (DL and Lite) distinguishes between data type ptoperties and object properties (RDFS does not) An ObjectProperty relates one Resource to another Resource: Resource ObjectProperty Resource A DatatypeProperty relates a Resource to a Literal or an XML Schema data type: Resource DatatypeProperty Value 56 Properties in OWL Transitive Property Example: If person A is a ancestor of person B and B of C then A is also an ancestor of C. ancestor+ ancestor <owl:ObjectProperty rdf:ID=“ancesotor"> <rdf:type rdf:resource="&owl;TransitiveProperty" /> <rdfs:domain rdf:resource="#Person" /> <rdfs:range rdf:resource="#Person" /> </owl:ObjectProperty> 58 Properties in OWL Symmetric Property Example: If Mary is relative to John then John is also relative to Mary relative- relative and relative relative- <owl:ObjectProperty rdf:ID=“relative"> <rdf:type rdf:resource="&owl;SymmetricProperty" /> <rdfs:domain rdf:resource="#Person" /> <rdfs:range rdf:resource="#Person" /> </owl:ObjectProperty> 59 Properties in OWL Inverse Property Example: If Mary is a child of John then John is the parent of Mary hasChild hasParent- <owl:ObjectProperty rdf:ID=“hasChild"> <owl:inverseOf rdf:resource="hasParent" /> </owl:ObjectProperty> 60 Properties in OWL Functional Properties A functional property states that the value of range for a certain object in the domain is always the same: Example: A child has always the same Father (biological) Person 1hasFather <owl:ObjectProperty rdf:ID=“hasFather"> <rdf:tyoe rdf:resource="&owl;FunctionalProperty"/> </owl:ObjectProperty> 61 OWL Property Classes The symmetric and transitive property may only used for connecting two resources: rdf:Property owl:ObjectProperty owl:SymmetricProperty owl:DatatypeProperty owl:FunctionalProperty owl:InverseFunctionalProperty owl:TransitiveProperty 62 OWL as DL: Axioms Description Logic First Order Logic 63 OWL as DL: Axioms Social Security Number 64 Accessing the Reasoner (“Racer”) in Protégé Classify taxonomy (and check consistency) Compute inferred types (for individuals) Just check consistency (for efficiency) 65 Subsumption The presented examples contain a number of classes and properties intended to illustrate particular aspects of reasoning in OWL. We can make inferences about relationships between classes, in particular subsumption between classes Recall that A subsumes B when it is the case that any instance of B must necessarily be an instance of A. A B 66 Subsumption An Example Woman ≡ Person ⊓ Female Man ≡ Person ⊓ Woman Mother ≡ Woman ⊓ hasChild.Person Father ≡ Man ⊓ hasChild.Person Parent ≡ Father ⊔ Mother Grandmother ≡ Mother ⊓ hasChild.Parent We can further infer (though not explicitly stated): Grandmother ⊑ Person Grandmother ⊑ Man ⊔ Woman etc. 67 Subsumption Example in Protégé 68 Subsumption Inferred Hierarchy in Protégé 69 Inconsistency You may define Classes were no individual can fulfill its definition. Via reasoning engines such a definition can be found also in big ontologies. 70 Inconsistency Example Cow ≡ Animal ⊓ Vegetarian Sheep ⊑ Animal Vegetarian ≡ eats Animal MadCow ≡ Cow ⊓ eats.Sheep 71 Inconsistency Example in Protégé 72 Inconsistency Detected Inconsistency in Protégé 73 OWL on one Slide Symmetric: if P(x, y) then P(y, x) Transitive: if P(x,y) and P(y,z) then P(x, z) Functional: if P(x,y) and P(x,z) then y=z InverseOf: if P1(x,y) then P2(y,x) InverseFunctional: if P(y,x) and P(z,x) then y=z allValuesFrom: P(x,y) and y=allValuesFrom(C) someValuesFrom: P(x,y) and y=someValuesFrom(C) hasValue: P(x,y) and y=hasValue(v) cardinality: cardinality(P) = N minCardinality: minCardinality(P) = N maxCardinality: maxCardinality(P) = N equivalentProperty: P1 = P2 intersectionOf: C = intersectionOf(C1, C2, …) unionOf: C = unionOf(C1, C2, …) complementOf: C = complementOf(C1) oneOf: C = one of(v1, v2, …) Legend: equivalentClass: C1 = C2 Properties are indicated by: P, P1, P2, etc disjointWith: C1 != C2 Specific classes are indicated by: x, y, z sameIndividualAs: I1 = I2 Generic classes are indicated by: C, C1, C2 differentFrom: I1 != I2 Values are indicated by: v, v1, v2 Instance documents are indicated by: I1, I2, I3, etc. AllDifferent: I1 != I2, I1 != I3, I2 != I3, … 74 A number is indicated by: N Thing: I1, I2, … P(x,y) is read as: “property P relates x to y” Back to the OWL Layers (Lite, DL, Full) OWL Lite (sub)classes, individuals (sub)properties, domain, range intersection (in)equality cardinality 0/1 datatypes inverse, transitive, symmetric hasValue someValuesFrom allValuesFrom OWL DL Negation (disjointWith, complementOf) unionOf Full Cardinality Enumerated types (oneOf) RDF Schema Full DL Lite OWL Full Allow meta-classes etc 75 Summary Compared with RDF/RDFS, OWL provides a more formal language which allows expressing more axioms, but also adds some restrictions We can do inferences such as classify instances, detect inconsistencies, etc. Last version Feb. 2004, but still under progress http://www.w3.org/2004/OWL/ 76 Resources W3C Documents Guide: http://www.w3.org/TR/owl-guide/ Reference: http://www.w3.org/TR/owl-ref/ Semantics and Abstract Syntax: http://www.w3.org/TR/owl-semantics/ OWL Tutorials Ian Horrocks, Sean Bechhofer: http://www.cs.man.ac.uk/~horrocks/Slides/Innsbruck-tutorial/ Roger L. Costello, David B. Jacobs: http://www.xfront.com/owl/ Example Ontologies, e.g. here: http://www.daml.org/ontologies/ 77 Tutorial: Designing Ontologies with Protégé Protégé is an ontology editor and a knowledgebase editor (download from http://protege.stanford.edu ). Protégé is also an open-source, Java tool that provides an extensible architecture for the creation of customized knowledge-based applications. Protégé's OWL Plug-in now provides support for editing Semantic Web ontologies. http://www.cs.man.ac.uk/~horrocks/Teaching/cs646/ http://www.co-ode.org/resources/tutorials/ProtegeOWLTutorial.pdf 78 RDF/OWL in Protégé Example 79 Protégé Screenshot: Classes 80 Creating Properties Delete Property New Object Property: Associates an individual to another individual - New Datatype Property (String, int etc) - New Annotation Properties for metadata - New SubProperty – ie create “under” the current selection 81 Naming Properties We often create properties using 2 standard naming patterns: has… (eg. hasColour); is…Of (eg. isTeacherOf) or other suffixes (eg. …In …To). This has several advantages: It is easier to find properties; It is easier for tools to generate a more readable form; Inverses properties typically follow this pattern eg. hasPart, isPartOf . 82 Protégé Screenshot: Datatype properties 83 Protégé Screenshot: Object Properties 84 Protégé Screenshot: Instances (1) 85 Protégé Screenshot: Instances (2) 86 Protégé Screenshot: Instances (3) 87 Protégé Screenshot: Forms 88 Protégé Screenshot: Ontologies 89 Protégé Screenshot: Code-1 (OWL/RDF) 90 Protégé Screenshot: Code-2 (OWL/RDF) 91 Some issues on Editing OWL Ontologies with Protégé From Holger Knublauch Stanford University July 06, 2004 http://protege.stanford.edu/doc/tutorial/get_started/ http://www.co-ode.org/resources/tutorials/ProtegeOWLTutorial.pdf 92 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 93 Cardinality Restrictions Meaning: The property must have at least/at most/exactly x values is the shortcut for and Example: A FamilyDestination is a Destination that has at least one Accomodation and at least 2 Activities 94 (Create defined class FamilyDestination) 95 allValuesFrom Restrictions Meaning: All values of the property must be of a certain type Warning: Also individuals with no values fulfill this condition (trivial satisfaction) Example: Hiking is a Sport that is only possible in NationalParks 96 someValuesFrom Restrictions Meaning: At least one value of the property must be of a certain type Others may exist as well Example: A NationalPark is a RuralArea that has at least one Campground and offers at least one Hiking opportunity 97 hasValue Restrictions Meaning: At least one of the values of the property is a certain value Similar to someValuesFrom but with Individuals and primitive values Example: A PartOfSydney is a Destination where one of the values of the isPartOf property is Sydney 98 Enumerated Classes Consist of exactly the listed individuals OneStarRating ThreeStarRating TwoStarRating BudgetAccomodation 99 Logical Class Definitions Define classes out of other classes unionOf (or) intersectionOf (and) complementOf (not) Allow arbitrary nesting of class descriptions (A and (B or C) and not D) 100 unionOf The class of individuals that belong to class A or class B (or both) Example: Adventure or Sports activities Adventure Sports 101 intersectionOf The class of individuals that belong to both class A and class B Example: A BudgetHotelDestination is a destination with accomodation that is a budget accomodation and a hotel BudgetAccomodation Hotel 102 Implicit intersectionOf When a class is defined by more than one class description, then it consists of the intersection of the descriptions Example: A luxury hotel is a hotel that is also an accomodation with 3 stars Hotel LuxuryHotel AccomodationWith3Stars 103 complementOf The class of all individuals that do not belong to a certain class Example: A quiet destination is a destination that is not a family destination Destination QuietDestination (grayed) FamilyDestination 104 Class Conditions Necessary Conditions: (Primitive / partial classes) “If we know that something is a X, then it must fulfill the conditions...” Necessary & Sufficient Conditions: (Defined / complete classes) “If something fulfills the conditions..., then it is an X.” 105 Class Conditions (2) NationalPark (not everything that fulfills these conditions is a NationalPark) QuietDestination (everything that fulfills these 106 conditions is a QuietDestination) Classification NationalPark A RuralArea is a Destination A Campground is BudgetAccomodation Hiking is a Sport Therefore: Every NationalPark is a Backpackers-Destiantion BackpackersDestination 107 (Other BackpackerDestinations) Classification (2) Input: Asserted class definitions Output: Inferred subclass relationships 108 (Create an enumerated class out of individuals) 109 (Create a hasValue restriction) 110 (Create a hasValue restriction) 111 (Create a defined class) 112 (Classify Campground) 113 (Add restrictions to City and Capital) 114 (Create defined class BackpackersDestination) 115 (Create defined class QuietDestination) 116 (Create defined class RetireeDestination) 117 (Classification) 118 Individuals 119 Individuals 120