Provenance

The provenance plugin enables the generation of inference closure from a specific named graph at query time. This is useful in situations when you want to trace what the implicit statements generated from a specific graph are and the axiomatic triples part of the configured ruleset, i.e., the ones inserted with a special predicate sys:schemaTransaction. For more information, check Reasoning.

By default, GraphDB’s forward-chaining inferencer materializes all implicit statements in the default graph. Therefore, it is impossible to trace which graphs these implicit statements are coming from. The provenance plugin provides the opposite approach. With the configured ruleset, the reasoner does forward-chaining over a specific named graph and generates all its implicit statements at query time.

Predicates

The plugin predicates gives you an easy access to the graph, which implicit statements you want to generate. The process is similar to the RDF reification. All plugin’s predicates start with <http://www.ontotext.com/provenance/>:

Plugin predicates

Semantics

http://www.ontotext.com/provenance/derivedFrom

Creates a request scope for the graph with the inference closure

http://www.ontotext.com/provenance/subject

Binds all subjects part of the inference closure

http://www.ontotext.com/provenance/predicate

Binds all predicates part of the inference closure

http://www.ontotext.com/provenance/object

Binds all objects part of the inference closure

Enabling the plugin

The plugin is disabled by default.

  1. Start the plugin by adding the parameter:

    ./graphdb -Dregister-plugins=com.ontotext.trree.plugin.provenance.ProvenancePlugin
    
  2. Check the startup log to validate that the plugin has started correctly.

    [INFO ] 2016-11-18 19:47:19,134 [http-nio-7200-exec-2 c.o.t.s.i.PluginManager] Initializing plugin 'provenance'
    

Usage and examples

  1. Copy the TRIG file in the Import ‣ RDF ‣ Text area of the Workbench:

    @prefix food: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#> .
    @prefix owl: <http://www.w3.org/2002/07/owl#> .
    @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
    @prefix vin: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#> .
    @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
    
    
    food:Ontology {
    
      food:Fruit a owl:Class ;
          rdfs:label "fruit"@en ;
          rdfs:comment "In botany, a fruit is the seed-bearing structure in flowering plants formed from the ovary after flowering".
    
      food:Grape rdfs:label "grape"@en ;
          rdfs:comment "A grape is a fruiting berry of the deciduous woody vines of the botanical genus Vitis";
          rdfs:subClassOf food:Fruit.
    }
    
    vin:Ontology {
    
      vin:WineGrape rdfs:label "wine grape"@en ;
          rdfs:comment "Grape used for the wine production";
          rdfs:subClassOf food:Grape.
    
      vin:RedWineGrape rdfs:label "white wine"@en;
          rdfs:comment "Red grape used for wine production";
          rdfs:subClassOf vin:WineGrape.
    
      vin:CabernetSauvignon rdfs:label "Cabernet Sauvignon"@en ;
          rdfs:comment "Cabernet Sauvignon is one of the world's most widely recognized red wine grape varieties";
          rdfs:subClassOf vin:RedWineGrape.
    }
    
  2. Example 1: Return all explicit and implicit statements

    This example returns all explicit and implicit statements derived from the vin:Ontology graph. The ?ctx variable binds a new graph pr:derivedFrom the vin:Ontology graph, which includes all its implicit and explicit statements.

    PREFIX pr: <http://www.ontotext.com/provenance/>
    PREFIX vin: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>
    
    CONSTRUCT {
      ?subject ?predicate ?object
    }
    WHERE {
        vin:Ontology pr:derivedFrom ?ctx .
        ?ctx pr:subject ?subject .
        ?ctx pr:predicate ?predicate .
        ?ctx pr:object ?object .
    }
    

    The result set will not include statements in which vin:WineGrape is food:Grape or food:Fruit.

  3. Example 2: Return only implicit statements

    The query below extends the previous example by excluding the explicit statements. It returns only the implicit statements materialized from vin:Ontology graph:

    PREFIX pr: <http://www.ontotext.com/provenance/>
    PREFIX vin: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>
    
    CONSTRUCT {
      ?subject ?predicate ?object
    }
    WHERE {
        vin:Ontology pr:derivedFrom ?ctx .
        ?ctx pr:subject ?subject .
        ?ctx pr:predicate ?predicate .
        ?ctx pr:object ?object .
        MINUS {
          GRAPH vin:Ontology {
              ?subject ?predicate ?object
        }
      }
    }
    
  4. Example 3: Return all implicit statements from multiple graphs

    The plugin accepts multiple graphs provided with a value keyword. The example returns all implicit statements derived from the vin:Ontology and food:Ontology graphs:

    PREFIX pr: <http://www.ontotext.com/provenance/>
    PREFIX vin: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/wine#>
    PREFIX food: <http://www.w3.org/TR/2003/PR-owl-guide-20031209/food#>
    
    CONSTRUCT {
      ?subject ?predicate ?object
    }
    WHERE {
        VALUES ?graph {
          food:Ontology vin:Ontology
        }
        ?graph pr:derivedFrom ?ctx .
        ?ctx pr:subject ?subject .
        ?ctx pr:predicate ?predicate .
        ?ctx pr:object ?object .
        MINUS {
          GRAPH vin:Ontology {
              ?subject ?predicate ?object
        }
      }
    }