Search in sources :

Example 46 with Solver

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

the class GEO091 method main.

/**
 * Usage: java examples.tptp.GEO191 [univ size]
 */
public static void main(String[] args) {
    if (args.length < 1)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final GEO091 model = new GEO091();
        final Formula f = model.checkTheorem_2_13();
        System.out.println(model.theorem_2_13());
        final Bounds b = model.bounds(n);
        final Solution sol = solver.solve(f, b);
        System.out.println(sol);
    // System.out.println((new
    // Evaluator(sol.instance())).evaluate(model.axioms().and(model.theorem213().not())));
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 47 with Solver

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

the class ALG195 method main.

/**
 * Usage: java examples.tptp.ALG195
 */
public static void main(String[] args) {
    try {
        final ALG195 model = new ALG195();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final Formula f = model.checkCO1();
        final Bounds b = model.bounds();
        // System.out.println(model.decls());
        // System.out.println(model.ax2ax7());
        // System.out.println(b);
        final Solution sol = solver.solve(f, b);
        if (sol.instance() == null) {
            System.out.println(sol);
        } else {
            System.out.println(sol.stats());
            model.display(sol.instance());
        }
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 48 with Solver

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

the class ALG197 method main.

/**
 * Usage: java examples.tptp.ALG197
 */
public static void main(String[] args) {
    try {
        final ALG197 model = new ALG197();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final Formula f = model.checkCO1();
        final Bounds b = model.bounds();
        final Solution sol = solver.solve(f, b);
        if (sol.instance() == null) {
            System.out.println(sol);
        } else {
            System.out.println(sol.stats());
            model.display(sol.instance());
        }
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 49 with Solver

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

the class GEO092 method main.

/**
 * Usage: ava examples.tptp.GEO192 [# curves] [# points]
 */
public static void main(String[] args) {
    if (args.length < 2)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final GEO092 model = new GEO092();
        final Formula f = model.checkProposition2141();
        System.out.println(model.proposition2141());
        final Bounds b = model.bounds(n);
        final Solution sol = solver.solve(f, b);
        System.out.println(sol);
    // System.out.println((new
    // Evaluator(sol.instance())).evaluate(model.axioms().and(model.theorem213().not())));
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 50 with Solver

use of kodkod.engine.Solver 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)

Aggregations

Solver (kodkod.engine.Solver)76 Solution (kodkod.engine.Solution)72 Formula (kodkod.ast.Formula)67 Bounds (kodkod.instance.Bounds)67 Universe (kodkod.instance.Universe)26 TupleFactory (kodkod.instance.TupleFactory)25 Relation (kodkod.ast.Relation)24 TupleSet (kodkod.instance.TupleSet)23 Expression (kodkod.ast.Expression)14 IntExpression (kodkod.ast.IntExpression)14 Variable (kodkod.ast.Variable)14 Decls (kodkod.ast.Decls)11 HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 ConsoleReporter (kodkod.engine.config.ConsoleReporter)6 LinkedHashSet (java.util.LinkedHashSet)5 Evaluator (kodkod.engine.Evaluator)3 AbstractReporter (kodkod.engine.config.AbstractReporter)3 Instance (kodkod.instance.Instance)3 Method (java.lang.reflect.Method)2