简体   繁体   中英

SWRL syntax in Protege

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 ie

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM