SWRL syntax in Protege

1.7k views Asked by At

I am using Protege5.0, and i want to implement SWRL rule ie

User(?u), isInActivity(?u, ?cm), ContextMeeting(?cm) -> FamilyContact(?f), hasStatus(?f, "Reject")

which means "if user is in meeting then familycontact has status "reject".

This syntax should work and protege doesn't show any error. However, its not working. And when i write

User(?u), isInActivity(?u, ?cm), ContextMeeting(?cm), FamilyContact(?f) -> hasStatus(?f, "Reject")

This syntax works perfectly but its useless when i write complex rules in such format. Can anyone explain me the difference between the two formats and also give me a perfect solution?

More explanation:

i have a main class People & subclasses of People are Contact & User. The subclasses of Contact are FamilyContact, EmployeeContact etc. **The User and Contact are related by an object property isContactOf(People,Contact).In my ontology there should be only one individual of class User. Now, i want to implement SWRL rules, ie If **user is in meeting then FamilyContact hasStatus "Reject".** This reject simply means that Family members can not call the user. Other rule is If user is in meeting then EmployeeContact hasStatus "Pass". hasStatus(Contact,String) is a functional property.

the second rule syntax works perfectly, however when I want to implement a rule for those instances which are both EmployeeContact and FamilyContact then i get problem. eg if i write a rule i.e

User(?u), isInActivity(?u, ?cm), ContextMeeting(?cm), FamilyContact(?f), EmployeeContact(?e), DifferentFrom(?f,?e)-> hasStatus(?f, "Reject").

It works somehow but i get a problem. It makes the other instances of EmployeeContact also the Instances of FamilyContact and vice versa.

1

There are 1 answers

3
Joshua Taylor On

The rule

User(?u) ∧ isInActivity(?u, ?cm) ∧ ContextMeeting(?cm) → FamilyContact(?f) ∧ hasStatus(?f, "Reject")

uses ?f in the right hand side (the consequent) of the rule, but not on the left (the antecedent). That's not allowed in the language (emphasis added):

2.1. Rules

Atoms may refer to individuals, data literals, individual variables or data variables. Variables are treated as universally quantified, with their scope limited to a given rule. As usual, only variables that occur in the antecedent of a rule may occur in the consequent (a condition usually referred to as "safety"). This safety condition does not, in fact, restrict the expressive power of the language (because existentials can already be captured using OWL someValuesFrom restrictions).

If it were legal, then your rule would mean:

For every u, cm, and f,

  • if u is a User and cm is a ContextMeeting and u is in cm,
  • then f is a family contact and has status "reject".

But since there are no constraints on ?f, this says that any user is in any context meeting, then everything is a family contact with status "reject", and that's probably not what you want. Shouldn't ?f be related to ?u somehow? The proposed alternative:

User(?u) ∧ isInActivity(?u, ?cm) ∧ ContextMeeting(?cm) ∧ FamilyContact(?f) → hasStatus(?f, "Reject")

has a similar problem. It would mean:

For every u, cm, and f,

  • if u is a User and cm is a ContextMeeting and u is in cm and f is a family contact,
  • then f has status "reject".

There's still no connection between u and f, so this says that if any user is in any context meeting, then every family contact has status "reject". That doesn't seem like what you'd want either.