/// <summary> /// SubClassTransitivity (rdfs11) implements structural entailments based on 'rdfs:subClassOf' taxonomy: /// ((C1 SUBCLASSOF C2) AND (C2 SUBCLASSOF C3)) => (C1 SUBCLASSOF C3); /// ((C1 SUBCLASSOF C2) AND (C2 EQUIVALENTCLASS C3)) => (C1 SUBCLASSOF C3); /// ((C1 EQUIVALENTCLASS C2) AND (C2 SUBCLASSOF C3)) => (C1 SUBCLASSOF C3) /// </summary> internal static RDFOntologyReasonerReport SubClassTransitivityExec(RDFOntology ontology) { var report = new RDFOntologyReasonerReport(); var subClassOf = RDFVocabulary.RDFS.SUB_CLASS_OF.ToRDFOntologyObjectProperty(); foreach (var c in ontology.Model.ClassModel) { //Enlist the superclasses of the current class var superclasses = ontology.Model.ClassModel.GetSuperClassesOf(c); foreach (var sc in superclasses) { //Create the inference as a taxonomy entry var sem_inf = new RDFOntologyTaxonomyEntry(c, subClassOf, sc).SetInference(RDFSemanticsEnums.RDFOntologyInferenceType.Reasoner); //Add the inference to the ontology and to the report if (ontology.Model.ClassModel.Relations.SubClassOf.AddEntry(sem_inf)) { report.AddEvidence(new RDFOntologyReasonerEvidence(RDFSemanticsEnums.RDFOntologyReasonerEvidenceCategory.ClassModel, "SubClassTransitivity", sem_inf)); } } } return(report); }
/// <summary> /// "RangeEntailment (rdfs3) implements structural entailments based on 'rdfs:range' taxonomy:" /// "((F1 P F2) AND (P RDFS:RANGE C)) => (F2 RDF:TYPE C)" /// </summary> internal static RDFOntologyReasonerReport RangeEntailmentExec(RDFOntology ontology) { var report = new RDFOntologyReasonerReport(); var type = RDFVocabulary.RDF.TYPE.ToRDFOntologyObjectProperty(); //Calculate the set of available properties on which to perform the reasoning (exclude BASE properties and annotation properties) var availableprops = ontology.Model.PropertyModel.Where(prop => !RDFOntologyChecker.CheckReservedProperty(prop) && !prop.IsAnnotationProperty()).ToList(); foreach (var p in availableprops) { if (p.Range != null) { //Filter the assertions using the current property (F1 P1 F2) var pAsns = ontology.Data.Relations.Assertions.SelectEntriesByPredicate(p); //Iterate the related assertions foreach (var pAsn in pAsns) { //Taxonomy-check for securing inference consistency if (pAsn.TaxonomyObject.IsFact()) { //Create the inference as a taxonomy entry var sem_inf = new RDFOntologyTaxonomyEntry(pAsn.TaxonomyObject, type, p.Range).SetInference(RDFSemanticsEnums.RDFOntologyInferenceType.Reasoner); //Add the inference to the ontology and to the report if (ontology.Data.Relations.ClassType.AddEntry(sem_inf)) { report.AddEvidence(new RDFOntologyReasonerEvidence(RDFSemanticsEnums.RDFOntologyReasonerEvidenceCategory.Data, "RangeEntailment", sem_inf)); } } } } } return(report); }