Search in sources :

Example 11 with HigherOrderDeclException

use of kodkod.engine.fol2sat.HigherOrderDeclException in project org.alloytools.alloy by AlloyTools.

the class GRA013_026 method main.

/**
 * Usage: java examples.tptp.GRA013_026 <graph size> <clique size>
 */
public static void main(String[] args) {
    if (args.length < 2)
        usage();
    try {
        final GRA013_026 model = new GRA013_026(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
        final Bounds b = model.bounds();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        solver.options().setReporter(new ConsoleReporter());
        final Formula f = model.checkGoalToBeProved();
        System.out.println(PrettyPrinter.print(f, 2));
        // System.out.println(b);
        final Solution s = solver.solve(f, b);
        System.out.println(s);
    // System.out.println((new Evaluator(s.instance())).evaluate(f));
    } catch (HigherOrderDeclException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnboundLeafException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) UnboundLeafException(kodkod.engine.fol2sat.UnboundLeafException) ConsoleReporter(kodkod.engine.config.ConsoleReporter) Bounds(kodkod.instance.Bounds) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException) Solution(kodkod.engine.Solution)

Example 12 with HigherOrderDeclException

use of kodkod.engine.fol2sat.HigherOrderDeclException in project org.alloytools.alloy by AlloyTools.

the class BugTests method testFelix_08022006.

public final void testFelix_08022006() {
    Relation x = Relation.nary("P", 1);
    String[] atoms = { "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1", "0", "1", "2", "3", "4", "5", "6", "7" };
    java.util.ArrayList<String> atomlist = new java.util.ArrayList<String>();
    for (String a : atoms) atomlist.add(a);
    Universe universe = new Universe(atomlist);
    TupleFactory factory = universe.factory();
    Bounds bounds = new Bounds(universe);
    for (int i = -8; i <= 7; i++) bounds.boundExactly(i, factory.setOf(String.valueOf(i)));
    bounds.bound(x, factory.allOf(1));
    Formula f = x.in(Expression.INTS).and(x.some());
    // System.out.println(bounds);
    Solver solver = new Solver();
    // solver.options().setSolver(SATFactory.ZChaff);
    solver.options().setSolver(SATFactory.DefaultSAT4J);
    solver.options().setBitwidth(4);
    solver.options().setIntEncoding(Options.IntEncoding.TWOSCOMPLEMENT);
    Solution sol;
    try {
        sol = solver.solve(f, bounds);
        assertNotNull(sol.instance());
    } catch (HigherOrderDeclException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnboundLeafException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Solver(kodkod.engine.Solver) UnboundLeafException(kodkod.engine.fol2sat.UnboundLeafException) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe) Formula(kodkod.ast.Formula) Relation(kodkod.ast.Relation) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException) Solution(kodkod.engine.Solution)

Aggregations

HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)12 Formula (kodkod.ast.Formula)8 Solution (kodkod.engine.Solution)7 Solver (kodkod.engine.Solver)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 Bounds (kodkod.instance.Bounds)7 ErrorType (edu.mit.csail.sdg.alloy4.ErrorType)4 CapacityExceededException (kodkod.engine.CapacityExceededException)4 Err (edu.mit.csail.sdg.alloy4.Err)3 ErrorFatal (edu.mit.csail.sdg.alloy4.ErrorFatal)3 Pos (edu.mit.csail.sdg.alloy4.Pos)3 ArrayList (java.util.ArrayList)3 Expression (kodkod.ast.Expression)2 IntExpression (kodkod.ast.IntExpression)2 QuantifiedFormula (kodkod.ast.QuantifiedFormula)2 Relation (kodkod.ast.Relation)2 TupleFactory (kodkod.instance.TupleFactory)2 Universe (kodkod.instance.Universe)2 A4Reporter (edu.mit.csail.sdg.alloy4.A4Reporter)1 Command (edu.mit.csail.sdg.ast.Command)1