use of fr.lirmm.graphik.graal.core.FreshVarSubstitution in project graal by graphik-team.
the class DlgpListener method createAtomSet.
@Override
protected void createAtomSet(InMemoryAtomSet atomset) {
FreshVarSubstitution s = new FreshVarSubstitution(DlgpParser.freeVarGen);
CloseableIteratorWithoutException<Atom> it = atomset.iterator();
while (it.hasNext()) {
Atom a = it.next();
this.set.write(s.createImageOf(a));
}
}
use of fr.lirmm.graphik.graal.core.FreshVarSubstitution in project graal by graphik-team.
the class UnifierUtils method getSafeCopy.
public static Rule getSafeCopy(Rule rule) {
Substitution substitution = new FreshVarSubstitution(varGen);
InMemoryAtomSet body = rule.getBody();
InMemoryAtomSet head = rule.getHead();
InMemoryAtomSet safeBody = new LinkedListAtomSet();
InMemoryAtomSet safeHead = new LinkedListAtomSet();
substitution.apply(body, safeBody);
substitution.apply(head, safeHead);
return DefaultRuleFactory.instance().create(safeBody, safeHead);
}
use of fr.lirmm.graphik.graal.core.FreshVarSubstitution in project graal by graphik-team.
the class FreeVarSubstitutionTest method test.
@Test
public void test() throws ParseException {
final Term X = DefaultTermFactory.instance().createVariable("X");
final Term Y = DefaultTermFactory.instance().createVariable("Y");
final Term Z = DefaultTermFactory.instance().createVariable("Z");
Rule rule = DlgpParser.parseRule("p(X,Y,Z) :- q(X,Y), q(Y,Z).");
FreshVarSubstitution subtitution = new FreshVarSubstitution();
Rule substitut = subtitution.createImageOf(rule);
for (Variable t : substitut.getVariables()) {
if (t.equals(X) || t.equals(Y) || t.equals(Z)) {
Assert.assertFalse(true);
}
}
}
Aggregations