use of kodkod.engine.ucore.AdaptiveRCEStrategy in project org.alloytools.alloy by AlloyTools.
the class ToyLists method main.
/**
* Usage: java examples.alloy.ToyLists <# of lists> <# of things> <id of
* assertion to check or 0 to just run the spec>
*/
public static void main(String[] args) {
if (args.length < 3)
usage();
try {
final int l = Integer.parseInt(args[0]);
final int t = Integer.parseInt(args[1]);
final int a = Integer.parseInt(args[2]);
final ToyLists model = new ToyLists();
final Bounds b = model.bounds(l, t);
final Solver solver = new Solver();
solver.options().setSolver(SATFactory.MiniSatProver);
solver.options().setLogTranslation(1);
solver.options().setSymmetryBreaking(1000);
final Formula f;
switch(a) {
case 0:
f = model.spec();
break;
case 1:
f = model.spec().and(model.equivPrefix().not());
break;
case 2:
f = model.spec().and(model.loneList().not());
break;
case 3:
f = model.spec().and(model.transitivePrefixes().not());
break;
case 4:
f = model.spec().and(model.acyclicity().not());
break;
case 5:
f = model.spec().and(model.equivReflexivity().not());
break;
default:
usage();
throw new AssertionError("dead code");
}
final Solution sol = solver.solve(f, b);
if (sol.instance() != null) {
System.out.println(sol);
} else {
System.out.println(sol.outcome());
System.out.println(sol.stats());
System.out.println("Top level formulas: " + sol.proof().log().roots().size());
System.out.println("Initial core: " + sol.proof().highLevelCore().size());
sol.proof().minimize(new AdaptiveRCEStrategy(sol.proof().log()));
System.out.println("Minimal core: " + sol.proof().highLevelCore().size());
final Set<Formula> core = Nodes.allRoots(f, sol.proof().highLevelCore().values());
for (Formula c : core) {
System.out.println(c);
}
System.out.print("checking the core ... ");
if (solver.solve(Formula.and(core), b).instance() == null) {
System.out.println("correct.");
} else {
System.out.println("incorrect!");
}
}
} catch (NumberFormatException nfe) {
usage();
}
}
Aggregations