public OWLAxioms() { m_classes=new HashSet<OWLClass>(); m_objectProperties=new HashSet<OWLObjectProperty>(); m_objectPropertiesOccurringInOWLAxioms=new HashSet<OWLObjectProperty>(); m_complexObjectPropertyExpressions=new HashSet<OWLObjectPropertyExpression>(); m_dataProperties=new HashSet<OWLDataProperty>(); m_namedIndividuals=new HashSet<OWLNamedIndividual>(); m_conceptInclusions=new ArrayList<OWLClassExpression[]>(); m_dataRangeInclusions=new ArrayList<OWLDataRange[]>(); m_simpleObjectPropertyInclusions=new ArrayList<OWLObjectPropertyExpression[]>(); m_complexObjectPropertyInclusions=new ArrayList<ComplexObjectPropertyInclusion>(); m_disjointObjectProperties=new ArrayList<OWLObjectPropertyExpression[]>(); m_reflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_irreflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_asymmetricObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_disjointDataProperties=new ArrayList<OWLDataPropertyExpression[]>(); m_dataPropertyInclusions=new ArrayList<OWLDataPropertyExpression[]>(); m_facts=new HashSet<OWLIndividualAxiom>(); m_hasKeys=new HashSet<OWLHasKeyAxiom>(); m_definedDatatypesIRIs=new HashSet<String>(); m_rules=new HashSet<DisjunctiveRule>(); }
public OWLAxioms() { m_classes=new HashSet<OWLClass>(); m_objectProperties=new HashSet<OWLObjectProperty>(); m_objectPropertiesOccurringInOWLAxioms=new HashSet<OWLObjectProperty>(); m_complexObjectPropertyExpressions=new HashSet<OWLObjectPropertyExpression>(); m_dataProperties=new HashSet<OWLDataProperty>(); m_namedIndividuals=new HashSet<OWLNamedIndividual>(); m_aspConstraints=new HashSet<ASPConstraint>(); m_aspRules=new HashSet<ASPRule>(); m_conceptInclusions=new ArrayList<OWLClassExpression[]>(); m_dataRangeInclusions=new ArrayList<OWLDataRange[]>(); m_simpleObjectPropertyInclusions=new ArrayList<OWLObjectPropertyExpression[]>(); m_complexObjectPropertyInclusions=new ArrayList<ComplexObjectPropertyInclusion>(); m_disjointObjectProperties=new ArrayList<OWLObjectPropertyExpression[]>(); m_reflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_irreflexiveObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_asymmetricObjectProperties=new HashSet<OWLObjectPropertyExpression>(); m_disjointDataProperties=new ArrayList<OWLDataPropertyExpression[]>(); m_dataPropertyInclusions=new ArrayList<OWLDataPropertyExpression[]>(); m_facts=new HashSet<OWLIndividualAxiom>(); m_hasKeys=new HashSet<OWLHasKeyAxiom>(); m_definedDatatypesIRIs=new HashSet<String>(); m_rules=new HashSet<DisjunctiveRule>(); }
/** * Atomic clash */ public void testUnsatifiabilityDueToClashInABoxAssertions() { OWLDataFactory factory = OWLManager.getOWLDataFactory(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLClassExpression expr1 = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A"))); OWLClassExpression expr2 = factory.getOWLObjectComplementOf(expr1); OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a"))); OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(expr1, indiv); OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(expr2, indiv); try { OWLOntology ontology = manager.createOntology(); manager.addAxiom(ontology, fact1); manager.addAxiom(ontology, fact2); Wolpertinger wolpertinger = new Wolpertinger(ontology); assertFalse(wolpertinger.isConsistent()); } catch (OWLOntologyCreationException e) { e.printStackTrace(); fail(); } }
public int rewriteNegativeObjectPropertyAssertions(OWLDataFactory factory,OWLAxioms axioms,int replacementIndex) { // now object property inclusion manager added all non-simple properties to axioms.m_complexObjectPropertyExpressions // now that we know which roles are non-simple, we can decide which negative object property assertions have to be // expressed as concept assertions so that transitivity rewriting applies properly. All new concepts for the concept // assertions must be normalised, because we are done with the normal normalisation phase. Set<OWLIndividualAxiom> redundantFacts=new HashSet<OWLIndividualAxiom>(); Set<OWLIndividualAxiom> additionalFacts=new HashSet<OWLIndividualAxiom>(); for (OWLIndividualAxiom axiom : axioms.m_facts) { if (axiom instanceof OWLNegativeObjectPropertyAssertionAxiom) { OWLNegativeObjectPropertyAssertionAxiom negAssertion=(OWLNegativeObjectPropertyAssertionAxiom)axiom; OWLObjectPropertyExpression prop=negAssertion.getProperty().getSimplified(); if (axioms.m_complexObjectPropertyExpressions.contains(prop)) { // turn not op(a b) into // C(a) and not C or forall op not{b} OWLIndividual individual=negAssertion.getObject(); // neg. op assertions cannot contain anonymous individuals OWLClass individualConcept=factory.getOWLClass(IRI.create("internal:nom#"+individual.asOWLNamedIndividual().getIRI().toString())); OWLClassExpression notIndividualConcept=factory.getOWLObjectComplementOf(individualConcept); OWLClassExpression allNotIndividualConcept=factory.getOWLObjectAllValuesFrom(prop,notIndividualConcept); OWLClassExpression definition=factory.getOWLClass(IRI.create("internal:def#"+(replacementIndex++))); axioms.m_conceptInclusions.add(new OWLClassExpression[] { factory.getOWLObjectComplementOf(definition), allNotIndividualConcept }); additionalFacts.add(factory.getOWLClassAssertionAxiom(definition,negAssertion.getSubject())); additionalFacts.add(factory.getOWLClassAssertionAxiom(individualConcept,individual)); redundantFacts.add(negAssertion); } } } axioms.m_facts.addAll(additionalFacts); axioms.m_facts.removeAll(redundantFacts); return replacementIndex; }
public void testUnsatisfiabilityDuetoSimpleSubsumptionViolation() { OWLDataFactory factory = OWLManager.getOWLDataFactory(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLClassExpression classA = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A"))); OWLClassExpression classB = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "B"))); OWLClassExpression complClassB = factory.getOWLObjectComplementOf(classB); OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a"))); OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(classA, indiv); OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(complClassB, indiv); OWLSubClassOfAxiom subClOf = factory.getOWLSubClassOfAxiom(classA, classB); try { OWLOntology ontology = manager.createOntology(); manager.addAxiom(ontology, fact1); manager.addAxiom(ontology, fact2); manager.addAxiom(ontology, subClOf); Wolpertinger wolpertinger = new Wolpertinger(ontology); assertFalse(wolpertinger.isConsistent()); } catch (OWLOntologyCreationException e) { e.printStackTrace(); fail(); } }
/** * Smth like: * A subClassOf B * A subClassOf C * C disjoint with B * ... */ public void testUnsatisfiabilityDueToConflictingAxioms1() { OWLDataFactory factory = OWLManager.getOWLDataFactory(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLClassExpression classA = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A"))); OWLClassExpression classB = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "B"))); OWLClassExpression classC = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "C"))); OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a"))); OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(classA, indiv); OWLSubClassOfAxiom axmAsubB = factory.getOWLSubClassOfAxiom(classA, classB); OWLSubClassOfAxiom axmAsubC = factory.getOWLSubClassOfAxiom(classA, classC); OWLDisjointClassesAxiom axmBdisC = factory.getOWLDisjointClassesAxiom(classB, classC); try { OWLOntology ontology = manager.createOntology(); manager.addAxiom(ontology, fact1); manager.addAxiom(ontology, axmAsubB); manager.addAxiom(ontology, axmAsubC); manager.addAxiom(ontology, axmBdisC); Wolpertinger wolpertinger = new Wolpertinger(ontology); assertFalse(wolpertinger.isConsistent()); } catch (OWLOntologyCreationException e) { e.printStackTrace(); fail(); } }
/** * Smth like * A subClassOf r min 5 B * But we have only a domain with 4 elements ... */ public void testUnsatisfiabilityDoToFixedDomain1() { OWLDataFactory factory = OWLManager.getOWLDataFactory(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLClassExpression classA = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A"))); OWLClassExpression classB = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "B"))); OWLObjectPropertyExpression roleR = factory.getOWLObjectProperty(IRI.create(String.format("%s#%s", PREFIX, "r"))); OWLNamedIndividual indA = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a"))); OWLNamedIndividual indB = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "b"))); OWLNamedIndividual indC = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "c"))); OWLNamedIndividual indD = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "d"))); OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(classA, indA); OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(classA, indB); OWLIndividualAxiom fact3 = factory.getOWLClassAssertionAxiom(classA, indC); OWLIndividualAxiom fact4 = factory.getOWLClassAssertionAxiom(classA, indD); OWLObjectMinCardinality exprRmin5B = factory.getOWLObjectMinCardinality(5, roleR, classB); OWLSubClassOfAxiom axmAsubRsomeB = factory.getOWLSubClassOfAxiom(classA, exprRmin5B); try { OWLOntology ontology = manager.createOntology(); manager.addAxiom(ontology, fact1); manager.addAxiom(ontology, fact2); manager.addAxiom(ontology, fact3); manager.addAxiom(ontology, fact4); manager.addAxiom(ontology, axmAsubRsomeB); Wolpertinger wolpertinger = new Wolpertinger(ontology); assertFalse(wolpertinger.isConsistent()); } catch (OWLOntologyCreationException e) { e.printStackTrace(); fail(); } }
protected void addFact(OWLIndividualAxiom axiom) { m_axioms.m_facts.add(axiom); }
public void clausify(OWLIndividualAxiom... axioms) { m_positiveFacts.clear(); m_negativeFacts.clear(); for (OWLIndividualAxiom fact : axioms) fact.accept(this); }
@SuppressWarnings("static-method") public ElkAssertionAxiom convert(OWLIndividualAxiom owlIndividualAxiom) { return owlIndividualAxiom.accept(OWL_INDIVIDUAL_AXIOM_CONVERTER); }
private OWLOntology createSimpleGraphColoring() { OWLOntology ontoColoring = null; OWLDataFactory factory = OWLManager.getOWLDataFactory(); OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); OWLObjectPropertyExpression edgeProp = factory.getOWLObjectProperty(IRI.create(String.format("%s#%s", PREFIX, "edge"))); OWLClassExpression classNode = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Node"))); OWLClassExpression classBlue = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Blue"))); OWLClassExpression classRed = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Red"))); OWLClassExpression classGreen = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "Green"))); OWLNamedIndividual indNode1 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node1"))); OWLNamedIndividual indNode2 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node2"))); OWLNamedIndividual indNode3 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node3"))); OWLNamedIndividual indNode4 = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "node4"))); // now the facts // nodes OWLIndividualAxiom axmNodeInst4 =factory.getOWLClassAssertionAxiom(classNode, indNode4); OWLIndividualAxiom axmNodeInst3 =factory.getOWLClassAssertionAxiom(classNode, indNode3); OWLIndividualAxiom axmNodeInst2 =factory.getOWLClassAssertionAxiom(classNode, indNode2); OWLIndividualAxiom axmNodeInst1 =factory.getOWLClassAssertionAxiom(classNode, indNode1); // 1 // | \ // | 3 - 4 // | / // 2 // OWLIndividualAxiom axmEdge12 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode1, indNode2); OWLIndividualAxiom axmEdge13 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode1, indNode3); OWLIndividualAxiom axmEdge23 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode2, indNode3); OWLIndividualAxiom axmEdge34 = factory.getOWLObjectPropertyAssertionAxiom(edgeProp, indNode3, indNode4); // symmetry of edge property OWLObjectPropertyAxiom axmEdgeSym = factory.getOWLSymmetricObjectPropertyAxiom(edgeProp); // axioms OWLObjectUnionOf exprColorUnion = factory.getOWLObjectUnionOf(classBlue, classRed, classGreen); OWLSubClassOfAxiom axmNodeColorings = factory.getOWLSubClassOfAxiom(classNode, exprColorUnion); // coloring constraints OWLSubClassOfAxiom axmRedConstraint = factory.getOWLSubClassOfAxiom(classRed, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classGreen, classBlue))); OWLSubClassOfAxiom axmBlueConstraint = factory.getOWLSubClassOfAxiom(classBlue, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classGreen, classRed))); OWLSubClassOfAxiom axmGreenConstraint = factory.getOWLSubClassOfAxiom(classGreen, factory.getOWLObjectAllValuesFrom(edgeProp, factory.getOWLObjectUnionOf(classRed, classBlue))); OWLDisjointClassesAxiom axmDisColors = factory.getOWLDisjointClassesAxiom(classRed, classBlue, classGreen); try { ontoColoring = manager.createOntology(); manager.addAxiom(ontoColoring, axmNodeInst1); manager.addAxiom(ontoColoring, axmNodeInst2); manager.addAxiom(ontoColoring, axmNodeInst3); manager.addAxiom(ontoColoring, axmNodeInst4); manager.addAxiom(ontoColoring, axmEdge12); manager.addAxiom(ontoColoring, axmEdge13); manager.addAxiom(ontoColoring, axmEdge23); manager.addAxiom(ontoColoring, axmEdge34); manager.addAxiom(ontoColoring, axmEdgeSym); manager.addAxiom(ontoColoring, axmNodeColorings); manager.addAxiom(ontoColoring, axmRedConstraint); manager.addAxiom(ontoColoring, axmBlueConstraint); manager.addAxiom(ontoColoring, axmGreenConstraint); manager.addAxiom(ontoColoring, axmDisColors); } catch (OWLOntologyCreationException e) { e.printStackTrace(); } return ontoColoring; }