I'm new to protege and ontologies. I wrote this rule in SQWRL tab in protege, to figure out if p is managed by r:
metadata(?md1) ^ hasValue(?md1, ?val) ^ hasLabel(?md1, ?lbl) ^ replicaset(?r) ^ hasMatchlabels(?r, ?md1) . sqwrl:makeSet(?sr, ?md1) ^
metadata(?md2) ^ pod(?p) ^ hasMetadata(?p, ?md2) ^ hasValue(?md2, ?val) ^ hasLabel(?md2, ?lbl) ^ sqwrl:makeSet(?sp, ?md1) ^ sqwrl:groupBy(?sp, ?p) .
sqwrl:difference(?s, ?sr, ?sp) ^ sqwrl:isEmpty(?s) -> isManagedBy(?p, ?r)
- First line creates a set of r's matchlabels
- second line if p has labels that have same values as the matchlabels, those matchlabels are put in another set and grouped by p.
- third line checks if difference between the two sets is empty. If yes, it infers that p is Managed by r.
If I change the left part to -> sqwrl:select(?p,?r)
it displays the correct (p,r) couple, but if I change the result to -> isManagedBy(?p,?r)
the reasoner(Pellet) doesn't apply that inference. I'm new to protege and sqwrl so I'm not sure what it is that I'm doing wrong?? Can the reasoner not apply sqwrl rules if they use set operations?
Edit: figured out that I made a confusion between sqwrl and swrl. swrl is for creating inference rules and sqwrl is for querying. So sqwrl can't be used to add inference rules. That said, I haven't figured out how to model the relationship I have here.