# PATHS with Reasoning

**URL:** <https://community.stardog.com/t/paths-with-reasoning/1507>\
**Category:** Support\
**Created:** [March 8, 2019, 4:15pm UTC](https://community.stardog.com/t/paths-with-reasoning/1507 "2019-03-08T16:15:17Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![NovasTaylor](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/novastaylor/32/344_2.png) [@NovasTaylor](https://community.stardog.com/u/NovasTaylor)\
**Post date:** [March 8, 2019, 4:15pm UTC](https://community.stardog.com/t/paths-with-reasoning/1507/1 "2019-03-08T16:15:18Z")

</div>

Hi everyone,

I am having trouble with a PATHS query that relies on reasoning. I define a parent (superClass) ThingA with a subclass ThingAB. I also define foo:superClassOf as the inverse of rdfs:subClassOf. Why can't I find the PATH via foo:superClassOf when Reasoning is on? What am I doing wrong here?

Here is my mock up data that recreates my issue:

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

foo:ThingA rdf:type owl:Class .

foo:ThingAB rdf:type owl:Class ;
            rdfs:subClassOf foo:ThingA .

# Define superClassOf as the the inverse of subClassOf
foo:superClassOf 
  owl:inverseOf rdfs:subClassOf .

```

With Reasoning ON the query for superClassOf is successful:

```
PREFIX foo: <http://www.example.org/foo/bar/ontology#>

SELECT ?superClass ?subClass
WHERE{
  ?superClass foo:superClassOf ?subClass .
}

```

But this PATHS query returns no results when Reasoning=ON

```
PREFIX foo: <http://www.example.org/foo/bar/ontology#>

PATHS ALL
START ?s
END ?o
    # VIA rdfs:subClassOf # Works, no reasoner needed
VIA foo:superClassOf # No result when Reasoning=ON 

```

Cheers,

Tim

---

<div class="post-metadata">

**Author:** ![pavel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pavel/32/18_2.png) [@pavel](https://community.stardog.com/u/pavel)\
**Post date:** [March 8, 2019, 9:14pm UTC](https://community.stardog.com/t/paths-with-reasoning/1507/2 "2019-03-08T21:14:47Z")

</div>

Hi Tim,

Two things are going on here. First of all, you indeed found a subtle bug in path queries with reasoning which occurs when the start variable is not bound. It will be fixed in the next release.

Second, and more importantly, `foo:superClassOf owl:inverseOf rdfs:subClassOf` is not a valid OWL axiom. This is prohibited in the OWL 2 spec, see [Section 2.4 IRIs](https://www.w3.org/TR/owl2-syntax/#IRIs):

> IRIs with prefixes _rdf:_ , _rdfs:_ , _xsd:_ , and _owl:_ constitute the _reserved vocabulary_ of OWL 2.

and [Section 5.3 Object Properties](https://www.w3.org/TR/owl2-syntax/#Object_Properties):

> IRIs from the reserved vocabulary other than _owl:topObjectProperty_ and _owl:bottomObjectProperty_ _MUST NOT_ be used to identify object properties in an OWL 2 DL ontology.

Simply put, you cannot use `rdfs:subClassOf` as a regular object property in an OWL axiom. It's accidental that you get the expected result from your SELECT query, we'll look into why Stardog did not warn you.

As a short term workaround for path queries, if you really need unbound start variables, you could put something like `start ?s { ?s a owl:Class }` instead.

Thanks,  
Pavel

---

<div class="post-metadata">

**Author:** ![NovasTaylor](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/novastaylor/32/344_2.png) [@NovasTaylor](https://community.stardog.com/u/NovasTaylor)\
**Post date:** [March 9, 2019, 12:56am UTC](https://community.stardog.com/t/paths-with-reasoning/1507/3 "2019-03-09T00:56:47Z")

</div>

My reading of Allemang and Hendler's "Semantic Web for the Working Ontologist" seems to suggest my proposed approach is accepted, as long as one does not define superClassOf within rdfs: (I define it within foo:). What am I missing?

Relevant section is here:

> **[Semantic Web for the Working Ontologist](https://books.google.com/books?id=_qGKPOlB1DgC&amp%3Bpg=PA159&amp%3Blpg=PA159&amp%3Bdq=inverse%2Bof%2BsuperClassOf%2Bdean%2Ballemang&amp%3Bsource=bl&amp%3Bots=-_jeF1xKjS&amp%3Bsig=ACfU3U0Z0smhqGwz1MptMMtsUAFYxGDp9w&amp%3Bhl=en&amp%3Bsa=X&amp%3Bved=2ahUKEwiSp9uy5vPgAhVLmbQKHe66DtcQ6AEwAHoECAkQAQ#v=onepage&amp;q=inverse%20of%20superClassOf%20dean%20allemang&amp;f=false)**
>
> Semantic Web for the Working Ontologist: Effective Modeling in RDFS and OWL, Second Edition, discusses the capabilities of Semantic Web modeling languages, such as RDFS (Resource Description Framework Schema) and OWL (Web Ontology Language)....

---

<div class="post-metadata">

**Author:** ![pavel](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/pavel/32/18_2.png) [@pavel](https://community.stardog.com/u/pavel)\
**Post date:** [March 9, 2019, 10:48am UTC](https://community.stardog.com/t/paths-with-reasoning/1507/4 "2019-03-09T10:48:57Z")

</div>

Tim,

I should have been more precise: the axiom is not valid in OWL DL as the OWL specification states. The book does not contradict the spec but it goes beyond OWL DL fragment into something that's called OWL Full. You can verify this independently of Stardog by using an OWL profile checker in tools like the OWL API or even Protege. I believe mainstream OWL reasoners like Pellet, FaCT++, HermiT, etc. will not accept the axiom.

The distinction between OWL DL and OWL Full used to be a subject of heated debate back in the day but it's not anymore. OWL has that quirk that its semantics can be specified in two different ways: [OWL Direct Semantics](https://www.w3.org/TR/owl2-direct-semantics/) where an OWL ontology is viewed as a knowledge base in a fragment of first-order logic (the so-called Description Logic) and [OWL RDF-based Semantics](https://www.w3.org/TR/owl2-rdf-based-semantics/) where an OWL ontology is viewed as an RDF graph (a bunch of triples according to the [OWL to RDF Mapping](https://www.w3.org/TR/owl2-mapping-to-rdf/)). The former defines inferences using the Description Logic model theory while the latter defines inferences using the RDF model theory. For the most part, you must get the same inferences _but_ only as long as you do not go beyond OWL DL. The main problem with OWL Full is that it's a computationally undecidable language.

This is all theory but what's important in practice is that each system must clearly specify which OWL semantics it implements. Stardog implements the Direct Semantics and says so in [Home | Stardog Documentation Latest](https://www.stardog.com/docs/#_owl_rule_reasoning). Other systems might implement the RDF-based semantics and, again, query results should be the same for the OWL DL fragment. But for anything beyond OWL DL, results for the Direct Semantics are not defined (see the definition of [legal graphs](https://www.w3.org/TR/sparql11-entailment/#OWLDSEntRegime)).

I haven't read the book but I imagine the authors make their readers aware of these nuances somewhere and make it clear that they work with the RDF-based semantics of OWL.

Cheers,  
Pavel

---

<div class="post-metadata">

**Author:** ![zachary.whitley](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/zachary.whitley/32/94_2.png) [@zachary.whitley](https://community.stardog.com/u/zachary.whitley)\
**Post date:** [March 9, 2019, 2:55pm UTC](https://community.stardog.com/t/paths-with-reasoning/1507/5 "2019-03-09T14:55:25Z")

</div>

Here's a handy little tool command line tool that does exactly what @pavel describes using OWL-API [GitHub - stain/profilechecker: OWL API profile checker](https://github.com/stain/profilechecker)

---

<div class="post-metadata">

**Author:** ![NovasTaylor](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/novastaylor/32/344_2.png) [@NovasTaylor](https://community.stardog.com/u/NovasTaylor)\
**Post date:** [March 10, 2019, 8:25pm UTC](https://community.stardog.com/t/paths-with-reasoning/1507/6 "2019-03-10T20:25:09Z")

</div>

Thanks, Pavel, for taking the time to provide this detailed explanation. I was definitely coming at this from the perspective of RDF-based semantics. Much appreciated

---

<div class="post-metadata">

**Author:** ![NovasTaylor](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.stardog.com/novastaylor/32/344_2.png) [@NovasTaylor](https://community.stardog.com/u/NovasTaylor)\
**Post date:** [March 10, 2019, 8:25pm UTC](https://community.stardog.com/t/paths-with-reasoning/1507/7 "2019-03-10T20:25:40Z")

</div>

Thanks, Zachary. I will check out the command line tool.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/stardog/original/2X/e/ed66b48a616f505106a4acde3c9cee7e6da9bc67.svg) [@system](https://community.stardog.com/u/system)\
**Post date:** [March 24, 2019, 8:30pm UTC](https://community.stardog.com/t/paths-with-reasoning/1507/8 "2019-03-24T20:30:18Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
