protegeproject / swrlapi

Java API for working with the SWRL rule and SQWRL query languages
Other
99 stars 40 forks source link

symmetric property and reflexive property #70

Open croussey opened 3 years ago

croussey commented 3 years ago

I am developping a rdf dataset using skos vocabulary. I use lots of mapping relation skos:exactMatch and skos:closeMatch and other skos:broadMatch, skos:broader and so on... I try to infer some of the link between individuals. for example when A skos:broader B I used SWRL tab to infer that B skos:narrower A. It works well. I specify in SWRL tab that I want to use only the prop_inv2 an,d prop_inv1 rules in table 5.

when I parameterize tab5 with prp_trp and I specify that A skos:exactMatch B and B skos:exactMatch A, SWRL Tab inferred that A skos:exactMatch A. Unfortunattely skos:exactMatch is not a reflexive property. Another issue is when I parameterize tab5 with prp_symp and I specify that A skos:closeMatch B, closeMatch is a symetric property then SWRL Tab does not infer that B skos:closeMatch A.

martinjoconnor commented 3 years ago

I am not fully following the above example.

Can you enclose a simple ontology illustrating the problem.

croussey commented 3 years ago

baggiolini_grapevine_secondaryStage_N skos:exactMatch baggiolini_grapevine_secondaryStage_N el_grapevine_secondaryStage_35 skos:exactMatch el_grapevine_secondaryStage_35
bbch_grapevine_secondaryStage_BBCH95 skos:exactMatch bbch_grapevine_secondaryStage_BBCH95
bbch_grapevine_secondaryStage_BBCH99 skos:exactMatch bbch_grapevine_secondaryStage_BBCH99
bbch_grapevine_secondaryStage_BBCH91 skos:exactMatch bbch_grapevine_secondaryStage_BBCH91
bbch_grapevine_secondaryStage_BBCH14 skos:exactMatch bbch_grapevine_secondaryStage_BBCH14
bbch_grapevine_secondaryStage_BBCH69 skos:exactMatch bbch_grapevine_secondaryStage_BBCH69
bbch_grapevine_secondaryStage_BBCH65 skos:exactMatch bbch_grapevine_secondaryStage_BBCH65
ifv_grapevine_secondaryStage_13 skos:exactMatch ifv_grapevine_secondaryStage_13 el_grapevine_secondaryStage_27 skos:exactMatch el_grapevine_secondaryStage_27
bbch_grapevine_secondaryStage_BBCH61 skos:exactMatch bbch_grapevine_secondaryStage_BBCH61
el_grapevine_secondaryStage_23 skos:exactMatch el_grapevine_secondaryStage_23
ifv_grapevine_secondaryStage_75 skos:exactMatch ifv_grapevine_secondaryStage_75 ifv_grapevine_secondaryStage_79 skos:exactMatch ifv_grapevine_secondaryStage_79 bbch_grapevine_secondaryStage_BBCH03 skos:exactMatch bbch_grapevine_secondaryStage_BBCH03
baggiolini_grapevine_secondaryStage_B skos:exactMatch baggiolini_grapevine_secondaryStage_B ifv_grapevine_secondaryStage_71 skos:exactMatch ifv_grapevine_secondaryStage_71 ifv_grapevine_secondaryStage_01 skos:exactMatch ifv_grapevine_secondaryStage_01 ifv_grapevine_secondaryStage_53 skos:exactMatch ifv_grapevine_secondaryStage_53 baggiolini_grapevine_secondaryStage_I skos:exactMatch baggiolini_grapevine_secondaryStage_I el_grapevine_secondaryStage_15 skos:exactMatch el_grapevine_secondaryStage_15
baggiolini_grapevine_secondaryStage_M skos:exactMatch baggiolini_grapevine_secondaryStage_M bbch_grapevine_secondaryStage_BBCH77 skos:exactMatch bbch_grapevine_secondaryStage_BBCH77
ifv_grapevine_secondaryStage_57 skos:exactMatch ifv_grapevine_secondaryStage_57 bbch_grapevine_secondaryStage_BBCH73 skos:exactMatch bbch_grapevine_secondaryStage_BBCH73
el_grapevine_secondaryStage_38 skos:exactMatch el_grapevine_secondaryStage_38
el_grapevine_secondaryStage_03 skos:exactMatch el_grapevine_secondaryStage_03
ifv_grapevine_secondaryStage_05 skos:exactMatch ifv_grapevine_secondaryStage_05 ifv_grapevine_secondaryStage_09 skos:exactMatch ifv_grapevine_secondaryStage_09 bbch_grapevine_secondaryStage_BBCH13 skos:exactMatch bbch_grapevine_secondaryStage_BBCH13
ifv_grapevine_secondaryStage_99 skos:exactMatch ifv_grapevine_secondaryStage_99 ifv_grapevine_secondaryStage_61 skos:exactMatch ifv_grapevine_secondaryStage_61 bbch_grapevine_secondaryStage_BBCH81 skos:exactMatch bbch_grapevine_secondaryStage_BBCH81
ifv_grapevine_secondaryStage_65 skos:exactMatch ifv_grapevine_secondaryStage_65 ifv_grapevine_secondaryStage_95 skos:exactMatch ifv_grapevine_secondaryStage_95 ifv_grapevine_secondaryStage_69 skos:exactMatch ifv_grapevine_secondaryStage_69 ifv_grapevine_secondaryStage_91 skos:exactMatch ifv_grapevine_secondaryStage_91 bbch_grapevine_secondaryStage_BBCH89 skos:exactMatch bbch_grapevine_secondaryStage_BBCH89
bbch_grapevine_secondaryStage_BBCH85 skos:exactMatch bbch_grapevine_secondaryStage_BBCH85
bbch_grapevine_secondaryStage_BBCH55 skos:exactMatch bbch_grapevine_secondaryStage_BBCH55
el_grapevine_secondaryStage_19 skos:exactMatch el_grapevine_secondaryStage_19
el_grapevine_secondaryStage_41 skos:exactMatch el_grapevine_secondaryStage_41
baggiolini_grapevine_secondaryStage_H skos:exactMatch baggiolini_grapevine_secondaryStage_H bbch_grapevine_secondaryStage_BBCH09 skos:exactMatch bbch_grapevine_secondaryStage_BBCH09
baggiolini_grapevine_secondaryStage_D skos:exactMatch baggiolini_grapevine_secondaryStage_D bbch_grapevine_secondaryStage_BBCH05 skos:exactMatch bbch_grapevine_secondaryStage_BBCH05
ifv_grapevine_secondaryStage_00 skos:exactMatch ifv_grapevine_secondaryStage_00 el_grapevine_secondaryStage_33 skos:exactMatch el_grapevine_secondaryStage_33
baggiolini_grapevine_secondaryStage_L skos:exactMatch baggiolini_grapevine_secondaryStage_L baggiolini_grapevine_secondaryStage_P skos:exactMatch baggiolini_grapevine_secondaryStage_P ifv_grapevine_secondaryStage_81 skos:exactMatch ifv_grapevine_secondaryStage_81 ifv_grapevine_secondaryStage_85 skos:exactMatch ifv_grapevine_secondaryStage_85 el_grapevine_secondaryStage_02 skos:exactMatch el_grapevine_secondaryStage_02
bbch_grapevine_secondaryStage_BBCH97 skos:exactMatch bbch_grapevine_secondaryStage_BBCH97
ifv_grapevine_secondaryStage_89 skos:exactMatch ifv_grapevine_secondaryStage_89 bbch_grapevine_secondaryStage_BBCH93 skos:exactMatch bbch_grapevine_secondaryStage_BBCH93
el_grapevine_secondaryStage_07 skos:exactMatch el_grapevine_secondaryStage_07
el_grapevine_secondaryStage_25 skos:exactMatch el_grapevine_secondaryStage_25
ifv_grapevine_secondaryStage_11 skos:exactMatch ifv_grapevine_secondaryStage_11 ifv_grapevine_secondaryStage_77 skos:exactMatch ifv_grapevine_secondaryStage_77 bbch_grapevine_secondaryStage_BBCH01 skos:exactMatch bbch_grapevine_secondaryStage_BBCH01
ifv_grapevine_secondaryStage_73 skos:exactMatch ifv_grapevine_secondaryStage_73 baggiolini_grapevine_secondaryStage_G skos:exactMatch baggiolini_grapevine_secondaryStage_G bbch_grapevine_secondaryStage_BBCH71 skos:exactMatch bbch_grapevine_secondaryStage_BBCH71
ifv_grapevine_secondaryStage_03 skos:exactMatch ifv_grapevine_secondaryStage_03 el_grapevine_secondaryStage_17 skos:exactMatch el_grapevine_secondaryStage_17
ifv_grapevine_secondaryStage_55 skos:exactMatch ifv_grapevine_secondaryStage_55 bbch_grapevine_secondaryStage_BBCH79 skos:exactMatch bbch_grapevine_secondaryStage_BBCH79
baggiolini_grapevine_secondaryStage_K skos:exactMatch baggiolini_grapevine_secondaryStage_K bbch_grapevine_secondaryStage_BBCH75 skos:exactMatch bbch_grapevine_secondaryStage_BBCH75
baggiolini_grapevine_secondaryStage_O skos:exactMatch baggiolini_grapevine_secondaryStage_O el_grapevine_secondaryStage_29 skos:exactMatch el_grapevine_secondaryStage_29
ifv_grapevine_secondaryStage_07 skos:exactMatch ifv_grapevine_secondaryStage_07 el_grapevine_secondaryStage_05 skos:exactMatch el_grapevine_secondaryStage_05
el_grapevine_secondaryStage_01 skos:exactMatch el_grapevine_secondaryStage_01
bbch_grapevine_secondaryStage_BBCH11 skos:exactMatch bbch_grapevine_secondaryStage_BBCH11
ifv_grapevine_secondaryStage_97 skos:exactMatch ifv_grapevine_secondaryStage_97 bbch_grapevine_secondaryStage_BBCH68 skos:exactMatch bbch_grapevine_secondaryStage_BBCH68
ifv_grapevine_secondaryStage_93 skos:exactMatch ifv_grapevine_secondaryStage_93 ifv_grapevine_secondaryStage_14 skos:exactMatch ifv_grapevine_secondaryStage_14 el_grapevine_secondaryStage_43 skos:exactMatch el_grapevine_secondaryStage_43
el_grapevine_secondaryStage_47 skos:exactMatch el_grapevine_secondaryStage_47
bbch_grapevine_secondaryStage_BBCH00 skos:exactMatch bbch_grapevine_secondaryStage_BBCH00
bbch_grapevine_secondaryStage_BBCH57 skos:exactMatch bbch_grapevine_secondaryStage_BBCH57
bbch_grapevine_secondaryStage_BBCH53 skos:exactMatch bbch_grapevine_secondaryStage_BBCH53

