

Hi,
Is it possible to use multiple options (in a disjunctive way) in a sparql query? For example, in the below query, I'm asking for all the (sub)classes that are defined using universal quantification on the property 'p1' on the class 'class1'... this query gives me the desired result...
SELECT ?a ?b
WHERE {
?b rdfs:subClassOf ?a .
?a rdf:type owl:Class .
?b rdfs:subClassOf ?c .
?c rdf:type owl:Restriction .
?c owl:onProperty :p1 .
?c owl:allValuesFrom :class1 .
}
What I also want to try to ask, is the following:
SELECT ?a ?b
WHERE {
?b rdfs:subClassOf ?a .
?a rdf:type owl:Class .
?b rdfs:subClassOf ?c .
?c rdf:type owl:Restriction .
?c owl:onProperty :p1 .
?c owl:allValuesFrom :class1 .
?c owl:allValuesFrom :class2 .
}
I want to query for the (sub)classes that are defined using the same universal quantification on the property 'p1', but on more/different classes, that is 'class1' or/and 'class2'... I'm not able to get the syntax for this kind of query... could anyone help me!
Thanks,
Raj
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


On Nov 25, 2009, at 2:43 PM, Mudunuri, Venkata Rajashekar Varma wrote:
>
> What I also want to try to ask, is the following:
>
> SELECT ?a ?b
> WHERE {
> ?b rdfs:subClassOf ?a .
> ?a rdf:type owl:Class .
> ?b rdfs:subClassOf ?c .
> ?c rdf:type owl:Restriction .
> ?c owl:onProperty :p1 .
> ?c owl:allValuesFrom :class1 .
> ?c owl:allValuesFrom :class2 .
> }
>
> I want to query for the (sub)classes that are defined using the same
> universal quantification on the property 'p1', but on more/different
> classes, that is 'class1' or/and 'class2'... I'm not able to get the
> syntax for this kind of query... could anyone help me!
Well, each owl:Restriction will only have a single owl:allValuesFrom
clause.
So, if there really are multiple allValuesFrom restrictions on the
same property with different classes, then you would have to ask about
multiple restriction items.
But this won't work if, instead, an intersection class is defined
which is the intersection of :class1 and :class2.
This is one of the reasons why you will find it frustrating to try to
write SPARQL queries that are really based on the OWL semantics. That
is because SPARQL operates on the RDF syntax of the representation and
not on the OWL semantics. So you will at some point end up trying to
write your own (incomplete) OWL reasoner in your queries as you try to
build something that does OWLsemantics queries.
I think you would be better off investigating the use of DLQueries or
SQWRL.
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


Hello Thomas,
> I think you would be better off investigating the use of DLQueries or
> SQWRL.
Same as Mudunuri I am having some troubles with SPARQL. I need to check
consistency of domains and ranges; I already know how to do it assuming
one of them is right but when both are wrong I have no idea:
select ?dom
where {
dom? a :MyClassDom .
optional { ?dom :myProp ?range . ?range a :MyClassRange } .
filter (!bound(?range)) #Meaning the range is the wrong
}
I think SQWRL could be useful in this case. I am just starting to take a
look on that and I found the SQWRLQueryTab requires Jess which is not
supported on Protégé 4.0. Is there any way to use SQWRL in Protégé 4.0?
Any ideas about how to check domain and range with SPARQL?
Thanks so much in advanced.
Best
>
> On Nov 25, 2009, at 2:43 PM, Mudunuri, Venkata Rajashekar Varma wrote:
>>
>> What I also want to try to ask, is the following:
>>
>> SELECT ?a ?b
>> WHERE {
>> ?b rdfs:subClassOf ?a .
>> ?a rdf:type owl:Class .
>> ?b rdfs:subClassOf ?c .
>> ?c rdf:type owl:Restriction .
>> ?c owl:onProperty :p1 .
>> ?c owl:allValuesFrom :class1 .
>> ?c owl:allValuesFrom :class2 .
>> }
>>
>> I want to query for the (sub)classes that are defined using the same
>> universal quantification on the property 'p1', but on more/different
>> classes, that is 'class1' or/and 'class2'... I'm not able to get the
>> syntax for this kind of query... could anyone help me!
>
> Well, each owl:Restriction will only have a single owl:allValuesFrom
> clause.
>
> So, if there really are multiple allValuesFrom restrictions on the
> same property with different classes, then you would have to ask about
> multiple restriction items.
>
> But this won't work if, instead, an intersection class is defined
> which is the intersection of :class1 and :class2.
>
> This is one of the reasons why you will find it frustrating to try to
> write SPARQL queries that are really based on the OWL semantics. That
> is because SPARQL operates on the RDF syntax of the representation and
> not on the OWL semantics. So you will at some point end up trying to
> write your own (incomplete) OWL reasoner in your queries as you try to
> build something that does OWLsemantics queries.
>
> I think you would be better off investigating the use of DLQueries or
> SQWRL.
>
> _______________________________________________
> protegeowl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protegeowl>
> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03>
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


