Getting superclasses implied by OWL intersection classes

An OWL ontology can have classes A, B, and C and an axiom (in the DL entry):

A & sqsubseteq; (B & sqcap; C)

or in the approximate syntax of Manchester OWL:

A subClassOf (B and C)

It is logically true that A is a subclass of B and that A is a subclass of C, but triples

A rdfs:subClassOf B
A rdfs:subClassOf C

not necessarily present in the RDF serialization of the OWL ontology. For example, consider this very simple ontology in Protégé and its serialization of RDF to RDF / XML and Turtle:

enter image description here

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns="http://stackoverflow.com/q/19924861/1281433/sample.owl#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
  <owl:Ontology rdf:about="http://stackoverflow.com/q/19924861/1281433/sample.owl"/>
  <owl:Class rdf:about="http://stackoverflow.com/q/19924861/1281433/sample.owl#C"/>
  <owl:Class rdf:about="http://stackoverflow.com/q/19924861/1281433/sample.owl#B"/>
  <owl:Class rdf:about="http://stackoverflow.com/q/19924861/1281433/sample.owl#A">
    <rdfs:subClassOf>
      <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
          <owl:Class rdf:about="http://stackoverflow.com/q/19924861/1281433/sample.owl#B"/>
          <owl:Class rdf:about="http://stackoverflow.com/q/19924861/1281433/sample.owl#C"/>
        </owl:intersectionOf>
      </owl:Class>
    </rdfs:subClassOf>
  </owl:Class>
</rdf:RDF>
@prefix :      <http://stackoverflow.com/q/19924861/1281433/sample.owl#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

<http://stackoverflow.com/q/19924861/1281433/sample.owl>
        a       owl:Ontology .

:B      a       owl:Class .

:C      a       owl:Class .

:A      a                owl:Class ;
        rdfs:subClassOf  [ a                   owl:Class ;
                           owl:intersectionOf  ( :B :C )
                         ] .

Serialization has a triple c rdfs:subClassOf, but the object is not :Bor :C, so the query is of type

:A rdfs:subClassOf ?superclass

will not return superclasses :A. How to write a SPARQL query that returns these superclasses :A?

+2
1

, , . ,

& sqsubseteq; & sqcap; In

ProtEg OWL :

Definition of student in Protege

SPARQL , ,

prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

select ?subclass ?superclass where { 
  ?subclass rdfs:subClassOf ?superclass
}

, , , () node:

---------------------------------------------------------
| subclass                                 | superclass |
=========================================================
| <http://www.examples.org/school#Student> | _:b0       |
---------------------------------------------------------

, , RDF . ( RDF/XML):

<rdf:RDF
    xmlns="http://www.examples.org/school#"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
  <owl:Ontology rdf:about="http://www.examples.org/school"/>
  <owl:Class rdf:about="http://www.examples.org/school#Course"/>
  <owl:Class rdf:about="http://www.examples.org/school#Person"/>
  <owl:Class rdf:about="http://www.examples.org/school#Student">
    <rdfs:subClassOf>
      <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
          <owl:Class rdf:about="http://www.examples.org/school#Person"/>
          <owl:Restriction>
            <owl:onProperty>
              <owl:ObjectProperty rdf:about="http://www.examples.org/school#enrolledIn"/>
            </owl:onProperty>
            <owl:someValuesFrom rdf:resource="http://www.examples.org/school#Course"/>
          </owl:Restriction>
        </owl:intersectionOf>
      </owl:Class>
    </rdfs:subClassOf>
  </owl:Class>
</rdf:RDF>

( SPARQL):

@prefix :      <http://www.examples.org/school#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

:Student  a              owl:Class ;
        rdfs:subClassOf  [ a                   owl:Class ;
                           owl:intersectionOf  ( :Person [ a                   owl:Restriction ;
                                                           owl:onProperty      :enrolledIn ;
                                                           owl:someValuesFrom  :Course
                                                         ] )
                         ] .

:Person  a      owl:Class .

:enrolledIn  a  owl:ObjectProperty .

:Course  a      owl:Class .

<http://www.examples.org/school>
        a       owl:Ontology .

, , Student rdfs:subClassOf [ ... ] , [ ... ] node; owl:Class, . , X & sqsubseteq; (Y Z), X & sqsubseteq; Y X & sqsubseteq; Z, SPARQL . SPARQL, :

prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
prefix owl:   <http://www.w3.org/2002/07/owl#>
prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

select ?subclass ?superclass where {
  { ?subclass rdfs:subClassOf ?superclass }
  union
  { ?subclass rdfs:subClassOf [ owl:intersectionOf [ rdf:rest* [ rdf:first ?superclass ] ] ] }
}
--------------------------------------------------------------------------------------
| subclass                                 | superclass                              |
======================================================================================
| <http://www.examples.org/school#Student> | _:b0                                    |
| <http://www.examples.org/school#Student> | <http://www.examples.org/school#Person> |
| <http://www.examples.org/school#Student> | _:b1                                    |
--------------------------------------------------------------------------------------

- ( ). IRI, filter:

prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
prefix owl:   <http://www.w3.org/2002/07/owl#>
prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

select ?subclass ?superclass where {
  { ?subclass rdfs:subClassOf ?superclass }
  union
  { ?subclass rdfs:subClassOf [ owl:intersectionOf [ rdf:rest* [ rdf:first ?superclass ] ] ] }

  filter( isIRI( ?superclass ) )
}
--------------------------------------------------------------------------------------
| subclass                                 | superclass                              |
======================================================================================
| <http://www.examples.org/school#Student> | <http://www.examples.org/school#Person> |
--------------------------------------------------------------------------------------

, , , union ed - , ?subclass ?superclass, . (, Sparql EquivalentTo, Protégé, .) , :

{ ?subclass rdfs:subClassOf ?superclass }
union
{ ?subclass rdfs:subClassOf [ owl:intersectionOf [ rdf:rest* [ rdf:first ?superclass ] ] ] }

, , :

?subclass ( rdfs:subClassOf |
            ( rdfs:subClassOf / owl:intersectionOf / rdf:rest* / rdf:first ) ) ?superclass

?subclass rdfs:subClassOf/((owl:intersectionOf/rdf:rest*/rdf:first)+) ?superclass

,

?subclass rdfs:subClassOf/(owl:intersectionOf/rdf:rest*/rdf:first)+ ?superclass

, . , :

prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
prefix owl:   <http://www.w3.org/2002/07/owl#>
prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

select ?subclass ?superclass where {
  ?subclass rdfs:subClassOf/(owl:intersectionOf/rdf:rest*/rdf:first)+ ?superclass
  filter( isIRI( ?superclass ) )
}
--------------------------------------------------------------------------------------
| subclass                                 | superclass                              |
======================================================================================
| <http://www.examples.org/school#Student> | <http://www.examples.org/school#Person> |
--------------------------------------------------------------------------------------
+5

Source: https://habr.com/ru/post/1525645/


All Articles