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 floatRestrictionWithSevenValues() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatRestrictionWithSevenValues = restrict(FLOAT, minExclusive(literal(Float.intBitsToFloat(0x00000000))), maxExclusive(literal(Float.intBitsToFloat(0x00000008)))); assertTrue(reasoner.isSatisfiable(Collections.singleton(floatRestrictionWithSevenValues))); assertTrue(reasoner.containsAtLeast(7, Collections.singleton(floatRestrictionWithSevenValues))); assertFalse(reasoner.containsAtLeast(8, Collections.singleton(floatRestrictionWithSevenValues))); }
@Test public void emptyIntegerInterval() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(0)), maxExclusive(literal(1))); assertFalse(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); }
@Test public void integerExclusiveIntervalExtreme() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(0)), maxExclusive(literal(Integer.MAX_VALUE))); assertTrue(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); assertTrue(reasoner.containsAtLeast(Integer.MAX_VALUE - 1, Collections.singleton(integerExclusiveInterval))); assertFalse(reasoner.containsAtLeast(Integer.MAX_VALUE, Collections.singleton(integerExclusiveInterval))); }
@Test public void integerTwoValues() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(-1)), maxExclusive(literal(1))); assertTrue(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); assertTrue(reasoner.containsAtLeast(1, Collections.singleton(integerExclusiveInterval))); assertFalse(reasoner.containsAtLeast(2, Collections.singleton(integerExclusiveInterval))); }
@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)); }
@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 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 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 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 test370() { // test case for issue #370. dataProperties(_p); individuals(_a); final ATermAppl dt = restrict(Datatypes.DECIMAL, minExclusive(literal("0.99", Datatypes.DECIMAL)), maxExclusive(literal("1.01", Datatypes.DECIMAL))); _kb.addType(_a, min(_p, 3, dt)); assertTrue(_kb.isConsistent()); }
@Test public void validLiteralRestrictedDatatype() { dataProperties(_p); individuals(_a); final ATermAppl uri = term("http//example.com/datatype"); _kb.addRange(_p, INTEGER); _kb.addDatatypeDefinition(uri, restrict(INTEGER, minExclusive(literal(0)))); _kb.addPropertyValue(_p, _a, literal("1", uri)); assertTrue(_kb.isConsistent()); }
@Test public void test484() { dataProperties(_p); individuals(_a); final ATermAppl dt = restrict(Datatypes.INTEGER, minExclusive(literal(0)), maxExclusive(literal(0))); _kb.addType(_a, some(_p, dt)); assertFalse(_kb.isConsistent()); assertEquals(Clash.ClashType.EMPTY_DATATYPE, _kb.getABox().getLastClash().getType()); }