use of fr.lirmm.graphik.graal.core.DefaultRule in project graal by graphik-team.
the class MFAProperty method translateToMFA.
public static RuleSet translateToMFA(Iterable<Rule> rules) {
RuleSet R = new LinkedListRuleSet();
for (Rule r : rules) {
for (Rule r2 : translateRuleToMFA(r)) R.add(r2);
}
DefaultRule rule = new DefaultRule();
Atom s = new DefaultAtom(S);
s.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
s.setTerm(1, DefaultTermFactory.instance().createVariable("X2"));
Atom d = new DefaultAtom(D);
d.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
d.setTerm(1, DefaultTermFactory.instance().createVariable("X2"));
rule.getBody().add(s);
rule.getHead().add(d);
R.add(rule);
s = new DefaultAtom(S);
d = new DefaultAtom(D);
Atom d2 = new DefaultAtom(D);
d.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
d.setTerm(1, DefaultTermFactory.instance().createVariable("X2"));
s.setTerm(0, DefaultTermFactory.instance().createVariable("X2"));
s.setTerm(1, DefaultTermFactory.instance().createVariable("X3"));
d2.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
d2.setTerm(1, DefaultTermFactory.instance().createVariable("X3"));
rule = new DefaultRule();
rule.getBody().add(d);
rule.getBody().add(s);
rule.getHead().add(d2);
R.add(rule);
return R;
}
use of fr.lirmm.graphik.graal.core.DefaultRule 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.core.DefaultRule in project graal by graphik-team.
the class MFAProperty method translateRuleToMFA.
public static List<Rule> translateRuleToMFA(final Rule r) {
List<Rule> result = new LinkedList<Rule>();
DefaultRule r2 = new DefaultRule(r);
/*r2.setBody(r.getBody());
r2.setHead(r.getHead());*/
for (Term yi : r2.getExistentials()) {
Predicate Fir = GraalConstant.freshPredicate(1);
DefaultAtom f = new DefaultAtom(Fir);
f.setTerm(0, yi);
r2.getHead().add(f);
for (Term xj : r2.getFrontier()) {
DefaultAtom ss = new DefaultAtom(S);
ss.setTerm(0, xj);
ss.setTerm(1, yi);
r2.getHead().add(ss);
}
DefaultRule r3 = new DefaultRule();
DefaultAtom f1 = new DefaultAtom(Fir);
f1.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
DefaultAtom f2 = new DefaultAtom(Fir);
f2.setTerm(0, DefaultTermFactory.instance().createVariable("X2"));
DefaultAtom d = new DefaultAtom(D);
d.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
d.setTerm(1, DefaultTermFactory.instance().createVariable("X2"));
r3.getBody().add(f1);
r3.getBody().add(d);
r3.getBody().add(f2);
DefaultAtom c = new DefaultAtom(C);
c.setTerm(0, FAKE);
r3.getHead().add(c);
result.add(r3);
}
result.add(r2);
return result;
}
use of fr.lirmm.graphik.graal.core.DefaultRule in project graal by graphik-team.
the class MSAProperty method translateRuleToMSA.
public static List<Rule> translateRuleToMSA(final Rule r) {
List<Rule> result = new LinkedList<Rule>();
Substitution s = buildMSASubstitution(r);
DefaultRule r2 = new DefaultRule(r);
/*r2.setBody(r.getBody());
r2.setHead(r.getHead());*/
for (Term yi : r2.getExistentials()) {
Predicate Fir = GraalConstant.freshPredicate(1);
DefaultAtom f = new DefaultAtom(Fir);
f.setTerm(0, yi);
r2.getHead().add(f);
for (Term xj : r2.getFrontier()) {
DefaultAtom ss = new DefaultAtom(S);
ss.setTerm(0, xj);
ss.setTerm(1, yi);
r2.getHead().add(ss);
}
DefaultRule r3 = new DefaultRule();
DefaultAtom f1 = new DefaultAtom(Fir);
f1.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
DefaultAtom f2 = new DefaultAtom(Fir);
f2.setTerm(0, DefaultTermFactory.instance().createVariable("X2"));
DefaultAtom d = new DefaultAtom(D);
d.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
d.setTerm(1, DefaultTermFactory.instance().createVariable("X2"));
r3.getBody().add(f1);
r3.getBody().add(d);
r3.getBody().add(f2);
DefaultAtom c = new DefaultAtom(C);
c.setTerm(0, FAKE);
r3.getHead().add(c);
result.add(r3);
}
r2.setHead(s.createImageOf(r2.getHead()));
result.add(r2);
return result;
}
use of fr.lirmm.graphik.graal.core.DefaultRule in project graal by graphik-team.
the class MSAProperty method translateToMSA.
public static RuleSet translateToMSA(Iterable<Rule> rules) {
RuleSet R = new LinkedListRuleSet();
for (Rule r : rules) {
for (Rule r2 : translateRuleToMSA(r)) R.add(r2);
}
DefaultRule rule = new DefaultRule();
Atom s = new DefaultAtom(S);
s.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
s.setTerm(1, DefaultTermFactory.instance().createVariable("X2"));
Atom d = new DefaultAtom(D);
d.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
d.setTerm(1, DefaultTermFactory.instance().createVariable("X2"));
rule.getBody().add(s);
rule.getHead().add(d);
R.add(rule);
s = new DefaultAtom(S);
d = new DefaultAtom(D);
Atom d2 = new DefaultAtom(D);
d.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
d.setTerm(1, DefaultTermFactory.instance().createVariable("X2"));
s.setTerm(0, DefaultTermFactory.instance().createVariable("X2"));
s.setTerm(1, DefaultTermFactory.instance().createVariable("X3"));
d2.setTerm(0, DefaultTermFactory.instance().createVariable("X1"));
d2.setTerm(1, DefaultTermFactory.instance().createVariable("X3"));
rule = new DefaultRule();
rule.getBody().add(d);
rule.getBody().add(s);
rule.getHead().add(d2);
R.add(rule);
return R;
}
Aggregations