Jess is free for academic or US government use. I plan to have a P4 implementation of the SWRLTab in early 2010.
Martin
>  Original Message 
> From: "leyla garcia" < [hidden email]>
> To: "User support for the ProtegeOWL editor" < [hidden email]>
> Sent: Monday, November 30, 2009 1:10:46 AM GMT 08:00 US/Canada Pacific
> Subject: Re: [protegeowl] conjunctions/disjunctions in sparql query!
>
> Hello Thomas,
>
>
>> I think you would be better off investigating the use of DLQueries or
>> SQWRL.
>>
>
> Same as Mudunuri I am having some troubles with SPARQL. I need to check
> consistency of domains and ranges; I already know how to do it assuming
> one of them is right but when both are wrong I have no idea:
>
> select ?dom
> where {
> dom? a :MyClassDom .
> optional { ?dom :myProp ?range . ?range a :MyClassRange } .
> filter (!bound(?range)) #Meaning the range is the wrong
> }
>
> I think SQWRL could be useful in this case. I am just starting to take a
> look on that and I found the SQWRLQueryTab requires Jess which is not
> supported on Protégé 4.0. Is there any way to use SQWRL in Protégé 4.0?
> Any ideas about how to check domain and range with SPARQL?
>
> Thanks so much in advanced.
>
> Best
>
>
>
>> On Nov 25, 2009, at 2:43 PM, Mudunuri, Venkata Rajashekar Varma wrote:
>>
>>> What I also want to try to ask, is the following:
>>>
>>> SELECT ?a ?b
>>> WHERE {
>>> ?b rdfs:subClassOf ?a .
>>> ?a rdf:type owl:Class .
>>> ?b rdfs:subClassOf ?c .
>>> ?c rdf:type owl:Restriction .
>>> ?c owl:onProperty :p1 .
>>> ?c owl:allValuesFrom :class1 .
>>> ?c owl:allValuesFrom :class2 .
>>> }
>>>
>>> I want to query for the (sub)classes that are defined using the same
>>> universal quantification on the property 'p1', but on more/different
>>> classes, that is 'class1' or/and 'class2'... I'm not able to get the
>>> syntax for this kind of query... could anyone help me!
>>>
>> Well, each owl:Restriction will only have a single owl:allValuesFrom
>> clause.
>>
>> So, if there really are multiple allValuesFrom restrictions on the
>> same property with different classes, then you would have to ask about
>> multiple restriction items.
>>
>> But this won't work if, instead, an intersection class is defined
>> which is the intersection of :class1 and :class2.
>>
>> This is one of the reasons why you will find it frustrating to try to
>> write SPARQL queries that are really based on the OWL semantics. That
>> is because SPARQL operates on the RDF syntax of the representation and
>> not on the OWL semantics. So you will at some point end up trying to
>> write your own (incomplete) OWL reasoner in your queries as you try to
>> build something that does OWLsemantics queries.
>>
>> I think you would be better off investigating the use of DLQueries or
>> SQWRL.
>>
>> _______________________________________________
>> protegeowl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protegeowl>>
>> Instructions for unsubscribing:
>> http://protege.stanford.edu/doc/faq.html#01a.03>>
>>
>
>
> _______________________________________________
> protegeowl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protegeowl>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03>
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


