public ChooseBranch(final ABox abox, final CompletionStrategy completion, final Node node, final ATermAppl c, final DependencySet ds) { super(abox, completion, node, c, ds, new ATermAppl[] { ATermUtils.negate(c), c }); }
public ChooseBranch(final ABox abox, final CompletionStrategy completion, final Node node, final ATermAppl c, final DependencySet ds) { super(abox, completion, node, c, ds, new ATermAppl[] { ATermUtils.negate(c), c }); }
private Set<ATermAppl> getDistinctSubclasses(final KnowledgeBase kb, final ATermAppl c) { final Set<ATermAppl> filteredClasses = new HashSet<>(); final Set<Set<ATermAppl>> subclasses = kb.getSubClasses(c); for (final Set<ATermAppl> s : subclasses) filteredClasses.addAll(s); filteredClasses.add(c); //Remove not(TOP), since taxonomy builder complains otherwise... filteredClasses.remove(ATermUtils.negate(ATermUtils.TOP)); return filteredClasses; }
@Override public boolean existType(final List<ATermAppl> inds, final ATermAppl cParam) { final ATermAppl c = ATermUtils.normalize(cParam); _logger.fine(() -> "Checking type " + ATermUtils.toString(c) + " for individuals " + inds.size()); final ATermAppl notC = ATermUtils.negate(c); final boolean isType = !isConsistent(inds, notC, false); _logger.fine(() -> "Type " + isType + " " + ATermUtils.toString(c) + " for individuals " + inds.size()); return isType; }
@Override public boolean existType(final List<ATermAppl> inds, final ATermAppl cParam) { final ATermAppl c = ATermUtils.normalize(cParam); _logger.fine(() -> "Checking type " + ATermUtils.toString(c) + " for individuals " + inds.size()); final ATermAppl notC = ATermUtils.negate(c); final boolean isType = !isConsistent(inds, notC, false); _logger.fine(() -> "Type " + isType + " " + ATermUtils.toString(c) + " for individuals " + inds.size()); return isType; }
private void cache(final Individual rootNode, final ATermAppl c, final boolean isConsistent) { if (!isConsistent) { if (_logger.isLoggable(Level.FINE)) { _logger.fine("Unsatisfiable: " + ATermUtils.toString(c)); _logger.fine("Equivalent to TOP: " + ATermUtils.toString(ATermUtils.negate(c))); } _cache.putSat(c, false); } else { _logger.fine(() -> "Cache " + rootNode.debugString()); _cache.put(c, CachedNodeFactory.createNode(c, rootNode)); } }
private void cache(final Individual rootNode, final ATermAppl c, final boolean isConsistent) { if (!isConsistent) { if (_logger.isLoggable(Level.FINE)) { _logger.fine("Unsatisfiable: " + ATermUtils.toString(c)); _logger.fine("Equivalent to TOP: " + ATermUtils.toString(ATermUtils.negate(c))); } _cache.putSat(c, false); } else { _logger.fine(() -> "Cache " + rootNode.debugString()); _cache.put(c, CachedNodeFactory.createNode(c, rootNode)); } }
private void absorbSubClass(final ATermAppl sub, final ATermAppl sup, final Set<ATermAppl> explanation) { _logger.fine(() -> "Absorb: subClassOf(" + ATermUtils.toString(sub) + ", " + ATermUtils.toString(sup) + ")"); final Set<ATermAppl> terms = SetUtils.create(); terms.add(nnf(sub)); terms.add(nnf(negate(sup))); absorbAxiom(terms, SetUtils.create(explanation)); }
private void absorbSubClass(final ATermAppl sub, final ATermAppl sup, final Set<ATermAppl> explanation) { _logger.fine(() -> "Absorb: subClassOf(" + ATermUtils.toString(sub) + ", " + ATermUtils.toString(sup) + ")"); final Set<ATermAppl> terms = SetUtils.create(); terms.add(nnf(sub)); terms.add(nnf(negate(sup))); absorbAxiom(terms, SetUtils.create(explanation)); }
@Override public void visit(final ClassAtom atom) { _tester = new TestClass(ATermUtils.normalize(ATermUtils.negate(atom.getPredicate())), atom.getArgument()); }
@Override public void visit(final ClassAtom atom) { _tester = new TestClass(ATermUtils.normalize(ATermUtils.negate(atom.getPredicate())), atom.getArgument()); }
private void addType(final ATermAppl ind, final ATermAppl cls) { DependencySet nodeDS = _ds; Individual node = _abox.getIndividual(ind); if (node.isMerged()) { nodeDS = node.getMergeDependency(true); node = node.getSame(); } _strategy.addType(node, _negated ? ATermUtils.negate(cls) : cls, nodeDS); }
@Override public boolean isSubClassOf(final ATermAppl c1, final ATermAppl c2) { if (!_doExplanation) { final Bool isKnownSubClass = isKnownSubClassOf(c1, c2); if (isKnownSubClass.isKnown()) return isKnownSubClass.isTrue(); } if (_logger.isLoggable(Level.FINE)) { final long count = _kb.getTimers().getTimer("subClassSat").map(t -> t.getCount()).orElse(0L); _logger.fine(count + ") Checking subclass [" + ATermUtils.toString(c1) + " " + ATermUtils.toString(c2) + "]"); } final ATermAppl notC2 = ATermUtils.negate(c2); final ATermAppl c = ATermUtils.makeAnd(c1, notC2); final Optional<Timer> timer = _kb.getTimers().startTimer("subClassSat"); final boolean sub = !isSatisfiable(c, false); timer.ifPresent(t -> t.stop()); _logger.fine(() -> " Result: " + sub + timer.map(t -> " (" + t.getLast() + "ms)").orElse("")); return sub; }
private void addType(final ATermAppl ind, final ATermAppl cls) { DependencySet nodeDS = _ds; Individual node = _abox.getIndividual(ind); if (node.isMerged()) { nodeDS = node.getMergeDependency(true); node = node.getSame(); } _strategy.addType(node, _negated ? ATermUtils.negate(cls) : cls, nodeDS); }
static public ATermList negate(final ATermList list) { if (list.isEmpty()) return list; ATermAppl a = (ATermAppl) list.getFirst(); a = isNot(a) ? (ATermAppl) a.getArgument(0) : makeNot(a); final ATermList result = makeList(a, negate(list.getNext())); return result; }
static public ATermList negate(final ATermList list) { if (list.isEmpty()) return list; ATermAppl a = (ATermAppl) list.getFirst(); a = isNot(a) ? (ATermAppl) a.getArgument(0) : makeNot(a); final ATermList result = makeList(a, negate(list.getNext())); return result; }
@Override public boolean putSat(final ATermAppl c, final boolean isSatisfiable) { final CachedNode cached = get(c); if (cached != null) { if (isSatisfiable != !cached.isBottom()) throw new InternalReasonerException("Caching inconsistent results for " + c); return false; } else if (isSatisfiable) put(c, CachedNodeFactory.createSatisfiableNode()); else { final ATermAppl notC = ATermUtils.negate(c); put(c, CachedNodeFactory.createBottomNode()); put(notC, CachedNodeFactory.createTopNode()); } return true; }
@Override public boolean putSat(final ATermAppl c, final boolean isSatisfiable) { final CachedNode cached = get(c); if (cached != null) { if (isSatisfiable != !cached.isBottom()) throw new InternalReasonerException("Caching inconsistent results for " + c); return false; } else if (isSatisfiable) put(c, CachedNodeFactory.createSatisfiableNode()); else { final ATermAppl notC = ATermUtils.negate(c); put(c, CachedNodeFactory.createBottomNode()); put(notC, CachedNodeFactory.createTopNode()); } return true; }
private static boolean block4(final BlockingContext cxt, final ATermAppl term) { final Role t = cxt._blocked.getABox().getRole(term.getArgument(0)); final int m; final ATermAppl c; if (ATermUtils.isMin(term)) { c = (ATermAppl) term.getArgument(2); m = ((ATermInt) term.getArgument(1)).getInt(); } else { c = ATermUtils.negate((ATermAppl) term.getArgument(1)); m = 1; } if (t.isDatatypeRole()) return true; if (cxt.isRSuccessor(t.getInverse()) && cxt._blocked.getParent().hasType(c)) return true; return cxt._blocker.getRSuccessors(t, c).size() >= m; } }
private static boolean block4(final BlockingContext cxt, final ATermAppl term) { final Role t = cxt._blocked.getABox().getRole(term.getArgument(0)); final int m; final ATermAppl c; if (ATermUtils.isMin(term)) { c = (ATermAppl) term.getArgument(2); m = ((ATermInt) term.getArgument(1)).getInt(); } else { c = ATermUtils.negate((ATermAppl) term.getArgument(1)); m = 1; } if (t.isDatatypeRole()) return true; if (cxt.isRSuccessor(t.getInverse()) && cxt._blocked.getParent().hasType(c)) return true; return cxt._blocker.getRSuccessors(t, c).size() >= m; } }