use of fr.lirmm.graphik.graal.core.grd.DefaultGraphOfRuleDependencies in project graal by graphik-team.
the class ChaseTest method restrictedChaseTestWithGrd.
@Theory
public void restrictedChaseTestWithGrd(InMemoryAtomSet atomSet) throws IOException, ChaseException, ParseException, AtomSetException, IteratorException {
atomSet.addAll(DlgpParser.parseAtomSet("<P>(a,a)."));
LinkedList<Rule> ruleSet = new LinkedList<>();
ruleSet.add(DlgpParser.parseRule("<Q>(X,Z) :- <P>(X,X)."));
ruleSet.add(DlgpParser.parseRule("<R>(X,Z) :- <Q>(X,Y)."));
ruleSet.add(DlgpParser.parseRule("<Q>(X,Z) :- <R>(X,Y)."));
ruleSet.add(DlgpParser.parseRule("<S>(X,X) :- <Q>(Y,X)."));
GraphOfRuleDependencies grd = new DefaultGraphOfRuleDependencies(ruleSet);
Chase chase = new ChaseWithGRDAndUnfiers<AtomSet>(grd, atomSet);
chase.execute();
int size = 0;
for (CloseableIterator<Atom> it = atomSet.iterator(); it.hasNext(); it.next()) {
++size;
}
Assert.assertEquals(4, size);
}
use of fr.lirmm.graphik.graal.core.grd.DefaultGraphOfRuleDependencies in project graal by graphik-team.
the class DefaultKnowledgeBase method getFESGraphOfRuleDependencies.
protected GraphOfRuleDependencies getFESGraphOfRuleDependencies() {
if (this.fesGRD == null) {
RuleSet fesRuleSet = this.getFESRuleSet();
this.fesGRD = new DefaultGraphOfRuleDependencies(fesRuleSet);
}
return this.fesGRD;
}
use of fr.lirmm.graphik.graal.core.grd.DefaultGraphOfRuleDependencies in project graal by graphik-team.
the class MFAProperty method check.
/**
*/
@Override
public int check(AnalyserRuleSet ruleSet) {
RuleSet R = translateToMFA(ruleSet);
AtomSet A = Rules.criticalInstance(ruleSet);
Chase chase = new ChaseWithGRD<AtomSet>(new DefaultGraphOfRuleDependencies(R), A, new DefaultRuleApplier<AtomSet>(new FrontierRestrictedChaseHaltingCondition()));
DefaultConjunctiveQuery Q = new DefaultConjunctiveQuery();
DefaultAtom q = new DefaultAtom(C);
q.setTerm(0, FAKE);
Q.getAtomSet().add(q);
try {
while (chase.hasNext()) {
chase.next();
if (SmartHomomorphism.instance().exist(Q, A)) {
return -1;
}
}
} catch (ChaseException e) {
LOGGER.warn("An error occurs during the chase: ", e);
return 0;
} catch (HomomorphismException e) {
LOGGER.warn("An error occurs during the homomorphism: ", e);
return 0;
}
return 1;
}
Aggregations