On Nov 30, 2009, at 1:10 AM, [hidden email] wrote:
>> I think you would be better off investigating the use of DLQueries
>> or
>> SQWRL.
>
> Same as Mudunuri I am having some troubles with SPARQL. I need to
> check
> consistency of domains and ranges;
Well, if you have the domains and ranges defined as OWL constructs,
then the standard OWL reasoners will check the consistency of the
domain and range for you. You don't need to do anything on your own
to get this.
Now, you will encounter issues with open world, which will also affect
any use of the NOT predicate in SWRL/SQWRL as well. With open world
semantics, it is not enough to be unable to prove, say "Car(x)". You
have to be able to affirmatively prove "not Car(x)". In other words,
it must be possible to show that assuming "Car(x)" leads to a
contradiction in the knowledge base.
Now, you also have to realize that the domain and range assertions in
OWL are inference rules, so that if you were to assert hasCar(water,
house) then the inference rules will conclude Person(water),
Car(house). And as long as those conclusions are consistent, there
will not be any logical inconsistency. To generate an inconsistency,
it has to be stated in your ontology that the types to which the
"water" and "house" individuals belong are disjoint types from Person
and Car.
Now, I suppose that if you wanted to, you could choose not to model
the domain and range of your properties in OWL directly, but manage
this on the side. But then you would have to have some other
representation that stores that information. But it would allow you
to use either a program or a set of queries to find some other
information:
1. p(?x, ?y) > sqwrl:select(?x, ?y)
2. p(?x, ?y) ^ p_domain(?x) ^ p_range(?y) > sqwrl:select(?x, ?y)
Query 1 would get you all of the property pairs. Query 2 would get
you all of the property pairs, where it is known that the range and
domain classes are satisfied. But you would need to do the set
difference of those sets of tuples yourself in procedural code. At
that point, you may find it simpler to just use the programming API
calls to get the sets of individuals in the property and then use
other API calls to test for class membership.
It may also be useful to know why you want to do this checking on your
own, rather than use the existing consistency checking tools like
Pellet, Fact++, Racer, etc.?
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


Thanks Martin,
I will be looking forward for SWRTab for P4.
Best,
LG
> Jess is free for academic or US government use. I plan to have a P4
> implementation of the SWRLTab in early 2010.
>
> Martin
>
>
>>  Original Message 
>> From: "leyla garcia" < [hidden email]>
>> To: "User support for the ProtegeOWL editor"
>> < [hidden email]>
>> Sent: Monday, November 30, 2009 1:10:46 AM GMT 08:00 US/Canada Pacific
>> Subject: Re: [protegeowl] conjunctions/disjunctions in sparql query!
>>
>> Hello Thomas,
>>
>>
>>> I think you would be better off investigating the use of DLQueries or
>>> SQWRL.
>>>
>>
>> Same as Mudunuri I am having some troubles with SPARQL. I need to check
>> consistency of domains and ranges; I already know how to do it assuming
>> one of them is right but when both are wrong I have no idea:
>>
>> select ?dom
>> where {
>> dom? a :MyClassDom .
>> optional { ?dom :myProp ?range . ?range a :MyClassRange } .
>> filter (!bound(?range)) #Meaning the range is the wrong
>> }
>>
>> I think SQWRL could be useful in this case. I am just starting to take a
>> look on that and I found the SQWRLQueryTab requires Jess which is not
>> supported on Protégé 4.0. Is there any way to use SQWRL in Protégé 4.0?
>> Any ideas about how to check domain and range with SPARQL?
>>
>> Thanks so much in advanced.
>>
>> Best
>>
>>
>>
>>> On Nov 25, 2009, at 2:43 PM, Mudunuri, Venkata Rajashekar Varma wrote:
>>>
>>>> What I also want to try to ask, is the following:
>>>>
>>>> SELECT ?a ?b
>>>> WHERE {
>>>> ?b rdfs:subClassOf ?a .
>>>> ?a rdf:type owl:Class .
>>>> ?b rdfs:subClassOf ?c .
>>>> ?c rdf:type owl:Restriction .
>>>> ?c owl:onProperty :p1 .
>>>> ?c owl:allValuesFrom :class1 .
>>>> ?c owl:allValuesFrom :class2 .
>>>> }
>>>>
>>>> I want to query for the (sub)classes that are defined using the same
>>>> universal quantification on the property 'p1', but on more/different
>>>> classes, that is 'class1' or/and 'class2'... I'm not able to get the
>>>> syntax for this kind of query... could anyone help me!
>>>>
>>> Well, each owl:Restriction will only have a single owl:allValuesFrom
>>> clause.
>>>
>>> So, if there really are multiple allValuesFrom restrictions on the
>>> same property with different classes, then you would have to ask about
>>> multiple restriction items.
>>>
>>> But this won't work if, instead, an intersection class is defined
>>> which is the intersection of :class1 and :class2.
>>>
>>> This is one of the reasons why you will find it frustrating to try to
>>> write SPARQL queries that are really based on the OWL semantics. That
>>> is because SPARQL operates on the RDF syntax of the representation and
>>> not on the OWL semantics. So you will at some point end up trying to
>>> write your own (incomplete) OWL reasoner in your queries as you try to
>>> build something that does OWLsemantics queries.
>>>
>>> I think you would be better off investigating the use of DLQueries or
>>> SQWRL.
>>>
>>> _______________________________________________
>>> protegeowl mailing list
>>> [hidden email]
>>> https://mailman.stanford.edu/mailman/listinfo/protegeowl>>>
>>> Instructions for unsubscribing:
>>> http://protege.stanford.edu/doc/faq.html#01a.03>>>
>>>
>>
>>
>> _______________________________________________
>> protegeowl mailing list
>> [hidden email]
>> https://mailman.stanford.edu/mailman/listinfo/protegeowl>>
>> Instructions for unsubscribing:
>> http://protege.stanford.edu/doc/faq.html#01a.03>>
>
> _______________________________________________
> protegeowl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protegeowl>
> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03>
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


