- From: Alex Nelson via GitHub <noreply@w3.org>
- Date: Mon, 18 Aug 2025 16:01:49 +0000
- To: public-shacl@w3.org
ajnelson-nist has just created a new issue for https://github.com/w3c/data-shapes: == Inferencing use case: Refining Intervals to ProperIntervals based on trinary relationship == This is a use case motivating retaining SHACL-SPARQL `CONSTRUCT`-based rules as the inferencing work proceeds. It goes a bit into OWL theory, but I try to only go as far as I see some similar expressiveness constraints from SHACL AF's `TripleRule`s. ## Relevance for related issues * PR #452 introduces SHACL Rules post-SHACL-AF and Variables, which I think are necessary to satisfy this use case without SPARQL. SHACL AF's discussion around variables, aside from `$this`, only went as far as exposing annotation links, per [Section 4](https://www.w3.org/TR/2017/NOTE-shacl-af-20170608/#sparql-constraints-annotations). * The long writeup is to give a case of Rules performing an inference that I believe is unavailable to OWL. There is also some implication of recurrence in pre-validation steps: Rule execution as described in this Issue would have an influence on RDFS and/or OWL inferencing, due to rule-inferred `owl:Class` assignments. I could have sworn this ordering matter was filed as an Issue already, but I'm having trouble finding it. Link welcome if this jogs anyone's memory. ## Caveat This example is based on an interpretation of a property `time:after` as it pertains to two `time:Instant`s: That `x time:after y` means there is a >0-duration interval of time between `x` and `y`. This is not explicit in the current OWL-Time specification, but it appears to be implied; discussion is [here](https://github.com/w3c/sdw/issues/1430). ## Background: OWL-Time excerpt OWL-Time has a few top-level classes that relate to each other in this way: * `TemporalEntity` is the parent class of `Instant` and `Interval` * `Interval` is the parent class of `ProperInterval`: intervals can be 0-duration, but `ProperInterval`s are non-0 duration * `Instant`s are disjoint with `Interval`s If helpful, here is a diagram showing these classes: ```mermaid flowchart subgraph legend direction BT subclass -->|⊏| superclass end subgraph Classes direction BT owl_Thing[owl:Thing] time_TemporalEntity[time:TemporalEntity] time_Instant[time:Instant] time_Interval[time:Interval] time_ProperInterval[time:ProperInterval] end time_Instant ---|⊓=∅| time_ProperInterval linkStyle 1 stroke:red,stroke-width:4px,color:red; time_TemporalEntity -->|⊏| owl_Thing time_Instant -->|⊏| time_TemporalEntity time_Interval -->|⊏| time_TemporalEntity time_ProperInterval -->|⊏| time_Interval ``` There is a property, `time:inside`, which denotes that an instant is inside an interval. `time:inside` has as part of its definition `time:inside rdfs:domain time:Interval .`---note this is _not_ `time:ProperInterval`. ## Use case Take this example data graph: ```turtle ex:Interval-A time:inside ex:Instant-B . ex:Interval-A time:inside ex:Instant-C . ``` Domain and range inferencing (either RDFS or OWL-RL) entail: ```turtle ex:Interval-A a time:Interval . ex:Instant-B a time:Instant . ex:Instant-C a time:Instant . ``` The example data graph, and even the example data graph with the inferred type triples, is insufficient information to determine whether `ex:Interval-A` is a `time:ProperInterval`. This is because: * `ex:Instant-B` and `ex:Instant-C` could pertain to the same graph-individual, just identified by different IRI. * `ex:Instant-B` and `ex:Instant-C` could be different graph-individuals (e.g., the independently-assigned end of some interval and beginning of some other interval), but pertain to the same temporal value (/position). This could occur with usage of [`time:intervalMeets`](https://www.w3.org/TR/owl-time/#time:intervalMeets). If this statement were also in the knowledge graph ... ```turtle ex:Instant-C time:after ex:Instant-B . ``` ... then, it should be possible to _infer_ that `ex:Interval-A` is a `time:ProperInterval`, because it is an interval that contains two instants with a gap between them. (Reminder of caveat - this assumes `time:after` is a greater-than predicate, not a greater-than-or-equal-to.) However, I don't think this is possible to infer using only mechanisms available to OWL, or SHACL Advanced Features (i.e., pre-SHACL-1.2) `TripleRule`s. My understanding is that the matter comes down to variable binding and trinary (/3-ary) relationships not being available without SPARQL. (Though `sh:disjoint` / `sh:equals` are also trinary relators, I don't think they have enough information available to meet this use case, due to the Open World assumption sneaking in to this one particular spot of SHACL.) I can express this in SPARQL and get the entailment I'm looking for: ```sparql CONSTRUCT { ?nInterval a time:ProperInterval . } WHERE { ?nInterval a time:Interval ; time:inside ?nInstant1 , ?nInstant2 . ?nInstant2 time:after ?nInstant1 . } ``` In OWL, I do not believe it is possible to write a set of `owl:Restriction`s that let me entail `time:ProperInterval` by some `owl:EquivalentClass` or `owl:allValuesFrom` on inverted properties. It's possible to come close, saying "A proper interval is an interval that contains at least two instants, and vice versa" - but it doesn't quite work because of the semantics specific to OWL-Time: ```turtle time:ProperInterval owl:equivalentClass [ a owl:Class ; rdfs:subClassOf time:Interval , [ a owl:Restriction ; owl:onProperty time:inside ; owl:minCardinality "2"^^xsd:nonNegativeInteger ; ] ] . ``` `owl:equivalentClass` says that anonymous class's conditions are necessary and sufficient. They're necessary, but _insufficient_ - the two `time:Instant`s linked by `time:inside` could pertain to the same temporal position. They need to be asserted as one `time:after` the other. To my understanding, OWL was consciously designed to _not_ have a way to say "Not only are there two `time:Instant`s linked by `time:inside`, but those two instants are also linked together by `time:after`"---more generally, to not have trinary restrictions available. This SPARQL path can be followed in OWL spelling with a lot of `owl:Restriction` nesting (which I'll skip typing out), but `nInterval1` doesn't get to know anything about how it relates directly to `nInterval2`, due to the Open World assumption. ``` ?nInterval1 time:inside/time:after/^time:inside ?nInterval2 . ``` ## Resolution SHACL-AF had provided `sh:SPARQLRule`, which can satisfy this use case with a SPARQL `CONSTRUCT` query. I suggest `sh:SPARQLRule` carry forward, though there is an interesting question of the concept's home between the SPARQL Rules and SHACL-SPARQL documents. (And/or) This seems like a good opportunity to test the Variable work going on in the Inferences Rules PR #452 . Please view or discuss this issue at https://github.com/w3c/data-shapes/issues/515 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Monday, 18 August 2025 16:01:50 UTC