@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 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 floatExclusiveRandom() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final long seed = System.currentTimeMillis(); final Random rand = new Random(seed); try { float high, low; high = rand.nextFloat(); low = rand.nextFloat(); if (low > high) { final float tmp = low; low = high; high = tmp; } final ATermAppl floatExclusiveRandom = restrict(FLOAT, minExclusive(literal(Float.valueOf(low))), maxExclusive(literal(Float.valueOf(high)))); // Both floats are known to be in (0,1) so this will work final int size = Float.floatToIntBits(high) - Float.floatToIntBits(low) - 1; assertTrue(reasoner.isSatisfiable(Collections.singleton(floatExclusiveRandom))); assertTrue(reasoner.containsAtLeast(size, Collections.singleton(floatExclusiveRandom))); assertFalse(reasoner.containsAtLeast(size + 1, Collections.singleton(floatExclusiveRandom))); } catch (final AssertionError e) { System.err.println("Random seed: " + seed); throw e; } }
@Test public void floatTwoZeros() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl floatTwoZeros = restrict(FLOAT, minExclusive(literal(-Float.MIN_VALUE)), maxExclusive(literal(Float.MIN_VALUE))); assertTrue(reasoner.isSatisfiable(Collections.singleton(floatTwoZeros))); assertTrue(reasoner.containsAtLeast(2, Collections.singleton(floatTwoZeros))); assertFalse(reasoner.containsAtLeast(3, Collections.singleton(floatTwoZeros))); }
@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 integerExclusiveRandom() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final long seed = System.currentTimeMillis(); final Random rand = new Random(seed); try { int high, low; high = rand.nextInt(); do { low = rand.nextInt(); if (low > high) { final int tmp = low; low = high; high = tmp; } } while (Long.valueOf(high) - Long.valueOf(low) > Integer.MAX_VALUE); final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(low)), maxExclusive(literal(high))); assertTrue(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); assertTrue(reasoner.containsAtLeast(high - low - 1, Collections.singleton(integerExclusiveInterval))); assertFalse(reasoner.containsAtLeast(high - low, Collections.singleton(integerExclusiveInterval))); } catch (final AssertionError e) { System.err.println("Random seed: " + seed); throw e; } }
public void integerExclusiveIntervalOverflow() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl integerExclusiveInterval = restrict(INTEGER, minExclusive(literal(Integer.MIN_VALUE)), maxExclusive(literal(Integer.MAX_VALUE))); assertTrue(reasoner.isSatisfiable(Collections.singleton(integerExclusiveInterval))); assertTrue(reasoner.containsAtLeast(Integer.MAX_VALUE, Collections.singleton(integerExclusiveInterval))); }
try if (!_strategy.getABox().getDatatypeReasoner().containsAtLeast(n, drs))
try if (!_strategy.getABox().getDatatypeReasoner().containsAtLeast(n, drs))
@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))); }
if (dtReasoner.isSatisfiable(types)) if (!dtReasoner.containsAtLeast(2, types))
if (dtReasoner.isSatisfiable(types)) if (!dtReasoner.containsAtLeast(2, types))
@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 intersectAnyURINegatedTextValue() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final Collection<ATermAppl> types = Arrays.asList(ANY_URI, not(value(literal("http://example.org")))); assertTrue(reasoner.isSatisfiable(types)); assertTrue(reasoner.containsAtLeast(2, types)); assertTrue(reasoner.isSatisfiable(types, literal("http://example.com", Datatypes.ANY_URI))); assertTrue(reasoner.isSatisfiable(types, literal("http://example.org", Datatypes.ANY_URI))); }
@Test public void intersectTextNegatedTextValue() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final Collection<ATermAppl> types = Arrays.asList(PLAIN_LITERAL, not(value(literal("http://example.org")))); assertTrue(reasoner.isSatisfiable(types)); assertTrue(reasoner.containsAtLeast(2, types)); assertTrue(reasoner.isSatisfiable(types, literal("http://example.com"))); assertFalse(reasoner.isSatisfiable(types, literal("http://example.org"))); }
@Test public void intersectAnyURINegatedURIValue() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final Collection<ATermAppl> types = Arrays.asList(ANY_URI, not(value(literal("http://example.org", ANY_URI)))); assertTrue(reasoner.isSatisfiable(types)); assertTrue(reasoner.containsAtLeast(2, types)); assertTrue(reasoner.isSatisfiable(types, literal("http://example.com", Datatypes.ANY_URI))); assertFalse(reasoner.isSatisfiable(types, literal("http://example.org", Datatypes.ANY_URI))); }
@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)))); }