private static Collection<ATermAppl> getSatisfiableDecimalRanges() { final ATermAppl dt1 = restrict(DECIMAL, minInclusive(literal("1.0", DECIMAL)), maxInclusive(literal("3.0", DECIMAL))); final ATermAppl dt2 = restrict(DECIMAL, minInclusive(literal("2.0", DECIMAL)), maxInclusive(literal("4.0", DECIMAL))); final Collection<ATermAppl> dataranges = Arrays.asList(dt1, dt2); return dataranges; }
private static Collection<ATermAppl> getUnsatisfiableDecimalRanges() { final ATermAppl dt1 = restrict(DECIMAL, minInclusive(literal("1.0", DECIMAL)), maxInclusive(literal("3.0", DECIMAL))); final ATermAppl dt2 = restrict(DECIMAL, minInclusive(literal("4.0", DECIMAL)), maxInclusive(literal("6.0", DECIMAL))); final Collection<ATermAppl> dataranges = Arrays.asList(dt1, dt2); return dataranges; }
@Test public void unionWithEmptyDatatype() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl dt1 = restrict(INTEGER, minInclusive(literal(1)), maxInclusive(literal(3))); final ATermAppl dt2 = restrict(INTEGER, minInclusive(literal(4)), maxInclusive(literal(6))); final ATermAppl dt3 = and(NEGATIVE_INTEGER, POSITIVE_INTEGER); final ATermAppl datarange = or(dt1, dt2, dt3); assertTrue(reasoner.isSatisfiable(Collections.singleton(datarange))); assertTrue(reasoner.containsAtLeast(6, Collections.singleton(datarange))); assertFalse(reasoner.containsAtLeast(7, Collections.singleton(datarange))); }
@Test public void intersectNegatedFloatInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatInterval1 = restrict(FLOAT, minInclusive(literal(0.0f)), maxInclusive(literal(1.0f))); final ATermAppl floatInterval2 = restrict(FLOAT, minInclusive(literal(2.0f)), maxInclusive(literal(3.0f))); assertSatisfiable(floatInterval1, not(floatInterval2)); }
@Test public void intersectNegatedIntegerInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl intInterval1 = restrict(INTEGER, minInclusive(literal(0)), maxInclusive(literal(1))); final ATermAppl intInterval2 = restrict(INTEGER, minInclusive(literal(2)), maxInclusive(literal(3))); assertSatisfiable(intInterval1, not(intInterval2)); }
@Test public void intersectNegatedDoubleInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl doubleInterval1 = restrict(DOUBLE, minInclusive(literal(0.0)), maxInclusive(literal(1.0))); final ATermAppl doubleInterval2 = restrict(DOUBLE, minInclusive(literal(2.0)), maxInclusive(literal(3.0))); assertSatisfiable(doubleInterval1, not(doubleInterval2)); }
@Test public void intersectFloatAndFloatInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatInterval = restrict(FLOAT, minInclusive(literal(0.0f)), maxInclusive(literal(1.0f))); assertSatisfiable(floatInterval, FLOAT, LITERAL); }
@Test public void floatInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatInterval = restrict(FLOAT, minInclusive(literal(1.0f)), maxExclusive(literal(2.0f))); assertFalse(reasoner.isSatisfiable(Collections.singleton(not(floatInterval)), 1.0f)); assertFalse(reasoner.isSatisfiable(Collections.singleton(not(floatInterval)), 1.5f)); assertTrue(reasoner.isSatisfiable(Collections.singleton(not(floatInterval)), 2.0f)); }
@Ignore("See ticket #524") @Test public void incomparableDateTime() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl d = restrict(DATE_TIME, minInclusive(literal("1956-01-01T04:00:00-05:00", DATE_TIME))); assertTrue(reasoner.isSatisfiable(Collections.singleton(d))); assertTrue(reasoner.isSatisfiable(Collections.singleton(d), reasoner.getValue(literal("1956-01-01T10:00:00", DATE_TIME)))); assertFalse(reasoner.isSatisfiable(Collections.singleton(d), reasoner.getValue(literal("1956-01-01T10:00:00Z", DATE_TIME)))); }
@Test public void intersectDoubleIntervalNotDouble() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl doubleInterval = restrict(DOUBLE, minInclusive(literal(0.0)), maxInclusive(literal(1.0))); assertUnsatisfiable(doubleInterval, not(DOUBLE)); }
@Ignore("Equal but not identical semantics is very counter-intuitive and currently Pellet treats equals values as identical") @Test public void equalbutNotIdenticalDateTime() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl d = restrict(DATE_TIME, minInclusive(literal("1956-06-25T04:00:00-05:00", DATE_TIME)), maxInclusive(literal("1956-06-25T04:00:00-05:00", DATE_TIME))); assertTrue(reasoner.isSatisfiable(Collections.singleton(d))); assertTrue(reasoner.isSatisfiable(Collections.singleton(d), reasoner.getValue(literal("1956-06-25T04:00:00-05:00", DATE_TIME)))); assertFalse(reasoner.isSatisfiable(Collections.singleton(d), reasoner.getValue(literal("1956-06-25T10:00:00+01:00", DATE_TIME)))); }
@Test public void testRestrictedDatatypeRange() { classes(_C, _D); dataProperties(_p); individuals(_a, _b, _c); _kb.addRange(_p, restrict(Datatypes.INTEGER, minInclusive(literal(10)))); _kb.addPropertyValue(_p, _a, literal(5)); assertFalse(_kb.isConsistent()); final Set<ATermAppl> explanation = _kb.getExplanationSet(); assertIteratorValues(explanation.iterator(), new Object[] { ATermUtils.makeRange(_p, restrict(Datatypes.INTEGER, minInclusive(literal(10)))), ATermUtils.makePropAtom(_p, _a, literal(5)) }); }
@Test public void intersectIntegerIntervalNotInteger() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerInterval = restrict(INTEGER, minInclusive(literal(0)), maxInclusive(literal(1))); assertUnsatisfiable(integerInterval, not(INTEGER)); }
@Test public void intersectFloatIntervalNotFloat() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatInterval = restrict(FLOAT, minInclusive(literal(0.0f)), maxInclusive(literal(1.0f))); assertUnsatisfiable(floatInterval, not(FLOAT)); }
@Test public void intersectIntegerNegatedEmptyIntegerRange() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl type = not(restrict(INTEGER, minInclusive(literal("2", INTEGER)), maxInclusive(literal("1", INTEGER)))); final Collection<ATermAppl> types = Arrays.asList(INTEGER, type); assertTrue(reasoner.isSatisfiable(types)); assertTrue(reasoner.containsAtLeast(2, types)); }
@Test public void testDatatypeDefinitionInconsistency() { classes(_C); dataProperties(_p); individuals(_a, _b, _c); _kb.addRange(_p, _D); _kb.addDatatypeDefinition(_D, restrict(Datatypes.INTEGER, minInclusive(literal(10)))); _kb.addPropertyValue(_p, _a, literal(5)); explainInconsistency(ATermUtils.makeRange(_p, _D), ATermUtils.makeDatatypeDefinition(_D, restrict(Datatypes.INTEGER, minInclusive(literal(10)))), ATermUtils.makePropAtom(_p, _a, literal(5))); }
@Test public void testDatatypeDefinition() { classes(_A); dataProperties(_p); individuals(_a); _kb.addDatatypeDefinition(_D, restrict(Datatypes.INTEGER, minInclusive(literal(10)))); _kb.addPropertyValue(_p, _a, literal(15)); _kb.addEquivalentClass(_A, some(_p, _D)); explainEntailment(_kb.isType(_a, _A), ATermUtils.makeEqClasses(_A, some(_p, _D)), ATermUtils.makeDatatypeDefinition(_D, restrict(Datatypes.INTEGER, minInclusive(literal(10)))), ATermUtils.makePropAtom(_p, _a, literal(15))); }
@Test public void simpleRestriction() { classes(_C); dataProperties(_p); individuals(_a, _b); _kb.addDatatypeDefinition(_D, restrict(INTEGER, minInclusive(literal(1)))); _kb.addEquivalentClass(_C, some(_p, _D)); _kb.addPropertyValue(_p, _a, literal(2)); _kb.addPropertyValue(_p, _b, literal(3)); assertTrue(_kb.isType(_a, _C)); assertTrue(_kb.isType(_b, _C)); }
@Test public void nestedRestriction() { classes(_C); dataProperties(_p); individuals(_a, _b); _kb.addDatatypeDefinition(_E, restrict(INTEGER, maxInclusive(literal(2)))); _kb.addDatatypeDefinition(_D, restrict(_E, minInclusive(literal(1)))); _kb.addEquivalentClass(_C, some(_p, _D)); _kb.addPropertyValue(_p, _a, literal(2)); _kb.addPropertyValue(_p, _b, literal(3)); assertTrue(_kb.isType(_a, _C)); assertFalse(_kb.isType(_b, _C)); }
@Test(expected = RuntimeException.class) public void invalidRestriction() { classes(_C); dataProperties(_p); individuals(_a, _b); _kb.addDatatypeDefinition(_E, oneOf(literal(1), literal(2), literal(3))); _kb.addDatatypeDefinition(_D, restrict(_E, minInclusive(literal(1)))); _kb.addEquivalentClass(_C, some(_p, _D)); _kb.addPropertyValue(_p, _a, literal(2)); _kb.addPropertyValue(_p, _b, literal(3)); assertTrue(_kb.isType(_a, _C)); assertFalse(_kb.isType(_b, _C)); }