Search in sources :

Example 51 with Bounds

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

the class ALG212 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);
    b.bound(f, u.factory().allOf(4));
    return b;
}
Also used : Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) Universe(kodkod.instance.Universe)

Example 52 with Bounds

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

the class ALG195 method bounds.

/**
 * Returns the bounds the problem (axioms 1, 4, 9-13, second formula of 14-15,
 * and first formula of 16-22).
 *
 * @return the bounds for the problem
 */
@Override
public final Bounds bounds() {
    final Bounds b = super.bounds();
    final TupleFactory f = b.universe().factory();
    final TupleSet op1h = b.upperBound(op1).clone();
    final TupleSet op2h = b.upperBound(op2).clone();
    for (int i = 0; i < 7; i++) {
        // axiom 12
        op1h.remove(f.tuple("e1" + i, "e1" + i, "e1" + i));
        // axiom 13
        op2h.remove(f.tuple("e2" + i, "e2" + i, "e2" + i));
    }
    // axiom
    final TupleSet op1l = f.setOf(f.tuple("e15", "e15", "e11"));
    // 14,
    // line
    // 2
    // axiom
    final TupleSet op2l = f.setOf(f.tuple("e25", "e25", "e21"));
    // 15,
    // line
    // 2
    op1h.removeAll(f.area(f.tuple("e15", "e15", "e10"), f.tuple("e15", "e15", "e16")));
    op1h.addAll(op1l);
    op2h.removeAll(f.area(f.tuple("e25", "e25", "e20"), f.tuple("e25", "e25", "e26")));
    op2h.addAll(op2l);
    b.bound(op1, op1l, op1h);
    b.bound(op2, op2l, op2h);
    final TupleSet high = f.area(f.tuple("e10", "e20"), f.tuple("e14", "e26"));
    high.addAll(f.area(f.tuple("e16", "e20"), f.tuple("e16", "e26")));
    // first line of axioms 16-22
    for (int i = 0; i < 7; i++) {
        Tuple t = f.tuple("e15", "e2" + i);
        high.add(t);
        b.bound(h[i], f.setOf(t), high);
        high.remove(t);
    }
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) TupleFactory(kodkod.instance.TupleFactory) Tuple(kodkod.instance.Tuple)

Example 53 with Bounds

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

the class COM008 method main.

/**
 * Usage: java examples.tptp.COM008 [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 COM008 model = new COM008();
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        // solver.options().setSymmetryBreaking(22);
        // solver.options().setFlatten(false);
        final Formula f = model.checkGoalToBeProved();
        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 54 with Bounds

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

the class COM008 method bounds.

/**
 * Returns 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);
    atoms.add("goal");
    for (int i = 0; i < n; i++) atoms.add("a" + i);
    final Universe u = new Universe(atoms);
    final Bounds bound = new Bounds(u);
    final TupleFactory f = u.factory();
    final TupleSet d1 = f.range(f.tuple("a0"), f.tuple("a" + (n - 1)));
    final TupleSet d2 = d1.product(d1);
    bound.bound(rewrite, d2);
    bound.bound(equalish, d2);
    bound.bound(a, d1);
    bound.bound(b, d1);
    bound.bound(c, d1);
    bound.boundExactly(Atom, d1);
    bound.bound(trr, d2);
    bound.bound(goal, f.setOf("goal"));
    return bound;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 55 with Bounds

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

the class GEO158 method main.

/**
 * Usage: java examples.tptp.GEO158 [# 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 GEO158 model = new GEO158();
        final Formula f = model.checkConsistent();
        // System.out.println(model.decls());
        // System.out.println(model.partOfDefn());
        // System.out.println(model.sumDefn());
        // 
        // System.out.println(model.endPointDefn());
        // System.out.println(model.innerPointDefn());
        // System.out.println(model.meetDefn());
        // 
        // System.out.println(model.openDefn());
        // System.out.println(model.closedDefn());
        // System.out.println(model.c1());
        // 
        // System.out.println(model.c2());
        // System.out.println(model.c3());
        // System.out.println(model.c4());
        // 
        // System.out.println(model.c6());
        // System.out.println(model.c7());
        // System.out.println(model.c8());
        // 
        // System.out.println(model.c9());
        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