DefaultKnowledgeBase extends AbstractProfilable implements KnowledgeBase { @Override public void saturate() throws KnowledgeBaseException { if(this.approach == Approach.REWRITING_ONLY) { throw new KnowledgeBaseException("Saturation is not allowed, this knowledge base is in rewriting only approach."); } if (!this.isSaturated) { boolean run = this.approach == Approach.SATURATION_ONLY; if(!run) { this.analyse(); run = this.analyse.isFES(); } if (run) { GraphOfRuleDependencies grd = this.getGraphOfRuleDependencies(); ChaseWithGRD<AtomSet> chase = new ChaseWithGRD<>(grd, this.store); chase.setProfiler(this.getProfiler()); try { chase.execute(); } catch (ChaseException e) { throw new KnowledgeBaseException(e); } this.isSaturated = true; this.isFESSaturated = true; this.isSemiSaturated = true; } else { throw new KnowledgeBaseException("There is no proof for FES decidability"); } } } DefaultKnowledgeBase(Parser<Object> parser);  DefaultKnowledgeBase(AtomSet store, Parser<Object> parser);  DefaultKnowledgeBase(AtomSet store, RuleSet ontology); @Override RuleSet getOntology(); @Override AtomSet getFacts(); GraphOfRuleDependencies getGraphOfRuleDependencies(); @Override boolean isConsistent(); @Override void saturate(); @Override void semiSaturate(); @Override CloseableIterator<Substitution> homomorphism(Query query); @Override CloseableIterator<Substitution> query(Query query); @Override CloseableIterator<Substitution> query(Query query, long timeout); @Override void close(); @Override Set<String> getRuleNames(); @Override Rule getRule(String name); @Override boolean addQuery(Query query); @Override Set<String> getQueryNames(); @Override Query getQuery(String name); @Override Approach getApproach(); @Override String toString();  }
@Test(expected = KnowledgeBaseException.class) public void githubIssue3_REWRITING_ONLY() throws ParseException, KBBuilderException, KnowledgeBaseException { KBBuilder kbb = new KBBuilder(); kbb.addAll(new DlgpParser("" + "p(a)." + "q(X) :- p(X).")); kbb.setApproach(Approach.REWRITING_ONLY); KnowledgeBase kb = kbb.build(); kb.saturate(); }
@Test public void testSaturate() throws ParseException, AtomSetException, KnowledgeBaseException { KnowledgeBase kb = new DefaultKnowledgeBase( new DlgpParser("p(X) :- q(X). q(X) :- r(X). r(X) :- s(X). s(a).")); kb.saturate(); Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("r(a)."))); Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("q(a)."))); Assert.assertTrue(kb.getFacts().contains(DlgpParser.parseAtom("p(a)."))); kb.close(); }