AtomDVariable z4 = new AtomDVariable( "z4" );
AtomDVariable z5 = new AtomDVariable( "z5" );
AtomDVariable z6 = new AtomDVariable( "z6" );
List<RuleAtom> body = new ArrayList<RuleAtom>();
body.add( new DatavaluedPropertyAtom( p, x, z1 ) );
body.add( new DatavaluedPropertyAtom( p, x, z2 ) );
body.add( new BuiltInAtom( SWRLB + "add", z3, z1, z2 ) );
body.add( new BuiltInAtom( SWRLB + "subtract", z4, z1, z2 ) );
body.add( new BuiltInAtom( SWRLB + "multiply", z5, z1, z2 ) );
body.add( new BuiltInAtom( SWRLB + "divide", z6, z1, z2 ) );
List<RuleAtom> head = new ArrayList<RuleAtom>();
head.add( new DatavaluedPropertyAtom( sum, x, z3 ) );
head.add( new DatavaluedPropertyAtom( difference, x, z4 ) );
head.add( new DatavaluedPropertyAtom( product, x, z5 ) );
head.add( new DatavaluedPropertyAtom( quotient, x, z6 ) );
Rule rule = new Rule( head, body );
kb.addRule( rule );
kb.realize();