calculation the number of the range values

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

calculation the number of the range values

Gennadie
Hello everyone,

if there is some method to calculate the number of the range values using
swrl when the object property doesn't appear in the individuals' perperty
assertions.

For example: "Person(?p) ^ hasChild(?p, ?c) ^ swrlb: count(?n,?c) ^
swrlb:equal(?c,0)-> noChind(?p)"
I define an individual called "John", however, in the object perperty
assertion, "John" doesn't have the "hasChild" object proerty, in this case,
the reasoner cannot infer that "John" "hasChild" zero.

How can I realize this process to make the reasoner to tell that "John"
"hasChild" "zero" when there is no "hasChild" object perperty in the object
property assertion of John?


Thank you




--
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: calculation the number of the range values

Michael DeBellis-2
Unfortunately, I think the answer to your question is simply no, that this can't be done in SWRL. First of all the way you are using the count operator isn't correct. Actually, I'm not sure there is such an operator, when I try typing "swrlb:count" into my swrltab in 5.2. it doesn't seem to recognize that as a builtin and I don't see documentation for it here where the builtins are defined: https://www.w3.org/Submission/SWRL/  

However, even if there is such a builtin the way you are using it wouldn't do what you want. Keep in mind that a SWRL rule will fire for every property value for every instance that it can find. But each time it fires is independent. So there is no way in a rule such as the one you wrote that you can keep track of how many times the rule has fired. Each firing is independent and doesn't know about the other firings. There are ways in SQWRL to collect values into a bag or set and I think there are ways to find the size (number of elements) in the collection. But remember that SQWRL rules can't assert new information into the ontology. That's what the "Q" means, SQWRL rules are just for querying what's there to help you debug your SWRL rules. 

You are running into some basic limitations of OWL and SWRL: the Open World assumption, monotonic reasoning, and not supporting negation as failure. In most programming languages you have a Closed World assumption. So if the value for an object doesn't exist in the Closed World assumption (i.e., you assume everything that can be known is known in the database) you can just assume it really doesn't exist and can do default values or other kinds of reasoning. But since OWL and SWRL are designed for the Internet the assumption is that there always might be more info out there. So you can't assume that the simple fact that say Joe has no children means he REALLY has 0 children. You need something stronger than that you need to directly assert that it's known that Joe has 0 children. Here is a great presentation that describes these issues:


Look for the section that starts with a slide titled "SWRL Semantics" and look at the slides after it that talk about Negation and Monotonic reasoning. 

I've run into this myself several times. I'm curious if others on the list have suggestions for tools to use that would support more traditional kinds of rules that can do things like this. Or does one just have to revert to Java code?

Michael

On Mon, Feb 18, 2019 at 2:38 AM Gennadie <[hidden email]> wrote:
Hello everyone,

if there is some method to calculate the number of the range values using
swrl when the object property doesn't appear in the individuals' perperty
assertions.

For example: "Person(?p) ^ hasChild(?p, ?c) ^ swrlb: count(?n,?c) ^
swrlb:equal(?c,0)-> noChind(?p)"
I define an individual called "John", however, in the object perperty
assertion, "John" doesn't have the "hasChild" object proerty, in this case,
the reasoner cannot infer that "John" "hasChild" zero.

How can I realize this process to make the reasoner to tell that "John"
"hasChild" "zero" when there is no "hasChild" object perperty in the object
property assertion of John?


Thank you




--
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: calculation the number of the range values

Michael DeBellis-2
In reply to this post by Gennadie
One more thing I should have mentioned. One way to satisfy your use case is to use a List pattern, but one that isn't part of SQWRL so that it can be reasoned about. Essentially you define/import an OWL class that defines an ordered list and then you can iterate through that list counting the number of occurrences. An example of such an ontology can be found here: https://lov.linkeddata.es/dataset/lov/vocabs/coll   

Also, if you look at my SWRL tutorial I use the same pattern as you would use for a list to iterate through a group of sub-tasks and to calculate the duration for the supertask based on summing up the duration of the subtasks. I was initially going to use the collections ontology for this but as I looked at the problem I realized I could do it without that model and for an intro tutorial I thought it was better to keep it simple, but the basic technique is the same.  Although I don't think my simple example would work for you because I always assume there will be subtasks so don't bother handling the zero case, it's not meant to be a full blown implementation, just a starting point for a tutorial. The tutorial can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html

Michael

On Mon, Feb 18, 2019 at 2:38 AM Gennadie <[hidden email]> wrote:
Hello everyone,

if there is some method to calculate the number of the range values using
swrl when the object property doesn't appear in the individuals' perperty
assertions.

For example: "Person(?p) ^ hasChild(?p, ?c) ^ swrlb: count(?n,?c) ^
swrlb:equal(?c,0)-> noChind(?p)"
I define an individual called "John", however, in the object perperty
assertion, "John" doesn't have the "hasChild" object proerty, in this case,
the reasoner cannot infer that "John" "hasChild" zero.

