protected void throwInconsistentOntologyExceptionIfNecessary() { if (!isConsistent() && m_configuration.throwInconsistentOntologyException) throw new InconsistentOntologyException(); } protected void throwFreshEntityExceptionIfNecessary(OWLObject... objects) {
protected void throwInconsistentOntologyExceptionIfNecessary() { if (!isConsistent() && m_configuration.throwInconsistentOntologyException) throw new InconsistentOntologyException(); }
public boolean isEntailed(OWLAxiom axiom) { checkPreConditions(axiom); if (!isConsistent()) return true; EntailmentChecker checker=new EntailmentChecker(this,getDataFactory()); return checker.entails(axiom); } public boolean isEntailed(Set<? extends OWLAxiom> axioms) {
@Override public boolean isEntailed(OWLAxiom axiom) { checkPreConditions(axiom); if (!isConsistent()) return true; EntailmentChecker checker=new EntailmentChecker(this,getDataFactory()); return checker.entails(axiom); } @Override
public NodeSet<OWLClass> getObjectPropertyDomains(OWLObjectPropertyExpression propertyExpression,boolean direct) { checkPreConditions(propertyExpression); classifyClasses(); if (!isConsistent()) return new OWLClassNodeSet(getBottomClassNode()); final Role role=H(propertyExpression);
public NodeSet<OWLClass> getObjectPropertyRanges(OWLObjectPropertyExpression propertyExpression,boolean direct) { checkPreConditions(propertyExpression); classifyClasses(); if (!isConsistent()) return new OWLClassNodeSet(getBottomClassNode()); final Role role=H(propertyExpression);
public Boolean visit(OWLHasKeyAxiom axiom) { reasoner.throwFreshEntityExceptionIfNecessary(axiom); reasoner.throwInconsistentOntologyExceptionIfNecessary(); if (!reasoner.isConsistent()) return true; OWLOntologyManager ontologyManager=OWLManager.createOWLOntologyManager(); OWLDataFactory factory=ontologyManager.getOWLDataFactory(); OWLIndividual individualA=factory.getOWLNamedIndividual(IRI.create("internal:named-fresh-individual-A")); OWLIndividual individualB=factory.getOWLNamedIndividual(IRI.create("internal:named-fresh-individual-B")); Set<OWLAxiom> axioms=new HashSet<OWLAxiom>(); axioms.add(factory.getOWLClassAssertionAxiom(axiom.getClassExpression(),individualA)); axioms.add(factory.getOWLClassAssertionAxiom(axiom.getClassExpression(),individualB)); int i=0; for (OWLObjectPropertyExpression p : axiom.getObjectPropertyExpressions()) { OWLIndividual tmp=factory.getOWLNamedIndividual(IRI.create("internal:named-fresh-individual-"+i)); axioms.add(factory.getOWLObjectPropertyAssertionAxiom(p,individualA,tmp)); axioms.add(factory.getOWLObjectPropertyAssertionAxiom(p,individualB,tmp)); i++; } for (OWLDataPropertyExpression p : axiom.getDataPropertyExpressions()) { OWLDatatype anonymousConstantsDatatype=factory.getOWLDatatype(IRI.create("internal:anonymous-constants")); OWLLiteral constant=factory.getOWLLiteral("internal:constant-"+i,anonymousConstantsDatatype); axioms.add(factory.getOWLDataPropertyAssertionAxiom(p,individualA,constant)); axioms.add(factory.getOWLDataPropertyAssertionAxiom(p,individualB,constant)); i++; } axioms.add(factory.getOWLDifferentIndividualsAxiom(individualA,individualB)); Tableau tableau=reasoner.getTableau(axioms.toArray(new OWLAxiom[axioms.size()])); return !tableau.isSatisfiable(true,true,null,null,null,null,null,ReasoningTaskDescription.isAxiomEntailed(axiom)); }
checkPreConditions(propertyExpression); classifyClasses(); if (!isConsistent()) return new OWLClassNodeSet(getBottomClassNode()); final Role role=H(propertyExpression);
if (propertyExpression.isOWLTopDataProperty() && isConsistent()) return new OWLDataPropertyNodeSet(new OWLDataPropertyNode(factory.getOWLBottomDataProperty())); else if (propertyExpression.isOWLBottomDataProperty() && isConsistent()) return new OWLDataPropertyNodeSet(new OWLDataPropertyNode(factory.getOWLTopDataProperty())); else
checkPreConditions(propertyExpression); classifyClasses(); if (!isConsistent()) return new OWLClassNodeSet(getBottomClassNode()); final Role role=H(propertyExpression);
reasoner.throwFreshEntityExceptionIfNecessary(axiom); reasoner.throwInconsistentOntologyExceptionIfNecessary(); if (!reasoner.isConsistent()) return Boolean.TRUE; OWLOntologyManager ontologyManager=OWLManager.createOWLOntologyManager();
if (propertyExpression.isOWLTopDataProperty() && isConsistent()) return new OWLDataPropertyNodeSet(new OWLDataPropertyNode(factory.getOWLBottomDataProperty())); else if (propertyExpression.isOWLBottomDataProperty() && isConsistent()) return new OWLDataPropertyNodeSet(new OWLDataPropertyNode(factory.getOWLTopDataProperty())); else
protected HierarchyNode<AtomicConcept> getHierarchyNode(OWLClassExpression classExpression) { checkPreConditions(classExpression); classifyClasses(); if (!isConsistent()) return m_atomicConceptHierarchy.getBottomNode(); else if (classExpression instanceof OWLClass) { AtomicConcept atomicConcept=H((OWLClass)classExpression); HierarchyNode<AtomicConcept> node=m_atomicConceptHierarchy.getNodeForElement(atomicConcept); if (node==null) node=new HierarchyNode<>(atomicConcept,Collections.singleton(atomicConcept),Collections.singleton(m_atomicConceptHierarchy.getTopNode()),Collections.singleton(m_atomicConceptHierarchy.getBottomNode())); return node; } else { OWLDataFactory factory=getDataFactory(); OWLClass queryConcept=factory.getOWLClass(IRI.create("internal:query-concept")); OWLAxiom classDefinitionAxiom=factory.getOWLEquivalentClassesAxiom(queryConcept,classExpression); final Tableau tableau=getTableau(classDefinitionAxiom); HierarchySearch.Relation<AtomicConcept> hierarchyRelation=(parent, child) ->{ Individual freshIndividual=Individual.createAnonymous("fresh-individual"); return !tableau.isSatisfiable(true,Collections.singleton(Atom.create(child,freshIndividual)),null,null,Collections.singleton(Atom.create(parent,freshIndividual)),null,ReasoningTaskDescription.isConceptSubsumedBy(child,parent)); }; HierarchyNode<AtomicConcept> extendedHierarchy=HierarchySearch.findPosition(hierarchyRelation,AtomicConcept.create("internal:query-concept"),m_atomicConceptHierarchy.getTopNode(),m_atomicConceptHierarchy.getBottomNode()); tableau.clearAdditionalDLOntology(); return extendedHierarchy; } }
protected HierarchyNode<AtomicConcept> getHierarchyNode(OWLClassExpression classExpression) { checkPreConditions(classExpression); classifyClasses(); if (!isConsistent()) return m_atomicConceptHierarchy.getBottomNode(); else if (classExpression instanceof OWLClass) { AtomicConcept atomicConcept=H((OWLClass)classExpression); HierarchyNode<AtomicConcept> node=m_atomicConceptHierarchy.getNodeForElement(atomicConcept); if (node==null) node=new HierarchyNode<AtomicConcept>(atomicConcept,Collections.singleton(atomicConcept),Collections.singleton(m_atomicConceptHierarchy.getTopNode()),Collections.singleton(m_atomicConceptHierarchy.getBottomNode())); return node; } else { OWLDataFactory factory=getDataFactory(); OWLClass queryConcept=factory.getOWLClass(IRI.create("internal:query-concept")); OWLAxiom classDefinitionAxiom=factory.getOWLEquivalentClassesAxiom(queryConcept,classExpression); final Tableau tableau=getTableau(classDefinitionAxiom); HierarchySearch.Relation<AtomicConcept> hierarchyRelation=new HierarchySearch.Relation<AtomicConcept>() { public boolean doesSubsume(AtomicConcept parent,AtomicConcept child) { Individual freshIndividual=Individual.createAnonymous("fresh-individual"); return !tableau.isSatisfiable(true,Collections.singleton(Atom.create(child,freshIndividual)),null,null,Collections.singleton(Atom.create(parent,freshIndividual)),null,ReasoningTaskDescription.isConceptSubsumedBy(child,parent)); } }; HierarchyNode<AtomicConcept> extendedHierarchy=HierarchySearch.findPosition(hierarchyRelation,AtomicConcept.create("internal:query-concept"),m_atomicConceptHierarchy.getTopNode(),m_atomicConceptHierarchy.getBottomNode()); tableau.clearAdditionalDLOntology(); return extendedHierarchy; } }
public boolean isSatisfiable(OWLClassExpression classExpression) { checkPreConditions(classExpression); if (!isConsistent()) return false; if (classExpression instanceof OWLClass && m_atomicConceptHierarchy!=null) { AtomicConcept concept=H((OWLClass)classExpression); HierarchyNode<AtomicConcept> node=m_atomicConceptHierarchy.getNodeForElement(concept); return node!=m_atomicConceptHierarchy.getBottomNode(); } else { OWLDataFactory factory=getDataFactory(); OWLIndividual freshIndividual=factory.getOWLAnonymousIndividual("fresh-individual"); OWLClassAssertionAxiom assertClassExpression=factory.getOWLClassAssertionAxiom(classExpression,freshIndividual); Tableau tableau=getTableau(assertClassExpression); return tableau.isSatisfiable(true,null,null,null,null,null,ReasoningTaskDescription.isConceptSatisfiable(classExpression)); } } protected boolean isSubClassOf(OWLClassExpression subClassExpression,OWLClassExpression superClassExpression) {
@Override public boolean isSatisfiable(OWLClassExpression classExpression) { checkPreConditions(classExpression); if (!isConsistent()) return false; if (classExpression instanceof OWLClass && m_atomicConceptHierarchy!=null) { AtomicConcept concept=H((OWLClass)classExpression); HierarchyNode<AtomicConcept> node=m_atomicConceptHierarchy.getNodeForElement(concept); return node!=m_atomicConceptHierarchy.getBottomNode(); } else { OWLDataFactory factory=getDataFactory(); OWLIndividual freshIndividual=factory.getOWLAnonymousIndividual("fresh-individual"); OWLClassAssertionAxiom assertClassExpression=factory.getOWLClassAssertionAxiom(classExpression,freshIndividual); Tableau tableau=getTableau(assertClassExpression); return tableau.isSatisfiable(true,null,null,null,null,null,ReasoningTaskDescription.isConceptSatisfiable(classExpression)); } } protected boolean isSubClassOf(OWLClassExpression subClassExpression,OWLClassExpression superClassExpression) {
@Override public Boolean visit(OWLDatatypeDefinitionAxiom axiom) { reasoner.throwInconsistentOntologyExceptionIfNecessary(); if (!reasoner.isConsistent()) return Boolean.TRUE; if (reasoner.m_dlOntology.hasDatatypes()) { OWLDataFactory df=reasoner.getDataFactory(); OWLIndividual freshIndividual=df.getOWLAnonymousIndividual("fresh-individual"); OWLDataProperty freshDataProperty=df.getOWLDataProperty(IRI.create("fresh-data-property")); OWLDataRange dataRange=axiom.getDataRange(); OWLDatatype dt=axiom.getDatatype(); OWLDataIntersectionOf dr1=df.getOWLDataIntersectionOf(df.getOWLDataComplementOf(dataRange),dt); OWLDataIntersectionOf dr2=df.getOWLDataIntersectionOf(df.getOWLDataComplementOf(dt),dataRange); OWLDataUnionOf union=df.getOWLDataUnionOf(dr1,dr2); OWLClassExpression c=df.getOWLDataSomeValuesFrom(freshDataProperty,union); OWLClassAssertionAxiom ax=df.getOWLClassAssertionAxiom(c,freshIndividual); Tableau tableau=reasoner.getTableau(ax); return Boolean.valueOf(!tableau.isSatisfiable(true,true,null,null,null,null,null,ReasoningTaskDescription.isAxiomEntailed(axiom))); } else return Boolean.FALSE; }
protected boolean isSubClassOf(OWLClassExpression subClassExpression,OWLClassExpression superClassExpression) { checkPreConditions(subClassExpression,superClassExpression); if (!isConsistent() || subClassExpression.isOWLNothing() || superClassExpression.isOWLThing()) return true; if (subClassExpression instanceof OWLClass && superClassExpression instanceof OWLClass) {
protected boolean isSubClassOf(OWLClassExpression subClassExpression,OWLClassExpression superClassExpression) { checkPreConditions(subClassExpression,superClassExpression); if (!isConsistent() || subClassExpression.isOWLNothing() || superClassExpression.isOWLThing()) return true; if (subClassExpression instanceof OWLClass && superClassExpression instanceof OWLClass) {
public Boolean visit(OWLDatatypeDefinitionAxiom axiom) { reasoner.throwInconsistentOntologyExceptionIfNecessary(); if (!reasoner.isConsistent()) return true; if (reasoner.m_dlOntology.hasDatatypes()) { OWLDataFactory factory=reasoner.getDataFactory(); OWLIndividual freshIndividual=factory.getOWLAnonymousIndividual("fresh-individual"); OWLDataProperty freshDataProperty=factory.getOWLDataProperty(IRI.create("fresh-data-property")); OWLDataRange dataRange=axiom.getDataRange(); OWLDatatype dt=axiom.getDatatype(); OWLDataIntersectionOf dr1=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dataRange),dt); OWLDataIntersectionOf dr2=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dt),dataRange); OWLDataUnionOf union=factory.getOWLDataUnionOf(dr1,dr2); OWLClassExpression c=factory.getOWLDataSomeValuesFrom(freshDataProperty,union); OWLClassAssertionAxiom ax=factory.getOWLClassAssertionAxiom(c,freshIndividual); Tableau tableau=reasoner.getTableau(ax); return !tableau.isSatisfiable(true,true,null,null,null,null,null,ReasoningTaskDescription.isAxiomEntailed(axiom)); } else return false; }