negation in swrlb

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

negation in swrlb

Loveleen
This post was updated on .
Hi everyone,
I am a protege newbie and was wondering if there are some specific built-ins
for negation in Protege5.2.0  while writing rules for string datatype
properties.

I am running the following query to retrieve all those ?f that have their
DIT and RFC set to VL:
 JFreeChartFiles(?f)^hasDIT(?f, ?dit) ^ swrlb:equal(?dit, "VL") ^ hasRFC(?f,
?rfc) ^ swrlb:equal(?rfc, "VL") -> sqwrl:select(?f)

However, what if i want to retrieve those ?f that do not have their DIT and
RFC set to VL. I am running the following query which yields correct but
incomplete results.
 JFreeChartFiles(?f) ^hasDIT(?f, ?dit) ^ hasRFC(?f, ?rfc) ^
swrlb:notEqual(?dit, "VL") ^  swrlb:notEqual(?rfc, "VL")  ->
sqwrl:select(?f)
Could you please help me in knowing where am i going wrong.
Thanks in advance,
Loveleen

Edit: I just noticed that the query is omitting those ?f in which either of the values of RFC or DIT are equal to VL. However, i want the query to only omit all those ?f that have both DIT and RFC set to VL.

--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
protege-user@lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: negation in swrlb

Michael DeBellis-2
Loveleen, without seeing your ontology (btw, it's fine to include your ontology in a message as long as it's not too big and you are able to let others see it) my guess is that you are running into the fact that SWRL doesn't support negation as failure. This is related to the Open World Assumption. If you haven't already seen this presentation I suggest giving it a look:  https://protege.stanford.edu/conference/2009/slides/SWRL2009ProtegeConference.pdf  

Specifically in your rule if an instance of JFreeChartFiles has no value(s) set for either property hasDIT or  hasRFC then your rule simply won't fire for those individuals and they won't get included in the sqwrl select statement on the right. One possible work around is to initialize all those properties with some default value such as the empty string. Although if you do that and try to then update the value with a rule you may run into the issue that SWRL doesn't support non-monotonic reasoning (again see that presentation). 

Michael

On Wed, Apr 24, 2019 at 5:44 AM Loveleen <[hidden email]> wrote:
Hi everyone,
I am a protege newbie and was wondering if there are some specific built-ins
for negation in Protege5.2.0  while writing rules for string datatype
properties.

I am running the following query to retrieve all those ?f that have their
DIT and RFC set to VL:
 JFreeChartFiles(?f)^hasDIT(?f, ?dit) ^ swrlb:equal(?dit, "VL") ^ hasRFC(?f,
?rfc) ^ swrlb:equal(?rfc, "VL") -> sqwrl:select(?f)

However, what if i want to retrieve those ?f that do not have their DIT and
RFC set to VL. I am running the following query which yields correct but
incomplete results.
 JFreeChartFiles(?f) ^hasDIT(?f, ?dit) ^ hasRFC(?f, ?rfc) ^
swrlb:notEqual(?dit, "VL") ^  swrlb:notEqual(?rfc, "VL")  ->
sqwrl:select(?f)
Could you please help me in knowing where am i going wrong.
Thanks in advance,
Loveleen



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
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: negation in swrlb

Loveleen
Hello Michael,
First of all, thank you so much for the prompt reply!

Secondly, agreeing to the fact that SWRL does not support non-monotonic
reasoning, is there a way to work around it?
For instance, if we had to re-write the query stated below so as to support
non-monotonic reasoning:
JFreeChartFiles(?f) ^hasDIT(?f, ?dit) ^ hasRFC(?f, ?rfc) ^
swrlb:notEqual(?dit, "VL") ^  swrlb:notEqual(?rfc, "VL")  ->
sqwrl:select(?f)

Could you please help me.
Thanks,
Loveleen



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: negation in swrlb

