Inverse property with range restriction - owl

In Protege, I have defined a class :Person, and an object property :likes (with domain :Person and range :Person).
I have defined an inverse property of :likes called :isLikedBy.
Then I define an additional class :Rich.
I wish I could define a property :likesBackForBadReasons in this way: an equivalent property (or is it a subproperty?) of :isLikedBy, but only when the range of that relationship is an instance of :Rich.
So my inference engines infers that any :Rich :Person "A" who :likes a :Person "B", then this "B" :likesBackForBadReasons "A".
How to define that :likesBackForBadReasons object property in Protege?

TL;TDR: This specific requirement can only be dealt with using rules and not by typical Description Logic (DL) inferences. You can use either of the following rules:
Person(?x) ^ PersonThatIsNotRich(?x) ^ RichPerson(?y) ^ likes(?y, ?x) ^ likes(?x, ?y) -> BadPerson(?x)
Person(?x) ^ PersonThatIsNotRich(?x) ^ RichPerson(?y) ^ likes(?y, ?x) ^ likes(?x, ?y) -> likesForBadReason(?x, ?y)
where PersonThatIsNotRich is disjoint with RichPerson. These rules also ensure that a rich person liking another rich person will not be considered a bad person.
How to use SWRL to do this inference:
The ontology using this rule in Manchester syntax is as follows:
ObjectProperty: isLikedBy
InverseOf: likes
ObjectProperty: likes
InverseOf: isLikedBy
ObjectProperty: likesForBadReason
SubPropertyOf: likes
Class: BadPerson
SubClassOf: Person
Class: Person
Class: PersonThatIsNotRich
SubClassOf: Person
DisjointWith: RichPerson
Class: RichPerson
SubClassOf: Person
DisjointWith: PersonThatIsNotRich
Individual: badPerson
Types: Person
Facts: likes richPerson
Individual: otherBadPerson
Types: Person
Facts: likes otherRichPerson
Individual: otherRichPerson
Types: RichPerson
Facts: likes badPerson, likes richPerson
Individual: richPerson
Types: RichPerson
Facts: likes badPerson, likes otherRichPerson
Rule:
Person(?x), PersonThatIsNotRich(?x), RichPerson(?y), likes(?y, ?x), likes(?x, ?y) - BadPerson(?x)
Notes:
You will note that badPerson is inferred to be a BadPerson while otherBadPerson is not inferred to be a BadPerson. This is because otherBadPerson likes otherRichPerson, but otherRichPerson likes badPerson, not otherBadPerson. It is because the same rich person is not liked-back. It is the involvement of the same individual that causes a typical Description Logic reasoner to not be able to infer this correctly (or at least that is my understanding - someone who understands the difference between DL reasoners and rules better is welcome to correct me).
You will also note that a rich person liking another rich person and being liked back by that rich person, does not cause the rich person to be inferred to be a BadPerson.
Why intuitive solution using DL axiom does not work:
Intuitively one may think that defining BadPerson as follows will give the desired inference, but it does not:
Class: BadPerson
EquivalentTo:
(isLikedBy some RichPerson)
and (likes some Person) and (not RichPerson)
SubClassOf: Person
This will merely ensure that a BadPerson is liked by some rich person and that BadPerson likes some rich person, but the rich person is not necessarily the same rich person.
Why define a BadPerson class rather than a likesForBadReasons property in DL?
Reasoning in DL is defined in terms of classes and not in terms of relations. The basic reasoning in DL is classification and this aims to classify classes form the most general to the most specific. There is no such reasoning procedure for classification of relations.

Related

Check OWL Class

Suppose the range of an object property is defined through a class expression. I want to know whether a particular instance of the class can be used in the range of the object property. Is it possible to use the OWL API and check if a particular class is subsumed by this class expression ?
OWLAPI cannot provide a complete answer for this - an OWLReasoner implementation is necessary for complete results.
Given an implementation of OWLReasoner, to check entailment you can either list all the subclasses of a class expression and check if the class you're interested in appears in the response, or ask the reasoner if your class of interest is a subclass, i.e.,
OWLDataFactory df = ...
OWLClassExpression ce = ...
OWLClass c = ...
OWLReasoner r = ...
OWLAxiom ax = df.getOWLObjectSubClassOf(c, ce);
boolean cIsSubclassOfCE = r.isEntailed(ax);

OWL Protegé: Using the same Object property for different Domains/Ranges [duplicate]

