0

I am using Protege 4.3 to make some SWRL rules. Is it possible to write a rule that contains a disjunction in it For instance :

Person(?x), Age(?x,?age), (?age < 10 or ?age > 30) -> blabla(?x)

Meaning all people having age < 10 OR > 30

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
riad
  • 361
  • 1
  • 9
  • 19
  • Every rule is implicitly a conjunction: _all_ the body atoms have to match in order for the head to be true. You're asking about (X or Y), which is a _disjunction_. I've edited the question appropriately. – Joshua Taylor Mar 20 '14 at 14:30

1 Answers1

2

You can't directly express a disjunction in the rule body the way that you'd like to, unfortunately, but there are some workarounds. The most direct solution is to write two rules:

Person(?x), Age(?x,?age), ?age < 10 -> blah(?x)
Person(?x), Age(?x,?age), ?age > 30 -> blah(?x)

SWRL does support the use of class expressions (see more in Martin Kuba's OWL 2 and SWRL Tutorial), so you could do this:

Person(?x), ((some Age xsd:integer[< 10]) or (some Age xsd:integer[> 30]))(?x) -> blah(?x)

but you won't be able to enter that rule in Protege, even though if you write it in some other ontology editor, or write it by hand, Protege can display it correctly. You could simply that even more and do this:

Person(?x), ((some Age (xsd:integer[< 10] or xsd:integer[> 30]))(?x) -> blah(?x)

or even father and do this:

(Person and (some Age (xsd:integer[< 10] or xsd:integer[> 30])))(?x) -> blah(?x)

Of course, at this point, depending on what blah(?x) is, you might be able to just use a general class axiom that Protege will accept. E.g., if blah is actually a class, Not10To30YearOldPerson, you can use an axiom like:

Person and (age some (xsd:integer[< 10] or xsd:integer[> 30])) subClassOf not TenToThirtyYearOldPerson

axiom instead of rule

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
  • Thanks a lot Joshua for the answer – riad Mar 20 '14 at 14:52
  • 1
    @riad If it solved your problem, you should [accept it](http://meta.stackexchange.com/q/5234/225437). It lets others (who might not see the comment) that it worked for you, and reduces the number of questions without accepted answers on Stack Overflow). It also gives both you and me some reputation points. If it didn't work for you, is there something else that I can add to help? – Joshua Taylor Mar 20 '14 at 14:59
  • I know that, I'll accept the answer as soon I try it – riad Mar 20 '14 at 15:11
  • Sorry Joshua, another silly question, I am not used to work with protégé, but I dont have this tab on the picture "General class axioms" am I missing something? – riad Mar 20 '14 at 15:14
  • For me, it's on the bottom pane of the "Active Ontology" tab, but that might not be standard. You can go to "Window > Views > Class Views > General Class Axioms" to add it to your interface. – Joshua Taylor Mar 20 '14 at 15:33
  • Ok Thanks for everything – riad Mar 20 '14 at 15:37