private static Collection<ATermAppl> getSatisfiableDecimalEnumerations() { final Collection<ATermAppl> dataranges = Arrays.asList(oneOf(literal("1.0", DECIMAL), literal("2.0", DECIMAL), literal("3.0", DECIMAL)), oneOf(literal("2.0", DECIMAL), literal("4.0", DECIMAL), literal("6.0", DECIMAL))); return dataranges; }
private static Collection<ATermAppl> getUnsatisfiableDecimalEnumerations() { final Collection<ATermAppl> dataranges = Arrays.asList(oneOf(literal("1.0", DECIMAL), literal("2.0", DECIMAL), literal("3.0", DECIMAL)), oneOf(literal("4.0", DECIMAL), literal("5.0", DECIMAL), literal("6.0", DECIMAL))); return dataranges; }
private void stringFunc(final Function func, final String expected, final String... args) { final ATermAppl expectedTerm = literal(expected); stringFunc(func, expectedTerm, args); }
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 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)); }
@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 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 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 intersectDoubleIntervalNotDouble() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl doubleInterval = restrict(DOUBLE, minInclusive(literal(0.0)), maxInclusive(literal(1.0))); assertUnsatisfiable(doubleInterval, not(DOUBLE)); }
@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 testFunctionalSubDataProperty() { // test for ticket #551 individuals(_a); dataProperties(_p, _q); _kb.addFunctionalProperty(_q); _kb.addSubProperty(_p, _q); _kb.addPropertyValue(_p, _a, literal(1)); _kb.addPropertyValue(_q, _a, literal(2)); explainInconsistency(ATermUtils.makeFunctional(_q), ATermUtils.makeSubProp(_p, _q), ATermUtils.makePropAtom(_p, _a, literal(1)), ATermUtils.makePropAtom(_q, _a, literal(2))); } }
@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 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 invalidLiteralStringRestriction() { assumeTrue(OpenlletOptions.INVALID_LITERAL_AS_INCONSISTENCY); dataProperties(_p); individuals(_a); final ATermAppl uri = term("http//example.com/datatype"); _kb.addDatatypeDefinition(uri, oneOf(literal("a"), literal("b"))); _kb.addRange(_p, uri); _kb.addPropertyValue(_p, _a, literal("a", uri)); assertFalse(_kb.isConsistent()); }
@Test public void intersectIntegerNegatedIntegerValue() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final Collection<ATermAppl> types = Arrays.asList(INTEGER, not(value(literal(3)))); assertTrue(reasoner.isSatisfiable(types)); assertTrue(reasoner.containsAtLeast(2, types)); assertTrue(reasoner.isSatisfiable(types, reasoner.getValue(literal(1)))); assertFalse(reasoner.isSatisfiable(types, reasoner.getValue(literal(3)))); }
@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 invalidLiteralBuiltInDatatype() { dataProperties(_p); individuals(_a); _kb.addRange(_p, INTEGER); _kb.addPropertyValue(_p, _a, literal("-1", POSITIVE_INTEGER)); assertFalse(_kb.isConsistent()); }