I would like to model an ontology where I can represent an absence of entity so to say. I want for example to have Rain and No_Rain, which I would define as disjoint classes. After this I have the object Property has_rain. I want somehow to be able to reason that it's not possible to have at the same time for the same individual has_rain(Rain) and has_rain(No_Rain) I've searched a lot and couldn't find the answer to my problem. Maybe I've missed it somewhere. Sorry if I didn't explain everything good, this is my first question. I hope you understood everything and thanks in advance! Edit:
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#has_rain -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#has_rain">
<rdfs:subPropertyOf rdf:resource="http://www.w3.org/2002/07/owl#topObjectProperty"/>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#No_Rain -->
<owl:Class rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#No_Rain"/>
<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#Rain -->
<owl:Class rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#Rain"/>
<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#Scene -->
<owl:Class rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#Scene"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#no_rain -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#no_rain"/>
<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#rain -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#rain"/>
<!-- http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#scene -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#scene">
<has_rain rdf:resource="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#rain"/>
</owl:NamedIndividual>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// General axioms
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDifferent"/>
<owl:distinctMembers rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#no_rain"/>
<rdf:Description rdf:about="http://www.semanticweb.org/qala/ontologies/2021/1/untitled-ontology-28#rain"/>
</owl:distinctMembers>
</rdf:Description>
</rdf:RDF>
I also started using owlready, but I am still new there, but if I had to model this in code it would be :
with ontology:
class Rain(Thing):
pass
class No_Rain(Thing):
pass
class Scene(Thing):
pass
class has_rain(ObjectProperty):
domain = [Scene]
range = [Rain or No_Rain]
rain = Rain("rain")
no_rain = No_Rain("no_rain")
AllDisjoint(Rain, No_Rain)
I hope this makes it more clear.
You seem to want to define scenes that can have different weather. Ideally a scene should not be able to have both snow and being dry.
Because this is about a scene, I will define different types of SceneWeather
, i.e. DryScene
, SnowyScene
and RainyScene
, which is disjoint from each other - it cannot snow and rain at the same time. Then I define object properties hasRain
with RainyScene
as domain and likewise hasSnow
and isDry
.
I have introduced SceneWeather
as a parent class with the assumption that you likely will want to capture various scene related information. In the example below I included SceneTimeOfDay
with Morning
as subclass and isMorning
as object property with Morning
as domain.
Based on the above you can then define a snowyMorningScene
by asserting that for snowyMorningScene
we have hasSnow
and isMorning
. Using a reasoner it will infer that snowyMorningScene
is of type SnowyScene
and Morning
. If you now state that snowyMorningScene
isDry
, it will result in an inconsistency.
Below is the complete ontology for doing this.
<rdf:RDF xmlns="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#"
xml:base="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291"
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-291="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#">
<owl:Ontology rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isDry -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isDry">
<rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#DryScene"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isMorning -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isMorning">
<rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneTimeOfDay"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Morning"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isRainy -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isRainy">
<rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#RainyScene"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isSnowy -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#isSnowy">
<rdfs:subPropertyOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather"/>
<rdfs:domain rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SnowyScene"/>
</owl:ObjectProperty>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneTimeOfDay -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneTimeOfDay"/>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#sceneWeather"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#DryScene -->
<owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#DryScene">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather"/>
</owl:Class>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#MidDay -->
<owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#MidDay">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneTimeOfDay"/>
<owl:disjointWith rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Morning"/>
</owl:Class>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Morning -->
<owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Morning">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneTimeOfDay"/>
</owl:Class>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#RainyScene -->
<owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#RainyScene">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather"/>
</owl:Class>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Scene -->
<owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Scene"/>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneTimeOfDay -->
<owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneTimeOfDay">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Scene"/>
</owl:Class>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather -->
<owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#Scene"/>
</owl:Class>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SnowyScene -->
<owl:Class rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SnowyScene">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SceneWeather"/>
</owl:Class>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#dry -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#dry"/>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#morning -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#morning"/>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snow -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snow"/>
<!-- http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snowyMorningScene -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snowyMorningScene">
<isDry rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#dry"/>
<isMorning rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#morning"/>
<isSnowy rdf:resource="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#snow"/>
</owl:NamedIndividual>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// General axioms
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDisjointClasses"/>
<owl:members rdf:parseType="Collection">
<rdf:Description rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#DryScene"/>
<rdf:Description rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#RainyScene"/>
<rdf:Description rdf:about="http://www.semanticweb.org/henriette/ontologies/2021/1/untitled-ontology-291#SnowyScene"/>
</owl:members>
</rdf:Description>
</rdf:RDF>
<!-- Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi -->