From ac147fcff6d0bec12d60407916f255f3f1773393 Mon Sep 17 00:00:00 2001 From: Tim Prudhomme Date: Sat, 22 Jun 2024 19:19:55 -0400 Subject: [PATCH 1/3] Deductive diff check, remap prov:insertedKeyEntityPair, fix Protege import, extra dev resources --- .gitignore | 3 ++ prov-cco-directmappings.ttl | 39 +++++++++++++++++------ src/Makefile | 15 ++++++++- src/build/artifacts/deductive-diff.txt | 1 + src/build/artifacts/inferred-mappings.csv | 4 --- src/catalog-v001.xml | 2 +- src/imports/BFO/bfo-ontologies.ttl | 16 ++++++++++ src/sparql/inferred-mappings.rq | 2 +- src/sparql/prov-triples.rq | 18 +++++++++++ 9 files changed, 84 insertions(+), 16 deletions(-) create mode 100644 src/build/artifacts/deductive-diff.txt create mode 100644 src/imports/BFO/bfo-ontologies.ttl create mode 100644 src/sparql/prov-triples.rq diff --git a/.gitignore b/.gitignore index 2682513..ff363f6 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,8 @@ # This is where Makefile artifacts and dependencies go build/lib +old-prov-triples.ttl +new-prov-triples.ttl + # Ontop files *.properties \ No newline at end of file diff --git a/prov-cco-directmappings.ttl b/prov-cco-directmappings.ttl index 35136d0..5ee4ee2 100644 --- a/prov-cco-directmappings.ttl +++ b/prov-cco-directmappings.ttl @@ -265,15 +265,6 @@ prov:pairKey rdf:type owl:ObjectProperty . rdfs:comment "A Key-Entity Pair is about a key because Key-Entity Pairs are Information Content Entities"@en . -prov:insertedKeyEntityPair rdf:type owl:ObjectProperty . -[] rdf:type owl:Axiom ; - owl:annotatedSource prov:insertedKeyEntityPair ; - owl:annotatedProperty rdfs:subPropertyOf ; - owl:annotatedTarget cco:has_output ; - sssom:object_label "has output" ; - rdfs:comment "Insertion of a Key-Entity Pair has output that Key-Entity Pair"@en . - - # PROV-AQ object property mappings prov:has_anchor rdf:type owl:ObjectProperty . [] rdf:type owl:Axiom ; @@ -518,4 +509,34 @@ prov:qualifiedInvalidation rdf:type owl:ObjectProperty . ] ; rdf:rest rdf:nil ] + ] . + + +# prov:insertedKeyEntityPair(?x,?y) ^ obo:BFO_0000015(?x) -> cco:has_output(?x,?y) +[ "true"^^xsd:boolean ; + rdfs:comment "If the Insertion of a Key-Entity Pair is a process, then that Insertion has output that Key-Entity Pair"@en ; + rdfs:label "Insertion insertedKeyEntityPair -> has_output" ; + rdf:type swrl:Imp ; + swrl:body [ rdf:type swrl:AtomList ; + rdf:first [ rdf:type swrl:IndividualPropertyAtom ; + swrl:propertyPredicate prov:insertedKeyEntityPair ; + swrl:argument1 :x ; + swrl:argument2 :y + ] ; + rdf:rest [ rdf:type swrl:AtomList ; + rdf:first [ rdf:type swrl:ClassAtom ; + swrl:classPredicate obo:BFO_0000015 ; + swrl:argument1 :x + ] ; + rdf:rest rdf:nil + ] + ] ; + swrl:head [ rdf:type swrl:AtomList ; + rdf:first [ rdf:type swrl:IndividualPropertyAtom ; + swrl:propertyPredicate cco:has_output ; + swrl:argument1 :x ; + swrl:argument2 :y + ] ; + rdf:rest rdf:nil + ] ] . \ No newline at end of file diff --git a/src/Makefile b/src/Makefile index c0f6fce..8211c0a 100644 --- a/src/Makefile +++ b/src/Makefile @@ -61,6 +61,9 @@ candidates-complex: $(ROBOT) query --input $(EDITOR_BUILD_FILE) -q $(config.QUERIES_DIR)/candidate-superproperties-complex.rq $(config.TEMP_DIR)/candidate-superproperties-complex.tsv --use-graphs true ; +# Axioms to materialize in reasoning +AXIOM_GENERATORS = "SubClass EquivalentClass SubObjectProperty EquivalentObjectProperty InverseObjectProperties" + # Check for unmapped terms after materializing inferred mappings (after removing individuals) unmapped: $(ROBOT) remove --input $(EDITOR_BUILD_FILE) --select individuals \ @@ -70,9 +73,19 @@ unmapped: # Materialize all mappings as a list inferred-mappings: $(ROBOT) remove --input $(EDITOR_BUILD_FILE) --select individuals \ - reason --reasoner HermiT --axiom-generators "SubClass SubObjectProperty InverseObjectProperties" --include-indirect true \ + reason --reasoner HermiT --axiom-generators $(AXIOM_GENERATORS) --include-indirect true \ query --output-dir $(config.TEMP_DIR) --queries $(config.QUERIES_DIR)/inferred-mappings.rq --use-graph true +# Materialize old and new entailments, then compare the differences. This doesn't include disjoint axioms. +deductive-diff: + $(ROBOT) remove --input $(EDITOR_BUILD_FILE) --select individuals \ + reason --reasoner HermiT --axiom-generators $(AXIOM_GENERATORS) --include-indirect true \ + query --query $(config.QUERIES_DIR)/prov-triples.rq $(config.TEMP_DIR)/new-prov-triples.ttl --use-graph true + + $(ROBOT) reason --input $(config.IMPORTS_DIR)/PROV/prov-ontologies.ttl --reasoner HermiT --axiom-generators $(AXIOM_GENERATORS) --include-indirect true \ + query --query $(config.QUERIES_DIR)/prov-triples.rq $(config.TEMP_DIR)/old-prov-triples.ttl --use-graph true + $(ROBOT) diff --left $(config.TEMP_DIR)/old-prov-triples.ttl --right $(config.TEMP_DIR)/new-prov-triples.ttl --output $(config.TEMP_DIR)/deductive-diff.txt + # Remove CCO individuals to speed up reasoner config.CCO_FILENAME = ../MergedAllCoreOntology-v1.4-2023-04-07 diff --git a/src/build/artifacts/deductive-diff.txt b/src/build/artifacts/deductive-diff.txt new file mode 100644 index 0000000..3307f8b --- /dev/null +++ b/src/build/artifacts/deductive-diff.txt @@ -0,0 +1 @@ +Ontologies are identical diff --git a/src/build/artifacts/inferred-mappings.csv b/src/build/artifacts/inferred-mappings.csv index b08ae89..84b9996 100644 --- a/src/build/artifacts/inferred-mappings.csv +++ b/src/build/artifacts/inferred-mappings.csv @@ -10,7 +10,6 @@ End,http://www.w3.org/2000/01/rdf-schema#subClassOf,process boundary Entity,http://www.w3.org/2000/01/rdf-schema#subClassOf,continuant Generation,http://www.w3.org/2000/01/rdf-schema#subClassOf,process boundary Influence,http://www.w3.org/2000/01/rdf-schema#subClassOf,occurrent -Insertion,http://www.w3.org/2000/01/rdf-schema#subClassOf,process InstantaneousEvent,http://www.w3.org/2000/01/rdf-schema#subClassOf,occurrent Invalidation,http://www.w3.org/2000/01/rdf-schema#subClassOf,process boundary Key-Entity Pair,http://www.w3.org/2000/01/rdf-schema#subClassOf,generically dependent continuant @@ -24,7 +23,6 @@ Person,http://www.w3.org/2000/01/rdf-schema#subClassOf,Person Plan,http://www.w3.org/2000/01/rdf-schema#subClassOf,generically dependent continuant Plan,http://www.w3.org/2000/01/rdf-schema#subClassOf,Information Content Entity Publish,http://www.w3.org/2000/01/rdf-schema#subClassOf,process -Removal,http://www.w3.org/2000/01/rdf-schema#subClassOf,process Replace,http://www.w3.org/2000/01/rdf-schema#subClassOf,process RightsAssignment,http://www.w3.org/2000/01/rdf-schema#subClassOf,process Role,http://www.w3.org/2000/01/rdf-schema#subClassOf,role @@ -84,8 +82,6 @@ has_provenance,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,is subject of influenced,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,causally related to influencer,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,causally related to informed,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,causally related to -insertedKeyEntityPair,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,has participant -insertedKeyEntityPair,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,has output invalidated,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,has participant invalidated,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,has participant invalidated,http://www.w3.org/2000/01/rdf-schema#subPropertyOf,has participant diff --git a/src/catalog-v001.xml b/src/catalog-v001.xml index 6f82754..9c0e9b6 100644 --- a/src/catalog-v001.xml +++ b/src/catalog-v001.xml @@ -5,7 +5,7 @@ - + diff --git a/src/imports/BFO/bfo-ontologies.ttl b/src/imports/BFO/bfo-ontologies.ttl new file mode 100644 index 0000000..a674a7a --- /dev/null +++ b/src/imports/BFO/bfo-ontologies.ttl @@ -0,0 +1,16 @@ +@prefix rdf: . +@prefix rdfs: . +@prefix owl: . +@base . + + + a owl:Ontology; + rdfs:comment "This file is used for analytics only"@en ; + owl:imports , # BFO Core + # , # BFO temporalized relations + + # , # Don't import all of RO, only import dependent terms below: + , # RO imports + + , # CCO +. \ No newline at end of file diff --git a/src/sparql/inferred-mappings.rq b/src/sparql/inferred-mappings.rq index 9b65c33..24cc94f 100644 --- a/src/sparql/inferred-mappings.rq +++ b/src/sparql/inferred-mappings.rq @@ -10,7 +10,7 @@ PREFIX ro: PREFIX cco: # Note: filters only work when all referenced terms and their axioms are succesfully imported -# Note: this should be used after materializing all mappings, however this query does not necessarily show all mappings +# Note: this should be used after materializing all mappings, however this query does not necessarily show all mappings (ex. SWRL rules) SELECT ?targetTermLabel ?predicate ?sourceTermLabel WHERE { VALUES ?termType { owl:Class owl:ObjectProperty } . diff --git a/src/sparql/prov-triples.rq b/src/sparql/prov-triples.rq new file mode 100644 index 0000000..725504f --- /dev/null +++ b/src/sparql/prov-triples.rq @@ -0,0 +1,18 @@ +PREFIX owl: +PREFIX rdf: +PREFIX rdfs: +PREFIX swrl: +PREFIX skos: + +PREFIX prov: +PREFIX bfo: + +CONSTRUCT { + ?targetTerm ?predicate ?sourceTerm +} WHERE { + FILTER ( + STRSTARTS(STR(?targetTerm), STR(prov:)) && + STRSTARTS(STR(?sourceTerm), STR(prov:)) + ) + ?targetTerm ?predicate ?sourceTerm . +} \ No newline at end of file From bb1e1c4c6500b70527180501ad99b993b9b01920 Mon Sep 17 00:00:00 2001 From: Tim Prudhomme Date: Sat, 22 Jun 2024 19:23:51 -0400 Subject: [PATCH 2/3] v2024-06-23 --- prov-bfo-directmappings.ttl | 4 ++-- prov-cco-directmappings.ttl | 4 ++-- prov-ro-directmappings.ttl | 4 ++-- src/prov-mappings-edit.ttl | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/prov-bfo-directmappings.ttl b/prov-bfo-directmappings.ttl index b031d76..2ed8f32 100644 --- a/prov-bfo-directmappings.ttl +++ b/prov-bfo-directmappings.ttl @@ -11,8 +11,8 @@ a owl:Ontology; rdfs:label "Basic Formal Ontology (BFO) ISO 21838-2:2020 mappings for W3C PROVenance Interchange Ontology (PROV-O)"@en ; - owl:versionInfo "2024-05-27"@en ; - owl:versionIRI ; + owl:versionInfo "2024-06-23"@en ; + owl:versionIRI ; dc:contributor "Tim Prudhomme", "Giacomo De Colle" , "Austin Liebers" , "Alec Sculley" , "Peihong Karl Xie", "Sydney Cohen", "John Beverley" ; dc:license ; prov:wasDerivedFrom , diff --git a/prov-cco-directmappings.ttl b/prov-cco-directmappings.ttl index 5ee4ee2..97f70c8 100644 --- a/prov-cco-directmappings.ttl +++ b/prov-cco-directmappings.ttl @@ -13,8 +13,8 @@ a owl:Ontology; rdfs:label "Common Core Ontologies (CCO) mappings for W3C PROVenance Interchange Ontology (PROV-O)"@en ; - owl:versionInfo "2024-05-27"@en ; - owl:versionIRI ; + owl:versionInfo "2024-06-23"@en ; + owl:versionIRI ; owl:imports ; rdfs:comment "This mapping depends on the imported PROV-O to BFO mapping" ; dc:contributor "Tim Prudhomme", "Giacomo De Colle" , "Austin Liebers" , "Alec Sculley" , "Peihong Karl Xie", "Sydney Cohen", "John Beverley" ; diff --git a/prov-ro-directmappings.ttl b/prov-ro-directmappings.ttl index 4c2d666..b15320c 100644 --- a/prov-ro-directmappings.ttl +++ b/prov-ro-directmappings.ttl @@ -11,8 +11,8 @@ a owl:Ontology; rdfs:label "Relation Ontology (RO) mappings for W3C PROVenance Interchange Ontology (PROV-O)"@en ; - owl:versionInfo "2024-05-27"@en ; - owl:versionIRI ; + owl:versionInfo "2024-06-23"@en ; + owl:versionIRI ; owl:imports ; rdfs:comment "This mapping depends on the imported PROV-O to BFO mapping." ; dc:contributor "Tim Prudhomme", "Giacomo De Colle" , "Austin Liebers" , "Alec Sculley" , "Peihong Karl Xie", "Sydney Cohen", "John Beverley" ; diff --git a/src/prov-mappings-edit.ttl b/src/prov-mappings-edit.ttl index e65547c..871076a 100644 --- a/src/prov-mappings-edit.ttl +++ b/src/prov-mappings-edit.ttl @@ -10,8 +10,8 @@ a owl:Ontology; rdfs:label "Editor's file for PROV-BFO Mappings."@en ; rdfs:comment "Open this in Protege to view the full mapping in context. Test the mapping with the imports in this file. This keeps imports out of the release version."@en ; - owl:versionInfo "2024-05-27"@en ; - owl:versionIRI ; + owl:versionInfo "2024-06-23"@en ; + owl:versionIRI ; owl:imports , # Release version of PROV-BFO containing actual mappings , # Release version of PROV-RO containing actual mappings , # Release version of PROV-CCO containing actual mappings From 65294ef93b892ec1cd296c3778b24d35222db679 Mon Sep 17 00:00:00 2001 From: Tim Prudhomme Date: Sat, 22 Jun 2024 19:37:42 -0400 Subject: [PATCH 3/3] Move SPARQL CONSTRUCTs to separate folder --- src/Makefile | 19 ++++++++++--------- src/sparql/{ => constructs}/prov-triples.rq | 0 2 files changed, 10 insertions(+), 9 deletions(-) rename src/sparql/{ => constructs}/prov-triples.rq (100%) diff --git a/src/Makefile b/src/Makefile index 8211c0a..76f5e91 100644 --- a/src/Makefile +++ b/src/Makefile @@ -17,13 +17,14 @@ config.DEV_IRI := $(config.ONTOLOGY-IRI)/dev config.MODULES_IRI := $(config.DEV_IRI)/modules # Local project directories -config.SOURCE_DIR := / -config.TEMP_DIR := build/artifacts -config.RELEASE_DIR := / -config.REPORTS_DIR := $(config.TEMP_DIR) -config.QUERIES_DIR := sparql -config.IMPORTS_DIR := imports -config.LIBRARY_DIR := ../build/lib +config.SOURCE_DIR := / +config.TEMP_DIR := build/artifacts +config.RELEASE_DIR := / +config.REPORTS_DIR := $(config.TEMP_DIR) +config.QUERIES_DIR := sparql +config.CONSTRUCT_QUERIES_DIR := sparql/construct +config.IMPORTS_DIR := imports +config.LIBRARY_DIR := ../build/lib # Settings # These will cause targets run by a Github Action to fail, if desired @@ -80,10 +81,10 @@ inferred-mappings: deductive-diff: $(ROBOT) remove --input $(EDITOR_BUILD_FILE) --select individuals \ reason --reasoner HermiT --axiom-generators $(AXIOM_GENERATORS) --include-indirect true \ - query --query $(config.QUERIES_DIR)/prov-triples.rq $(config.TEMP_DIR)/new-prov-triples.ttl --use-graph true + query --query $(config.CONSTRUCT_QUERIES_DIR)/prov-triples.rq $(config.TEMP_DIR)/new-prov-triples.ttl --use-graph true $(ROBOT) reason --input $(config.IMPORTS_DIR)/PROV/prov-ontologies.ttl --reasoner HermiT --axiom-generators $(AXIOM_GENERATORS) --include-indirect true \ - query --query $(config.QUERIES_DIR)/prov-triples.rq $(config.TEMP_DIR)/old-prov-triples.ttl --use-graph true + query --query $(config.CONSTRUCT_QUERIES_DIR)/prov-triples.rq $(config.TEMP_DIR)/old-prov-triples.ttl --use-graph true $(ROBOT) diff --left $(config.TEMP_DIR)/old-prov-triples.ttl --right $(config.TEMP_DIR)/new-prov-triples.ttl --output $(config.TEMP_DIR)/deductive-diff.txt diff --git a/src/sparql/prov-triples.rq b/src/sparql/constructs/prov-triples.rq similarity index 100% rename from src/sparql/prov-triples.rq rename to src/sparql/constructs/prov-triples.rq