0

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.

user2083529
  • 715
  • 3
  • 13
  • 25
  • I've added an explanation of what's wrong with the rules, but I can't really tell you what the better thing to do is without knowing what you're actually *trying* to do. What is the rule that you're trying to write *supposed* to accomplish? The domain and intended meaning isn't clear from context, so a simplified example might help. – Joshua Taylor Dec 12 '14 at 12:56
  • @JoshuaTaylor , i edited it, i hope its now more clear – user2083529 Dec 12 '14 at 22:34

1 Answers1

3

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.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thanks for the helpful reply. I understood your explanation. and yeah the user and FamilyContact are related by the object property "isContactOf" ie User(?u),isContactOf(?u,?f),FamilyContact(?f). And also in my ontology there should be only one individual of User, not more. Btw thanks for ur detailed explanation. I'll try out the adding the relation between user and FamilyContact in the SWRL rule. – user2083529 Dec 12 '14 at 18:33
  • @user2083529 Then you'd need to add that connection to the antecedent of the rule. You don't necessarily have to specify all the class conditions, though. E.g., if you already have **frobsBar(?f,?b)**, then you probably don't need to make it **frobsBar(?f,?b), Frobber(?f), Bar(?b)** since the domain and range of the property might already guarantee that. – Joshua Taylor Dec 12 '14 at 18:36
  • yeah i understand that. However, what i am dealing with is different. i have `People` as main class and `user`, `familyContact` as subclasses of `People`. The domain and range of `"isContactOf"` is `People` and `Contact`. `FamilyContact` is actually subclass of `Contact` which intern is subclass of `People`. Anyway i think i have to define everything in the rule. – user2083529 Dec 12 '14 at 18:54