0

I am trying to write a SWRL rule that takes the facts :

Robot:robot1 hasSkill RobotSkill:location.
Robot:robot1 hasSkill RobotSkill:move.
Robot:robot2 hasSkill RobotSkill:location.
Robot:robot2 hasSkill RobotSkill:greeting.
RobotTask:guide2visitor dependOn RobotSkill:location.
RobotTask:guide2visitor dependOn RobotSkill:move.

and the rule should state that a robot with all the skills required for a task (via "dependOn" relation) can take the task. My attempt in SWRL is like this:

Robot(?robot), RobotSkill(?skill), RobotTask(?task), hasSkill(?robot, ?skill), dependOn(?task, ?skill) -> takeTask(?robot, ?task)

and the inference result I'm expecting should include a new fact:

Robot:robot1 take RobotTask:guide2visitor.

but the real result include two new facts:

Robot:robot1 take RobotTask:guide2visitor.
Robot:robot2 take RobotTask:guide2visitor.

I have a feeling the rule might require set operations (the skill set required for the task must be a subset of the skill set possessed by the robot), but I can't find useful information on this. I also tried Jena rules and the same problem happened.

How should I correct my SWRL rule? Or if you can let me know the corresponding Jena production rule? Thank you very much in advance!

Alex
  • 21
  • 1
  • 7
  • your rule will match any bindings fulfilling the rule which are indeed `robot1` and `robot2` - the other problem is, that you can't express what you want because there is 1) no such operator in SWRL and moreover the Open World Assumption holds. You'd never know if your robot has **all** the skills because the world is "open" and there might be more skills a task depends on but are still not stated in your ontology. – UninformedUser Mar 17 '23 at 08:19
  • what you could use is a SPARQL query with double negation, i.e. "give me every robot `r` with task `t` such that there is no skill `t` depends on which robot `r` doesn't have. `FILTER NOT EXISTS` is what you need in SPARQL here. – UninformedUser Mar 17 '23 at 08:21

0 Answers0