@Override public Node copyTo(final ABoxImpl abox) { return new Literal(this, abox); }
@Override protected boolean test(final Literal a, final Literal b) { final Object aval = a.getValue(); final Object bval = b.getValue(); // Numbers are a special case, since they can be promoted from Integers and Decimals to Floats and Doubles. if (aval instanceof Number && bval instanceof Number) { final NumericPromotion promoter = new NumericPromotion(); final Number anum = (Number) aval; final Number bnum = (Number) bval; promoter.promote(anum, bnum); final NumericComparisonVisitor visitor = new NumericComparisonVisitor(); promoter.accept(visitor); if (visitor.getComparison() == 0) return true ^ _flip; return false ^ _flip; } if (a.getValue() != null && b.getValue() != null) return (aval.getClass().equals(bval.getClass()) && aval.equals(bval)) ^ _flip; return false; } }
@Override public boolean restore(final int branch) { final Boolean restorePruned = restorePruned(branch); if (Boolean.FALSE.equals(restorePruned)) return restorePruned; boolean restored = Boolean.TRUE.equals(restorePruned); restored |= super.restore(branch); if (_clashed) checkClash(); return restored; }
@Override public boolean apply(final ABox abox, final Literal[] args) { if (args.length != 2) return false; if (args[0] == null) { if (args[1] != null && args[1].getValue() instanceof Boolean) { args[0] = abox.addLiteral(((Boolean) args[1].getValue()).booleanValue() ? FALSE_TERM : TRUE_TERM); return true; } } else if (args[1] == null) { if (args[0].getValue() instanceof Boolean) { args[1] = abox.addLiteral(((Boolean) args[0].getValue()).booleanValue() ? FALSE_TERM : TRUE_TERM); return true; } } else if (args[0].getValue() instanceof Boolean && args[1].getValue() instanceof Boolean) return !args[0].equals(args[1]); return false; }
public void addAllTypes(final Map<ATermAppl, DependencySet> types, final DependencySet ds) { for (final Entry<ATermAppl, DependencySet> entry : types.entrySet()) { final ATermAppl c = entry.getKey(); if (hasType(c)) continue; final DependencySet depends = entry.getValue(); super.addType(c, depends.union(ds, _abox.doExplanation())); } checkClash(); }
y.setSame(x, ds); x.addAllTypes(y.getDepends(), ds); final EdgeList inEdges = y.getInEdges(); for (int e = 0; e < inEdges.size(); e++) x.inheritDifferents(y, ds); y.prune(ds); if (x.getNodeDepends() == null || y.getNodeDepends() == null) throw new OpenError("No node depend.");
reportClash(Clash.invalidLiteral(this, getDepends(_name), getTerm())); return; if (hasType(ATermUtils.BOTTOM_LIT)) reportClash(Clash.emptyDatatype(this, getDepends(ATermUtils.BOTTOM_LIT))); if (_abox.doExplanation()) System.out.println("1) Literal clash dependency = " + _abox.getClash()); final Set<ATermAppl> types = getTypes(); final DatatypeReasoner dtReasoner = _abox.getDatatypeReasoner(); for (final ATermAppl element : dt) ds = ds.union(getDepends(element), _abox.doExplanation()); if (_abox.doExplanation()) reportClash(Clash.valueDatatype(this, ds, (ATermAppl) _atermValue.getArgument(0), dt[0])); for (final ATermAppl element : dt) ds = ds.union(getDepends(element), _abox.doExplanation()); if (_abox.doExplanation()) reportClash(Clash.emptyDatatype(this, ds, dt));
if (((Literal) node).getValue() == null && OpenlletOptions.USE_COMPLETION_QUEUE) final Literal lit = new Literal(name, dataValue, this, ds); lit.addType(ATermUtils.TOP_LIT, ds); _nodeList.add(name); if (lit.getValue() == null && OpenlletOptions.USE_COMPLETION_QUEUE) _branchEffects.add(getBranchIndex(), lit.getName());
/** * Verify that overlapping decimal ranges for a single variable are satisfiable. * * @throws UnrecognizedDatatypeException * @throws InvalidLiteralException * @throws InvalidConstrainingFacetException */ @Test public void oneVSatisfiableDecimalRanges() throws InvalidConstrainingFacetException, InvalidLiteralException, UnrecognizedDatatypeException { final Literal x = new Literal(term("x"), null, abox, DependencySet.INDEPENDENT); for (final ATermAppl a : getSatisfiableDecimalRanges()) x.addType(a, DependencySet.INDEPENDENT); assertTrue(reasoner.isSatisfiable(singleton(x), Collections.<Literal, Set<Literal>> emptyMap())); }
@Override public boolean test(final Literal l1, final Literal l2) final Object l1val = l1.getValue(); final Object l2val = l2.getValue(); final DatatypeReasoner dtr = l1.getABox().getDatatypeReasoner(); final ATermAppl term1 = l1.getTerm(); final ATermAppl type1 = (ATermAppl) term1.getArgument(ATermUtils.LIT_URI_INDEX); final ATermAppl type2 = (ATermAppl) l2.getTerm().getArgument(ATermUtils.LIT_URI_INDEX); try final String msg = format("Unexpected datatype reasoner exception comparaing two literals ('%s','%s'). Treating as incomparable.", term1, l2.getTerm()); _logger.log(Level.WARNING, msg, e); return false;
final NodeMerge mtc = l.getMergeToConstant(); if (mtc != null) l.clearMergeToConstant(); final Literal mergeTo = _abox.getLiteral(mtc.getTarget()); mergeTo(l, mergeTo, mtc.getDepends());
@Override public DependencySet getDifferenceDependency(final Node node) { DependencySet ds = null; if (isDifferent(node)) { ds = _differents.get(node); if (ds == null) ds = DependencySet.INDEPENDENT; } return ds; }
@Override public void unprune(final int branch) { super.unprune(branch); checkClash(); }
final Literal current = newBinding.get(arg); if (current != null && !current.equals(result))
y.setSame(x, ds); x.addAllTypes(y.getDepends(), ds); final EdgeList inEdges = y.getInEdges(); for (int e = 0; e < inEdges.size(); e++) x.inheritDifferents(y, ds); y.prune(ds); if (x.getNodeDepends() == null || y.getNodeDepends() == null) throw new OpenError("No node depend.");