You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@jena.apache.org by "rybesh (via GitHub)" <gi...@apache.org> on 2026/10/07 23:53:16 UTC
[I] riot --rdfs: rdfs:subPropertyOf ignored unless the vocabulary has an rdfs:subClassOf, and never combined with rdfs:domain/rdfs:range [jena]
rybesh opened a new issue, #4312:
URL: https://github.com/apache/jena/issues/4312
### Version
6.2.0 (also 5.5.0)
### What happened?
Streaming RDFS inference (`riot --rdfs=VOCAB`, i.e. `InfStreamRDFS` / `ApplyRDFS`) handles `rdfs:subPropertyOf` incorrectly in two ways.
**1. `rdfs:subPropertyOf` is skipped when the vocabulary has no `rdfs:subClassOf` triple.**
`vocab1.ttl`:
```turtle
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://example/>
:p rdfs:subPropertyOf :q .
:q rdfs:domain :D .
```
`vocab2.ttl` is the same plus one unrelated subclass triple:
```turtle
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX : <http://example/>
:p rdfs:subPropertyOf :q .
:q rdfs:domain :D .
:A rdfs:subClassOf :B .
```
`data.ttl`:
```turtle
PREFIX : <http://example/>
:x :p :y .
```
With `vocab1.ttl`, nothing is inferred. With `vocab2.ttl`, `:x :q :y` is inferred (rdfs7). Adding an unrelated `rdfs:subClassOf` should not change whether rdfs7 applies.
This looks like a copy-paste slip in `ApplyRDFS.subProperty()`. Its short-circuit tests `hasClassDeclarations()`, the same test `subClass()` uses, where it should test `hasPropertyDeclarations()`:
https://github.com/apache/jena/blob/d77438478938cc651760f4a61e5d9ee7acff072b/jena-arq/src/main/java/org/apache/jena/rdfs/engine/ApplyRDFS.java#L102-L103
**2. A superproperty's domain and range are never applied.**
Even with `vocab2.ttl`, `:x rdf:type :D` is not inferred. By rdfs7, `:x :q :y` holds, and by rdfs2, `:q rdfs:domain :D` then gives `:x rdf:type :D`. The same is true for `rdfs:range` (rdfs3).
`ApplyRDFS.domain()` and `range()` look up only the asserted predicate (`setup.getDomain(p)`), so the triples that `subProperty()` derives never go through domain and range:
https://github.com/apache/jena/blob/d77438478938cc651760f4a61e5d9ee7acff072b/jena-arq/src/main/java/org/apache/jena/rdfs/engine/ApplyRDFS.java#L63-L74
The backward-chaining graph has the same gap. With `RDFSFactory.graphRDFS(data, vocab1)`, `find(ANY, ANY, ANY)` returns `:x :q :y` but not `:x rdf:type :D`, and neither do `find(:x, rdf:type, :D)` or `find(ANY, rdf:type, :D)`. `MatchRDFS` uses `getDomain`/`getRange` and `getPropertiesByDomain`/`getPropertiesByRange` without considering sub-/super-properties.
Expected for `riot --rdfs=vocab1.ttl data.ttl` (and for `vocab2.ttl`):
```
<http://example/x> <http://example/p> <http://example/y> .
<http://example/x> <http://example/q> <http://example/y> .
<http://example/x> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example/D> .
```
For comparison, the textbook example in Allemang, Hendler & Gandon, *Semantic Web for the Working Ontologist* (2nd ed., ch. 8), uses only `rdfs:subPropertyOf` (`:freeLancesTo rdfs:subPropertyOf :contractsTo`, `:contractsTo rdfs:subPropertyOf :worksFor`, …). With `riot --rdfs` it infers nothing at all.
Related: #3507 (other RDFS engine issues) and #1720.
### Relevant output and stacktrace
```shell
$ riot --version
Apache Jena RIOT version 6.2.0
$ riot --rdfs=vocab1.ttl data.ttl
<http://example/x> <http://example/p> <http://example/y> .
$ riot --rdfs=vocab2.ttl data.ttl
<http://example/x> <http://example/p> <http://example/y> .
<http://example/x> <http://example/q> <http://example/y> .
```
### Are you interested in making a pull request?
Yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@jena.apache.org
For additional commands, e-mail: issues-help@jena.apache.org