@Ignore("Equal but not identical semantics is very counter-intuitive and currently Pellet treats equals values as identical") @Test public void equalbutNotIdenticalDateTimeOneOf() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl d = oneOf(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 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))); }
/** * Adds a new datatype defined to be equivalent to the given data range expression. * * @param name name of the datatype * @param datarange a data range expression * @return true if the add success */ @Override public boolean addDatatypeDefinition(final ATermAppl name, final ATermAppl datarange) { if (null == name || null == datarange) return false; return getDatatypeReasoner().define(name, datarange); }
@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)))); }
public void testSatisfiability(final boolean isSatisfiable, final ATermAppl... dataranges) throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { assertTrue(isSatisfiable == reasoner.isSatisfiable(Arrays.asList(dataranges))); }
if (!dtReasoner.isSatisfiable(types, _value)) final ATermAppl definition = dtReasoner.getDefinition(dtName); if (definition != null) ds = ds.union(Collections.singleton(ATermUtils.makeDatatypeDefinition(dtName, definition)), true); if (dtReasoner.isSatisfiable(types)) if (!dtReasoner.containsAtLeast(2, types)) final Object value = dtReasoner.valueIterator(types).next(); final ATermAppl valueTerm = dtReasoner.getLiteral(value); Literal valueLiteral = _abox.getLiteral(valueTerm); if (valueLiteral == null) if (_abox.doExplanation()) final ATermAppl definition = dtReasoner.getDefinition(element); if (definition != null) ds = ds.union(Collections.singleton(ATermUtils.makeDatatypeDefinition(element, definition)), true);
@Override public Bool hasObviousPropertyValue(final ATermAppl s, final ATermAppl p, final ATermAppl o) { final Role prop = getRole(p); if (prop.isDatatypeRole()) try { final Object value = o == null ? null : _dtReasoner.getValue(o); return hasObviousDataPropertyValue(s, p, value); } catch (final UnrecognizedDatatypeException e) { _logger.warning(format("Returning false for property value check (%s,%s,%s) due to datatype problem with input literal: %s", s, p, o, e.getMessage())); return Bool.FALSE; } catch (final InvalidLiteralException e) { _logger.warning(format("Returning false for property value check (%s,%s,%s) due to problem with input literal: %s", s, p, o, e.getMessage())); return Bool.FALSE; } else return hasObviousObjectPropertyValue(s, p, o); }
/** * Verify that a named decimal range contains correct constants * * @throws UnrecognizedDatatypeException * @throws InvalidLiteralException * @throws InvalidConstrainingFacetException */ @Test public void unaryValuesInNamedDecimalRange() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final ATermAppl rdt = restrict(DECIMAL, minInclusive(literal("1.0", DECIMAL)), maxInclusive(literal("2.5", DECIMAL))); final ATermAppl name = term("newDt"); final Collection<ATermAppl> types = singleton(name); assertTrue(reasoner.define(name, rdt)); assertFalse(reasoner.isSatisfiable(types, decimal("0.99"))); assertTrue(reasoner.isSatisfiable(types, 1)); assertTrue(reasoner.isSatisfiable(types, 2)); assertTrue(reasoner.isSatisfiable(types, decimal("2.5"))); assertFalse(reasoner.isSatisfiable(types, decimal("2.51"))); }
if (dtr.isSatisfiable(Arrays.asList(type1, type2))) final ATermAppl canon1 = dtr.getCanonicalRepresentation(term1); final ATermAppl baseType = (ATermAppl) canon1.getArgument(ATermUtils.LIT_URI_INDEX); final ATermAppl dr = ATermUtils.makeRestrictedDatatype(baseType, new ATermAppl[] { ATermUtils.makeFacetRestriction(f.getName(), canon1) }); return dtr.isSatisfiable(Collections.singleton(dr), l2val);
final ATermAppl canonical = _abox.getDatatypeReasoner().getCanonicalRepresentation(input); if (!canonical.equals(input)) type = ATermUtils.makeValue(canonical);
for (final ATermAppl dtype : _kb.getDatatypeReasoner().listDataRanges()) rangeRhsDTypeCandidates.add(dtype);
try if (!_strategy.getABox().getDatatypeReasoner().containsAtLeast(n, drs))
@Override public void addDatatype(final ATermAppl p) { if (null == p) return; getDatatypeReasoner().declare(p); }
@Override public void visitTerm(final ATermAppl term) { if (getDatatypeReasoner().isDeclared(term)) _isDatatype = true; }
@Override public void rebind(final VariableBinding newBinding) { final Literal dValue = newBinding.get(_atom.getArgument()); if (dValue == null) throw new InternalReasonerException("DataRangeBindingHelper cannot generate bindings for " + _atom); try { _hasNext = _dtReasoner.isSatisfiable(Collections.singleton(_atom.getPredicate()), dValue.getValue()); } catch (final DatatypeReasonerException e) { final String msg = "Unexpected datatype reasoner exception: " + e.getMessage(); _logger.severe(msg); throw new InternalReasonerException(e); } }
if (!dtReasoner.isSatisfiable(types, _value)) final ATermAppl definition = dtReasoner.getDefinition(dtName); if (definition != null) ds = ds.union(Collections.singleton(ATermUtils.makeDatatypeDefinition(dtName, definition)), true); if (dtReasoner.isSatisfiable(types)) if (!dtReasoner.containsAtLeast(2, types)) final Object value = dtReasoner.valueIterator(types).next(); final ATermAppl valueTerm = dtReasoner.getLiteral(value); Literal valueLiteral = _abox.getLiteral(valueTerm); if (valueLiteral == null) if (_abox.doExplanation()) final ATermAppl definition = dtReasoner.getDefinition(element); if (definition != null) ds = ds.union(Collections.singleton(ATermUtils.makeDatatypeDefinition(element, definition)), true);
@Override public Bool hasObviousPropertyValue(final ATermAppl s, final ATermAppl p, final ATermAppl o) { final Role prop = getRole(p); if (prop.isDatatypeRole()) try { final Object value = o == null ? null : _dtReasoner.getValue(o); return hasObviousDataPropertyValue(s, p, value); } catch (final UnrecognizedDatatypeException e) { _logger.warning(format("Returning false for property value check (%s,%s,%s) due to datatype problem with input literal: %s", s, p, o, e.getMessage())); return Bool.FALSE; } catch (final InvalidLiteralException e) { _logger.warning(format("Returning false for property value check (%s,%s,%s) due to problem with input literal: %s", s, p, o, e.getMessage())); return Bool.FALSE; } else return hasObviousObjectPropertyValue(s, p, o); }
if (dtr.isSatisfiable(Arrays.asList(type1, type2))) final ATermAppl canon1 = dtr.getCanonicalRepresentation(term1); final ATermAppl baseType = (ATermAppl) canon1.getArgument(ATermUtils.LIT_URI_INDEX); final ATermAppl dr = ATermUtils.makeRestrictedDatatype(baseType, new ATermAppl[] { ATermUtils.makeFacetRestriction(f.getName(), canon1) }); return dtr.isSatisfiable(Collections.singleton(dr), l2val);
final ATermAppl canonical = _abox.getDatatypeReasoner().getCanonicalRepresentation(input); if (!canonical.equals(input)) type = ATermUtils.makeValue(canonical);
for (final ATermAppl dtype : _kb.getDatatypeReasoner().listDataRanges()) rangeRhsDTypeCandidates.add(dtype);