croussey commented 3 years ago

I give you an example of SWRL output. as you may notice the exactMatch link is between the same individual. unfortinatelly exactMatch is not reflexive property. You could find example in the gitlab repository https://gitlab.irstea.fr/copain/phenologicalstages/-/tree/master

croussey commented 3 years ago

I made a mistake it comes from the fact that skos:exactMatch is a transitive property. the output come is the result of the PRP_TRP property. but exactMatch is not reflexive so I do not expect such output.

martinjoconnor commented 3 years ago

Sorry - I'm not really following the above.

Can you create a simple ontology with a minimal number of OWL entities that illustrates the problem. (You can add a .txt extension or the like to the uploaded OWL since GitHub does not support the .owl extension.)

And then specify what missing inference you are expecting.

croussey commented 3 years ago

I generate a ttl file with 3 concepts A, B and C. if you run the swrl appy with only PRP_TRP. SWRL Tab will produce B skos:exactMatch B C skos:exactMatch C A skos:exactMatch A

@prefix : http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84# . @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/catherineroussey/ontologies/2020/10/untitled-ontology-84 .

http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84 rdf:type owl:Ontology ; owl:imports http://www.w3.org/2004/02/skos/core .

#################################################################

Individuals

#################################################################

http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/A

http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/A rdf:type owl:NamedIndividual , http://www.w3.org/2004/02/skos/core#Concept ; http://www.w3.org/2004/02/skos/core#exactMatch http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/B , http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/C .

