Search in sources :

Example 21 with Bounds

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

the class GEO159 method bounds.

/**
 * Returns a bounds with the given number of maximum curves and points
 *
 * @return a bounds with the given number of maximum curves and points
 */
@Override
public Bounds bounds(int scope) {
    final Bounds b = super.bounds(scope);
    final TupleSet c = b.upperBound(curve);
    final TupleSet p = b.upperBound(point);
    b.bound(between, c.product(p).product(p).product(p));
    return b;
}
Also used : TupleSet(kodkod.instance.TupleSet) Bounds(kodkod.instance.Bounds)

Example 22 with Bounds

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

the class LAT258 method main.

/**
 * Usage: java examples.tptp.LAT258 [scope]
 */
public static void main(String[] args) {
    if (args.length < 1)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final LAT258 model = new LAT258();
        final Bounds b = model.bounds(n);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final Formula f = model.checkGoalToBeProved();
        System.out.println(f);
        // System.out.println(b);
        final Solution 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 23 with Bounds

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

the class LAT258 method bounds.

/**
 * Returns the bounds for the given scope.
 *
 * @return the 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("n" + i);
    final Universe univ = new Universe(atoms);
    final TupleFactory f = univ.factory();
    final Bounds b = new Bounds(univ);
    b.bound(goal, f.setOf("n0"));
    final TupleSet all1 = f.allOf(1);
    b.bound(p, all1);
    b.bound(t, all1);
    b.bound(v, all1);
    b.bound(w, all1);
    b.bound(u, all1);
    b.bound(x, all1);
    b.bound(y, all1);
    b.bound(z, all1);
    b.bound(lessThan, f.allOf(2));
    final TupleSet all3 = f.allOf(3);
    b.bound(join, all3);
    b.bound(meet, all3);
    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 24 with Bounds

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

the class DiffEg method bounds.

/**
 * Returns the bounds for the given alloy scope.
 *
 * @return bounds for the given alloy scope
 */
public final Bounds bounds(int scope) {
    assert scope > 0;
    final List<String> atoms = new ArrayList<String>(4 * scope + 1);
    // Subject, Resource, Action, Conflicted
    for (int i = 0; i < scope; i++) atoms.add("Subject" + i);
    for (int i = 0; i < scope; i++) atoms.add("Resource" + i);
    for (int i = 0; i < scope; i++) atoms.add("Action" + i);
    for (int i = 0; i < scope; i++) atoms.add("Conflicted" + i);
    for (int i = 0; i < scope; i++) atoms.add("Request" + i);
    final Universe u = new Universe(atoms);
    final TupleFactory f = u.factory();
    final Bounds b = new Bounds(u);
    final int max = scope - 1;
    b.bound(Subject, f.range(f.tuple("Subject0"), f.tuple("Subject" + max)));
    b.bound(Resource, f.range(f.tuple("Resource0"), f.tuple("Resource" + max)));
    b.bound(Action, f.range(f.tuple("Action0"), f.tuple("Action" + max)));
    b.bound(Conflicted, f.range(f.tuple("Conflicted0"), f.tuple("Conflicted" + max)));
    b.bound(Request, f.range(f.tuple("Request0"), f.tuple("Request" + max)));
    // sRequest, rRequest, action, sConflicted, rConflicted;
    b.bound(sRequest, b.upperBound(Request).product(b.upperBound(Subject)));
    b.bound(rRequest, b.upperBound(Request).product(b.upperBound(Resource)));
    b.bound(action, b.upperBound(Request).product(b.upperBound(Action)));
    b.bound(sConflicted, b.upperBound(Conflicted).product(b.upperBound(Subject)));
    b.bound(rConflicted, b.upperBound(Conflicted).product(b.upperBound(Resource)));
    return b;
}
Also used : Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 25 with Bounds

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

the class FileSystem method main.

/**
 * Usage: java examples.alloy.FileSystem [scope]
 */
public static void main(String[] args) {
    if (args.length < 1)
        usage();
    try {
        final int n = Integer.parseInt(args[0]);
        final FileSystem model = new FileSystem();
        final Formula f = model.checkNoDirAliases();
        System.out.println(f);
        final Bounds b = model.bounds(n);
        final Solver solver = new Solver();
        solver.options().setSolver(SATFactory.MiniSat);
        final Solution 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)

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