SWRL-rule with negation

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

SWRL-rule with negation

Лещева Ирина Анатольевна

Hi,

 

Here I have found that it should be possible to write a SWRL-rule like this:

 

Person(?p) ^ (hasCar = 0)(?p) -> CarlessPerson(?p)

 

But when I have tried to input this example in SWRLtab in Protégé 5 I got an error: Unexpected character '='

I tried to input it in another way:

Person(?p) ^ (hasCar max 0 Car)(?p) -> CarlessPerson(?p)

 

but it also doesn't work.

How to input such rules in SWRLtab?

 

Thank you in advance,

Irina

 

 


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: SWRL-rule with negation

Michael DeBellis-2
There are a few issues. First,  I think the DL example in that documentation may be wrong. I don't think 

Person(?p) ^ (hasCar = 0)(?p) -> CarlessPerson(?p)  

is properly formatted and I suggest someone revise the documentation. as you pointed out you need something after hasCar such as "max" or "min" or "exactly" if you are going to then compare it to a number. The only way that rule makes sense to me is if hasCar is a data property with an integer value. 

However, I think the most important issue is that you may be misunderstanding what the SWRL documentation meant. Forget about SWRL for a minute because you could just use that same DL to create a defined class: 

CarLessPerson Equivalent To Person and hasCar max 0

If you then expect that any instance of Person that has no values for hasCar will be classified as a CarLessPerson that is not what will happen because of the Open World Assumption (OWA). That's an essential difference between OWL and other languages. Unless there is some axiom that explicitly states that some Person has 0 cars then the reasoner won't assume it's true just because at this point the ontology doesn't include the info on what Car(s) the Person has. The default assumption is that there may always be some additional info out there that isn't in the ontology. Since the goal is to provide a semantic layer for the Internet that was the design decision.

I suggest you look at the slides on OWA and negation as failure here: https://protege.stanford.edu/conference/2009/slides/SWRL2009ProtegeConference.pdf

The other issue is that the SWRL Tab as currently implemented doesn't support embedding DL syntax into rules. That is part of the standard it's just the SWRL tab doesn't support that part of the standard yet. That's common in tools, there is often a gap between what a standard created by a committee of lots of people defines and how much of it any particular tool implements. Also, personally I can understand why this hasn't yet been included in the SWRL tab because I've been using SWRL for a while and I've never come up against a situation where I needed DL in a rule that I couldn't put on a defined class just as easily and get the same result. 

If you want to use DL in rules there is another UI you can use called the Rules pane. You have to explicitly add it to some Tab because it's not part of the UI by default. In that pane you use "," instead of "^" so your rule would look like: 

Person(?p), (hasCar max 0)(?p) ->CarlessPerson(?p)

My recommendation is that unless you find some DL that you can't make into a defined class for some reason just stick to using DL for defined classes and use SWRL rules in the SWRL tab for situations where DL won't work. If you look at my short SWRL tutorial I show an example of using the Rules pane: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html

I included the example just for completeness. Also, while I'm at it, a common source of confusion in the SWRL tab are those Drools buttons. Here is a brief tutorial for all new SWRL users on what you need to know about Drools: 

Ignore it. End of Tutorial. 

Drools is very useful for some people. But for new SWRL users you won't need to use it or even know what it does and it is better to use the Pellet reasoner and then just run the reasoner and it will fire your rules for you as well as all the other things it does. 

Michael

On Fri, Jul 19, 2019 at 12:13 PM Лещева Ирина Анатольевна <[hidden email]> wrote:

Hi,

 

Here I have found that it should be possible to write a SWRL-rule like this:

 

Person(?p) ^ (hasCar = 0)(?p) -> CarlessPerson(?p)

 

But when I have tried to input this example in SWRLtab in Protégé 5 I got an error: Unexpected character '='

I tried to input it in another way:

Person(?p) ^ (hasCar max 0 Car)(?p) -> CarlessPerson(?p)

 

but it also doesn't work.

How to input such rules in SWRLtab?

 

Thank you in advance,

Irina

 

 

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: SWRL-rule with negation

Igor Toujilov-2
In reply to this post by Лещева Ирина Анатольевна

Hi Irina,

Do it in the Rules tab, not in SWRLtab.

 

Cheers,

Igor

 

 
Sent: Friday, July 19, 2019 at 8:13 PM
From: "Лещева Ирина Анатольевна" <[hidden email]>
To: "'[hidden email]'" <[hidden email]>
Subject: [protege-user] SWRL-rule with negation

Hi,

 

Here I have found that it should be possible to write a SWRL-rule like this:

 

Person(?p) ^ (hasCar = 0)(?p) -> CarlessPerson(?p)

 

But when I have tried to input this example in SWRLtab in Protégé 5 I got an error: Unexpected character '='

I tried to input it in another way:

Person(?p) ^ (hasCar max 0 Car)(?p) -> CarlessPerson(?p)

 

but it also doesn't work.

How to input such rules in SWRLtab?

 

Thank you in advance,

Irina

 

 

_______________________________________________ protege-user mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: SWRL-rule with negation

Igor Toujilov-2

Thought I agree with previous Michael’s comments.

 
Sent: Saturday, July 20, 2019 at 9:32 PM
From: "Igor Toujilov" <[hidden email]>
To: [hidden email]
Subject: Re: [protege-user] SWRL-rule with negation

Hi Irina,

Do it in the Rules tab, not in SWRLtab.

 

Cheers,

Igor

 

 
Sent: Friday, July 19, 2019 at 8:13 PM
From: "Лещева Ирина Анатольевна" <[hidden email]>
To: "'[hidden email]'" <[hidden email]>
Subject: [protege-user] SWRL-rule with negation

Hi,

 

Here I have found that it should be possible to write a SWRL-rule like this:

 

Person(?p) ^ (hasCar = 0)(?p) -> CarlessPerson(?p)

 

But when I have tried to input this example in SWRLtab in Protégé 5 I got an error: Unexpected character '='

I tried to input it in another way:

Person(?p) ^ (hasCar max 0 Car)(?p) -> CarlessPerson(?p)

 

but it also doesn't work.

How to input such rules in SWRLtab?

 

Thank you in advance,

Irina

 

 

_______________________________________________ protege-user mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-user
_______________________________________________ protege-user mailing list [hidden email] https://mailman.stanford.edu/mailman/listinfo/protege-user

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user