Search code examples
sparqlrdfowl

Getting instance involved in OWL Restriction classes through SPARQL 1.1


I'm creating two classes Book and Person, and an object property hasAuthor:

  • Person has subClasses Man and Women.
  • Book has subClasses Hard_bounded_book and Soft_bounded_book.

I'm creating another subClass of Book as Book_With_Atleast_One_Male_Author using an OWL restriction as follows:

:Book_With_Atleast_One_Male_Author rdfs:subClassOf [
  rdf:type owl:Class ;
  owl:intersectionOf (
                      :Book 
                      [ a owl:Restriction ;
                        owl:onProperty bf:hasAuthor ;
                        owl:someValuesFrom :Male ]
                      )
] .

Now I create some instances of Book and Person and relationships:

:Hard_bounded_book1 rdf:type :Hard_bounded_book .
:Hard_bounded_book2 rdf:type :Hard_bounded_book .
:Soft_bounded_book1 rdf:type :Soft_bounded_book .
:Soft_bounded_book2 rdf:type :Soft_bounded_book .
:Male1 rdf:type :Male .
:Male2 rdf:type :Male .
:Female1 rdf:type :Female .
:Female2 rdf:type :Female .
:Hard_bounded_book1 :hasAuthor :Male1
:Hard_bounded_book1 :hasAuthor :Male2
:Hard_bounded_book1 :hasAuthor :Female1
:Hard_bounded_book1 :hasAuthor :Female2
:Soft_bounded_book1 :hasAuthor :Male1
:Soft_bounded_book2 :hasAuthor :Female1

When I write a SPARQL query to get the instances of class Book_With_Atleast_One_Male_Author, I don't get anything. Please let me know if you have any idea of what is happening?

Thanks.


Solution

  • Sure you will not get! You are defining :Book_With_Atleast_One_Male_Author as a subClassOf of that intersection between Book and the restriction.

    The subClassOf semantics:

    Sub subClassOf Super
    

    means that each instance of Sub is an instance of Super.

    That means that instances of :Book_With_Atleast_One_Male_Author must follow this restriction you defined, but that doesn't mean that arbitrary individuals following this restriction are instances of Book_With_Atleast_One_Male_Author.

    What you can do is that you define :Book_With_Atleast_One_Male_Author as an equivalent class of the intersection between Book and an anonymous class for that restriction you created. As a consequence, each individual that is both Book and meets the restriction, will be (with a reasoner running) classified as a :Book_With_Atleast_One_Male_Author.

    Here is how you can do it:

    :Book_With_Atleast_One_Male_Author rdf:type owl:Class ;
                                   owl:equivalentClass [ owl:intersectionOf (  :Book :EquivalentToBookAndHasMaleAuthor ) ;rdf:type owl:Class ] .
    
    :EquivalentToBookAndHasMaleAuthor rdf:type owl:Class ;
                                  owl:equivalentClass [ rdf:type owl:Restriction; owl:onProperty  :hasAuthor ; owl:someValuesFrom :Male] .