This question already has an answer here:
How to create multiple relations with same object property?
(1 answer)
Closed 4 years ago.
I'm using Protegé to create an OWL ontology and I have Question.
I have the following set up:
(relation1)
ClassA isTriggeredBy ClassB
(relation1)
ClassC isTriggeredBy ClassD
Nevertheless the relation should be either (ClassA, ClassB) or (ClassC,ClassD). I don't want combinations like (ClassA, ClassD) to be possible since it makes no sense from the ontology semantic perspective. I tried to avoid that by specifying the following in the Object Property Description of relation1 isTriggeredBy:
Domain (intersection)
ClassA or ClassC
Ranges (intersection)
ClassB or ClassD
and I added local constraints in both Class Description of ClassA and ClassC:
Description:ClassA
SubClass Of
isTriggeredBy some ClassB
Description:ClassC
SubClass of
isTriggeredBy some ClassD
But I don't know if this is correct. Moreover I don't know if this the more appropriate way to do this or if it necessary to create different object properties.
Thanks for the attention and support,
pLs
To answer your question, it is important to understand the reason for using domain and range restrictions. If have
ObjectProperty: isTriggeredBy
Domain: A
Range: B
what you want to achieve is that whenever you know that an individual a is related via isTriggeredBy to individual b, the reasoner can infer that a is of type A and b is of type B.
If you have
ObjectProperty: isTriggeredBy
Domain: ClassA or ClassC
Range: ClassB or ClassD
it can at most infer that individual a is of type ClassA or ClassC and individual b is of type ClassB or ClassD. That is even with the added axioms
Class:ClassA
SubClassOf: isTriggeredBy some ClassB
Class:ClassC
SubClassOf:isTriggeredBy some ClassD
you will not get to differentiate between the relations (ClassA, ClassB) and (ClassC,ClassD).
A way to achieve this differentiation is to use subproperties:
ObjectProperty: isTriggeredBy
Domain: ClassA or ClassC
Range: ClassB or ClassD
ObjectProperty: isTriggeredByB
SubPropertyOf: isTriggeredBy
Domain: ClassA
Range:ClassB
ObjectProperty: isTriggeredByD
SubPropertyOf: isTriggeredBy
Domain: ClassC
Range:ClassD
Then when you have an individual a that is associated via isTriggeredByB to individual b, it will infer that a is of type ClassA and b is of type ClassB.

Protege min cardinality not adding member to defined class

I'm new to Protege and ontology.
I have a defined class UniqueScreening that is
equivalent to -> FilmScreening and (hasTrack min 2 Track)
then i create some members of Track that is tr001 and tr002
and then I create a member of FilmScreening which is fs001 that has Types
Film Screening
hasTrack some {tr001}
hasTrack some {tr002}
and the hasTrack object property has domain Track
my question is, why fs001 member is not inferred to UniqueScreening class?
does my class definition wrong?
As commented by Ignazio:
Declare tr001 and tr002 to be different individuals. By default they could be the same individual, so the cardinality would not be matched.

SWRL - using knowledge from classes

