protected void checkPreConditions(OWLObject... objects) { flushChangesIfRequired(); if (objects!=null && objects.length>0) throwFreshEntityExceptionIfNecessary(objects); throwInconsistentOntologyExceptionIfNecessary(); } protected void flushChangesIfRequired() {
protected void checkPreConditions(OWLObject... objects) { flushChangesIfRequired(); if (objects!=null && objects.length>0) throwFreshEntityExceptionIfNecessary(objects); throwInconsistentOntologyExceptionIfNecessary(); } protected void flushChangesIfRequired() {
@Override public Boolean visit(OWLHasKeyAxiom axiom) { reasoner.throwFreshEntityExceptionIfNecessary(axiom); reasoner.throwInconsistentOntologyExceptionIfNecessary(); if (!reasoner.isConsistent()) return Boolean.TRUE;
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)); }
@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; }
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; }