How can I realize this process to make the reasoner to tell that "John"
"hasChild" "zero" when there is no "hasChild" object perperty in the object
property assertion of John?


Thank you




--
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: calculation the number of the range values

Igor Toujilov-2

To count children of a person p, in Protégé run a reasoner, in the DL Query write "inverse(hasChild) value p", in "Query for" options tick only Instances, and press Execute. In "Query results" see the number of children.

 

Cheers,

Igor

 

 
 
Sent: Monday, February 18, 2019 at 9:43 PM
From: "Michael DeBellis" <[hidden email]>
To: "User support for WebProtege and Protege Desktop" <[hidden email]>
Subject: Re: [protege-user] calculation the number of the range values
One more thing I should have mentioned. One way to satisfy your use case is to use a List pattern, but one that isn't part of SQWRL so that it can be reasoned about. Essentially you define/import an OWL class that defines an ordered list and then you can iterate through that list counting the number of occurrences. An example of such an ontology can be found here: https://lov.linkeddata.es/dataset/lov/vocabs/coll   
 
Also, if you look at my SWRL tutorial I use the same pattern as you would use for a list to iterate through a group of sub-tasks and to calculate the duration for the supertask based on summing up the duration of the subtasks. I was initially going to use the collections ontology for this but as I looked at the problem I realized I could do it without that model and for an intro tutorial I thought it was better to keep it simple, but the basic technique is the same.  Although I don't think my simple example would work for you because I always assume there will be subtasks so don't bother handling the zero case, it's not meant to be a full blown implementation, just a starting point for a tutorial. The tutorial can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html
 
Michael
 
On Mon, Feb 18, 2019 at 2:38 AM Gennadie <[hidden email]> wrote:
Hello everyone,

if there is some method to calculate the number of the range values using
swrl when the object property doesn't appear in the individuals' perperty
assertions.

For example: "Person(?p) ^ hasChild(?p, ?c) ^ swrlb: count(?n,?c) ^
swrlb:equal(?c,0)-> noChind(?p)"
I define an individual called "John", however, in the object perperty
assertion, "John" doesn't have the "hasChild" object proerty, in this case,
the reasoner cannot infer that "John" "hasChild" zero.

How can I realize this process to make the reasoner to tell that "John"
"hasChild" "zero" when there is no "hasChild" object perperty in the object
property assertion of John?


Thank you




--
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

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

Re: calculation the number of the range values

Michael DeBellis-2
 >run a reasoner, in the DL Query write "inverse(hasChild) value p"  

A few caveats. For one thing unless p is bound to some named individual this query will generate an error. If p is bound to some named individual that has children it will work and will list each child for that named individual but that just gives you the children for a specific named individual, not a general solution for all individuals that have children and if you want to reason about the number of children you obviously can't just read them off of the DL query screen, you need to collect them in a list which is the solution I mentioned previously. 

Michael

On Mon, Feb 18, 2019 at 3:27 PM Igor Toujilov <[hidden email]> wrote:

To count children of a person p, in Protégé run a reasoner, in the DL Query write "inverse(hasChild) value p", in "Query for" options tick only Instances, and press Execute. In "Query results" see the number of children.

 

Cheers,

Igor

 

 
 
Sent: Monday, February 18, 2019 at 9:43 PM
From: "Michael DeBellis" <[hidden email]>
To: "User support for WebProtege and Protege Desktop" <[hidden email]>
Subject: Re: [protege-user] calculation the number of the range values
One more thing I should have mentioned. One way to satisfy your use case is to use a List pattern, but one that isn't part of SQWRL so that it can be reasoned about. Essentially you define/import an OWL class that defines an ordered list and then you can iterate through that list counting the number of occurrences. An example of such an ontology can be found here: https://lov.linkeddata.es/dataset/lov/vocabs/coll   
 
Also, if you look at my SWRL tutorial I use the same pattern as you would use for a list to iterate through a group of sub-tasks and to calculate the duration for the supertask based on summing up the duration of the subtasks. I was initially going to use the collections ontology for this but as I looked at the problem I realized I could do it without that model and for an intro tutorial I thought it was better to keep it simple, but the basic technique is the same.  Although I don't think my simple example would work for you because I always assume there will be subtasks so don't bother handling the zero case, it's not meant to be a full blown implementation, just a starting point for a tutorial. The tutorial can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html
 
Michael
 
On Mon, Feb 18, 2019 at 2:38 AM Gennadie <[hidden email]> wrote:
Hello everyone,

if there is some method to calculate the number of the range values using
swrl when the object property doesn't appear in the individuals' perperty
assertions.

For example: "Person(?p) ^ hasChild(?p, ?c) ^ swrlb: count(?n,?c) ^
swrlb:equal(?c,0)-> noChind(?p)"
I define an individual called "John", however, in the object perperty
assertion, "John" doesn't have the "hasChild" object proerty, in this case,
the reasoner cannot infer that "John" "hasChild" zero.

How can I realize this process to make the reasoner to tell that "John"
"hasChild" "zero" when there is no "hasChild" object perperty in the object
property assertion of John?


Thank you