Michael DeBellis-2
Loveleen, Sorry, I think my last reply may not have been clear. The problem (again I'm guessing based just on the rule since I of course haven't seen the ontology) that I think you are most likely having isn't due to lack of non-monotonic reasoning per se but rather due to not supporting negation as failure. So if you want that rule to report all JFreeChartFiles that don't have both hasDIT and hasRFC  set to "VL". and there are some JFreeChartFiles individuals that have no value at all for either of those properties that rule won't report them. It will only report Individuals that are  JFreeChartFiles  and have both those properties set to some value other than "VL". If EITHER property has no value the rule will simply fail for that individual. 

So a work around for that problem would be that whenever you create a JFreeChartFiles  individual you always set the properties for both hasDIT and hasRFC to some value and if you don't currently know the value or if there is no value you use some string to indicate that, e.g., "Unknown" or just the empty string. Then I think the rule should fire. 

Where the problem with non-monotonic reasoning comes in is if you have another rule that on the right hand side changes the value of one of those properties. e.g., something like 

JFreeChartFiles (?f) ^ hasFoo(?f, "Bar") -> hasRFC(?f, "VL")

You might expect that what this rule would do would be to replace the default value string you gave hasRFC with "VL" but that's not what will happen. Instead what would happen is that you now have two values for hasRFC: the initial default value and now the new value "VL".  Probably not what you want and if hasRFC is a functional property you will then get an inconsistent ontology because it has two values.  

The work around of initializing the property to some default value should (I think) solve your problem and if you are okay with just changing those values manually or with some other program (e.g., a Java program) then I think that would be a work around. My only point was that if you use default values and you try to combine them with rules that change those values you will probably end up in trouble due to SWRL not supporting non-monotonic reasoning.  As far as I know there is no way around this issue working within SWRL. You would need a Java program or another rule system or SPARQL. 

I hope that makes sense. I encourage you to look at Martin's presentation that I linked to in my previous email. Some of these things in SWRL are a bit unintuitive if you are used to other rule systems but I think his presentation is pretty clear on explaining the limitations of SWRL. Hope that made sense, feel free to send the ontology if you still have questions.

Michael

On Wed, Apr 24, 2019 at 9:47 AM Loveleen <[hidden email]> wrote:
Hello Michael,
First of all, thank you so much for the prompt reply!

Secondly, agreeing to the fact that SWRL does not support non-monotonic
reasoning, is there a way to work around it?
For instance, if we had to re-write the query stated below so as to support
non-monotonic reasoning:
JFreeChartFiles(?f) ^hasDIT(?f, ?dit) ^ hasRFC(?f, ?rfc) ^
swrlb:notEqual(?dit, "VL") ^  swrlb:notEqual(?rfc, "VL")  ->
sqwrl:select(?f)

Could you please help me.
Thanks,
Loveleen



--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
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: negation in swrlb

Loveleen
Hi Michael,
I have fixed the issue via some hit and trial and am including the solution
in this response message just to help out anyone who might be plagued with
the same problem:
Given the following query:
JFreeChartFiles(?f) ^hasDIT(?f, ?dit) ^ hasRFC(?f, ?rfc) ^
swrlb:notEqual(?dit, "VL") ^  swrlb:notEqual(?rfc, "VL")  ->
sqwrl:select(?f)
If we had to re-write the query stated above so as to support non-monotonic
reasoning:
Solution:
Break the query as rules into two different parts, each having the same
target class as a consequent and then list out the elements of the class via
a query:
Rule1: JFreeChartFiles(?f) ^hasDIT(?f, ?dit) ^swrlb:notEqual(?dit,
"VL")->class1(?f)
Rule2: JFreeChartFiles(?f) ^ hasRFC(?f, ?rfc) ^ swrlb:notEqual(?rfc, "VL")
->class1(?f)
Query: class1(?f)->sqwrl:select(?f)
Hope this helps anyone in need!
Regards,
Loveleen




--
Sent from: http://protege-project.136.n4.nabble.com/Protege-User-f4659818.html
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user