public ABoxImpl(final KnowledgeBase kb, final boolean copyCache) { this(kb); if (copyCache) _cache = kb.getABox().getCache(); }
public ABoxImpl(final KnowledgeBase kb, final boolean copyCache) { this(kb); if (copyCache) _cache = kb.getABox().getCache(); }
private boolean subsumes(final ATermAppl sup, final ATermAppl sub) // CPU hot spot. { return _kb.getABox().isSubClassOf(sub, sup); }
private boolean subsumes(final ATermAppl sup, final ATermAppl sub) // CPU hot spot. { return _kb.getABox().isSubClassOf(sub, sup); }
private Map<ATermAppl, Boolean> fastPrune(final Query q, final ATermAppl var) { final ATermAppl c = q.rollUpTo(var, Collections.<ATermAppl> emptySet(), STOP_ROLLING_ON_CONSTANTS); if (_logger.isLoggable(Level.FINER)) _logger.finer(var + " rolled to " + c); final CandidateSet<ATermAppl> set = _kb.getABox().getObviousInstances(c); final Map<ATermAppl, Boolean> map = new HashMap<>(); for (final Object o : set.getKnowns()) map.put((ATermAppl) o, true); for (final Object o : set.getUnknowns()) map.put((ATermAppl) o, false); return map; }
private Map<ATermAppl, Boolean> fastPrune(final Query q, final ATermAppl var) { final ATermAppl c = q.rollUpTo(var, Collections.<ATermAppl> emptySet(), STOP_ROLLING_ON_CONSTANTS); if (_logger.isLoggable(Level.FINER)) _logger.finer(var + " rolled to " + c); final CandidateSet<ATermAppl> set = _kb.getABox().getObviousInstances(c); final Map<ATermAppl, Boolean> map = new HashMap<>(); for (final Object o : set.getKnowns()) map.put((ATermAppl) o, true); for (final Object o : set.getUnknowns()) map.put((ATermAppl) o, false); return map; }
private Map<ATermAppl, Boolean> fastPrune(final Query q, final ATermAppl var) { final ATermAppl c = q.rollUpTo(var, Collections.<ATermAppl> emptySet(), STOP_ROLLING_ON_CONSTANTS); if (_logger.isLoggable(Level.FINER)) _logger.finer(var + " rolled to " + c); final CandidateSet<ATermAppl> set = _kb.getABox().getObviousInstances(c); final Map<ATermAppl, Boolean> map = new HashMap<>(); for (final Object o : set.getKnowns()) map.put((ATermAppl) o, true); for (final Object o : set.getUnknowns()) map.put((ATermAppl) o, false); return map; }
public static void printCounts(final KnowledgeBase kb) { final int classCount = kb.getClasses().size(); final int objPropertyCount = kb.getObjectProperties().size(); final int dataPropertyCount = kb.getDataProperties().size(); System.out.println("Expressivity : " + kb.getExpressivity()); System.out.println("Classes : " + classCount); System.out.println("Obj Properties : " + objPropertyCount); System.out.println("Data Properties: " + dataPropertyCount); printCounts(kb.getABox()); } }
@Override public void realize(final ATermAppl x) { realize(_kb.getABox().getIndividual(x)); }
/** * @param val * @return */ private static boolean isRootNominal(final KnowledgeBase kb, final ATermAppl val) { final Individual ind = kb.getABox().getIndividual(val); return ind != null && ind.isRootNominal(); }
@Override public void realize(final ATermAppl x) { realize(_kb.getABox().getIndividual(x)); }
/** * @param val * @return */ private static boolean isRootNominal(final KnowledgeBase kb, final ATermAppl val) { final Individual ind = kb.getABox().getIndividual(val); return ind != null && ind.isRootNominal(); }
/** * Restore a clash dependency * * @param assertion * @param clash */ private void restoreClash(final ATermAppl assertion, final ClashDependency clash) { DependencyIndex._logger.fine(() -> " Restoring clash dependency clash: " + clash.getClash()); clash.getClash().getDepends().removeExplain(assertion); // remove the dependency if (clash.getClash().getDepends().getExplain().isEmpty() && clash.getClash().getDepends().isIndependent()) // undo clash if empty and is independent { DependencyIndex._logger.fine(() -> " Actually removing clash!"); _kb.getABox().setClash(null); } }
@Test public void test553() { final KnowledgeBase kb = new KnowledgeBaseImpl(); final KnowledgeBase copyKB = kb.copy(); assertTrue(copyKB != kb); assertTrue(copyKB.getABox().getKB() == copyKB); }
public static void assertSubClass(final KnowledgeBase kb, final ATermAppl c1, final ATermAppl c2, final boolean expectedSubClass) { boolean computedSubClass = kb.isSubClassOf(c1, c2); assertEquals("Subclass check failed for (" + ATermUtils.toString(c1) + " [= " + ATermUtils.toString(c2) + ")", expectedSubClass, computedSubClass); kb.isSatisfiable(c1); kb.isSatisfiable(not(c1)); kb.isSatisfiable(c2); kb.isSatisfiable(not(c2)); final long satCount = kb.getABox().getStats()._satisfiabilityCount; computedSubClass = kb.isSubClassOf(c1, c2); final boolean cached = satCount == kb.getABox().getStats()._satisfiabilityCount; assertEquals("Subclass check (Cached: " + cached + ") failed for (" + ATermUtils.toString(c1) + " [= " + ATermUtils.toString(c2) + ")", expectedSubClass, computedSubClass); } }
public static void assertSubClass(final KnowledgeBase kb, final ATermAppl c1, final ATermAppl c2, final boolean expectedSubClass) { boolean computedSubClass = kb.isSubClassOf(c1, c2); assertEquals("Subclass check failed for (" + ATermUtils.toString(c1) + " [= " + ATermUtils.toString(c2) + ")", expectedSubClass, computedSubClass); kb.isSatisfiable(c1); kb.isSatisfiable(not(c1)); kb.isSatisfiable(c2); kb.isSatisfiable(not(c2)); final long satCount = kb.getABox().getStats()._satisfiabilityCount; computedSubClass = kb.isSubClassOf(c1, c2); final boolean cached = satCount == kb.getABox().getStats()._satisfiabilityCount; assertEquals("Subclass check (Cached: " + cached + ") failed for (" + ATermUtils.toString(c1) + " [= " + ATermUtils.toString(c2) + ")", expectedSubClass, computedSubClass); } }
@Test public void test484() { dataProperties(_p); individuals(_a); final ATermAppl dt = restrict(Datatypes.INTEGER, minExclusive(literal(0)), maxExclusive(literal(0))); _kb.addType(_a, some(_p, dt)); assertFalse(_kb.isConsistent()); assertEquals(Clash.ClashType.EMPTY_DATATYPE, _kb.getABox().getLastClash().getType()); }
@Test public void instanceCheckForMergedNode() { classes(_D, _E); individuals(_a, _b, _c, _d, _e); _kb.addType(_a, oneOf(_b, _c)); _kb.addSubClass(_E, not(_D)); _kb.addType(_a, _D); assertTrue(_kb.isConsistent()); final ATermAppl mergedTo = _kb.getABox().getIndividual(_a).getMergedTo().getName(); _kb.addType(mergedTo, oneOf(_d, _e)); assertTrue(_kb.isConsistent()); assertTrue(_kb.isType(_a, not(_E))); }