use of kodkod.ast.QuantifiedFormula in project org.alloytools.alloy by AlloyTools.
the class HOLTranslator method visit.
@Override
public Proc visit(QuantifiedFormula qf) {
assertNotSkolemizable(qf);
Formula qfFlipped = qf.body().quantify(qf.quantifier().opposite, qf.decls(), qf.domain());
Proc body = toProc(qfFlipped);
boolean firstOrder = true;
for (Decl decl : qf.decls()) if (decl.multiplicity() != Multiplicity.ONE) {
firstOrder = false;
break;
}
if (firstOrder && body instanceof FOL && noNewHOLSkolems(((FOL) body).bounds.skolems(), bounds.skolems()))
return new Proc.FOL(bounds, qf);
else
return new Proc.Some4All(bounds, qf, body);
}
use of kodkod.ast.QuantifiedFormula in project org.alloytools.alloy by AlloyTools.
the class HOLSome4AllTest method testE7.
@Test
public void testE7() {
// SAT: some s: ints |
// s > 3 || (all ns: set Node | #ns > s)
Formula cnd = si.gt(I3);
QuantifiedFormula allQF = (QuantifiedFormula) ns.count().gt(si).forAll(ns.setOf(Node));
Decl someDecls = s.oneOf(Expression.INTS);
{
Formula f = cnd.or(allQF).forSome(someDecls);
Solution sol = solve(f);
assertTrue(sol.sat());
assertEquals(-1, evalS(sol));
}
{
Formula f = cnd.or(flip(allQF)).forSome(someDecls);
Solution sol = solve(f);
assertTrue(sol.sat());
assertEquals(-1, evalS(sol));
}
}
use of kodkod.ast.QuantifiedFormula in project org.alloytools.alloy by AlloyTools.
the class HOLSome4AllTest method testE9i.
@Test
public void testE9i() {
// SAT: some s: ints |
// s > 3 || (some ns: set Node | #ns > s + 3)
Formula cnd = si.gt(I3);
QuantifiedFormula innerSomeQF = (QuantifiedFormula) ns.count().gt(si.plus(I3)).forSome(ns.setOf(Node));
Decl someDecls = s.oneOf(Expression.INTS);
Formula f = cnd.or(innerSomeQF).forSome(someDecls);
Solution sol = solve(f);
assertTrue(sol.sat());
assertEquals(-1, evalS(sol));
}
use of kodkod.ast.QuantifiedFormula in project org.alloytools.alloy by AlloyTools.
the class HOLSome4AllTest method testE9ii.
@Test
public void testE9ii() {
// SAT: some s: ints - 1 |
// s > 2 || (some ns: set Node | #ns > s + 3)
Formula cnd = si.gt(I2);
QuantifiedFormula innerSomeQF = (QuantifiedFormula) ns.count().gt(si.plus(I3)).forSome(ns.setOf(Node));
Decl someDecls = s.oneOf(Expression.INTS.difference(M1.toExpression()));
Formula f = cnd.or(innerSomeQF).forSome(someDecls);
Solution sol = solve(f);
assertTrue(sol.sat());
assertEquals(3, evalS(sol));
}
Aggregations