I would like to infer an anonymous class definition for my Individuals in Protege.
I have a simple Ontology with the Classes Rain NoRain and Scene
, The object Property has_weather
.
My desire is to be able to infer "has_weather(?x, ?noRain), NoRain(?noRain), Scene(?x) -> (has_weather exactly 0 Rain)(?x)
which i wrote in the Rules tab, where i can mix SWRL and OWL Expressions.
I am using Pellet Reasoner, however I also tried with OnTop and Hermit and none works. For example if I do the rule the other way around:
`has_weather(?x, ?noRain), (has_weather exactly 0 Rain)(?x), Scene(?x) -> Test(?x)`
It works without problems.
Is the problem, that Protege just can't infer anonymous classes? Is there any workaround? Thank you in Advance!
here is the code to the ontology
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#has_weather -->
<owl:ObjectProperty rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#has_weather">
<rdfs:subPropertyOf rdf:resource="http://www.w3.org/2002/07/owl#topObjectProperty"/>
</owl:ObjectProperty>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain -->
<owl:Class rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain">
<owl:disjointWith rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Rain"/>
</owl:Class>
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Rain -->
<owl:Class rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Rain"/>
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene -->
<owl:Class rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene"/>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain">
<rdf:type rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain"/>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene -->
<owl:NamedIndividual rdf:about="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene">
<rdf:type rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene"/>
<has_weather rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain"/>
</owl:NamedIndividual>
<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Rules
//
///////////////////////////////////////////////////////////////////////////////////////
-->
<rdf:Description rdf:about="urn:swrl:var#x">
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable"/>
</rdf:Description>
<rdf:Description rdf:about="urn:swrl:var#noRain">
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Variable"/>
</rdf:Description>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#Imp"/>
<swrl:body>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#IndividualPropertyAtom"/>
<swrl:propertyPredicate rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#has_weather"/>
<swrl:argument1 rdf:resource="urn:swrl:var#x"/>
<swrl:argument2 rdf:resource="urn:swrl:var#noRain"/>
</rdf:Description>
</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#ClassAtom"/>
<swrl:classPredicate rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#NoRain"/>
<swrl:argument1 rdf:resource="urn:swrl:var#noRain"/>
</rdf:Description>
</rdf:first>
<rdf:rest>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#ClassAtom"/>
<swrl:classPredicate rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Scene"/>
<swrl:argument1 rdf:resource="urn:swrl:var#x"/>
</rdf:Description>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</rdf:rest>
</rdf:Description>
</swrl:body>
<swrl:head>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#AtomList"/>
<rdf:first>
<rdf:Description>
<rdf:type rdf:resource="http://www.w3.org/2003/11/swrl#ClassAtom"/>
<swrl:classPredicate>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#has_weather"/>
<owl:qualifiedCardinality rdf:datatype="http://www.w3.org/2001/XMLSchema#nonNegativeInteger">0</owl:qualifiedCardinality>
<owl:onClass rdf:resource="http://www.semanticweb.org/stefi/ontologies/2021/8/8/untitled-ontology-55#Rain"/>
</owl:Restriction>
</swrl:classPredicate>
<swrl:argument1 rdf:resource="urn:swrl:var#x"/>
</rdf:Description>
</rdf:first>
<rdf:rest rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#nil"/>
</rdf:Description>
</swrl:head>
</rdf:Description>
</rdf:RDF>
`
In general a set of axioms has an infinite amout of entailments. See for example this paper. For this reason reasoners restrict inferences to known classes (not anonymous classes). I suspect this holds true for rules as well.
I therefore suggest you add a class NoRain
that you set equivalent to has_weather 0 Rain
and change your SWRL rule to use the class NoRain
.