I have an ontology with Person and City classes. People travel to cities and this travel is represented in the traveledTo object property. I'd like to add a WorldTraveler class. People are world travelers if they have traveled to 2 or more cities. How can I do this in my ontology?
#prefix : <http://www.semanticweb.org/chris/ontologies/2017/9/untitled-ontology-64#> .
#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/chris/ontologies/2017/9/untitled-ontology-64> .
<http://www.semanticweb.org/chris/ontologies/2017/9/untitled-ontology-64> rdf:type owl:Ontology .
:traveledTo rdf:type owl:ObjectProperty ;
rdfs:domain :Person ;
rdfs:range :City .
:City rdf:type owl:Class .
:Person rdf:type owl:Class .
:Bob rdf:type owl:NamedIndividual ,
:Person ;
:traveledTo :London ,
:Ottawa ,
:Paris .
:Brussels rdf:type owl:NamedIndividual ,
:City .
:London rdf:type owl:NamedIndividual ,
:City .
:Ottawa rdf:type owl:NamedIndividual ,
:City .
:Paris rdf:type owl:NamedIndividual ,
:City .
:Ralph rdf:type owl:NamedIndividual ,
:Person ;
:traveledTo :Rome .
:Rome rdf:type owl:NamedIndividual ,
:City .
:Washington rdf:type owl:NamedIndividual ,
:City .
I tried adding the following Class but it didn't seem to work:
:WorldTraveler rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( :Person
[ rdf:type owl:Restriction ;
owl:onProperty :traveledTo ;
owl:minQualifiedCardinality "2"^^xsd:nonNegativeInteger ;
owl:onClass :City
]
) ;
rdf:type owl:Class
] .
I believe that my reasoner may not be able to infer that Ralph is not a WorldTraveler because of the open world assumption. However, it should be able to infer that Bob is a WorldTraveler because he has traveled to 3 cities.
Thanks for your help.
Chris
In addition to the open world assumption (OWA), there exists the unique name assumption (UNA). OWL does make the former (OWA) and does not make the latter (UNA).
You should explicitely make individuals different.
In the Turtle syntax, it should look like this:
:London owl:differentFrom :Paris .
or
[ rdf:type owl:AllDifferent ;
owl:distinctMembers ( :Brussels :London :Ottawa :Paris :Rome :Washington )
] .
Related
For example 1 :
Classes : A and B.
Property : hasValue.
Axiom : hasValue some A disjointWith hasValue some B.
Individual : user1.
user1 hasValue A.
user1 hasValue B.
Protege reasoner (HermiT) throws no error.
For example 2 :
Classes : A and B.
A disjoint with B.
Property : hasValue.
Axiom : hasValue some A disjointWith hasValue some B.
Individual : user1.
user1 hasValue A.
user1 hasValue B.
Protege reasoner (HermiT) throws error.
Shouldn't "hasValue some A disjointWith hasValue some B" alone be sufficient to throw error in eg 1's case?
EDIT : example 1's reasoner result is wrong. As #Henriette Harmse showed below reasoner will throw error.
I was doing declaring Axiom a little differently than what I wrote above. I declared axiom as "hasValue some B DisjointWith hasValue some
(P and (not (B)))", where P is parent class of both A and B. (Full sample ontology below.) If you import it in protege and run, you'll not get error.
It seems :
"hasValue some B DisjointWith hasValue some A"
"hasValue some B DisjointWith hasValue some (P and (not (B)))"
are not equivalent statements.
Sample ontology :
#prefix : <http://test.org/#> .
#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://test.org/> .
<http://test.org/> rdf:type owl:Ontology .
#################################################################
# Object Properties
#################################################################
### http://test.org/#hasValue
:hasValue rdf:type owl:ObjectProperty .
#################################################################
# Classes
#################################################################
### http://test.org/#A
:A rdf:type owl:Class ;
rdfs:subClassOf :P .
### http://test.org/#B
:B rdf:type owl:Class ;
rdfs:subClassOf :P .
### http://test.org/#P
:P rdf:type owl:Class .
### http://test.org/#USER
:USER rdf:type owl:Class .
#################################################################
# Individuals
#################################################################
### http://test.org/#A
:A rdf:type owl:NamedIndividual ,
:A .
### http://test.org/#B
:B rdf:type owl:NamedIndividual ,
:B .
### http://test.org/#user1
:user1 rdf:type owl:NamedIndividual ;
:hasValue :A ,
:B .
#################################################################
# General axioms
#################################################################
[ rdf:type owl:Restriction ;
owl:onProperty :hasValue ;
owl:someValuesFrom :A ;
owl:disjointWith [ rdf:type owl:Restriction ;
owl:onProperty :hasValue ;
owl:someValuesFrom [ owl:intersectionOf ( :P
[ rdf:type owl:Class ;
owl:complementOf :A
]
) ;
rdf:type owl:Class
]
]
] .
[ rdf:type owl:Restriction ;
owl:onProperty :hasValue ;
owl:someValuesFrom :B ;
owl:disjointWith [ rdf:type owl:Restriction ;
owl:onProperty :hasValue ;
owl:someValuesFrom [ owl:intersectionOf ( :P
[ rdf:type owl:Class ;
owl:complementOf :B
]
) ;
rdf:type owl:Class
]
]
] .
### Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi
I have tried this now myself and for your first example I get an inconsistency with the following explanation:
Here is the actual ontology giving the inconsistency. I will need to see your actual ontology to understand why you are not getting an inconsistency.
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#"
xml:base="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:untitled-ontology-9="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#">
<owl:Ontology rdf:about="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9"/>
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#hasValue"/>
<owl:Class rdf:about="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#A"/>
<owl:Class rdf:about="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#B"/>
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#a">
<rdf:type rdf:resource="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#A"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#b">
<rdf:type rdf:resource="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#B"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#user1">
<hasValue rdf:resource="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#a"/>
<hasValue rdf:resource="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#b"/>
</owl:NamedIndividual>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#hasValue"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#A"/>
<owl:disjointWith>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#hasValue"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/henri/ontologies/2022/6/untitled-ontology-9#B"/>
</owl:Restriction>
</owl:disjointWith>
</owl:Restriction>
</rdf:RDF>
Update after reviewing ACTUAL ontology
The main problem is that you stated the GCI you used incorrectly. What you said you used are substantially different from what you actually used.
What you said used: hasValue some A disjointWith hasValue some B
What you actually used:
hasValue some A DisjointWith hasValue some (P and (not (A)))
hasValue some B DisjointWith hasValue some (P and (not (B)))
To understand why your GCIs do not have the desired effect, I have drawn an example Venn diagram:
Note that hasValue some A DisjointWith hasValue some (P and (not (A))) states that there is no individual x that belongs to both the set hasValue some A and the set hasValue some (P and (not (A))). It does however allow for the possibility that you have an individual user1 that is related via hasValue to an individual in set A and that is related via hasValue to an individual in set B. This is because nothing prohibits the sets hasValue some A (to which user1 hasValue A belongs) and hasValue some B (to which user1 hasValue B belongs)` to overlap. To prohibit this, you have to add the following GCI:
hasValue some A DisjointWith hasValue some B
How to get a inconsistency using you GCIs
To get an inconsistency using your GCIs, you have to have an individual that actually belong to the disjoint sets you defined. I.e.,
Define individual x as follows:
:x rdf:type owl:NamedIndividual ,
[ owl:intersectionOf ( :P
[ rdf:type owl:Class ;
owl:complementOf :A
]
) ;
rdf:type owl:Class
] .
and then define user2:
:user2 rdf:type owl:NamedIndividual ;
:hasValue :A ,
:x .
You will get an inconsistency with the following explanation:
I need to check the violations to the OWL2DL profile in this simplified ontology:
#prefix : <http://www.onto.com/test#> .
#prefix owl: <http://www.w3.org/2002/07/owl#> .
#prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
#prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
#base <http://www.onto.com/test#> .
<http://www.onto.com/test#> rdf:type owl:Ontology ;
rdfs:label "Test"#en .
xsd:date rdf:type rdfs:Datatype .
<http://www.onto.com/test#hasPart2> rdf:type owl:ObjectProperty .
<http://www.onto.com/test#isPartOf> rdf:type owl:ObjectProperty ,
owl:TransitiveProperty ;
rdfs:domain <http://www.onto.com/test#TestRestriction> .
<http://www.onto.com/test#isPartOf2> rdf:type owl:ObjectProperty ;
rdfs:subPropertyOf owl:topObjectProperty ;
rdf:type owl:TransitiveProperty ;
rdfs:domain <http://www.onto.com/test#A2PartOfClass> .
<http://www.onto.com/test#maxCardinality0> rdf:type owl:ObjectProperty .
<http://www.onto.com/test#A2PartOfClass> rdf:type owl:Class .
<http://www.onto.com/test#TestRestriction> rdf:type owl:Class ;
rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty <http://www.onto.com/test#isPartOf2> ;
owl:minQualifiedCardinality "0"^^xsd:nonNegativeInteger ;
owl:onClass <http://www.onto.com/test#A2PartOfClass>
] ;
rdfs:comment "A1 PartOf Class Comment"#en ;
rdfs:label "A1PartOfClass"#en .
<http://www.onto.com/test#isPartOf2> rdf:type owl:Class .
To this end, I have the following code in the OWL API to check for the violations of the given ontology to the OWL2DL profile.
OWL2DLProfile profile = new OWL2DLProfile();
OWLProfileReport report = profile.checkOntology(ontology);
for(OWLProfileViolation v:report.getViolations()) {
System.out.println(v);
}
In the console I'm getting this:
Use of non-simple property in a restriction: ObjectMinCardinality(0 <http://www.onto.com/test#isPartOf2> <http://www.onto.com/test#A2PartOfClass>) [SubClassOf(<http://www.onto.com/test#TestRestriction> ObjectMinCardinality(0 <http://www.onto.com/test#isPartOf2> <http://www.onto.com/test#A2PartOfClass>)) in OntologyID(OntologyIRI(<http://www.onto.com/test#>) VersionIRI(<null>))]
And I would like to retrieve the URIs involved, i.e., http://www.onto.com/test#isPartOf2, http://www.onto.com/test#A2PartOfClass
as well as the message of the violation, i.e., Use of non-simple property in a restriction.
How can I achieve this?
You can get the signature of the axiom involved in the violation as follows:
violation.getAxiom()
.signature()
.forEach(System.out::println);
There is no easy way to get the type of the violation besides doing the following:
violation.getClass().getSimpleName()
which will return UseOfNonSimplePropertyInCardinalityRestriction.
I have defined an object property that requires two individuals. However, Protege do not let me to add these two but only one. The question could be summarised as follows: I have A and B belonging to a class (instances of that class). I have one object property, say proper, I would like to express: proper A, B. Here it is the code I wrote up to know.
#prefix : <http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age#> .
#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/24188632/1281433/people-have-exactly-one-age> .
<http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age> rdf:type owl:Ontology .
#################################################################
# Object Properties
#################################################################
### http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age#Interact2
:Interact2 rdf:type owl:ObjectProperty ,
owl:FunctionalProperty ;
rdfs:domain :Person ;
rdfs:range :Person .
#################################################################
# Data properties
#################################################################
### http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age#Interact
:Interact rdf:type owl:DatatypeProperty .
### http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age#hasAge
:hasAge rdf:type owl:DatatypeProperty .
#################################################################
# Classes
#################################################################
### http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age#Person
:Person rdf:type owl:Class ;
rdfs:subClassOf [ rdf:type owl:Restriction ;
owl:onProperty :Interact2 ;
owl:qualifiedCardinality "2"^^xsd:nonNegativeInteger ;
owl:onClass :Person
] ,
[ rdf:type owl:Restriction ;
owl:onProperty :hasAge ;
owl:cardinality "1"^^xsd:nonNegativeInteger
] .
#################################################################
# Individuals
#################################################################
### http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age#Pallino
:Pallino rdf:type owl:NamedIndividual ,
:Person .
### http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age#Pinco
:Pinco rdf:type owl:NamedIndividual ,
:Person .
### http://stackoverflow.com/q/24188632/1281433/people-have-exactly-one-age#Pinco_Pallino
:Pinco_Pallino rdf:type owl:NamedIndividual ,
:Person ;
:Interact2 :Pinco .
### Generated by the OWL API (version 4.2.8.20170104-2310) https://github.com/owlcs/owlapi
I'm learning about reasoning and knowledge engineering and I made up the following example:
#prefix : <http://example.org#> .
#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.w3.org/2002/07/owl> .
[ rdf:type owl:Ontology
] .
:value rdf:type owl:DatatypeProperty ;
rdfs:range xsd:string .
:humiditySensor rdf:type owl:Class ;
rdfs:subClassOf :sensor .
:location rdf:type owl:Class .
:room rdf:type owl:Class ;
rdfs:subClassOf :location .
:sensor rdf:type owl:Class.
:temperatureSensor rdf:type owl:Class ;
rdfs:subClassOf :sensor .
:temp1 rdf:type owl:NamedIndividual ,
:temperatureSensor ;
:room 201 ;
:value 29 .
I'm trying to infer that temp1 is of type sensor. When I pose the following query to Eye reasoner (backward chaining) I get nothing, i.e. the fact that temp1 is of type sensor is not inferred, even though subClassOf is transitive:
#prefix : <http://example.org#>.
#prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
{
?x a :sensor.
?x :value ?y.
}
=>
{
?x :value ?y.
}.
If I write a couple of rules manually to express this transitivity property of subClassOf, it will work. However, CWM reasoner (forward chaining) in the proof states correctly that temp1 is of type sensor, without the additional rules.
Is this because of the difference between forward and backward chaining?
I hope I'm making sense.
I have developed an ontology and I want to add the following SWRL in protege:
Divider_intersection(?node), is_extent_of(?node, ?s), builds(?s, ?l),Segment(?s),Lane(?l),detailed_partition(?d), builds(?l, ?d)-> is_divided_at(?d, ?node)
with this I wish to add an object property, is_divided_at, between an individual from detailed_partition (?d) and a node that is classified as a divider_intersection if it is the extent of a segment (?s) that build a lane (?l) which then build the detailed?partition (?d). As noted here, I am looking for NamedIndividuals, hence I presume the SWRL should do the job.
Further research, I found Rolification (1, 2, 3) as a possible answer however I have never used it before, but I made the following chain:
r_Divider_intersection o is_extent_of o r_Segment o builds o r_Lane o builds o r_detailed_partition
still I do not get the answer. Any idea what is wrong?
Your approach works, and without seeing your ontology (your link requires permissions, and offsite links aren't very helpful anyhow) we can't see why your particular construction of it works. One thing that jumps out from your question is that the it looks like your is_divided_at property has its arguments (?d,?node) in the opposite order from what the property chain axiom would produce. Anyhow, here's a working example.
#prefix : <urn:ex:#> .
#prefix ex: <urn:ex:#> .
#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 rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
ex:isDividedAt a owl:ObjectProperty ;
owl:propertyChainAxiom ( ex:_DividerIntersection ex:isExtentOf ex:_Segment ex:builds ex:_Lane ex:builds ex:_DetailedPartition ) .
ex:Segment a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_Segment
] .
ex:_DetailedPartition
a owl:ObjectProperty .
ex:DividerIntersection
a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_DividerIntersection
] .
ex:_Segment a owl:ObjectProperty .
ex:_Lane a owl:ObjectProperty .
ex:builds a owl:ObjectProperty .
ex:dividerIntersection0
a owl:NamedIndividual , ex:DividerIntersection ;
ex:isExtentOf ex:segment0 .
<urn:ex:> a owl:Ontology .
ex:detailedPartition0
a owl:NamedIndividual , ex:DetailedPartition .
ex:_DividerIntersection
a owl:ObjectProperty .
ex:segment0 a owl:NamedIndividual , ex:Segment ;
ex:builds ex:lane0 .
ex:DetailedPartition a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_DetailedPartition
] .
ex:isExtentOf a owl:ObjectProperty .
ex:lane0 a owl:NamedIndividual , ex:Lane ;
ex:builds ex:detailedPartition0 .
ex:Lane a owl:Class ;
owl:equivalentClass [ a owl:Restriction ;
owl:hasSelf true ;
owl:onProperty ex:_Lane
] .