Search in sources :

Example 36 with Universe

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

the class SET948 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);
    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();
    b.bound(empty, f.allOf(1));
    b.bound(subset, f.allOf(2));
    b.bound(in, f.allOf(2));
    b.bound(disjoint, f.allOf(2));
    b.bound(union, f.allOf(2));
    b.bound(intersect2, f.allOf(3));
    b.bound(union2, f.allOf(3));
    return b;
}
Also used : Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 37 with Universe

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

the class MGT066 method bounds.

/**
 * Returns a bounds for a universe of the given size.
 *
 * @return bounds for a universe of the given size.
 */
public final Bounds bounds(int size) {
    assert size > 0;
    final List<String> atoms = new ArrayList<String>(size);
    for (int i = 0; i < size; i++) atoms.add("a" + i);
    final Universe u = new Universe(atoms);
    final TupleFactory f = u.factory();
    final Bounds b = new Bounds(u);
    b.bound(lt, f.allOf(2));
    b.bound(leq, f.allOf(2));
    b.bound(gt, f.allOf(2));
    b.bound(geq, f.allOf(2));
    return b;
}
Also used : Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 38 with Universe

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

the class SET943 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);
    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();
    b.bound(empty, f.allOf(1));
    b.bound(subset, f.allOf(2));
    b.bound(in, f.allOf(2));
    b.bound(union, f.allOf(2));
    b.bound(union2, f.allOf(3));
    return b;
}
Also used : Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 39 with Universe

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

the class SET967 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);
    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();
    b.bound(empty, f.allOf(1));
    b.bound(subset, f.allOf(2));
    b.bound(in, f.allOf(2));
    b.bound(disjoint, f.allOf(2));
    b.bound(union, f.allOf(2));
    b.bound(singleton, f.allOf(2));
    b.bound(intersect2, f.allOf(3));
    b.bound(cartesian2, f.allOf(3));
    b.bound(union2, f.allOf(3));
    b.bound(ordered, f.allOf(3));
    b.bound(unordered, f.allOf(3));
    return b;
}
Also used : Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Example 40 with Universe

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

the class Lists method bounds.

/**
 * Returns the bounds for the given scope.
 *
 * @return the bounds for the given scope.
 */
public final Bounds bounds(int scope) {
    assert scope > 0;
    final int n = scope * 2;
    final List<String> atoms = new ArrayList<String>(n);
    for (int i = 0; i < scope; i++) atoms.add("Thing" + i);
    for (int i = 0; i < scope; i++) atoms.add("List" + i);
    // private final Relation Thing, List, NonEmptyList, EmptyList;
    // private final Relation car, cdr, equivTo, prefixes;
    final Universe u = new Universe(atoms);
    final TupleFactory f = u.factory();
    final Bounds b = new Bounds(u);
    final int max = scope - 1;
    b.bound(Thing, f.range(f.tuple("Thing0"), f.tuple("Thing" + max)));
    b.bound(List, f.range(f.tuple("List0"), f.tuple("List" + max)));
    b.bound(EmptyList, b.upperBound(List));
    b.bound(NonEmptyList, b.upperBound(List));
    b.bound(car, b.upperBound(List).product(b.upperBound(Thing)));
    b.bound(cdr, b.upperBound(List).product(b.upperBound(List)));
    b.bound(equivTo, b.upperBound(cdr));
    b.bound(prefixes, b.upperBound(cdr));
    return b;
}
Also used : Bounds(kodkod.instance.Bounds) ArrayList(java.util.ArrayList) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe)

Aggregations

Universe (kodkod.instance.Universe)83 Bounds (kodkod.instance.Bounds)79 TupleFactory (kodkod.instance.TupleFactory)77 TupleSet (kodkod.instance.TupleSet)50 ArrayList (java.util.ArrayList)46 Relation (kodkod.ast.Relation)45 Formula (kodkod.ast.Formula)37 Solution (kodkod.engine.Solution)32 Solver (kodkod.engine.Solver)26 Variable (kodkod.ast.Variable)21 Expression (kodkod.ast.Expression)20 IntExpression (kodkod.ast.IntExpression)20 Instance (kodkod.instance.Instance)14 Decls (kodkod.ast.Decls)11 Evaluator (kodkod.engine.Evaluator)9 LinkedList (java.util.LinkedList)4 Tuple (kodkod.instance.Tuple)4 LinkedHashSet (java.util.LinkedHashSet)3 Map (java.util.Map)2 Set (java.util.Set)2