/* * Check advanced instance checking */ public void testTightLexicographicEntailment7() throws Exception { ProbKnowledgeBase pkb = new KBStandaloneLoader().load(FILE_PREFIX + "test_tlexent_4.xml"); ProntoReasoner reasoner = new BasicLexicographicReasoner(new PSATSolverImpl()); ConditionalConstraint lewisCC = reasoner.membershipEntailment( pkb, ATermUtils.makeTermAppl(URI_PREFIX + "Lewis"), ATermUtils.makeTermAppl(URI_PREFIX + "WingedFlying")); /* ConditionalConstraint awfCC = reasoner.subsumptionEntailment( pkb, ATermUtils .makeTermAppl( URI_PREFIX + "ArcticPenguin" ), ATermUtils.makeTermAppl( URI_PREFIX + "WingedFlying" ) ); */ /* ConditionalConstraint apfCC = reasoner.subsumptionEntailment( pkb, ATermUtils .makeTermAppl( URI_PREFIX + "ArcticPenguin" ), ATermUtils.makeTermAppl( URI_PREFIX + "FlyingObject" ) ); */ /* ConditionalConstraint lewisF = reasoner.membershipEntailment( pkb, ATermUtils .makeTermAppl( URI_PREFIX + "Lewis" ), ATermUtils .makeTermAppl( URI_PREFIX + "FlyingObject" ) ); ConditionalConstraint lewisW = reasoner.membershipEntailment( pkb, ATermUtils .makeTermAppl( URI_PREFIX + "Lewis" ), ATermUtils .makeTermAppl( URI_PREFIX + "WingedObject" ) ); */ assertEquals(0.03, lewisCC.getLowerBound(), 0.0001); assertEquals(0.46, lewisCC.getUpperBound(), 0.0001); }
/* * Check inheritance and overriding simultaneously */ public void testTightLexicographicEntailment5() throws Exception { ProbKnowledgeBase pkb = new KBStandaloneLoader().load(FILE_PREFIX + "test_tlexent_3.xml"); ProntoReasoner reasoner = new BasicLexicographicReasoner(new PSATSolverImpl()); ConditionalConstraint awfCC = reasoner.subsumptionEntailment( pkb, ATermUtils.makeTermAppl(URI_PREFIX + "ArcticPenguin"), ATermUtils.makeTermAppl(URI_PREFIX + "WingedFlying")); assertEquals(0.1, awfCC.getLowerBound(), 0.0001); assertEquals(0.5, awfCC.getUpperBound(), 0.0001); }
/* * Check the case of (D|C)[l_1,u_1] and (E|D)[l_2,u_2] */ public void testTightLexicographicEntailment4() throws Exception { ProbKnowledgeBase pkb = new KBStandaloneLoader().load(FILE_PREFIX + "test_tlexent_2.xml"); BasicLexicographicReasoner reasoner = new BasicLexicographicReasoner(new PSATSolverImpl()); ConditionalConstraint wfCC = reasoner.tightLexicographicEntailment( pkb.getPTBox(), null, ATermUtils.makeTermAppl(URI_PREFIX + "WingedObject"), ATermUtils.makeTermAppl(URI_PREFIX + "FlyingObject")); assertEquals(0.63, wfCC.getLowerBound(), 0.0001); assertEquals(0.965, wfCC.getUpperBound(), 0.0001); }
/* * Check that if KB |= C \in D then KB |=(lex) (C|D)[1,1] */ public void testTightLexicographicEntailment2() throws Exception { ProbKnowledgeBase pkb = new KBStandaloneLoader().load(FILE_PREFIX + "test_tlexent_1.xml"); BasicLexicographicReasoner reasoner = new BasicLexicographicReasoner(new PSATSolverImpl()); ConditionalConstraint apfCC = reasoner.tightLexicographicEntailment( pkb.getPTBox(), null, ATermUtils.makeTermAppl(URI_PREFIX + "ArcticPenguin"), ATermUtils.makeTermAppl(URI_PREFIX + "Bird")); assertEquals(1.0, apfCC.getLowerBound(), 0.0001); assertEquals(1.0, apfCC.getUpperBound(), 0.0001); }
/* * Check simple instance checking */ public void testTightLexicographicEntailment6() throws Exception { ProbKnowledgeBase pkb = new KBStandaloneLoader().load(FILE_PREFIX + "test_tlexent_5.xml"); ProntoReasoner reasoner = new BasicLexicographicReasoner(new PSATSolverImpl()); ConditionalConstraint tweetyCC = reasoner.membershipEntailment( pkb, ATermUtils.makeTermAppl(URI_PREFIX + "Tweety"), ATermUtils.makeTermAppl(URI_PREFIX + "FlyingObject")); assertEquals(0.28, tweetyCC.getLowerBound(), 0.0001); assertEquals(0.72, tweetyCC.getUpperBound(), 0.0001); }
/** * Membership entailment is supposed to check PABox consistency for that individual. And it must * fail in this case * * @throws Exception */ public void testNotAConsistent() throws Exception { ProbKnowledgeBase pkb = new KBStandaloneLoader().load(FILE_PREFIX + "test_membership_1.xml"); ProntoReasoner reasoner = new BasicLexicographicReasoner(new PSATSolverImpl()); boolean result = false; try { reasoner.membershipEntailment( pkb, ATermUtils.makeTermAppl(URI_PREFIX + "Lewis"), ATermUtils.makeTermAppl(URI_PREFIX + "Penguin")); } catch (RuntimeException e) { result = true; } assertTrue(result); }
public static UnknownDatatype create(String name) { UnknownDatatype unknown = (UnknownDatatype) instance.derive(instance.values, false); unknown.name = ATermUtils.makeTermAppl(name); return unknown; }
public UnknownDatatype() { super(ATermUtils.makeTermAppl("UnknownDatatype")); }
/** @author kolovski */ public class XSDDay extends BaseXSDAtomicType implements AtomicDatatype, XSDAtomicType { private static XSDatatype dt = null; private static IDateTimeValueType min = null; private static IDateTimeValueType max = null; static { try { dt = DatatypeFactory.getTypeByName("gDay"); min = (IDateTimeValueType) dt.createValue("---01", null); max = (IDateTimeValueType) dt.createValue("---31", null); } catch (DatatypeException e) { e.printStackTrace(); } } private static final ValueSpace DAY_VALUE_SPACE = new DayValueSpace(); private static class DayValueSpace extends AbstractDateTimeValueSpace implements ValueSpace { public DayValueSpace() { super(min, max, dt); } // return the difference in Days public int count(Object start, Object end) { BigDateTimeValueType calendarStart = ((IDateTimeValueType) start).getBigValue(); BigDateTimeValueType calendarEnd = ((IDateTimeValueType) end).getBigValue(); return calendarEnd.getDay().intValue() - calendarStart.getDay().intValue() + 1; } public Object succ(Object value, int n) { BigInteger bigN = new BigInteger(String.valueOf(n)); ITimeDurationValueType nDays = new BigTimeDurationValueType( NumberUtils.INTEGER_ZERO, NumberUtils.INTEGER_ZERO, bigN, NumberUtils.INTEGER_ZERO, NumberUtils.INTEGER_ZERO, NumberUtils.DECIMAL_ZERO); IDateTimeValueType s = ((IDateTimeValueType) value).add(nDays); return s; } } public static XSDDay instance = new XSDDay(ATermUtils.makeTermAppl(Namespaces.XSD + "gDay")); protected XSDDay(ATermAppl name) { super(name, DAY_VALUE_SPACE); } public BaseXSDAtomicType create(GenericIntervalList intervals) { XSDDay type = new XSDDay(null); type.values = intervals; return type; } public AtomicDatatype getPrimitiveType() { return instance; } }