public void testDLSafeRules() throws OWLOntologyCreationException {
String ns = "http://owldl.com/ontologies/dl-safe.owl#";
OWLOntology ont = loadOntology( base + "dl-safe.owl" );
PelletReasoner reasoner = PelletReasonerFactory.getInstance().createReasoner( ont );
// OWLObjectProperty father = factory.getOWLObjectProperty( URI.create(
// ns + "father" ) );
OWLObjectProperty hates = ObjectProperty( ns + "hates" );
OWLObjectProperty sibling = ObjectProperty( ns + "sibling" );
OWLClass BadChild = Class( ns + "BadChild" );
OWLClass Child = Class( ns + "Child" );
// OWLClass GoodChild = Class( ns +
// "GoodChild" );
OWLClass Grandchild = Class( ns + "Grandchild" );
OWLClass Person = Class( ns + "Person" );
OWLNamedIndividual Abel = Individual( ns + "Abel" );
OWLNamedIndividual Cain = Individual( ns + "Cain" );
OWLNamedIndividual Oedipus = Individual( ns + "Oedipus" );
OWLNamedIndividual Remus = Individual( ns + "Remus" );
OWLNamedIndividual Romulus = Individual( ns + "Romulus" );
for( int test = 0; test < 2; test++ ) {
if( test != 0 ) {
reasoner.prepareReasoner();
}
assertTrue( reasoner.isEntailed( propertyAssertion( Abel, sibling, Cain ) ) );
assertPropertyValues( reasoner, Abel, sibling, Cain);
assertTrue( reasoner.isEntailed( propertyAssertion( Cain, sibling, Abel ) ) );
assertPropertyValues( reasoner, Cain, sibling, Abel );
assertTrue( reasoner.isEntailed( propertyAssertion( Cain, hates, Abel ) ) );
assertFalse( reasoner.isEntailed( propertyAssertion( Abel, hates, Cain ) ) );
assertTrue( reasoner.isEntailed( classAssertion( Cain, Grandchild ) ) );
assertTrue( reasoner.isEntailed( classAssertion( Cain, BadChild ) ) );
assertFalse( reasoner.isEntailed( propertyAssertion( Romulus, sibling, Remus ) ) );
assertTrue( reasoner.isEntailed( classAssertion( Romulus, Grandchild ) ) );
assertFalse( reasoner.isEntailed( classAssertion( Romulus, BadChild ) ) );
assertTrue( reasoner.isEntailed( classAssertion( Oedipus, Child ) ) );
}
assertIteratorValues( reasoner.getTypes( Cain, true ).getFlattened().iterator(),
new Object[] { BadChild, Child, Person } );
}