@prefix :         <https://openprovenance.org/ns/openprov#> .
@prefix openprov: <https://openprovenance.org/ns/openprov#> .
@prefix provext:  <https://openprovenance.org/ns/provext#> .
@prefix prov:     <http://www.w3.org/ns/prov#> .
@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#> .
@base             <https://openprovenance.org/ns/openprov#> .

<https://openprovenance.org/ns/openprov#>
    rdf:type owl:Ontology ;
    rdfs:label "OpenProvenance vocabulary"@en ;
    rdfs:comment "The vocabulary the OpenProvenance template library and ProvToolbox use in provenance documents beyond PROV-DM and provext: the statements a summarising relation was folded from, the roles of the parties to a change of collection, and the kinds of activity and derivation that change a collection. Distinct from provext, the minimal extension PROV-JSONLD needs for its regular JSON shape, whose classes this vocabulary builds on."@en ;
    owl:imports <https://openprovenance.org/ns/provext#> .


#################################################################
#    Object Properties: the statements a relation arose from
#
#    A template folds a triangle of statements — an activity, its
#    usage, generation, invalidation or derivation, an agent's
#    association — into one relation: an attribution, a membership,
#    a specialization, a communication, a start, an end. These properties, optional on that relation,
#    point back at the statements it summarises. They follow the
#    convention of PROV-O's qualified derivation, whose hadActivity,
#    hadGeneration and hadUsage name the statements a derivation
#    arose from, where activity and entity name what a relation is
#    about.
#################################################################

###  On attributions and memberships

:hadActivity rdf:type owl:ObjectProperty ;
    rdfs:domain [ rdf:type owl:Class ; owl:unionOf ( prov:Attribution provext:Membership ) ] ;
    rdfs:range prov:Activity ;
    rdfs:subPropertyOf prov:hadActivity ;
    rdfs:label "had activity"@en ;
    rdfs:comment "The activity the relation arose from: for an attribution, the activity that generated, invalidated or derived the entity while the agent was associated with it; for a membership, the activity that placed the member in the collection. A sub-property of prov:hadActivity, whose domain PROV-O states as prov:Influence and, more precisely, as the union of Delegation, Derivation, End and Start; an attribution or membership carrying this property is therefore entailed to be an Influence, and, under the precise domain, a member of that union, which PROV-O declares nothing to contradict."@en .

:hadGeneration rdf:type owl:ObjectProperty ;
    rdfs:domain [ rdf:type owl:Class ; owl:unionOf ( prov:Attribution provext:Membership prov:Communication prov:Start prov:End ) ] ;
    rdfs:range prov:Generation ;
    rdfs:label "had generation"@en ;
    rdfs:comment "For an attribution, the generation of the attributed entity by the activity it arose from; for a membership, the generation of the collection by that activity; for a communication, the generation, by the informant, of the entity the informed activity used; for a start or an end, the generation of the trigger entity by the starter or ender activity."@en .

###  On attributions

:hadAssociation rdf:type owl:ObjectProperty ;
    rdfs:domain prov:Attribution ;
    rdfs:range prov:Association ;
    rdfs:label "had association"@en ;
    rdfs:comment "The association of the agent with the activity the attribution arose from."@en .

:hadInvalidation rdf:type owl:ObjectProperty ;
    rdfs:domain prov:Attribution ;
    rdfs:range prov:Invalidation ;
    rdfs:label "had invalidation"@en ;
    rdfs:comment "The invalidation of the attributed entity by the activity the attribution arose from."@en .

:hadEntityDerivation rdf:type owl:ObjectProperty ;
    rdfs:domain prov:Attribution ;
    rdfs:range prov:Derivation ;
    rdfs:label "had entity derivation"@en ;
    rdfs:comment "The derivation of the attributed entity, from its earlier version, by the activity the attribution arose from."@en .

:hadAgentDerivation rdf:type owl:ObjectProperty ;
    rdfs:domain prov:Attribution ;
    rdfs:range prov:Derivation ;
    rdfs:label "had agent derivation"@en ;
    rdfs:comment "The derivation of the agent, from its earlier version, by the activity the attribution arose from."@en .

###  On memberships and communications

:hadUsage rdf:type owl:ObjectProperty ;
    rdfs:domain [ rdf:type owl:Class ; owl:unionOf ( provext:Membership prov:Communication ) ] ;
    rdfs:range prov:Usage ;
    rdfs:label "had usage"@en ;
    rdfs:comment "For a membership, the usage of the member by the activity the membership arose from; for a communication, the usage, by the informed activity, of the entity the informant generated."@en .

