public void testFamily() throws OWLException {
String ns = "http://www.example.org/family#";
OWLOntology ont = loadOntology( base + "family.owl" );
Reasoner reasoner = new Reasoner( OWL.manager );
reasoner.setOntology( ont );
OWLObjectProperty hasBrother = ObjectProperty( ns + "hasBrother" );
OWLObjectProperty hasSon = ObjectProperty( ns + "hasSon" );
OWLObjectProperty hasFather = ObjectProperty( ns + "hasFather" );
OWLObjectProperty hasParent = ObjectProperty( ns + "hasParent" );
OWLObjectProperty hasChild = ObjectProperty( ns + "hasChild" );
OWLObjectProperty hasMother = ObjectProperty( ns + "hasMother" );
OWLObjectProperty hasDaughter = ObjectProperty( ns + "hasDaughter" );
OWLObjectProperty hasAncestor = ObjectProperty( ns + "hasAncestor" );
OWLObjectProperty likes = ObjectProperty( ns + "likes" );
OWLObjectProperty isMarriedTo = ObjectProperty( ns + "isMarriedTo" );
OWLObjectProperty dislikes = ObjectProperty( ns + "dislikes" );
OWLObjectProperty hasSister = ObjectProperty( ns + "hasSister" );
OWLObjectProperty hasDescendant = ObjectProperty( ns + "hasDescendant" );
OWLObjectProperty hasSibling = ObjectProperty( ns + "hasSibling" );
OWLClass Child = Class( ns + "Child" );
OWLClass Person = Class( ns + "Person" );
OWLClass PersonWithAtLeastTwoMaleChildren = Class( ns + "PersonWithAtLeastTwoMaleChildren" );
OWLClass PersonWithAtLeastTwoFemaleChildren = Class( ns
+ "PersonWithAtLeastTwoFemaleChildren" );
OWLClass PersonWithAtLeastTwoChildren = Class( ns + "PersonWithAtLeastTwoChildren" );
OWLClass PersonWithAtLeastFourChildren = Class( ns + "PersonWithAtLeastFourChildren" );
OWLClass Teen = Class( ns + "Teen" );
OWLClass Teenager = Class( ns + "Teenager" );
OWLClass Male = Class( ns + "Male" );
OWLClass Adult = Class( ns + "Adult" );
OWLClass Female = Class( ns + "Female" );
OWLClass Senior = Class( ns + "Senior" );
OWLIndividual grandmother = Individual( ns + "grandmother" );
OWLIndividual grandfather = Individual( ns + "grandfather" );
OWLIndividual father = Individual( ns + "father" );
OWLIndividual son = Individual( ns + "son" );
OWLIndividual mother = Individual( ns + "mother" );
OWLIndividual daughter = Individual( ns + "daughter" );
OWLIndividual personX = Individual( ns + "personX" );
OWLIndividual personY = Individual( ns + "personY" );
OWLIndividual personZ = Individual( ns + "personZ" );
assertTrue( reasoner.isConsistent() );
KnowledgeBase kb = reasoner.getKB();
for( int test = 0; test < 2; test++ ) {
if( test != 0 )
kb.realize();
assertTrue( reasoner.isTransitive( hasAncestor ) );
assertFalse( reasoner.isFunctional( hasAncestor ) );
assertTrue( reasoner.isTransitive( hasDescendant ) );
assertFalse( reasoner.isFunctional( hasDescendant ) );
assertTrue( reasoner.isSymmetric( isMarriedTo ) );
assertTrue( reasoner.isIrreflexive( isMarriedTo ) );
assertTrue( reasoner.isSubPropertyOf( hasParent, hasAncestor ) );
assertTrue( reasoner.isSubPropertyOf( hasFather, hasAncestor ) );
assertTrue( reasoner.isSubPropertyOf( hasMother, hasAncestor ) );
assertTrue( reasoner.isSubPropertyOf( hasChild, hasDescendant ) );
assertTrue( reasoner.isDisjointWith( likes, dislikes ) );
assertTrue( reasoner.isDisjointWith( dislikes, likes ) );
assertTrue( reasoner.isDisjointWith( hasFather, hasMother ) );
assertTrue( reasoner.isDisjointWith( hasMother, hasFather ) );
assertTrue( reasoner.hasType( grandfather, Person ) );
assertTrue( reasoner.hasType( grandfather, PersonWithAtLeastTwoChildren ) );
assertTrue( reasoner.hasType( grandfather, PersonWithAtLeastTwoMaleChildren ) );
assertTrue( reasoner.hasType( grandfather, Male ) );
assertTrue( reasoner.hasType( grandfather, Senior ) );
assertTrue( reasoner.hasObjectPropertyRelationship( grandfather, isMarriedTo,
grandmother ) );
assertTrue( reasoner.hasObjectPropertyRelationship( grandfather, hasChild, father ) );
assertTrue( reasoner.hasObjectPropertyRelationship( grandfather, hasSon, father ) );
assertTrue( reasoner.isDifferentFrom( grandfather, grandmother ) );
assertTrue( reasoner.isDifferentFrom( grandfather, father ) );
assertTrue( reasoner.isDifferentFrom( grandfather, mother ) );
assertTrue( reasoner.isDifferentFrom( grandfather, son ) );
assertTrue( reasoner.isDifferentFrom( grandfather, daughter ) );
assertTrue( reasoner.hasType( grandmother, Person ) );
assertTrue( reasoner.hasType( grandmother, Female ) );
assertTrue( reasoner.hasType( grandmother, Senior ) );
assertTrue( reasoner.hasObjectPropertyRelationship( grandmother, isMarriedTo,
grandfather ) );
assertTrue( reasoner.hasObjectPropertyRelationship( grandmother, hasChild, father ) );
assertFalse( reasoner.hasObjectPropertyRelationship( grandmother, hasSon, father ) );
assertTrue( reasoner.hasType( father, Person ) );
assertTrue( reasoner.hasType( father, Male ) );
assertTrue( reasoner.hasType( father, Adult ) );
assertTrue( reasoner.hasObjectPropertyRelationship( father, hasParent, grandfather ) );
assertTrue( reasoner.hasObjectPropertyRelationship( father, hasParent, grandmother ) );
assertTrue( reasoner.hasObjectPropertyRelationship( father, hasFather, grandfather ) );
assertTrue( reasoner.hasObjectPropertyRelationship( father, hasMother, grandmother ) );
assertTrue( reasoner.hasObjectPropertyRelationship( father, hasChild, son ) );
assertTrue( reasoner.hasObjectPropertyRelationship( father, hasSon, son ) );
assertTrue( reasoner.hasObjectPropertyRelationship( father, hasChild, daughter ) );
assertFalse( reasoner.hasObjectPropertyRelationship( father, hasDaughter, daughter ) );
assertTrue( reasoner.hasType( mother, Person ) );
assertTrue( reasoner.hasType( mother, Female ) );
assertTrue( reasoner.hasType( son, Male ) );
assertTrue( reasoner.hasType( son, Teenager ) );
// assertTrue( reasoner.hasType( son, Teen ) );
assertTrue( reasoner.hasObjectPropertyRelationship( son, hasParent, father ) );
assertTrue( reasoner.hasObjectPropertyRelationship( son, hasFather, father ) );
assertTrue( reasoner.hasObjectPropertyRelationship( son, hasSibling, daughter ) );
assertTrue( reasoner.hasObjectPropertyRelationship( son, hasSister, daughter ) );
assertTrue( reasoner.hasType( daughter, Female ) );
assertTrue( reasoner.hasType( daughter, Child ) );
assertTrue( reasoner.hasObjectPropertyRelationship( daughter, hasAncestor, grandfather ) );
assertTrue( reasoner.hasObjectPropertyRelationship( daughter, hasAncestor, grandmother ) );
assertTrue( reasoner.hasObjectPropertyRelationship( daughter, hasParent, father ) );
assertTrue( reasoner.hasObjectPropertyRelationship( daughter, hasFather, father ) );
assertTrue( reasoner.hasObjectPropertyRelationship( daughter, hasParent, mother ) );
assertTrue( reasoner.hasObjectPropertyRelationship( daughter, hasMother, mother ) );
assertTrue( reasoner.hasObjectPropertyRelationship( daughter, hasSibling, son ) );
assertFalse( reasoner.hasObjectPropertyRelationship( daughter, hasBrother, son ) );
assertTrue( reasoner.isDifferentFrom( personX, personY ) );
assertTrue( reasoner.isDifferentFrom( personX, personZ ) );
assertTrue( reasoner.isDifferentFrom( personY, personZ ) );
// assertTrue( reasoner.isEquivalentClass( Teen, Teenager ) );
assertTrue( reasoner.isSubClassOf( Senior, Adult ) );
assertTrue( reasoner.isSubClassOf( PersonWithAtLeastTwoMaleChildren, Person ) );
assertTrue( reasoner.isSubClassOf( PersonWithAtLeastTwoFemaleChildren, Person ) );
assertTrue( reasoner.isSubClassOf( PersonWithAtLeastTwoChildren, Person ) );
assertTrue( reasoner.isSubClassOf( PersonWithAtLeastFourChildren, Person ) );
assertTrue( reasoner.isSubClassOf( PersonWithAtLeastFourChildren,
PersonWithAtLeastTwoChildren ) );
assertTrue( reasoner.isSubClassOf( PersonWithAtLeastTwoMaleChildren,
PersonWithAtLeastTwoChildren ) );
assertTrue( reasoner.isSubClassOf( PersonWithAtLeastTwoFemaleChildren,
PersonWithAtLeastTwoChildren ) );
assertFalse( reasoner.isSubClassOf( PersonWithAtLeastTwoFemaleChildren,
PersonWithAtLeastTwoMaleChildren ) );
assertFalse( reasoner.isSubClassOf( PersonWithAtLeastTwoMaleChildren,
PersonWithAtLeastTwoFemaleChildren ) );
}
// kb.timers.print();
}