Java Code Examples for org.semanticweb.owlapi.apibinding.OWLManager#createConcurrentOWLOntologyManager()

The following examples show how to use org.semanticweb.owlapi.apibinding.OWLManager#createConcurrentOWLOntologyManager() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 6 votes vote down vote up
@Test
public void inconsistentOwlThing() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	// top subclass bottom => inconsistent
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(
			factory.getOWLThing(), factory.getOWLNothing()));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(
					factory.getOWLObjectIntersectionOf(a, b),
					factory.getOWLNothing()));
}
 
Example 2
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 6 votes vote down vote up
@Test
public void inconsistentIndividual() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLNamedIndividual ind = factory
			.getOWLNamedIndividual(IRI.create("http://example.org/i"));
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	// ind instance of bottom => inconsistent
	owlManager.addAxiom(ontology, factory
			.getOWLClassAssertionAxiom(factory.getOWLNothing(), ind));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(
					factory.getOWLObjectIntersectionOf(a, b),
					factory.getOWLNothing()));
}
 
Example 3
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 6 votes vote down vote up
@Test
public void inconsistentClass() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	// A subclass of bottom => A is inconsistent
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(a, factory.getOWLNothing()));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
}
 
Example 4
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 6 votes vote down vote up
@Test
public void emptyDisjointUnion() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	// DisjointUnion(A ) = EquivalentClasses(A owl:Nothing)
	owlManager.addAxiom(ontology, factory.getOWLDisjointUnionAxiom(a,
			Collections.<OWLClassExpression> emptySet()));
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(b, b));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
}
 
Example 5
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Test
public void emptyConjunction() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	OWLClass d = factory.getOWLClass(IRI.create("http://example.org/D"));
	// ObjectInteresectionOf() = owl:Thing
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(a,
			factory.getOWLObjectIntersectionOf()));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(b, factory.getOWLThing()));
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(
			factory.getOWLObjectIntersectionOf(), c));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(factory.getOWLThing(), d));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, c));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, d));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, c));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, d));
}
 
Example 6
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Test
public void emptyDisjunction() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	// ObjectUnionOf() = owl:Nothing
	owlManager.addAxiom(ontology, factory.getOWLSubClassOfAxiom(a,
			factory.getOWLObjectUnionOf()));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(b, factory.getOWLNothing()));
	owlManager.addAxiom(ontology, factory
			.getOWLSubClassOfAxiom(factory.getOWLObjectUnionOf(), c));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, a));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, c));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, c));
}
 
Example 7
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 5 votes vote down vote up
@Test
public void emptyEnumeration() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	// creating an ontology
	final OWLOntology ontology = owlManager.createOntology();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	// ObjectOneOf() = owl:Nothing
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(a, factory.getOWLObjectOneOf()));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(b, factory.getOWLNothing()));
	owlManager.addAxiom(ontology,
			factory.getOWLSubClassOfAxiom(factory.getOWLObjectOneOf(), c));

	final OWLProver prover = OWLAPITestUtils.createProver(ontology);

	prover.precomputeInferences(InferenceType.CLASS_HIERARCHY);

	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, b));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, a));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(a, c));
	ProofTestUtils.provabilityTest(prover,
			factory.getOWLSubClassOfAxiom(b, c));
}
 
Example 8
Source File: ProofTest.java    From elk-reasoner with Apache License 2.0 4 votes vote down vote up
@Test
public void proofListener() throws Exception {
	OWLOntologyManager owlManager = OWLManager
			.createConcurrentOWLOntologyManager();
	OWLClass a = factory.getOWLClass(IRI.create("http://example.org/A"));
	OWLClass b = factory.getOWLClass(IRI.create("http://example.org/B"));
	OWLClass c = factory.getOWLClass(IRI.create("http://example.org/C"));
	OWLObjectProperty r = factory
			.getOWLObjectProperty(IRI.create("http://example.org/R"));
	OWLObjectProperty s = factory
			.getOWLObjectProperty(IRI.create("http://example.org/S"));
	OWLAxiom ax1 = factory.getOWLSubClassOfAxiom(a, c);
	OWLAxiom ax2 = factory.getOWLSubClassOfAxiom(c, b);
	OWLAxiom ax3 = factory.getOWLSubClassOfAxiom(a,
			factory.getOWLObjectSomeValuesFrom(r, c));
	OWLAxiom ax4 = factory.getOWLSubClassOfAxiom(
			factory.getOWLObjectSomeValuesFrom(s, c), b);
	OWLAxiom ax5 = factory.getOWLSubObjectPropertyOfAxiom(r, s);

	boolean changed = false; // means entailment has changed

	for (boolean bufferringMode : Arrays.asList(true, false)) {
		// creating an ontology
		final OWLOntology ontology = owlManager.createOntology();

		final OWLProver prover = OWLAPITestUtils.createProver(
				OWLAPITestUtils.createReasoner(ontology, bufferringMode));
		OWLSubClassOfAxiom entailment = factory.getOWLSubClassOfAxiom(a, b);
		DynamicProof<? extends Inference<OWLAxiom>> proof = prover
				.getProof(entailment);
		ProofChangeTracker tracker = new ProofChangeTracker();
		proof.addListener(tracker);

		assertFalse(Proofs.isDerivable(proof, entailment));

		// add ax1 and ax2 => ENTAIL
		owlManager.applyChanges(Arrays.asList(new AddAxiom(ontology, ax1),
				new AddAxiom(ontology, ax2)));

		// derivable only in non-buffering mode
		changed = tracker.changed();
		assertEquals(!bufferringMode, changed);
		assertEquals(!bufferringMode,
				Proofs.isDerivable(proof, entailment));
		// but always derivable after flush
		prover.flush();
		changed |= tracker.changed();
		assertTrue(changed);
		assertTrue(Proofs.isDerivable(proof, entailment));

		// remove ax1, add ax3, ax4 => NOT ENTAIL
		owlManager.applyChanges(Arrays.asList(
				new RemoveAxiom(ontology, ax1), new AddAxiom(ontology, ax3),
				new AddAxiom(ontology, ax4)));

		// still derivable only in bufferring mode
		changed = tracker.changed();
		assertEquals(!bufferringMode, changed);
		assertEquals(bufferringMode, Proofs.isDerivable(proof, entailment));
		// always non derivable after flush
		prover.flush();
		changed |= tracker.changed();
		assertTrue(changed);
		assertFalse(Proofs.isDerivable(proof, entailment));

		// add ax5 => ENTAIL
		owlManager.applyChanges(Arrays.asList(new AddAxiom(ontology, ax5)));

		// derivable only in non-buffering mode
		changed = tracker.changed();
		assertEquals(!bufferringMode, changed);
		assertEquals(!bufferringMode,
				Proofs.isDerivable(proof, entailment));
		// but always derivable after flush
		prover.flush();
		changed |= tracker.changed();
		assertTrue(changed);
		assertTrue(Proofs.isDerivable(proof, entailment));

	}

}