--
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
_______________________________________________
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: calculation the number of the range values

Igor Toujilov-2

Obviously p is a name of individual. This is a simplest solution for Protégé. For a generic solution, a Java program is needed to iterate over individuals of interest, and invoke the DL query for each.

Yes, I agree, an alternative approach is organising brothers/sisters in a list, and counting the list members. Actually I suggested such approach some years ago for generic aggregation calculations like sum, average, count and so on. The latest developments on this can be found in Aggregation Properties and Partial Closure of the World at https://sourceforge.net/p/meloproject/wiki/open_world_and_closed_world/ .

 

 
 
Sent: Monday, February 18, 2019 at 11:41 PM
From: "Michael DeBellis" <[hidden email]>
To: "User support for WebProtege and Protege Desktop" <[hidden email]>
Subject: Re: [protege-user] calculation the number of the range values
 >run a reasoner, in the DL Query write "inverse(hasChild) value p"  
 
A few caveats. For one thing unless p is bound to some named individual this query will generate an error. If p is bound to some named individual that has children it will work and will list each child for that named individual but that just gives you the children for a specific named individual, not a general solution for all individuals that have children and if you want to reason about the number of children you obviously can't just read them off of the DL query screen, you need to collect them in a list which is the solution I mentioned previously. 
 
Michael
 
On Mon, Feb 18, 2019 at 3:27 PM Igor Toujilov <[hidden email]> wrote:

To count children of a person p, in Protégé run a reasoner, in the DL Query write "inverse(hasChild) value p", in "Query for" options tick only Instances, and press Execute. In "Query results" see the number of children.

 

Cheers,

Igor

 

 
 
Sent: Monday, February 18, 2019 at 9:43 PM
From: "Michael DeBellis" <[hidden email]>
To: "User support for WebProtege and Protege Desktop" <[hidden email]>
Subject: Re: [protege-user] calculation the number of the range values
One more thing I should have mentioned. One way to satisfy your use case is to use a List pattern, but one that isn't part of SQWRL so that it can be reasoned about. Essentially you define/import an OWL class that defines an ordered list and then you can iterate through that list counting the number of occurrences. An example of such an ontology can be found here: https://lov.linkeddata.es/dataset/lov/vocabs/coll   
 
Also, if you look at my SWRL tutorial I use the same pattern as you would use for a list to iterate through a group of sub-tasks and to calculate the duration for the supertask based on summing up the duration of the subtasks. I was initially going to use the collections ontology for this but as I looked at the problem I realized I could do it without that model and for an intro tutorial I thought it was better to keep it simple, but the basic technique is the same.  Although I don't think my simple example would work for you because I always assume there will be subtasks so don't bother handling the zero case, it's not meant to be a full blown implementation, just a starting point for a tutorial. The tutorial can be found here: https://symbolicshacker.blogspot.com/2017/06/swrl-process-modeling-tutorial.html
 
Michael
 
On Mon, Feb 18, 2019 at 2:38 AM Gennadie <[hidden email]> wrote:
Hello everyone,

if there is some method to calculate the number of the range values using
swrl when the object property doesn't appear in the individuals' perperty
assertions.

For example: "Person(?p) ^ hasChild(?p, ?c) ^ swrlb: count(?n,?c) ^
swrlb:equal(?c,0)-> noChind(?p)"
I define an individual called "John", however, in the object perperty
assertion, "John" doesn't have the "hasChild" object proerty, in this case,
the reasoner cannot infer that "John" "hasChild" zero.

How can I realize this process to make the reasoner to tell that "John"
"hasChild" "zero" when there is no "hasChild" object perperty in the object
property assertion of John?


Thank you




--
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
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: calculation the number of the range values

samsontu
In reply to this post by Gennadie
To solve the original problem in the email, i.e., finding persons who have no child, another approach is to use a SPARQL query:

SELECT ?p WHERE {
    {?p a :Person
    } MINUS {
    ?p :hasChild ?s}
}

If we have a SPARQL engine and front end that support INSERT, the original example rule may be written as

INSERT {
 ?p a NoChild .}
WHERE {
    {?p a :Person
    } MINUS {
    ?p :hasChild ?s}
}

SPARQL has a count operator for counting matching tuples.

With best regards,
Samson



On Feb 18, 2019, at 2:37 AM, Gennadie <[hidden email]> wrote:

Hello everyone,

if there is some method to calculate the number of the range values using
swrl when the object property doesn't appear in the individuals' perperty
assertions.

For example: "Person(?p) ^ hasChild(?p, ?c) ^ swrlb: count(?n,?c) ^
swrlb:equal(?c,0)-> noChind(?p)"
I define an individual called "John", however, in the object perperty
assertion, "John" doesn't have the "hasChild" object proerty, in this case,
the reasoner cannot infer that "John" "hasChild" zero.

How can I realize this process to make the reasoner to tell that "John"
"hasChild" "zero" when there is no "hasChild" object perperty in the object
property assertion of John?


Thank you




--
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

smime.p7s (1K) Download Attachment