OWL Equivalent Classes as complement of Sibling SubClass - owl

I have the following made up example class hierarchy for clearing my doubt.
The class of Dog and Human are subclasses of Animal. Also present is the class Leash.
I have modelled the Dog class as a Defined Class with a property restriction on an object property wearsLeash as shown.
I have modelled the Human class as the complement of the Dog class as shown
I have three individuals for these classes as below. Leo is supposed to be the Dog and David the Human
I have asserted that Leo wearsLeash RedLeash as shown.
On running the built-in reasoner, Leo gets classified as a Dog but David doesn't get classified as a Human. My questions is why is it that David not inferred as an individual of Human as the class of animals that are not dogs? Is it due to the Open world assumption ? What other ways do I have to automatically infer David as Human using this logic?
Thanks!
EDIT: OWL file
#prefix : <http://www.semanticweb.org/university/untitled-ontology-107#> .
#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#> .
#base <http://www.semanticweb.org/university/untitled-ontology-107> .
<http://www.semanticweb.org/university/untitled-ontology-107> rdf:type owl:Ontology .
#################################################################
# Object Properties
#################################################################
### http://www.semanticweb.org/university/untitled-ontology-107#wearsLeash
:wearsLeash rdf:type owl:ObjectProperty .
#################################################################
# Classes
#################################################################
### http://www.semanticweb.org/university/untitled-ontology-107#Animal
:Animal rdf:type owl:Class .
### http://www.semanticweb.org/university/untitled-ontology-107#Dog
:Dog rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( :Animal
[ rdf:type owl:Restriction ;
owl:onProperty :wearsLeash ;
owl:someValuesFrom :Leash
]
) ;
rdf:type owl:Class
] ;
rdfs:subClassOf :Animal ;
owl:disjointWith :Human .
### http://www.semanticweb.org/university/untitled-ontology-107#Human
:Human rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( :Animal
[ rdf:type owl:Class ;
owl:complementOf :Dog
]
) ;
rdf:type owl:Class
] .
### http://www.semanticweb.org/university/untitled-ontology-107#Leash
:Leash rdf:type owl:Class .
#################################################################
# Individuals
#################################################################
### http://www.semanticweb.org/university/untitled-ontology-107#David
:David rdf:type owl:NamedIndividual ,
:Animal .
### http://www.semanticweb.org/university/untitled-ontology-107#Leo
:Leo rdf:type owl:NamedIndividual ,
:Animal ;
:wearsLeash :RedLeash .
### http://www.semanticweb.org/university/untitled-ontology-107#RedLeash
:RedLeash rdf:type owl:NamedIndividual ,
:Leash .
#################################################################
# General axioms
#################################################################
[ rdf:type owl:AllDifferent ;
owl:distinctMembers ( :David
:Leo
)
] .
### Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi

In the ontology Human is defined as the intersection of Animal and the complement of Dog, which, for the purpose of classifying Human instances, is equivalent to defining Animal as the disjoint union of Dog and Human.
This means that anything that is defined as being an Animal will be either a Dog or a Human; an instance can be classified as a Dog if it is known to wear a leash.
The problem here is that David is not known to wear a leash and is not known not to wear a leash; Open World Assumption means that the reasoner cannot choose either possibility and cannot, therefore decide whether David is a Dog or a Human. To obtain what you want it's necessary to add more information to the ontology, such as that David belongs to a class that is outside the domain of wearsLeash.

Related

What does rdfs:domain and rdfs:range mean?

I simply do not understand what either rdfs:domain and rdfs:range mean.
I have read what is says here, but it isn't clear enough.
If someone could explain it with an example, that would be great.
If you have an object property related with domain Class1 and range Class2, it will infer that whenever 2 individuals x,y are related via related, then x will be inferred to be of type Class1 and y will be inferred to be of type Class2.
DomainRangeExample:related rdf:type owl:ObjectProperty ;
rdfs:domain DomainRangeExample:Class1 ;
rdfs:range DomainRangeExample:Class2 .
DomainRangeExample:Class1 rdf:type owl:Class .
DomainRangeExample:Class2 rdf:type owl:Class .
DomainRangeExample:x rdf:type owl:NamedIndividual ;
DomainRangeExample:related DomainRangeExample:y .
DomainRangeExample:y rdf:type owl:NamedIndividual .

Can GraphDB support inferences based on cardinality?

