Search code examples
protegeswrl

else branch of a swrl rule


I want to ask if it is possible to express the else branch of a rule in SWRL? I know it can express p->q but i want to be able to assert r if non(p)

example HeavyPrecipitation(?x) -> hasObservationTag(?x,FalsePositiveOutlier)

and now i want to say else hasObservationTag(?x,TruePositiveOutlier)

How can this be done?

thanks


Solution

  • In a rule like (p->q) there is no way to say (not(p) -> ...); in OWL-DL+SWRL it will never be possible.

    BUT, you can do things that may a be a workaround for your specific usage:

    1. OWL : ComplementOf(ClassExpression) : work like a negation of the ClassExpression

    2. SWRL : DifferentIndividualsAtom(Arg1,Arg2) : useful to exclude a Value or a Range

    They are is the only way to express something that look like negation.

    On your example :

    then-rule   ClassAtom(HeavyPrecipitation,?x) -> propertyAtom(hasObservationTag,?x,FalsePositiveOutlier)
    
    else-rule   ClassAtom(ComplementOf(HeavyPrecipitation),?x) -> propertyAtom(hasObservationTag,?x,TruePositiveOutlier)
    

    Note : the negation is tricky with Open World Assumption and DL; sometime both rules (the 'then' and 'else') can be true at the same time (mainly depend on how your class are defined). Sometime none of your rules will apply : it totaly depend on how you declare classes on your individuals.