Thanks for your answer Thomas.
I realize now about the open world issue you mentioned. And you are
completely right, using a reasoner makes more sense than checking by my
one, we recently got that conclusion as well.
However, I still have some questions about your answer.
>
> 1. p(?x, ?y) > sqwrl:select(?x, ?y)
> 2. p(?x, ?y) ^ p_domain(?x) ^ p_range(?y) > sqwrl:select(?x, ?y)
>
> Query 1 would get you all of the property pairs. Query 2 would get
> you all of the property pairs, where it is known that the range and
> domain classes are satisfied.
If I have Person, Car and hasCar and this query:
3. Person(?x) ^ Car(?y) ^ hasCar(?x, ?y) > sqwrl:select(?x, ?y)
Query 2 and Query 3 would be equivalent, meaning both are getting only
those pairs where domain and range are satisfied, right?
Thanks again.
Best,
LG
>
> On Nov 30, 2009, at 1:10 AM, [hidden email] wrote:
>
>>> I think you would be better off investigating the use of DLQueries
>>> or
>>> SQWRL.
>>
>> Same as Mudunuri I am having some troubles with SPARQL. I need to
>> check
>> consistency of domains and ranges;
>
>
> Well, if you have the domains and ranges defined as OWL constructs,
> then the standard OWL reasoners will check the consistency of the
> domain and range for you. You don't need to do anything on your own
> to get this.
>
> Now, you will encounter issues with open world, which will also affect
> any use of the NOT predicate in SWRL/SQWRL as well. With open world
> semantics, it is not enough to be unable to prove, say "Car(x)". You
> have to be able to affirmatively prove "not Car(x)". In other words,
> it must be possible to show that assuming "Car(x)" leads to a
> contradiction in the knowledge base.
>
> Now, you also have to realize that the domain and range assertions in
> OWL are inference rules, so that if you were to assert hasCar(water,
> house) then the inference rules will conclude Person(water),
> Car(house). And as long as those conclusions are consistent, there
> will not be any logical inconsistency. To generate an inconsistency,
> it has to be stated in your ontology that the types to which the
> "water" and "house" individuals belong are disjoint types from Person
> and Car.
>
> Now, I suppose that if you wanted to, you could choose not to model
> the domain and range of your properties in OWL directly, but manage
> this on the side. But then you would have to have some other
> representation that stores that information. But it would allow you
> to use either a program or a set of queries to find some other
> information:
>
> 1. p(?x, ?y) > sqwrl:select(?x, ?y)
> 2. p(?x, ?y) ^ p_domain(?x) ^ p_range(?y) > sqwrl:select(?x, ?y)
>
> Query 1 would get you all of the property pairs. Query 2 would get
> you all of the property pairs, where it is known that the range and
> domain classes are satisfied. But you would need to do the set
> difference of those sets of tuples yourself in procedural code. At
> that point, you may find it simpler to just use the programming API
> calls to get the sets of individuals in the property and then use
> other API calls to test for class membership.
>
> It may also be useful to know why you want to do this checking on your
> own, rather than use the existing consistency checking tools like
> Pellet, Fact++, Racer, etc.?
>
>
> _______________________________________________
> protegeowl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protegeowl>
> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03>
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


