@Override public boolean isPrimitive(final ATermAppl c) // CPU hot spot. { if (ATermUtils.isPrimitive(c)) { final TermDefinition td = _Tu.getTD(c); // Time consuming so we avoid to do it if possible. return td == null || td.isPrimitive(); } return false; } }
@Override public boolean isPrimitive(final ATermAppl c) // CPU hot spot. { if (ATermUtils.isPrimitive(c)) { final TermDefinition td = _Tu.getTD(c); // Time consuming so we avoid to do it if possible. return td == null || td.isPrimitive(); } return false; } }
@Override public boolean addDef(final ATermAppl axiom) { boolean added = false; final ATermAppl name = (ATermAppl) axiom.getArgument(0); TermDefinition td = getTD(name); if (td == null) { td = new TermDefinition(); _termhash.put(name, td); } added = td.addDef(axiom); if (added && _termsToNormalize != null) _termsToNormalize.add(name); return added; }
protected boolean findTarget(final ATermAppl term, final ATermAppl target, final Set<ATermAppl> seen) { final List<ATermAppl> queue = new ArrayList<>(); queue.add(term); while (!queue.isEmpty()) { _kb.getTimers().checkTimer("preprocessing"); final ATermAppl current = queue.remove(queue.size() - 1); if (!seen.add(current)) continue; if (current.equals(target)) return true; final TermDefinition td = getTD(current); if (td != null) { // Shortcut if (td.getDependencies().contains(target)) return true; queue.addAll(td.getDependencies()); } } return false; }
protected boolean findTarget(final ATermAppl term, final ATermAppl target, final Set<ATermAppl> seen) { final List<ATermAppl> queue = new ArrayList<>(); queue.add(term); while (!queue.isEmpty()) { _kb.getTimers().checkTimer("preprocessing"); final ATermAppl current = queue.remove(queue.size() - 1); if (!seen.add(current)) continue; if (current.equals(target)) return true; final TermDefinition td = getTD(current); if (td != null) { // Shortcut if (td.getDependencies().contains(target)) return true; queue.addAll(td.getDependencies()); } } return false; }
@Override public boolean addDef(final ATermAppl axiom) { boolean added = false; final ATermAppl name = (ATermAppl) axiom.getArgument(0); TermDefinition td = getTD(name); if (td == null) { td = new TermDefinition(); _termhash.put(name, td); } added = td.addDef(axiom); if (added && _termsToNormalize != null) _termsToNormalize.add(name); return added; }
@Override public Collection<ATermAppl> getAxioms(final ATermAppl term) { final List<ATermAppl> axioms = new ArrayList<>(); TermDefinition def = _Tg.getTD(term); if (def != null) { axioms.addAll(def.getSubClassAxioms()); axioms.addAll(def.getEqClassAxioms()); } def = _Tu.getTD(term); if (def != null) { axioms.addAll(def.getSubClassAxioms()); axioms.addAll(def.getEqClassAxioms()); } return axioms; }
@Override public Collection<ATermAppl> getAxioms(final ATermAppl term) { final List<ATermAppl> axioms = new ArrayList<>(); TermDefinition def = _Tg.getTD(term); if (def != null) { axioms.addAll(def.getSubClassAxioms()); axioms.addAll(def.getEqClassAxioms()); } def = _Tu.getTD(term); if (def != null) { axioms.addAll(def.getSubClassAxioms()); axioms.addAll(def.getEqClassAxioms()); } return axioms; }
final TermDefinition td = getTD(c); if (null == td) // FIXME related to bug 453 @see testUnsatisfiable453
final TermDefinition td = getTD(c); if (null == td) // FIXME related to bug 453 @see testUnsatisfiable453
private boolean absorbII(final Set<ATermAppl> set) { for (final ATermAppl term : set) { final TermDefinition td = _tbox._Tu.getTD(term); boolean canAbsorb; if (td != null) canAbsorb = td.getEqClassAxioms().isEmpty(); else canAbsorb = term.getArity() == 0 && set.size() > 1; if (canAbsorb) { set.remove(term); final ATermList setlist = ATermUtils.makeList(set); ATermAppl conjunct = ATermUtils.makeAnd(setlist); conjunct = ATermUtils.makeNot(conjunct); final ATermAppl sub = ATermUtils.makeSub(term, ATermUtils.nnf(conjunct)); _tbox._Tu.addDef(sub); _subLogger.fine(() -> "Absorb named: " + ATermUtils.toString(sub)); _tbox.addAxiomExplanation(sub, _explanation); return true; } } return false; }
private boolean absorbII(final Set<ATermAppl> set) { for (final ATermAppl term : set) { final TermDefinition td = _tbox._Tu.getTD(term); boolean canAbsorb; if (td != null) canAbsorb = td.getEqClassAxioms().isEmpty(); else canAbsorb = term.getArity() == 0 && set.size() > 1; if (canAbsorb) { set.remove(term); final ATermList setlist = ATermUtils.makeList(set); ATermAppl conjunct = ATermUtils.makeAnd(setlist); conjunct = ATermUtils.makeNot(conjunct); final ATermAppl sub = ATermUtils.makeSub(term, ATermUtils.nnf(conjunct)); _tbox._Tu.addDef(sub); _subLogger.fine(() -> "Absorb named: " + ATermUtils.toString(sub)); _tbox.addAxiomExplanation(sub, _explanation); return true; } } return false; }
if (ATermUtils.isPrimitive(term)) final TermDefinition td = _Tu.getTD(term); if (td == null || td.getEqClassAxioms().isEmpty()) primitiveClassAtoms++;
if (ATermUtils.isPrimitive(term)) final TermDefinition td = _Tu.getTD(term); if (td == null || td.getEqClassAxioms().isEmpty()) primitiveClassAtoms++;
public boolean addIfUnfoldable(final ATermAppl term) { final ATermAppl name = (ATermAppl) term.getArgument(0); if (!ATermUtils.isPrimitive(name)) return false; TermDefinition td = getTD(name); if (td == null) td = new TermDefinition(); // Basic Check if (!td.isUnique(term)) return false; // Loop Checks final ATermAppl body = (ATermAppl) term.getArgument(1); final Set<ATermAppl> nameDependencies = td.getDependencies(); final Set<ATermAppl> bodyDependencies = ATermUtils.findPrimitives(body); if (!nameDependencies.containsAll(bodyDependencies)) { final Set<ATermAppl> seen = new IdentityHashSet<>(); // Identity hashSet because dependencies are manage on identity hash set for (final ATermAppl current : bodyDependencies) if (findTarget(current, name, seen)) return false; } return addDef(term); }
public boolean addIfUnfoldable(final ATermAppl term) { final ATermAppl name = (ATermAppl) term.getArgument(0); if (!ATermUtils.isPrimitive(name)) return false; TermDefinition td = getTD(name); if (td == null) td = new TermDefinition(); // Basic Check if (!td.isUnique(term)) return false; // Loop Checks final ATermAppl body = (ATermAppl) term.getArgument(1); final Set<ATermAppl> nameDependencies = td.getDependencies(); final Set<ATermAppl> bodyDependencies = ATermUtils.findPrimitives(body); if (!nameDependencies.containsAll(bodyDependencies)) { final Set<ATermAppl> seen = new IdentityHashSet<>(); // Identity hashSet because dependencies are manage on identity hash set for (final ATermAppl current : bodyDependencies) if (findTarget(current, name, seen)) return false; } return addDef(term); }