use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class UnifierTest method pieceUnifierTest2.
@Test
public void pieceUnifierTest2() {
Rule rule = DefaultRuleFactory.instance().create();
rule.getBody().add(TestUtils.sX);
rule.getHead().add(TestUtils.pXB);
InMemoryAtomSet atomset = DefaultAtomSetFactory.instance().create();
atomset.add(TestUtils.pAU);
CloseableIteratorWithoutException<Substitution> unifiers = DefaultUnifierAlgorithm.instance().computePieceUnifier(rule, atomset);
Assert.assertEquals(1, Iterators.count(unifiers));
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class UnifierTest method example35MelanieThesis.
@Test
public void example35MelanieThesis() {
Rule rule = DefaultRuleFactory.instance().create();
rule.getBody().add(TestUtils.pXY);
rule.getHead().add(TestUtils.qXY);
InMemoryAtomSet atomset = DefaultAtomSetFactory.instance().create();
atomset.add(TestUtils.qUV);
atomset.add(TestUtils.pVW);
atomset.add(TestUtils.qTW);
CloseableIteratorWithoutException<Substitution> unifiers = DefaultUnifierAlgorithm.instance().computePieceUnifier(rule, atomset);
Assert.assertEquals(2, Iterators.count(unifiers));
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class FrontierRestrictedChaseHaltingConditionTest method test.
@Test
public void test() throws IteratorException, HomomorphismFactoryException, HomomorphismException {
InMemoryAtomSet atomset = DefaultAtomSetFactory.instance().create(DlgpParser.parseAtom("p(a,b)."));
Rule rule = DlgpParser.parseRule("p(X,Z):-p(X,Y).");
Variable x = DefaultTermFactory.instance().createVariable("X");
Variable y = DefaultTermFactory.instance().createVariable("Y");
Constant a = DefaultTermFactory.instance().createConstant("a");
Constant b = DefaultTermFactory.instance().createConstant("b");
Substitution s = DefaultSubstitutionFactory.instance().createSubstitution();
s.put(x, a);
s.put(y, b);
FrontierRestrictedChaseHaltingCondition condition = new FrontierRestrictedChaseHaltingCondition();
CloseableIterator<Atom> toAdd = condition.apply(rule, s, atomset);
Assert.assertTrue(toAdd.hasNext());
Atom atom1 = toAdd.next();
atomset.add(atom1);
Assert.assertFalse(toAdd.hasNext());
toAdd.close();
s = DefaultSubstitutionFactory.instance().createSubstitution();
s.put(x, a);
s.put(y, atom1.getTerm(1));
toAdd = condition.apply(rule, s, atomset);
Assert.assertFalse(toAdd.hasNext());
toAdd.close();
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class DefaultRuleFactory method create.
@Override
public Rule create(String label, Atom body, Atom head) {
InMemoryAtomSet bodySet = DefaultAtomSetFactory.instance().create(body);
InMemoryAtomSet headSet = DefaultAtomSetFactory.instance().create(head);
return new DefaultRule(label, bodySet, headSet);
}
use of fr.lirmm.graphik.graal.api.core.InMemoryAtomSet in project graal by graphik-team.
the class AbstractMapper method map.
@Override
public Rule map(Rule rule) {
InMemoryAtomSet body = this.map(rule.getBody());
InMemoryAtomSet head = this.map(rule.getHead());
return DefaultRuleFactory.instance().create(rule.getLabel(), body, head);
}
Aggregations