Search in sources :

Example 11 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class Lists method main.

/**
 * Usage: java examples.Lists [scope]
 */
public static void main(String[] args) {
    if (args.length < 1)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final Lists model = new Lists();
        final Bounds b = model.bounds(n);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        // solver.options().setFlatten(false);
        // solver.options().setSkolemize(false);
        Formula f = model.runShow();
        System.out.println("running show");
        Solution s = solver.solve(f, b);
        System.out.println(s);
        f = model.checkEmpties();
        System.out.println("checking empties");
        s = solver.solve(f, b);
        System.out.println(s);
        f = model.checkReflexive();
        System.out.println("checking reflexive");
        s = solver.solve(f, b);
        System.out.println(s);
        f = model.checkSymmetric();
        System.out.println("checking symmetric");
        s = solver.solve(f, b);
        System.out.println(s);
    } catch (NumberFormatException nfe) {
        usage();
    } catch (HigherOrderDeclException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (UnboundLeafException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) UnboundLeafException(kodkod.engine.fol2sat.UnboundLeafException) Bounds(kodkod.instance.Bounds) HigherOrderDeclException(kodkod.engine.fol2sat.HigherOrderDeclException) Solution(kodkod.engine.Solution)

Example 12 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class RingElection method main.

/**
 * Usage: java examples.RingElection [# processes] [# times]
 */
public static void main(String[] args) {
    if (args.length < 2)
        usage();
    try {
        final RingElection model = new RingElection();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final int p = Integer.parseInt(args[0]);
        final int t = Integer.parseInt(args[1]);
        final Formula checkAtMostOneElected = model.checkAtMostOneElected();
        final Bounds boundspt = model.bounds(p, t);
        System.out.println("*****check AtMostOneElected for " + p + " Process, " + t + " Time*****");
        Solution sol1 = solver.solve(checkAtMostOneElected, boundspt);
        System.out.println(sol1);
    // // run looplessPath for 13 Time, 3 Process
    // final Formula runLooplessPath =
    // model.declsAndFacts();//.and(model.looplessPath());
    // final Bounds bounds313 = model.bounds(p, t);
    // System.out.println("*****run looplessPath for 13 Time, 3
    // Process*****");
    // System.out.println(runLooplessPath);
    // System.out.println(bounds313);
    // Solution sol2 = solver.solve(runLooplessPath, bounds313);
    // System.out.println(sol2);
    } catch (NumberFormatException nfe) {
        usage();
    }
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 13 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class ToyFilesystem method bounds.

/**
 * Returns the toy filesystem bounds.
 *
 * @return toy filesystem bounds
 */
public final Bounds bounds() {
    final Universe universe = new Universe("d0", "d1", "f0", "f1", "f2");
    final Bounds bounds = new Bounds(universe);
    final TupleFactory factory = universe.factory();
    bounds.boundExactly(root, factory.setOf("d0"));
    bounds.bound(dir, factory.setOf("d0", "d1"));
    bounds.bound(file, factory.setOf("f0", "f1", "f2"));
    bounds.bound(contents, factory.setOf(factory.tuple("d0", "d1")), bounds.upperBound(dir).product(factory.allOf(1)));
    return bounds;
}
Also used : Bounds(kodkod.instance.Bounds) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 14 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class ToyFilesystem method main.

/**
 * Usage: java examples.alloy.ToyFilesystem
 */
public static void main(String[] args) {
    final ToyFilesystem toy = new ToyFilesystem();
    final Formula f = toy.constraints();
    System.out.println(PrettyPrinter.print(f, 2));
    final Bounds b = toy.bounds();
    final Solver solver = new Solver();
    solver.options().setSolver(SATFactory.MiniSat);
    final Solution s = solver.solve(f, b);
    System.out.println(s);
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Example 15 with Bounds

use of kodkod.instance.Bounds in project org.alloytools.alloy by AlloyTools.

the class IntConstraints method main.

/**
 * Usage: java examples.IntConstraints
 */
public static void main(String[] args) {
    final IntConstraints model = new IntConstraints();
    final Bounds bounds = model.bounds();
    final Formula formula = model.formula();
    final Solver solver = new Solver();
    solver.options().setBitwidth(32);
    solver.options().setSolver(SATFactory.MiniSat);
    final Solution sol = solver.solve(formula, bounds);
    model.print(sol, solver.options());
}
Also used : Formula(kodkod.ast.Formula) Solver(kodkod.engine.Solver) Bounds(kodkod.instance.Bounds) Solution(kodkod.engine.Solution)

Aggregations

Bounds (kodkod.instance.Bounds)140 Formula (kodkod.ast.Formula)83 Universe (kodkod.instance.Universe)79 TupleFactory (kodkod.instance.TupleFactory)76 Solution (kodkod.engine.Solution)75 Solver (kodkod.engine.Solver)67 TupleSet (kodkod.instance.TupleSet)55 Relation (kodkod.ast.Relation)49 ArrayList (java.util.ArrayList)45 Expression (kodkod.ast.Expression)21 Variable (kodkod.ast.Variable)21 IntExpression (kodkod.ast.IntExpression)20 Instance (kodkod.instance.Instance)12 Decls (kodkod.ast.Decls)11 Evaluator (kodkod.engine.Evaluator)8 HigherOrderDeclException (kodkod.engine.fol2sat.HigherOrderDeclException)7 UnboundLeafException (kodkod.engine.fol2sat.UnboundLeafException)7 ConsoleReporter (kodkod.engine.config.ConsoleReporter)6 Tuple (kodkod.instance.Tuple)6 LinkedHashSet (java.util.LinkedHashSet)5