use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class HOLSome4AllTest method testE1.
@Test
public void testE1() {
// SAT: some s: ints | all ns: set Node | #ns > s
Formula f = ns.count().gt(si).forAll(ns.setOf(Node)).forSome(s.oneOf(Expression.INTS));
Solution sol = solve(f);
assertEquals(true, sol.sat());
assertEquals(-1, evalS(sol));
}
use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class HOLSome4AllTest method testE2.
@Test
public void testE2() {
// UNSAT: some s: ints | s > 0 && (all ns: set Node | #ns > s)
Formula cnd = si.gt(I0);
Formula f = cnd.and(ns.count().gt(si).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS));
Solution sol = solve(f);
assertEquals(false, sol.sat());
}
use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class ReductionAndProofTest method testProof.
public final void testProof() {
Variable v0 = Variable.unary("v0"), v1 = Variable.unary("v1"), v2 = Variable.unary("v2");
Formula f0 = v0.join(a2b).eq(v1.union(v2)).and(v1.eq(v2).not());
Formula f1 = f0.forSome(v0.oneOf(a).and(v1.oneOf(b)).and(v2.oneOf(b)));
Formula f2 = a2b.function(a, b);
Formula f3 = f1.and(f2).and(total.totalOrder(ordered, first, last));
Solution sol = null;
solver.options().setLogTranslation(0);
solver.options().setSolver(SATFactory.MiniSat);
sol = solver.solve(f3, bounds);
assertEquals(Solution.Outcome.UNSATISFIABLE, sol.outcome());
assertNull(sol.proof());
solver.options().setLogTranslation(1);
sol = solver.solve(f3, bounds);
assertNull(sol.proof());
solver.options().setSolver(SATFactory.MiniSatProver);
sol = solver.solve(f3, bounds);
// System.out.println(f3 + ", " + bounds);
sol.proof().minimize(new ECFPStrategy());
final Set<Formula> top = Nodes.minRoots(f3, sol.proof().highLevelCore().values());
assertEquals(2, top.size());
assertTrue(top.contains(f1));
assertTrue(top.contains(f2));
// for(Iterator<TranslationLog.Record> itr = sol.proof().core();
// itr.hasNext(); ) {
// System.out.println(itr.next());
// }
}
use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class ReductionAndProofTest method reduce.
private Set<Formula> reduce(Formula formula) {
final Solution sol = solver.solve(formula, bounds);
assertEquals(Solution.Outcome.TRIVIALLY_UNSATISFIABLE, sol.outcome());
sol.proof().minimize(null);
return Nodes.minRoots(formula, sol.proof().highLevelCore().values());
}
use of kodkod.engine.Solution in project org.alloytools.alloy by AlloyTools.
the class ReductionAndProofTest method core.
private Set<Node> core(Formula formula, int granularity) {
solver.options().setCoreGranularity(granularity);
final Solution sol = solver.solve(formula, bounds);
assertEquals(Solution.Outcome.UNSATISFIABLE, sol.outcome());
sol.proof().minimize(new NCEStrategy(sol.proof().log()));
return new IdentityHashSet<Node>(sol.proof().highLevelCore().values());
}
Aggregations