170 likes | 310 Views
Logics for Data and Knowledge Representation. Web Ontology Language (OWL) -- Exercises. Feroz Farazi. Exercise 1.
E N D
Logics for Data and Knowledge Representation Web Ontology Language (OWL) -- Exercises Feroz Farazi
Exercise 1 • Suppose that a family consists of a father (John), a mother (Maria), two sisters (Sara and Jenifer) and two brothers (David and Robert). In an OWL representation we find that the two brothers and the two sisters are codified as follows: :David :hasFather :John :Sara :hasFather :John :John :spouseOf :Maria Later on another property :hasChild is codified. (i) What will be the output of the following SPARQL Query when a reasoner is activated? :John :hasChild ?y
Exercise 1 (ii) Expand the OWL representation in a way that supports returning non-empty result of the following query and this expansion is independent of the entity-entity triples. :John :hasChild ?y (iii) Add also the following axioms to the dataset. :Jenifer :hasFather :John :Robert :hasFather :John What result the following query will return? :John :hasChild ?y (iv) How can we infer the spouse relation in the reverse direction?
Solution (iv) We can make the relation :spouseOf its own inverse as follows: :spouseOf owl:inverseOf :spouseOf (i) The result of the query is empty. (ii) We can make the property :hasFather as an inverse property of :hasChild as follows: :hasFather owl:inverseOf :hasChild Query Result: :David :Sara (iii) Query Result: :David :Sara :Jenifer :Robert
Exercise 2 • Within a family, relations such as :spouseOf :marriedTo :siblingOf are applicable in both directions (from subject to object, and vice versa) whereas the following do not hold always. :brotherOf :sisterOf • Which property holds in the relations that are applicable in both directions? • How can we represent these relations in OWL? • In which basic category this property belongs?
Solution • Symmetric property holds in these relations • They can be represented as follows: :spouseOfrdf:typeowl:SymmetricProperty :marriedTordf:typeowl:SymmetricProperty :siblingOfrdf:typeowl:SymmetricProperty iii) The symmetric property is an object property. Moreover, the domain and range of the symmetric property are the same.
Exercise 3 • Consider that in the family of John and Maria, also John’s father (James) and mother (Jerry) live. Relations such as :hasAncestor and :hasDescendent can be applied between different levels. For example: :John :hasAncestor :James :Sara :hasAncestor :John :James :hasDescendent:John :John :hasDescendent:Sara • Which property holds in the relations that are applicable in different levels of the hierarchy? • How can we represent these relations in OWL? • In which basic category this property belongs? • Show the results of the following queries: a) :James :hasDescendent ?y b) :John :hasAncestor ?y
Solution • Transitive property holds in these relations • They can be represented as follows: :hasAncestorrdf:typeowl:TransitiveProperty :hasDescendentrdf:typeowl:TransitiveProperty • The transitive property is an object property. • a) Query Result :John :Sara b) Query Result: :James
Exercise 4 1. In RDFS we can represent that two classes :Test and :Experiment are equivalent. :Test rdfs:subClassOf :Experiment :Experiment rdfs:subClassOf :Test Convert this representation in OWL. 2. In RDFS we can represent that two properties :hasChild and :hasKid are equivalent. :hasChild rdfs:subPropertyOf :hasKid :hasKid rdfs:subPropertyOf :hasChild Convert this representation in OWL. 3. Is there any way to represent the fact that two entities (or individuals) :Italia and :Il_Bel_Paese are same.
Solution • OWL representation: :Test owl:equivalentClass :Experiment 2. OWL representation: :hasChildowl:equivalentProperty:hasKid • It can be represented in OWL as follows: :Italia owl:sameAs :Il_Bel_Paese
Exercise 5 • a) Which OWL property allows to have exactly one value for a particular individual? b) In a family tree, relations such as the following ones can be defined as functional. :hasFather :hasMother Represent them in OWL and demonstrate their use with necessary entity-entity axioms. • a) Which OWL property allows to have exactly one subject for a particular object? c) Demonstrate the use of this property in developing applications such as entity matching.
Solution • a) OWL Functional property has this feature. b) OWL representations of the properties :hasFather and :hasMother are as follows: :hasFatherrdf:typeowl:FunctionalProperty :hasMotherrdf:typeowl:FunctionalProperty Two entity-entity axioms are provided below: :John :hasFather :James :John :hasFather:Handler The objects :James and :Handler are the values of the same subject and property. We already have defined that :hasFather property is functional. Therefore, it can be concluded that :James and :Handler refer to the same person.
Solution 2. a) OWL Inverse Functional property has this feature. b) Given that the property :SSN (social security number) is an Inverse Functional property and it is encoded as follows: :SSN rdf:type owl:InverseFunctionalProperty Two entity-entity axioms are provided below: mo:James :SSN N123812834 ps:Handler :SSN N123812834 The subjects :James and :Handler are attached to the same social security number, which cannot be shared by two different persons. Therefore, we can conclude that mo:James and ps:Handler are the same entity.
Exercise 6 Which OWL constructs support the encoding of the following statements? i) If x and y are brothers and y is son of z then x is son of z. ii) If y is brother of z and z is father of x, then y is uncle of x. iii) If disease x is located in body part y which is part of body part z, then x is located in z. Represent all the above statements in OWL. Also write explicitly which version of OWL supports the encoding of such statements.
Solution SubPropertyOf and ObjectPropertyChain support the encoding of such statements. i) SubPropertyOf( ObjectPropertyChain( :brotherOf :sonOf) :sonOf) ii) SubPropertyOf( ObjectPropertyChain( :brotherOf :fatherOf) :uncleOf) iii) SubPropertyOf( ObjectPropertyChain( :locatedIn :part of) :locatedIn)
Exercise 7 (Laboratory) • Create the family tree ontology in Protégé (can be downloaded here: http://protege.stanford.edu/download/registered.html#p4.3). • Encode inverse relation between entities. • Implement symmetric properties. • Implement functional properties. • Implement inverse functional properties. • Develop Pizza ontology according to the manual provided in the following link: http://130.88.198.11/tutorials/protegeowltutorial/resources/ProtegeOWLTutorialP4_v1_3.pdf