I have a simple OWL ontology that I have loaded into a GraphDB repo (standard prefixes omitted for clarity):
#prefix s: <urn:sample:> .
s:Fruit a owl:Class;
owl:oneOf (s:Apple s:Banana s:Pear) .
[a owl:AllDifferent;
owl:distinctMembers (s:Apple s:Banana s:Pear)] .
s:eats a owl:ObjectProperty .
s:Fruitivore owl:equivalentClass
[a owl:Restriction;
owl:onProperty s:eats;
owl:allValuesFrom s:Fruit].
s:Henry a s:Fruitivore .
s:LimitedDiet owl:equivalentClass
[a owl:Restriction;
owl:onProperty s:eats;
owl:maxCardinality 3].
I'm asserting that there are only 3 types of fruit, and that Henry is someone who eats only Fruit.
Finally I've defined a class (LimitedDiet) of those individuals that eat no more than 3 different things.
If I load this, I see all 6 expected owl:differentFrom inferences (fruitA owl:differentFrom fruitB) as long as I choose owl-max as my ruleset.
However, regardless of which precanned ruleset type I choose for my repository, I never see the inference that Henry is an individual belonging to the class LimitedDiet.
Is this expected, given the available rulesets? If I wanted to define my own ruleset that could support this type of inference, are there any pointers anyone could direct me to that could help?
Also - should I have expected to see all:differentFrom assertions inferred in OWL-RL and OWL-QL as well as OWL-MAX? I thought they were both extensions of the latter.
Many thanks!

Unable to infer instances using axioms