I want to use knowledge, which is modelled between classes. E.g. I have modelled a car and a bus have 4 wheels, a bike 2 wheels. Now, I want to express that bike can tip (if you don't keep them in balance - incompetent driver).
If I add an instance "CB450", subClassOf Bike, a rule should enable reasoning: can(CB450,Tip).
Way:
Type(Cb450,Bike) and has(Bike,TwoWheels) and can(TwoWheels,Tip) -> can (CB450,Tip)
I did not find any way to express this rule in SWRL, or Jena rules. Is there a possibility?
I know that it can be modelled differently, but I need to use class relations for rules in instances.
I use Protege 5.16 with pellet 2.3.1.
See the example ontology below
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://www.semanticweb.org/vehicle>
ObjectProperty: <http://www.semanticweb.org/vehicle#has>
ObjectProperty: <http://www.semanticweb.org/vehicle#can>
Class: <http://www.semanticweb.org/vehicle#Car>
SubClassOf:
<http://www.semanticweb.org/vehicle#Vehicle>,
<http://www.semanticweb.org/vehicle#has> some <http://www.semanticweb.org/vehicle#FourWheels>
Class: <http://www.semanticweb.org/vehicle#Vehicle>
Class: <http://www.semanticweb.org/vehicle#Bike>
SubClassOf:
<http://www.semanticweb.org/vehicle#Vehicle>,
<http://www.semanticweb.org/vehicle#has> some <http://www.semanticweb.org/vehicle#TwoWheels>
Class: <http://www.semanticweb.org/vehicle#FourWheels>
SubClassOf:
<http://www.semanticweb.org/vehicle#Property>
Class: <http://www.semanticweb.org/vehicle#TwoWheels>
SubClassOf:
<http://www.semanticweb.org/vehicle#can> some <http://www.semanticweb.org/vehicle#Tip>,
<http://www.semanticweb.org/vehicle#Property>
Class: <http://www.semanticweb.org/vehicle#Property>
Class: <http://www.semanticweb.org/vehicle#Tip>
SubClassOf:
<http://www.semanticweb.org/vehicle#Property>
Individual: <http://www.semanticweb.org/vehicle#CB450>
Types:
<http://www.semanticweb.org/vehicle#Bike>
Individual: <http://www.semanticweb.org/vehicle#Tip>
Types:
<http://www.semanticweb.org/vehicle#Tip>
Based on the way you have explained the problem it looks like "CB40" isn't a subclass of Bike but rather an individual of type Bike. So say you have a class Vehicle, a data property hasWheels on Vehicle and a boolean property canTip on Vehicle, you can write a SWRL rule as
Vehicle(?x) ^ hasWheels(?x, 2) -> canTip(?x, true)
which translates as "A vehicle with two wheels can tip over" . The ?x is any individual of the specified type. So if you create a class Bike as a subclass of Vehicle and an individual CB40 of that class and set all the relevant data properties a reasoner will assign the canTip property to true for CB40

Protege: Object property restrictions 1

I'm using Protege 4.3 to create my first ontology, so I encountered a few problems
Let's say we have the classes Shop, Mall, and Person and the properties works-inand is-part-of.
So the first problem is we want: if a Person works-in Shop and Shop is-part-of Mall then Person works-in Mall.
I tried to add the property chain works-in o is-part-of to the property is-part-of but then the reasoner died when I activated it.
Any idea how to solve that?
Thanks.
To answer your first question: you are looking for property chains. In Protege you can say that works-in o is-part-of is a subPropertyOf (Chain) works-in, this will give you expected inferences
EDIT: I did the following experiment:
a) create general ontology following your description (in Manchester syntax):
Ontology: <http://www.semanticweb.org/o>
ObjectProperty: <http://www.semanticweb.org/o#works-in>
SubPropertyChain:
<http://www.semanticweb.org/o#works-in> o <http://www.semanticweb.org/o#is-part-of>
ObjectProperty: <http://www.semanticweb.org/o#is-part-of>
Domain:
<http://www.semanticweb.org/o#Department> or <http://www.semanticweb.org/o#Shop>
Range:
<http://www.semanticweb.org/o#Mall> or <http://www.semanticweb.org/o#Shop>
Class: <http://www.semanticweb.org/o#Shop>
Class: <http://www.semanticweb.org/o#Mall>
Class: <http://www.semanticweb.org/o#Department>
Class: <http://www.semanticweb.org/o#Person>
b) Add some individuals to that ontology to check the inference. After classifying with FaCT++ Protege shows that person1 is related to mall1 via works-in. The additional axioms are as follows:
Individual: <http://www.semanticweb.org/o#shop1>
Types:
<http://www.semanticweb.org/o#Shop>
Facts:
<http://www.semanticweb.org/o#is-part-of> <http://www.semanticweb.org/o#mall1>
Individual: <http://www.semanticweb.org/o#mall1>
Types:
<http://www.semanticweb.org/o#Mall>
Individual: <http://www.semanticweb.org/o#person1>
Types:
<http://www.semanticweb.org/o#Person>
Facts:
<http://www.semanticweb.org/o#works-in> <http://www.semanticweb.org/o#shop1>
c) Add axioms saying that Person works in Shop, and Shop is part of Mall to the ontology from a). In this case again Person is a part of WorksInMall class, that shows that the property chain axiom is taken into account. Additional axioms are:
Class: <http://www.semanticweb.org/o#WorksInMall>
EquivalentTo:
<http://www.semanticweb.org/o#works-in> some <http://www.semanticweb.org/o#Mall>
Class: <http://www.semanticweb.org/o#Person>
SubClassOf:
<http://www.semanticweb.org/o#works-in> some <http://www.semanticweb.org/o#Shop>
Class: <http://www.semanticweb.org/o#Shop>
SubClassOf:
<http://www.semanticweb.org/o#is-part-of> some <http://www.semanticweb.org/o#Mall>

Resources