Search in sources :

Example 1 with ChaseWithGRD

use of fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD in project graal by graphik-team.

the class DefaultKnowledgeBase method fesSaturate.

// /////////////////////////////////////////////////////////////////////////
// PRIVATE METHODS
// /////////////////////////////////////////////////////////////////////////
/**
 * Run saturation with a timeout at <code>timeout</code> milliseconds for this thread to die. A timeout of 0 means to wait forever.
 * @param timeout in milliseconds
 * @throws ChaseException
 * @throws TimeoutException
 */
protected void fesSaturate(long timeout) throws ChaseException, TimeoutException {
    if (!isFESSaturated) {
        GraphOfRuleDependencies grd = this.getFESGraphOfRuleDependencies();
        ChaseWithGRD<AtomSet> chase = new ChaseWithGRD<>(grd, this.store);
        chase.setProfiler(this.getProfiler());
        chase.execute(timeout);
        this.isFESSaturated = true;
    }
}
Also used : AtomSet(fr.lirmm.graphik.graal.api.core.AtomSet) ChaseWithGRD(fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD) GraphOfRuleDependencies(fr.lirmm.graphik.graal.api.core.GraphOfRuleDependencies) DefaultGraphOfRuleDependencies(fr.lirmm.graphik.graal.core.grd.DefaultGraphOfRuleDependencies)

Example 2 with ChaseWithGRD

use of fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD 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;
}
Also used : AnalyserRuleSet(fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet) RuleSet(fr.lirmm.graphik.graal.api.core.RuleSet) LinkedListRuleSet(fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet) DefaultConjunctiveQuery(fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery) FrontierRestrictedChaseHaltingCondition(fr.lirmm.graphik.graal.forward_chaining.halting_condition.FrontierRestrictedChaseHaltingCondition) HomomorphismException(fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException) DefaultGraphOfRuleDependencies(fr.lirmm.graphik.graal.core.grd.DefaultGraphOfRuleDependencies) AtomSet(fr.lirmm.graphik.graal.api.core.AtomSet) DefaultAtom(fr.lirmm.graphik.graal.core.DefaultAtom) ChaseWithGRD(fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD) ChaseException(fr.lirmm.graphik.graal.api.forward_chaining.ChaseException) Chase(fr.lirmm.graphik.graal.api.forward_chaining.Chase)

Example 3 with ChaseWithGRD

use of fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD in project graal by graphik-team.

the class DefaultKnowledgeBase method saturate.

@Override
public void saturate() throws KnowledgeBaseException {
    if (!this.isSaturated) {
        boolean run = this.approach == Approach.SATURATION_ONLY;
        if (!run) {
            this.analyse();
            run = this.analyse.isFES();
        }
        if (run) {
            GraphOfRuleDependencies grd = this.analysedRuleSet.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");
        }
    }
}
Also used : AtomSet(fr.lirmm.graphik.graal.api.core.AtomSet) ChaseWithGRD(fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD) KnowledgeBaseException(fr.lirmm.graphik.graal.api.kb.KnowledgeBaseException) GraphOfRuleDependencies(fr.lirmm.graphik.graal.api.core.GraphOfRuleDependencies) DefaultGraphOfRuleDependencies(fr.lirmm.graphik.graal.core.grd.DefaultGraphOfRuleDependencies) ChaseException(fr.lirmm.graphik.graal.api.forward_chaining.ChaseException)

Aggregations

AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)3 DefaultGraphOfRuleDependencies (fr.lirmm.graphik.graal.core.grd.DefaultGraphOfRuleDependencies)3 ChaseWithGRD (fr.lirmm.graphik.graal.forward_chaining.ChaseWithGRD)3 GraphOfRuleDependencies (fr.lirmm.graphik.graal.api.core.GraphOfRuleDependencies)2 ChaseException (fr.lirmm.graphik.graal.api.forward_chaining.ChaseException)2 RuleSet (fr.lirmm.graphik.graal.api.core.RuleSet)1 Chase (fr.lirmm.graphik.graal.api.forward_chaining.Chase)1 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)1 KnowledgeBaseException (fr.lirmm.graphik.graal.api.kb.KnowledgeBaseException)1 DefaultAtom (fr.lirmm.graphik.graal.core.DefaultAtom)1 DefaultConjunctiveQuery (fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery)1 LinkedListRuleSet (fr.lirmm.graphik.graal.core.ruleset.LinkedListRuleSet)1 FrontierRestrictedChaseHaltingCondition (fr.lirmm.graphik.graal.forward_chaining.halting_condition.FrontierRestrictedChaseHaltingCondition)1 AnalyserRuleSet (fr.lirmm.graphik.graal.rulesetanalyser.util.AnalyserRuleSet)1