http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/B

http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/B rdf:type owl:NamedIndividual , http://www.w3.org/2004/02/skos/core#Concept ; http://www.w3.org/2004/02/skos/core#exactMatch http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/A , http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/C .

http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/C

http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/C rdf:type owl:NamedIndividual , http://www.w3.org/2004/02/skos/core#Concept ; http://www.w3.org/2004/02/skos/core#exactMatch http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/A , http://www.semanticweb.org/catherineroussey/ontologies/2020/10/untitled-ontology-84/B .

croussey commented 3 years ago

my problem was I do not want that such inferences were produced B skos:exactMatch B C skos:exactMatch C A skos:exactMatch A because skos:exactMatch is not a reflexive property

martinjoconnor commented 3 years ago

According to the SKOS specification, "None of the SKOS mapping properties are reflexive, neither are they irreflexive".

So the above entailments are correct. See 10.6.4 in https://www.w3.org/TR/skos-reference/#semantic-relations.

martinjoconnor commented 3 years ago

That said, I am not sure why the reasoner is producing these assertions since OWL 2 RL does not support reflexive object property axioms. I will take a look over the next few days.

martinjoconnor commented 3 years ago

I have generated a new 2.0.9 release of the SWRLAPI and the SWRLTab Plugin. (You can download the plugin in Protege via File->Check for plugins...)

The OWL 2 RL rule enable/disable functionality should now work. However, these selections are not persisted to the ontology - they are only reflected in the current session.

Please let me know if this works for you.

croussey commented 3 years ago

I have installed the latest version of protégé and 5.5.0 and the tab swrl. The problem still persist the rule prp_trp still produce the output A skos:exactMatch A. as you mentioned it previously the point is that exactMatch is not defined as reflexive and neither as irreflexive Maybe I do not know how to import in protege your new version of swrl tab or maybe I am wrong the output is correct. I do not know what to think about this output