@base <https://w3id.org/edwin/ontology/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix : <> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix swrl: <http://www.w3.org/2003/11/swrl#> .
@prefix vann: <http://purl.org/vocab/vann/> .
@prefix swrla: <http://swrl.stanford.edu/ontologies/3.3/swrla.owl#> .
@prefix swrlb: <http://www.w3.org/2003/11/swrlb#> .
@prefix terms: <http://purl.org/dc/terms/> .
@prefix schema: <http://schema.org/> .

swrla:isRuleEnabled
    a owl:AnnotationProperty .

<>
    dc:description <https://raw.githubusercontent.com/luigi-asprino/edwin/master/ontology/0.01/esg_schema.png> ;
    a owl:Ontology ;
    owl:imports <http://www.w3.org/1999/02/22-rdf-syntax-ns#>, <http://www.w3.org/ns/dcat> .

:EquivalenceSetGraph
    a owl:Class ;
    rdfs:subClassOf [
        a owl:Restriction ;
        owl:onProperty :computedFrom ;
        owl:someValuesFrom dcat:Dataset
    ], [
        a owl:Restriction ;
        owl:allValuesFrom :Node ;
        owl:onProperty :hasNode
    ], [
        a owl:Restriction ;
        owl:allValuesFrom rdf:Property ;
        owl:onProperty :observesSpecializationProperty
    ], [
        a owl:Restriction ;
        owl:onClass rdf:Property ;
        owl:onProperty :observesEquivalenceProperty ;
        owl:qualifiedCardinality "1"^^xsd:nonNegativeInteger
    ] .

:Node
    a owl:Class ;
    rdfs:subClassOf [
        a owl:Restriction ;
        owl:onProperty :contains ;
        owl:someValuesFrom owl:Thing
    ], [
        a owl:Restriction ;
        owl:allValuesFrom :Node ;
        owl:onProperty :isAdjacentTo
    ], [
        a owl:Restriction ;
        owl:allValuesFrom :Node ;
        owl:onProperty :isSpecializedBy
    ], [
        a owl:Restriction ;
        owl:allValuesFrom :Node ;
        owl:onProperty :specializes
    ] .

:computedFrom
    a owl:ObjectProperty ;
    rdfs:domain :EquivalenceSetGraph ;
    rdfs:range dcat:Dataset .

:contains
    a owl:ObjectProperty ;
    rdfs:domain :Node ;
    rdfs:range owl:Thing .

:e1
    a swrl:Variable .

:e2
    a swrl:Variable .

:equivalencePropertyForProperties
    a owl:ObjectProperty ;
    rdfs:domain :EquivalenceSetGraph ;
    rdfs:range rdf:Property .

:g
    a swrl:Variable .

:hasNode
    a owl:ObjectProperty ;
    rdfs:domain :EquivalenceSetGraph ;
    rdfs:range :Node .

:isAdjacentTo
    a owl:ObjectProperty ;
    rdfs:domain :Node ;
    rdfs:range :Node .

:isSpecializedBy
    a owl:ObjectProperty ;
    rdfs:subPropertyOf :isAdjacentTo ;
    owl:inverseOf :specializes .

:n
    a swrl:Variable .

:n1
    a swrl:Variable .

:n2
    a swrl:Variable .

:observesEquivalenceProperty
    a owl:ObjectProperty ;
    rdfs:subPropertyOf :observesProperty .

:observesProperty
    a owl:ObjectProperty ;
    rdfs:domain :EquivalenceSetGraph ;
    rdfs:range rdf:Property .

:observesSpecializationProperty
    a owl:ObjectProperty ;
    rdfs:subPropertyOf :observesProperty .

:peq
    a swrl:Variable .

:psub
    a swrl:Variable .

:specializationPropertyForProperties
    a owl:ObjectProperty ;
    rdfs:domain :EquivalenceSetGraph ;
    rdfs:range rdf:Property .

:specializes
    a owl:ObjectProperty ;
    rdfs:subPropertyOf :isAdjacentTo .

[]
    swrla:isRuleEnabled true ;
    a swrl:Imp ;
    rdfs:comment ""^^xsd:string ;
    rdfs:label "specialization"^^xsd:string ;
    swrl:body ([
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :g ;
            swrl:argument2 :n1 ;
            swrl:propertyPredicate :hasNode
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :g ;
            swrl:argument2 :n2 ;
            swrl:propertyPredicate :hasNode
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :g ;
            swrl:argument2 :psub ;
            swrl:propertyPredicate :observesSpecializationProperty
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :n1 ;
            swrl:argument2 :e1 ;
            swrl:propertyPredicate :contains
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :n2 ;
            swrl:argument2 :e2 ;
            swrl:propertyPredicate :contains
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :n1 ;
            swrl:argument2 :n2 ;
            swrl:propertyPredicate :specializes
        ]
    ) ;
    swrl:head ([
            a swrl:BuiltinAtom ;
            swrl:arguments (:e1
                :psub
                :e2
            ) ;
            swrl:builtin swrlb:add
        ]
    ) .

[]
    swrla:isRuleEnabled true ;
    a swrl:Imp ;
    rdfs:comment ""^^xsd:string ;
    rdfs:label "equivalence sets"^^xsd:string ;
    swrl:body ([
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :g ;
            swrl:argument2 :n ;
            swrl:propertyPredicate :hasNode
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :g ;
            swrl:argument2 :peq ;
            swrl:propertyPredicate :observesEquivalenceProperty
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :n ;
            swrl:argument2 :e1 ;
            swrl:propertyPredicate :contains
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :n ;
            swrl:argument2 :e2 ;
            swrl:propertyPredicate :contains
        ]
    ) ;
    swrl:head ([
            a swrl:BuiltinAtom ;
            swrl:arguments (:e1
                :peq
                :e2
            ) ;
            swrl:builtin swrlb:add
        ]
        [
            a swrl:BuiltinAtom ;
            swrl:arguments (:e2
                :peq
                :e1
            ) ;
            swrl:builtin swrlb:add
        ]
    ) .

[]
    swrla:isRuleEnabled true ;
    a swrl:Imp ;
    rdfs:comment ""^^xsd:string ;
    rdfs:label "generalization"^^xsd:string ;
    swrl:body ([
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :g ;
            swrl:argument2 :n1 ;
            swrl:propertyPredicate :hasNode
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :g ;
            swrl:argument2 :n2 ;
            swrl:propertyPredicate :hasNode
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :g ;
            swrl:argument2 :psub ;
            swrl:propertyPredicate :observesSpecializationProperty
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :n1 ;
            swrl:argument2 :e1 ;
            swrl:propertyPredicate :contains
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :n2 ;
            swrl:argument2 :e2 ;
            swrl:propertyPredicate :contains
        ]
        [
            a swrl:IndividualPropertyAtom ;
            swrl:argument1 :n1 ;
            swrl:argument2 :n2 ;
            swrl:propertyPredicate :isSpecializedBy
        ]
    ) ;
    swrl:head ([
            a swrl:BuiltinAtom ;
            swrl:arguments (:e2
                :psub
                :e1
            ) ;
            swrl:builtin swrlb:add
        ]
    ) .

