Search in sources :

Example 96 with Bounds

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

the class Dijkstra method bounds.

/**
 * Returns the bounds corresponding to the given scopes.
 *
 * @return bounds
 */
public Bounds bounds(int states, int processes, int mutexes) {
    final List<String> atoms = new ArrayList<String>(states + processes + mutexes);
    for (int i = 0; i < states; i++) {
        atoms.add("State" + i);
    }
    for (int i = 0; i < processes; i++) {
        atoms.add("Process" + i);
    }
    for (int i = 0; i < mutexes; i++) {
        atoms.add("Mutex" + i);
    }
    final Universe u = new Universe(atoms);
    final TupleFactory f = u.factory();
    final Bounds b = new Bounds(u);
    final TupleSet sb = f.range(f.tuple("State0"), f.tuple("State" + (states - 1)));
    final TupleSet pb = f.range(f.tuple("Process0"), f.tuple("Process" + (processes - 1)));
    final TupleSet mb = f.range(f.tuple("Mutex0"), f.tuple("Mutex" + (mutexes - 1)));
    b.bound(State, sb);
    b.bound(holds, sb.product(pb).product(mb));
    b.bound(waits, sb.product(pb).product(mb));
    b.bound(sfirst, sb);
    b.bound(slast, sb);
    b.bound(sord, sb.product(sb));
    b.bound(Process, pb);
    b.bound(Mutex, mb);
    b.bound(mfirst, mb);
    b.bound(mlast, mb);
    b.bound(mord, mb.product(mb));
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 97 with Bounds

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

the class NUM374 method bounds.

/**
 * Returns the bounds for the given scope.
 *
 * @return bounds for the given scope
 */
public final Bounds bounds(int n) {
    assert n > 0;
    final List<String> atoms = new ArrayList<String>(n);
    for (int i = 0; i < n; i++) atoms.add("a" + i);
    final Universe u = new Universe(atoms);
    final Bounds b = new Bounds(u);
    final TupleFactory f = u.factory();
    final TupleSet all3 = f.allOf(3);
    b.bound(sum, all3);
    b.bound(product, all3);
    b.bound(exponent, all3);
    b.bound(n1, f.allOf(1));
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 98 with Bounds

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

the class Quasigroups7 method bounds.

/**
 * Returns the partial bounds the problem (axioms 1, 4, 9-11).
 *
 * @return the partial bounds for the problem
 */
public Bounds bounds() {
    final List<String> atoms = new ArrayList<String>(14);
    for (int i = 0; i < 7; i++) atoms.add("e1" + i);
    for (int i = 0; i < 7; i++) atoms.add("e2" + i);
    final Universe u = new Universe(atoms);
    final Bounds b = new Bounds(u);
    final TupleFactory f = u.factory();
    b.boundExactly(s1, f.range(f.tuple("e10"), f.tuple("e16")));
    b.boundExactly(s2, f.range(f.tuple("e20"), f.tuple("e26")));
    // axioms 9, 10, 11
    for (int i = 0; i < 7; i++) {
        b.boundExactly(e1[i], f.setOf("e1" + i));
        b.boundExactly(e2[i], f.setOf("e2" + i));
    }
    // axom 1
    final TupleSet op1h = f.area(f.tuple("e10", "e10", "e10"), f.tuple("e16", "e16", "e16"));
    // axiom 4
    final TupleSet op2h = f.area(f.tuple("e20", "e20", "e20"), f.tuple("e26", "e26", "e26"));
    b.bound(op1, op1h);
    b.bound(op2, op2h);
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 99 with Bounds

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

the class SET948 method main.

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

Example 100 with Bounds

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

the class GEO159 method main.

/**
 * Usage: ava examples.tptp.GEO159 [scope]
 */
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 GEO159 model = new GEO159();
        final Formula f = model.checkDefs();
        final Bounds b = model.bounds(n);
        final Solution sol = solver.solve(f, b);
        System.out.println(sol);
    } catch (NumberFormatException nfe) {
        usage();
    }
}
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