I want to gather data via ontology matching and reasoning. To do that, I'd like to first identify relevant Individuals for later use if they fulfill certain criteria (using general class axioms).
Currently however, I am unable to achieve the necessary inferences using Protégé. The data consisting of various individuals looks like this:
# Data
# Common Prefixes omitted for readability
#prefix ns: <http://example.org/underlyingSchema#> .
#prefix data: <http://example.org/data#> .
data:A1 a ns:A .
data:A2 a ns:A .
data:R1 a ns:R .
ns:defines data:A1 ;
ns:definedBy data:P1 .
data:R2 a ns:R .
ns:defines data:A2 ;
ns:definedBy data:P2 .
data:P1 a ns:P ;
ns:hasS data:S1.
data:P2 a ns:P ;
ns:hasS data:S2.
data:S1 a ns:S ;
ns:hasI data:I1 ;
ns:hasV data:B1 .
data:S2 a ns:S ;
ns:hasI data:I1 ;
ns:hasV data:B2 .
data:I1 a ns:I ;
expr:hasString "relevant" .
data:B1 a ns:B ;
expr:hasBoolean "true"^^xsd:boolean .
data:B2 a ns:B ;
expr:hasBoolean "false"^^xsd:boolean .
I want to infer that every instance of A for which the relevant attribute is true is also an instance of my example-class, defined in my own ontology as eg:Example a owl:class.
Unfortunately, since the underlying schema for the data is very cumbersome, I have to do that via A -> R -> P -> S -> I and B. As R however isn't a straightforward definition (A <- R -> P -> S -> I and B is probably a more accurate representation), I can't just do a someValuesFrom chain and (I assume) this is where I fail.
Using Protégé, I loaded the schema which defines the properties and classes (Namespace ns) to be able to use the suggestions/auto-complete in the class expression editor. In my own ontology (containing only the example-class) following a previous suggestion I tried using the axiom:
A and (inverse defines some) and definedBy some (hasS some (hasI some(hasString value "relevant")) and (hasV some(hasBoolean value "true"^^xsd:boolean))) EquivalentTo: Example
I then merged my ontology with the data and ran the reasoner, expecting to see A1 (but not A2) as an instance of my example-class, but didn't get any results. I also tried using just "true" and true as well as "relevant"^^xsd:string to see if datatypes were causing the problem, yet it is only inferred that Example is a subclass of A.
I believe that my understanding of what inverse does is incorrect (I thought it's used since A1 is the object in the triple R1 defines A1; so I also tried inverse defines self), but I cannot figure it out. Any help is greatly appreciated.
Edit:
As Joshua correctly pointed out, my example lacks declarations. In my case, these are made in a different schema ontology, so I forgot about them here. Will add for the sake of completeness:
# Might as well include prefixes
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix expr: <http://purl.org/voc/express#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
# Classes
ns:A a owl:Class .
ns:R a owl:Class .
ns:P a owl:Class .
ns:S a owl:Class .
ns:I a owl:Class .
ns:B a owl:Class .
# Object Properties
ns:defines a owl:ObjectProperty .
ns:definedBy a owl:ObjectProperty .
ns:hasS a owl:ObjectProperty .
ns:hasI a owl:ObjectProperty .
ns:hasV a owl:ObjectProperty .
# Data Properties
expr:hasString a owlDatatypeProperty .
expr:hasBoolean a owlDatatypeProperty .
It doesn't look like that data was generated by Protege. When I copy that content and load it into Protege, everything shows up as annotation properties, which aren't generally handled under OWL reasoning. They show up as annotation properties because there are no property declarations making them object properties or datatype properties. That might be part of your problem. That axiom doesn't look quite right, either. E.g., (inverse defines some) doesn't make sense; that would have to be (inverse defines) some class expression, etc. In general, it helps a lot if you can provide complete working examples that we can work with. See How to create a Minimal, Complete, and Verifiable example.
All that said, I think we can recreate enough of the problem to figure out how to fix it. It sounds like you want to recognize a pattern like
A <--rdf:type-- ?a <--p-- ?b --q--> ?c --r--> 42
and then infer the triple
?a --rdf:type--> Goal
That is achievable in OWL. It requires an axiom of the form:
A and ((inverse p) some (q some (r value 42))) SubClassOf Goal
That says that if something is an A and is the p value of something that has a q value that has an r value of 42, then that first something is also a Goal.
Here's what it looks like in an actual ontology:
Once a reasoner has been started, it correctly infers that a is an instance of Goal:
Here's the actual ontology:
#prefix : <http://example.org/gca#> .
#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#> .
#base <http://example.org/gca> .
<http://example.org/gca> rdf:type owl:Ontology .
#################################################################
# Object Properties
#################################################################
### http://example.org/gca#p
:p rdf:type owl:ObjectProperty .
### http://example.org/gca#q
:q rdf:type owl:ObjectProperty .
#################################################################
# Data properties
#################################################################
### http://example.org/gca#r
:r rdf:type owl:DatatypeProperty .
#################################################################
# Classes
#################################################################
### http://example.org/gca#A
:A rdf:type owl:Class .
### http://example.org/gca#Goal
:Goal rdf:type owl:Class .
#################################################################
# Individuals
#################################################################
### http://example.org/gca#a
:a rdf:type owl:NamedIndividual ,
:A .
### http://example.org/gca#b
:b rdf:type owl:NamedIndividual ;
:p :a ;
:q :c .
### http://example.org/gca#c
:c rdf:type owl:NamedIndividual ;
:r 42 .
#################################################################
# General axioms
#################################################################
[ owl:intersectionOf ( :A
[ rdf:type owl:Restriction ;
owl:onProperty [ owl:inverseOf :p
] ;
owl:someValuesFrom [ rdf:type owl:Restriction ;
owl:onProperty :q ;
owl:someValuesFrom [ rdf:type owl:Restriction ;
owl:onProperty :r ;
owl:hasValue 42
]
]
]
) ;
rdf:type owl:Class ;
rdfs:subClassOf :Goal
] .
### Generated by the OWL API (version 4.2.5.20160517-0735) https://github.com/owlcs/owlapi

Defined class with annotation property in Protégé

How do I create a defined class using an annotation property in an OWL ontology?
Currently, I have created a defined class by using an object property hasSubject.
The defined class:
I would prefer to create this class by re-using the annotation 'Subject' from the DC-Terms set instead of a custom object property.
Is it possible to create a defined class with an annotation property?
How would I do that in Protégé?
You can't use annotation properties in OWL class restrictions. You can use object properties and datatype properties, but not annotation properties. In particular, the abstract syntax for an existential restriction like
isSubjectOf some Film
is, from 8.2.1 Existenial Quantification:
ObjectSomeValuesFrom := 'ObjectSomeValuesFrom' '(' ObjectPropertyExpression ClassExpression ')'
You won't have an ObjectPropertyExpression when you're working with an annotation property.
What you can do, however, is declare dcterms:subject as an object property in your ontology, and then you'll be able to use it. According to the documentation on dcterms:subject, the IRI is http://purl.org/dc/terms/subject. You'd declare that in Protege like any other object property:
Then you can use it in class expressions:
Do note that the documentation for dcterms:subject says:
Note: This term is intended to be used with non-literal values as
defined in the DCMI Abstract Model
(http://dublincore.org/documents/abstract-model/). As of December
2007, the DCMI Usage Board is seeking a way to express this intention
with a formal range declaration.
That means that that you're actually saying something a bit more restrictive. By declaring dcterms:subject as an object property, you'll be able to infer that whenever "X dcterms:subject Y", both X and Y are instances of owl:Thing, as well as whatever else you might say about the domain and range of the property. Since other people might not use dcterms:subject as an object property, they might not expect those inferences.
Here's what the ontology ends up as:
#prefix : <http://stackoverflow.com/q/29317444/1281433/> .
#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#> .
#base <http://stackoverflow.com/q/29317444/1281433/> .
<http://stackoverflow.com/q/29317444/1281433/> rdf:type owl:Ontology .
#################################################################
#
# Object Properties
#
#################################################################
### http://purl.org/dc/terms/subject
<http://purl.org/dc/terms/subject> rdf:type owl:ObjectProperty .
#################################################################
#
# Classes
#
#################################################################
### http://stackoverflow.com/q/29317444/1281433/FilmSubjectComposer
:FilmSubjectComposer rdf:type owl:Class ;
owl:equivalentClass [ rdf:type owl:Class ;
owl:intersectionOf ( <http://stackoverflow.com/q/29317444/1281433/#Composer>
[ rdf:type owl:Restriction ;
owl:onProperty [ owl:inverseOf <http://purl.org/dc/terms/subject>
] ;
owl:someValuesFrom <http://stackoverflow.com/q/29317444/1281433/#Film>
]
)
] .
### http://stackoverflow.com/q/29317444/1281433/#Composer
<http://stackoverflow.com/q/29317444/1281433/#Composer> rdf:type owl:Class .
### http://stackoverflow.com/q/29317444/1281433/#Film
<http://stackoverflow.com/q/29317444/1281433/#Film> rdf:type owl:Class .
### Generated by the OWL API (version 3.5.0) http://owlapi.sourceforge.net

I need to connect an Individual to a Class through an ObjectProperty, but can't because OWL-DL does not allow it. Is There a workaround for this?

I am building an ontology that describes some web services. How should I express the following OWL-Full statements in OWL-DL:
:Service a owl:Class
:Location a owl:Class
:hasInputType rdfs:domain :Service
:hasInputType rdfs:range owl:Class
:Service1 a :Service
:Service1 :hasInputType :Location
In OWL 2 DL, you can use a class name as an individual name. This is called "punning". So the following is valid OWL 2 DL:
:InputType a owl:Class .
:Service a owl:Class .
:Location a owl:Class, :InputType .
:hasInputType a owl:ObjectProperty;
rdfs:domain :Service;
rdfs:range :InputType .
:Service1 a :Service;
:hasInputType :Location .
You could even get rid of the class :InputType and simply use owl:Thing instead. Note that the third line actually defines two terms: a class called :Location and an individual called :Location too. These are two distinct terms.
As you mentioned, it is not possible to create a relation between a class and an individual using OWL-DL. So you have to revise the way you represent your domain knowledge, that's the only solution if you want to be able to use reasoners.
Here service instances could be linked to location instances, or you could also describe specific services using classes rather than individuals. You can then create a relation between Service1 and Location using a existential restriction.
Example using individuals:
:hasInput rdf:type owl:ObjectProperty ;
rdfs:domain :Service .
:Location rdf:type owl:Class .
:Service rdf:type owl:Class .
:Location1 rdf:type :Location , owl:NamedIndividual .
:Service1 rdf:type :Service , owl:NamedIndividual ;
:hasInput :Location1 .
Example using classes:
:hasInput rdf:type owl:ObjectProperty ;
rdfs:domain :Service .
:Location rdf:type owl:Class .
:Service rdf:type owl:Class .
:Service1 rdf:type owl:Class .
rdfs:subClassOf :Service ,
[ rdf:type owl:Restriction ;
owl:onProperty :hasInput ;
owl:someValuesFrom :Location
] .
To say that any input of Service1 must be a Location, but without implying that any such input must exist, then you can add one more type to Service1, namely a universal restriction on hasInput for Location.
:Service1
a owl:NamedIndividual , :Service ;
a [ a owl:Restriction ;
owl:allValuesFrom :Location ;
owl:onProperty :hasInput
] .
This says that forall x, if Service1 hasInput x, then x a Location. It does not imply the existence of an x such that Service1 hasInput x.

Resources