ontodev / robot

ROBOT is an OBO Tool
http://robot.obolibrary.org
BSD 3-Clause "New" or "Revised" License
264 stars 74 forks source link

Should `validate-profile` recognize `owl:onProperties`? #1176

Open ajnelson-nist opened 9 months ago

ajnelson-nist commented 9 months ago

I have been doing some testing of general OWL syntax, and came across a curiosity as I was enumerating usages of OWL "Sequences" from the document OWL 2 Web Ontology Language Mapping to RDF Graphs (Second Edition).

The predicate owl:onProperties occurs four times in that file. It maps the OWL construct DataAllValuesFrom and DataSomeValuesFrom from a single propertty to multiple properties in one owl:Restriction.

I tried writing an exemplar class to verify I was understanding the syntax, but I get an error from validate-profile, though things look consistent with the tables in that W3C document. From a quick grep over the ROBOT source, I don't see occurrences of onProperties, but I also couldn't catch onProperty by eye because [a|A]nnotationProperty happens to cover it too. Is this just a missed OWL property?

For issue reproduction, my input graph is:

@prefix ex: <http://example.org/ontology/example/> .
@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#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<http://example.org/kb>
    a owl:Ontology ;
    .

ex:Class-2017f153-97f3-417f-b611-096ca48b0025
    a owl:Class ;
    rdfs:subClassOf [
        a owl:Restriction ;
        owl:onProperty ex:DatatypeProperty-64bb66a5-798a-4e0b-874b-6d995ab784a2 ;
        owl:allValuesFrom xsd:integer ;
    ] ;
    .

ex:Class-d7316c48-8616-4754-84b1-b17745f91e92
    a owl:Class ;
    rdfs:subClassOf [
        a owl:Restriction ;
        owl:onProperties (
            ex:DatatypeProperty-76981918-ac99-4423-aeb6-2ce760debc4a
            ex:DatatypeProperty-9e6f4b87-1fe4-4c9f-9a26-4e0a33d4ba99
        ) ;
        owl:allValuesFrom xsd:integer ;
    ] ;
    .

ex:DatatypeProperty-64bb66a5-798a-4e0b-874b-6d995ab784a2
    a owl:DatatypeProperty ;
    .

ex:DatatypeProperty-76981918-ac99-4423-aeb6-2ce760debc4a
    a owl:DatatypeProperty ;
    .

ex:DatatypeProperty-9e6f4b87-1fe4-4c9f-9a26-4e0a33d4ba99
    a owl:DatatypeProperty ;
    .

My test command with ROBOT version 1.9.5 is:

java -jar robot.jar \
  validate-profile \
  --input example.ttl \
  --profile DL

An example of my test output is:

2024-01-25 15:37:08,565 ERROR org.semanticweb.owlapi.rdf.rdfxml.parser.OWLRDFConsumer - Entity not properly recognized, missing triples in input? http://org.semanticweb.owlapi/error#Error1 for type Class
2024-01-25 15:37:08,579 ERROR org.obolibrary.robot.IOHelper - Input ontology contains 1 triple(s) that could not be parsed:
 - _:genid-nodeid-node1hl15edmgx2 <http://www.w3.org/2002/07/owl#onProperties> _:genid-nodeid-node1hl15edmgx3.

OWL 2 DL Profile Report: Ontology and imports closure NOT in profile. The following violations are present:
Use of undeclared class: <http://org.semanticweb.owlapi/error#Error1> [SubClassOf(<http://example.org/ontology/example/Class-d7316c48-8616-4754-84b1-b17745f91e92> <http://org.semanticweb.owlapi/error#Error1>) in OntologyID(OntologyIRI(<http://example.org/kb>) VersionIRI(<null>))]

PROFILE VIOLATION ERROR http://example.org/kb violates profile DL
For details see: http://robot.obolibrary.org/validate-profile#profile-violation-error
Use the -vvv option to show the stack trace.
Use the --help option to see usage information.

I am fine with this test input being added to unit tests, and I do not require crediting. All the same, acknowledgement would be appreciated.

matentzn commented 9 months ago

Wow, indeed! This is very interesting - ROBOT ownly wraps OWL API, so it will have to be raised there.. But just searching through the OWL API https://github.com/owlcs/owlapi repo shows no mention of owl:onProperties - and I have to be honest, despite working extensively with OWL over the last 10 years, I didnt even know of its existence.

@matthewhorridge @ignazio1977 maybe you have some insight?

ignazio1977 commented 9 months ago

Rings a bell, need to Google a bit.

ignazio1977 commented 9 months ago

So, the thing I had in mind was datatype n-arity - the OWL specs say that owl:onProperties is to be used to map restrictions with multiple properties, and those are defined as restrictions where the number of properties matches the n-arity of the datatype.

But, there's no defined datatype with n-arity more than 1 (to my knowledge - it's been a few years since last time I looked it up). Integers certainly are not.

The error reported is because of a parsing failure, not because of an actual recognised violation. I'm not sure if owl:onProperties would be accepted, but it won't work with integers, I believe. So, as is, I think the owlapi is failing, but that input shouldn't pass anyway. It's failing wrongly, so to speak.

ajnelson-nist commented 9 months ago

Thank you @ignazio1977 , I'd only guessed at what datatype to use from syntactic form.

Would something like a latitude-longitude coordinate pair work?

ajnelson-nist commented 9 months ago

Ah, perhaps it's not possible to demonstrate owl:onProperties, if a datatype of arity ≥ 2 is needed? I'm a little fuzzy on "Data range" vs "datatype" in light of OWL 2 deprecating owl:DataRange.

Implementations are not required to support the IRI owl:onProperties, but may support it in order to realize n-ary dataranges with arity ≥ 2 (see Sections 7 and 8.4 of the OWL 2 Structural Specification [OWL 2 Specification] for further information).

Source: https://www.w3.org/TR/2012/REC-owl2-rdf-based-semantics-20121211/#Vocabulary_Terms

Each data range is associated with a positive arity, which determines the size of the tuples in the data range. All datatypes have arity one. This specification currently does not define data ranges of arity more than one; however, by allowing for n-ary data ranges, the syntax of OWL 2 provides a "hook" allowing implementations to introduce extensions such as comparisons and arithmetic.

Source: https://www.w3.org/TR/2012/REC-owl2-syntax-20121211/#Data_Ranges

Emphasis added.

ajnelson-nist commented 9 months ago

Actually, the rest of Section 7, "Data Ranges" looks less gloomy for this property than I thought. Please pardon my last comment.