Skip to content

GH-4312: RDFS: subPropertyOf without subClassOf; super-property domain and range - #4313

Open
rybesh wants to merge 1 commit into
apache:mainfrom
rybesh:rdfs-subproperty
Open

rybesh wants to merge 1 commit into
apache:mainfrom
rybesh:rdfs-subproperty

Conversation

@rybesh

@rybesh rybesh commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

GitHub issue resolved #4312

Pull request Description:

Two fixes to RDFS inference with rdfs:subPropertyOf, in both the stream (ApplyRDFS, used by riot --rdfs) and the graph (MatchRDFS, used by RDFSFactory.graphRDFS):

  • ApplyRDFS.subProperty() short-circuited on hasClassDeclarations(); it now tests hasPropertyDeclarations(). Before, a vocabulary with rdfs:subPropertyOf but no rdfs:subClassOf inferred nothing from it.
  • The domain and range of a super-property now apply to triples using a sub-property: (:x :p :y), (:p rdfs:subPropertyOf :q), (:q rdfs:domain :D) gives (:x rdf:type :D). CxtInf has four lookups that include super-properties (getDomainInc, getRangeInc) or sub-properties (getPropertiesByDomainInc, getPropertiesByRangeInc). ApplyRDFS.domain()/range() and MatchRDFS's accTypesDomain/accTypesRange/accInstancesDomain/accInstancesRange use them.

I first tried propagating domains and ranges to sub-properties in BaseSetupRDFS, but that makes the inference graph report entailed vocabulary triples (:pp rdfs:domain :Q), which TestMatchVocab and AbstractTestRDFS rightly reject. So the vocabulary maps are unchanged, and only the lookups are.

Tests: 9 new, in TestStreamRDFS (including :pp from the existing rdfs-vocab.ttl, which the shared data never used) and TestMiscRDFS (graph finds by several patterns). All 9 fail on main and pass with the change. The full jena-arq test suite passes (16742 run, 0 failures, 1 skipped).

The patch was written with the help of an AI coding assistant (Claude Code), and is disclosed in the commit with a Generated-by: trailer.


  • Tests are included.
  • Documentation change and updates are provided for the Apache Jena website (none needed: no change to documented behaviour)
  • Commits have been squashed to remove intermediate development commit messages.
  • Key commit messages start with the issue number (GH-xxxx)

By submitting this pull request, I acknowledge that I am making a contribution to the Apache Software Foundation under the terms and conditions of the Contributor's Agreement.


See the Apache Jena "Contributing" guide.

… domain and range

ApplyRDFS.subProperty() short-circuited on hasClassDeclarations(), so a
vocabulary with rdfs:subPropertyOf but no rdfs:subClassOf inferred
nothing from it. It now tests hasPropertyDeclarations().

The domain and range of a super-property were never applied to triples
using a sub-property: (:x :p :y), (:p rdfs:subPropertyOf :q),
(:q rdfs:domain :D) did not give (:x rdf:type :D), in either the stream
(ApplyRDFS) or the graph (MatchRDFS). CxtInf now has lookups that
include super-properties (domain, range) and sub-properties (properties
by domain, by range), used by both.

Generated-by: Claude Opus 5.5 (Claude Code)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

riot --rdfs: rdfs:subPropertyOf ignored unless the vocabulary has an rdfs:subClassOf, and never combined with rdfs:domain/rdfs:range

1 participant