OWL 2 how to express equivalent class - owl

In my ontology I have a class Parent and a class Child. I have an object property isChildOf(Child, Parent).
I'd like to express a new class, FatherWithTwoOrMoreChildren, which corresponds to the class of Parent having at least 2 Child.
Declaration(Class(p:FatherWithTwoOrMoreChildren))
SubClassOf(p:FatherWithTwoOrMoreChildren
ObjectSomeValueFrom(ObjectPropertyAssertion(ObjectMinCardinality(2
p:isChildOf) owl:Thing))
My doubt is if I'm expressing it correctly, or if calling ObjectPropertyAssertion I'm changing isChildOf's definition.

Easiest way is to define :FatherWithTwoOrMoreChildren as :
:hasChild owl:inverseOf :isChildOf
:FatherWithTwoOrMoreChildren owl:equivalentClass (:hasChild min 2 :Child)
But maybe don't you want to create a hasChild objectproperty.

Related

Using Same Object Property between Multiple Classes

I tried to use the same object property between multiple classes, but I got a warning that the same object property has been set multiple times as follows, can you please let me know what is wrong with that and how to solve it? Does this restrict reasoning later on (i.e. confuse the reasoner since the same object property is set multiple times)?
Thanks
Contrary to the comments it actually is very problematic to use the same object property between multiple classes.
What you don't see in your visualization is that in RDF/OWL, the starting point of your relation arrows is modelled as rdfs:domain and the target point of the arrows is modelled as rdfs:range.
The semantic of an OWL class is that it is a set of individuals and rdfs:domain and rdfs:range specify the domain, respectively range of a relation. That is, they specify the sets of allowed values in subject, respectively object position of a triple with that relation in the predicate position.
If you express your example in RDF Turtle it would look like this:
:hasPart rdfs:domain :ClassA, :ClassB;
rdfs:range :ClassB, :ClassC, :ClassD.
This causes multiple problems:
Intersection
The semantic of multiple domains, respectively ranges, is the intersection of those classes, not the union!
Even if we disregard the relation between :ClassB and :ClassD, this means :hasPart is only allowed by individuals that are instances of class C and class D at the same time!
For example, lets say class A is "car", class B is "tire" and class C is "motor". Now you want to say that a car can have tires and motors but what you actually specify is that a car can only have things that are a motor and a tire at the same time!
Unwanted but allowed usage
If you fix the first problem but specifying the union instead of the intersection, it will be very messy in serialized RDF because you need a large amount of triples to represent OWL restrictions such as unions. But even if you do that, you could now connect an instance of class A with an instance of class D, which is not allowed in the image.
Solution
The solution is simple, just separate those relations, for example into :hasB, :hasC and :hasD, although in a real scenario you can probably find a more suitable naming scheme, where the "has" prefix is often not used. For example, in DBpedia, the property for the country of a city is expressed using dbo:country, not dbo:hasCountry.

Is it possible that an individual changes its type from one to another class in OWL ontology?

I have a base class of which there are two subclasses. Let say, Base is the base class and A and B are subclasses. Let us have an individual, I, belongs to class A initially. Is it possible in OWL that the same individual starts belonging to class B (and stops belonging to class A) after satisfying the attributes of class B? Note that class A and B are disjoint.

OWL axiom: Given an individual of a particular class, enforce an existence of an Object Property relation with another individual

In OWL, is there a way to state that an individual of a particular class must be related to another individual via a specific object property?
For example, I would like to state that:
forall(x) Object(x) -> exists(y) Shape(y) ^ hasShape(x, y)
i.e., "For all objects, there exists a shape that is the shape of the object."
so that if there is an individual of the type Object that has no shape associated with it, a reasoner would find it to be inconsistent.
I tried an axiom:
Object SubClassOf hasShape min 1 Shape
but it's not working.
It seems like the issue is because Object Property in OWL has no identity, but is there a workaround for this issue?
(I'm using Protege 5.2.0)
You are correct that the meaning of Object SubClassOf hasShape min 1 Shape is that every individual of Object is associated with an individual of Shape via the hasShape property.
So if you create an individual x of type Object without x being associated with an individual of Shape, why does the reasoner not determine that your ontology is inconsistent? The reason for this is due to the open world assumption. Informally it means that the only inferences that the reasoner can make from an ontology is based on explicit information stated in the ontology or what can derived from explicit stated information.
When you state x is an Object, there is no explicit information in the ontology that states that x is not associated with an individual of Shape via the hasShape property. To make explicit that x is not is such a relation, you have to define x as follows:
Individual: x
Types:
Object,
hasShape max 0 owl:Thing
Btw, this problem has nothing to do with identity as you stated.
One solution I found was to make the ontology "closed world", by making owl:Thing equivalent to the set of all individuals defined so far.

In OWL 1; are min 1 Thing and some Thing equivalent?

In OWL 1; What is the difference between:
Parent subclassOf hasChildren min 1 Thing
and
Parent subclassOf hasChildren some Thing
Are they equivalent as both of them assert that each Parent instance must has at least one value from any class through hasChildren? as we don't specify a particular range for the someValuesFrom restriction?
In OWL 1; What is the difference between:
Parent subclassOf hasChildren min 1 Thing
and
Parent subclassOf hasChildren some Thing
OWL1 doesn't have qualified cardinality restrictions. You can't say
property min n Class
in OWL1. You can use unqualified cardinality restrictions (1), and qualified existential restrictions, like:
property min n
property some Class
In OWL 2, where you do have qualified cardinality restrictions, you have the ability to write
property min n Class
and you're absolutely right that the following are equivalent:
property min 1 Class
property some Class
and as a special case, the following are equivalent:
property min 1 owl:Thing
property some owl:Thing
The someValuesFromin OWL is equivalent to the existential quantifier in predicate logic:
In predicate logic, an existential quantification is a type of quantifier, a logical constant which is interpreted as "there exists," "there is at least one," or "for some." It expresses that a propositional function can be satisfied by at least one member of a domain of discourse. In other terms, it is the predication of a property or relation to at least one member of the domain. It asserts that a predicate within the scope of an existential quantifier is true of at least one value of a predicate variable.
Keeping this in mind, please refer to the definition of Restirction:
OWL Lite allows restrictions to be placed on how properties can be used by instances of a class.
And the definition of Cardinality:
OWL (and OWL Lite) cardinality restrictions are referred to as local restrictions, since they are stated on properties with respect to a particular class. That is, the restrictions constrain the cardinality of that property on instances of that class.
In OWL, someValuesFrom has been defined as:
The restriction someValuesFrom is stated on a property with respect to a class. A particular class may have a restriction on a property that at least one value for that property is of a certain type.
And minCardinality has been defined as:
If a minCardinality of 1 is stated on a property with respect to a class, then any instance of that class will be related to at least one individual by that property.
So, although logically they are the same, they represent different ideas.

Sub class instance variable in super-class object?

Let's say I have two classes called "SuperClass" and SubClass. SubClass extends SuperClass.
I just found out that it's not possible for SuperClass to have an instance variable of type SubClass.
That is, this will not work:
class SuperClass{
SubClass x = new SubClass();
}
because it causes the constructors to call each other, entering a perpetual loop. (because Java automatically puts in the call to Super())
Is creating a subclass instance variable impossible and a bad design idea? or is there some kind of work-around?
It is generally a bad idea. If your super class needs an instance of a subclass, that's a code smell. It creates circular dependencies and suggests a broken analysis.
The workaround/fix is usually to bring up whatever code the super class is using from the subclass into the super class.
The only restriction is in placing an allocation of the subclass (or, for that matter, another instance of the superclass) within the superclass constructor. You can most certainly have an instance field with the type of a subclass, and set it at some point after construction of the superclass. (Though you would obviously need to prevent any recursion via the setter method.)
And actually one could put the allocation in the superclass constructor if there were conditional logic in the constructor to skip the allocation if constructing the subclass. Eg:
class SuperClass {
SubClass subClassField;
SuperClass() {
if (!(this instanceof SubClass)) {
subClassField = new SubClass();
}
}
}
But, of course, just because you can do this does not say that you should. While I can imagine a few scenarios where it might be a valid approach, they would be "oddball" situations.

Resources