###  On communications

:hadEntity rdf:type owl:ObjectProperty ;
    rdfs:domain prov:Communication ;
    rdfs:range prov:Entity ;
    rdfs:label "had entity"@en ;
    rdfs:comment "The entity a communication arose from: generated by the informant activity and used by the informed one. The counterpart, for a communication, of the activity a derivation arose from, prov:hadActivity."@en .

:hadCollectionGeneration rdf:type owl:ObjectProperty ;
    rdfs:domain provext:Membership ;
    rdfs:range prov:Generation ;
    rdfs:label "had collection generation"@en ;
    rdfs:comment "The generation of the collection by the activity the membership arose from."@en .

:hadItemGeneration rdf:type owl:ObjectProperty ;
    rdfs:domain provext:Membership ;
    rdfs:range prov:Generation ;
    rdfs:label "had item generation"@en ;
    rdfs:comment "The generation of the member by the activity the membership arose from."@en .

###  On specializations

:hadPreviousEntity rdf:type owl:ObjectProperty ;
    rdfs:domain provext:Specialization ;
    rdfs:range prov:Entity ;
    rdfs:label "had previous entity"@en ;
    rdfs:comment "The previous entity, from which the specific entity was derived, itself a specialization of the same general entity. Named previous, not entity, beside the specific and general entities of the specialization."@en .

:hadDerivation rdf:type owl:ObjectProperty ;
    rdfs:domain provext:Specialization ;
    rdfs:range prov:Derivation ;
    rdfs:label "had derivation"@en ;
    rdfs:comment "The derivation of the specific entity from the entity the specialization arose from."@en .

:hadSpecialization rdf:type owl:ObjectProperty ;
    rdfs:domain provext:Specialization ;
    rdfs:range provext:Specialization ;
    rdfs:label "had specialization"@en ;
    rdfs:comment "The specialization, of the entity the specific entity was derived from, to the same general entity."@en .


#################################################################
#    Roles: the parties to a change of collection
#################################################################

:asCollection rdf:type prov:Role ;
    rdfs:label "as collection"@en ;
    rdfs:comment "The role of a collection in the usage or generation by an activity that inserts into it or removes from it."@en .

:asMember rdf:type prov:Role ;
    rdfs:label "as member"@en ;
    rdfs:comment "The role of a member in the usage or generation by an activity that inserts it into, or removes it from, a collection."@en .

:asItem rdf:type prov:Role ;
    rdfs:label "as item"@en ;
    rdfs:comment "The role of the item an activity takes in and hands on, as in an assignment or a handover."@en .

:asEntity rdf:type prov:Role ;
    rdfs:label "as entity"@en ;
    rdfs:comment "The role of the entity an activity acts upon, when no more specific role applies."@en .


#################################################################
#    Types: changes of collection
#
#    Stamped as prov:type on the activity that changes a collection
#    and on the derivations it accounts for.
#################################################################

:InsertingItemIntoCollection rdf:type owl:Class ;
    rdfs:label "Inserting item into collection"@en ;
    rdfs:comment "The insertion of an item into a collection: the type of the activity that uses the collection and the item and generates the new collection, and of the derivations it accounts for."@en .

:InsertingInto_Collection rdf:type owl:Class ;
    rdfs:subClassOf prov:Derivation ;
    rdfs:label "Inserting into: collection"@en ;
    rdfs:comment "The derivation of the new collection from the old one by an insertion."@en .

:InsertingInto_Item rdf:type owl:Class ;
    rdfs:subClassOf prov:Derivation ;
    rdfs:label "Inserting into: item"@en ;
    rdfs:comment "The derivation of the inserted item, as it is in the collection, from the item that was inserted."@en .

:InsertingElement rdf:type owl:Class ;
    rdfs:label "Inserting element"@en ;
    rdfs:comment "The membership that an insertion establishes, alongside prov:Derivation; used by ProvToolbox's collection scenarios."@en .

:RemovingElementFromCollection rdf:type owl:Class ;
    rdfs:label "Removing element from collection"@en ;
    rdfs:comment "The removal of an element from a collection: the type of the activity that uses the collection and generates the new one, and of the derivations it accounts for."@en .

:RemovingElement rdf:type owl:Class ;
    rdfs:subClassOf prov:Derivation ;
    rdfs:label "Removing element"@en ;
    rdfs:comment "The derivation of the collection, as it is once the element is removed, from the element that was removed."@en .
