ucoProject / UCO

This repository is for development of the Unified Cyber Ontology.
Apache License 2.0
73 stars 34 forks source link

UCO OWL review of RDF List was scoped too broadly #571

Closed ajnelson-nist closed 5 months ago

ajnelson-nist commented 7 months ago

Bug description

As part of reviewing UCO's syntax for semi-open vocabularies before UCO 1.0.0 (done in Issue 406), some shapes were written to check the syntax for OWL definitions of custom datatypes. Those shapes recognized some requirements OWL makes on rdf:List, but incorrectly scoped them to apply to all rdf:Lists. This causes some issues with review of certain OWL "A-Box" review (used for representing individuals, i.e. instances of the classes and users of properties from the "T-Box"), as well as SHACL review.

The shapes around rdf:List, rdf:first, and rdf:rest currently in the UCO OWL shapes file need to be revised to be scoped to OWL. This will mean going with a more strict enumeration style, following the rule-matching in the OWL 2 Web Ontology Language Mapping to RDF Graphs (Second Edition).

This Issue houses a bug report and a remediating Change Proposal. It appears complex enough to me to need a Requirements Review vote.

Steps to reproduce

These RDF snippets should not cause UCO's SHACL validation to fail, but currently they do:

@prefix kb: <http://example.org/kb/> .
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
kb:MyOrderedCollection
  a skos:OrderedCollection ;
  skos:memberList ( kb:X kb:Y kb:Z ) .

The above instance-data snippet is drawn from Example 41 in the SKOS reference Section 9.3.

@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

dash:DateOrDateTime
  a rdf:List ;
  rdf:first [
      sh:datatype xsd:date ;
    ] ;
  rdf:rest (
      [
        sh:datatype xsd:dateTime ;
      ]
    ) ;
  rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:date or xsd:dateTime." ;
  rdfs:label "Date or date time" ;
. 

The above SHACL supplementary snippet is drawn from DASH Data Shapes Vocabulary Section 8.1, where the prescribed usage of the shape follows this general form:

@prefix dash: <http://datashapes.org/dash#> .
@prefix ex: <http://example.org/shapes/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:DateOrDateTimeShape
    a sh:NodeShape ;
    sh:property [
        sh:path ex:timeStamp ;
        sh:or dash:DateOrDateTime ;
    ] .

As an aside, a sibling shape snippet, dash:StringOrLangString, could support a goal in the CASE backlog (ONT-6) of supporting language strings without universally requiring language string annotations. (I was informed of this shape in discussion on this pySHACL issue.)

dash:StringOrLangString
  a rdf:List ;
  rdf:first [
      sh:datatype xsd:string ;
    ] ;
  rdf:rest (
      [
        sh:datatype rdf:langString ;
      ]
    ) ;
  rdfs:comment "An rdf:List that can be used in property constraints as value for sh:or to indicate that all values of a property must be either xsd:string or rdf:langString." ;
  rdfs:label "String or langString" ;
.   

Requirements

Requirement 1

UCO's OWL review must not prevent other RDF idioms that are not necessarily within OWL's purview (e.g. instance-data rdf:Lists and SHACL constructs).

Risk / Benefit analysis

Benefits

Risks

Competencies demonstrated

UCO's OWL review should not raise any issues for the DASH and SKOS usage patterns described above. The examples are encoded in updated unit tests accompanying this Issue.

Solution suggestion

For instance, for owl:oneOf, this new shape is defined:

uco-owl:oneOf-objects-shape
    a sh:NodeShape ;
    sh:node uco-owl:Sequence-shape ;
    sh:targetObjectsOf owl:oneOf ;
    .

This issue leaves the following out of scope, to remain focused on fixing the overly-broad review bug:

Coordination

ajnelson-nist commented 7 months ago

Update: This proposal initially included several shapes using sh:targetObjectsOf on OWL sequence-valued predicates. In this comment on the PR, I concluded that it would be better for issue remediation to use sh:targetSubjectsOf instead, so the PR now implements shapes targeting predicates' subjects.