On Dec 1, 2009, at 5:34 AM, [hidden email] wrote:
> Thanks for your answer Thomas.
>
> I realize now about the open world issue you mentioned. And you are
> completely right, using a reasoner makes more sense than checking by
> my
> one, we recently got that conclusion as well.
>
> However, I still have some questions about your answer.
>
>>
>> 1. p(?x, ?y) > sqwrl:select(?x, ?y)
>> 2. p(?x, ?y) ^ p_domain(?x) ^ p_range(?y) > sqwrl:select(?x, ?y)
>>
>> Query 1 would get you all of the property pairs. Query 2 would get
>> you all of the property pairs, where it is known that the range and
>> domain classes are satisfied.
>
> If I have Person, Car and hasCar and this query:
> 3. Person(?x) ^ Car(?y) ^ hasCar(?x, ?y) > sqwrl:select(?x, ?y)
>
> Query 2 and Query 3 would be equivalent, meaning both are getting only
> those pairs where domain and range are satisfied, right?
Sure. I just used more generic names in the example.
But as I noted, if you tell OWL that the domain of hasCar is Person,
and the range of hasCar is Car, then this will always be satisfied
(barring other sources of contradictions), because OWL can use the
inference rule:
p(?x, ?y) ^ domain(p, c) > c(?x)
or in concrete terms:
hasCar(?x, ?y) ^ domain(hasCar, Car) > Car(?x)
so you could only test for explicit assertions of the domain and range
if you DID NOT tell OWL what the domain and range of the property
are. But then you would have to encode that information elsewhere
(like maybe in the rules?).
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03


Thanks so much for this explanation Thomas
>
> On Dec 1, 2009, at 5:34 AM, [hidden email] wrote:
>
>> Thanks for your answer Thomas.
>>
>> I realize now about the open world issue you mentioned. And you are
>> completely right, using a reasoner makes more sense than checking by
>> my
>> one, we recently got that conclusion as well.
>>
>> However, I still have some questions about your answer.
>>
>>>
>>> 1. p(?x, ?y) > sqwrl:select(?x, ?y)
>>> 2. p(?x, ?y) ^ p_domain(?x) ^ p_range(?y) > sqwrl:select(?x, ?y)
>>>
>>> Query 1 would get you all of the property pairs. Query 2 would get
>>> you all of the property pairs, where it is known that the range and
>>> domain classes are satisfied.
>>
>> If I have Person, Car and hasCar and this query:
>> 3. Person(?x) ^ Car(?y) ^ hasCar(?x, ?y) > sqwrl:select(?x, ?y)
>>
>> Query 2 and Query 3 would be equivalent, meaning both are getting only
>> those pairs where domain and range are satisfied, right?
>
> Sure. I just used more generic names in the example.
>
> But as I noted, if you tell OWL that the domain of hasCar is Person,
> and the range of hasCar is Car, then this will always be satisfied
> (barring other sources of contradictions), because OWL can use the
> inference rule:
>
> p(?x, ?y) ^ domain(p, c) > c(?x)
>
> or in concrete terms:
>
> hasCar(?x, ?y) ^ domain(hasCar, Car) > Car(?x)
>
> so you could only test for explicit assertions of the domain and range
> if you DID NOT tell OWL what the domain and range of the property
> are. But then you would have to encode that information elsewhere
> (like maybe in the rules?).
>
> _______________________________________________
> protegeowl mailing list
> [hidden email]
> https://mailman.stanford.edu/mailman/listinfo/protegeowl>
> Instructions for unsubscribing:
> http://protege.stanford.edu/doc/faq.html#01a.03>
_______________________________________________
protegeowl mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protegeowlInstructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03

