1

My question is about superclass inheritance. My understanding says that if I have instances that belong to Class B, then Class A which is the mother class of Class B will also have these instances. For instance: suppose I have a superclass called Car, and two subclass classes Sedan and SUV. The instances of classes Sedan and SUV are also instances of the class Car, is that correct? If it is the case, then I cannot see any return of my sparql query when I say give me all instances of class Car. Am I missing anything here?

I am using Topbraid editor.

user1894963
  • 635
  • 3
  • 11
  • 18
  • Speaking in terms of polymorphism, yes, Sedan and SUV are types of Car but not instances of type Car. –  Feb 03 '15 at 14:13

2 Answers2

3

Actually this is the definition of superclass/subclass --- that all instances of a subclass are instances of a superclass.

Don't know why the sparql query is not working. It's only going to work if the engine is inferencing, though, I think.

Phil Lord
  • 2,917
  • 1
  • 20
  • 31
  • Thanks. I thought the same also. TopBraid offers many ways (engines) to do inferencing. I could not figure out which one to use. Mainly there are: TopSpin, Jena Rules, Jena Built-in Reasoner, and SwiftOWLIM. – user1894963 Feb 03 '15 at 18:05
  • Well, all you need is rdfs inferencing. Fraid I am not an expert with TopBraid specifically. – Phil Lord Feb 03 '15 at 19:14
0

If you want the subclass entailments for your SPARQL query without the burden of running an inference engine, you can use standard SPARQL property paths, specifically the transitive operator:

SELECT *
WHERE {
   ?cls rdfs:subClassOf* :ClassA .
   ?inst a ?cls .
}

The first triple pattern gets all subclasses of :ClassA down to the root. The second triple pattern gets the instances of all of those classes, effectively getting you the same subsumption operation that a reasoner performs.

scotthenninger
  • 3,921
  • 1
  • 15
  • 24