Search in sources :

Example 6 with Tuple

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

the class A4SolutionReader method parseTuple.

/**
 * Parse tuple.
 */
private Tuple parseTuple(XMLNode tuple, int arity) throws Err {
    Tuple ans = null;
    try {
        for (XMLNode sub : tuple) if (sub.is("atom")) {
            Tuple x = factory.tuple(sub.getAttribute("label"));
            if (ans == null)
                ans = x;
            else
                ans = ans.product(x);
        }
        if (ans == null)
            throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>");
        if (ans.arity() != arity)
            throw new ErrorFatal("Expecting: tuple of arity " + arity + " but got tuple of arity " + ans.arity());
        return ans;
    } catch (Throwable ex) {
        throw new ErrorFatal("Expecting: <tuple> <atom label=\"..\"/> .. </tuple>", ex);
    }
}
Also used : ErrorFatal(edu.mit.csail.sdg.alloy4.ErrorFatal) XMLNode(edu.mit.csail.sdg.alloy4.XMLNode) Tuple(kodkod.instance.Tuple)

Example 7 with Tuple

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

the class BookExamples method trial.

/**
 * If one of the solution is a solution to the given problem, return it, else
 * return null.
 */
static Solution trial(A4Reporter rep, A4Solution frame, Formula formula, Solver solver, boolean check) {
    TupleFactory fac = frame.getFactory();
    Solution sol = null;
    Iterable<Sig> sigs = frame.getAllReachableSigs();
    if (hasSig(sigs, "this/Book") != null) {
        Tuple B0N0A0 = t_tuple(fac, "Book$0", "Name$0", "Addr$0");
        Tuple B0N1A0 = t_tuple(fac, "Book$0", "Name$1", "Addr$0");
        Tuple B0N2A0 = t_tuple(fac, "Book$0", "Name$2", "Addr$0");
        Tuple B0N2A1 = t_tuple(fac, "Book$0", "Name$2", "Addr$1");
        Tuple B0N1A1 = t_tuple(fac, "Book$0", "Name$1", "Addr$1");
        Tuple B1N0A0 = t_tuple(fac, "Book$1", "Name$0", "Addr$0");
        Tuple B1N2A1 = t_tuple(fac, "Book$1", "Name$2", "Addr$1");
        Tuple B1N1A1 = t_tuple(fac, "Book$1", "Name$1", "Addr$1");
        Tuple B000 = t_tuple(fac, "Book$0", "Target$0", "Target$0");
        Tuple B001 = t_tuple(fac, "Book$0", "Target$0", "Target$1");
        Tuple B002 = t_tuple(fac, "Book$0", "Target$0", "Target$2");
        Tuple B010 = t_tuple(fac, "Book$0", "Target$1", "Target$0");
        Tuple B101 = t_tuple(fac, "Book$1", "Target$0", "Target$1");
        Tuple B110 = t_tuple(fac, "Book$1", "Target$1", "Target$0");
        Tuple B102 = t_tuple(fac, "Book$1", "Target$0", "Target$2");
        Tuple B210 = t_tuple(fac, "Book$2", "Target$1", "Target$0");
        Tuple B202 = t_tuple(fac, "Book$2", "Target$0", "Target$2");
        Tuple B212 = t_tuple(fac, "Book$2", "Target$1", "Target$2");
        Tuple B302 = t_tuple(fac, "Book$3", "Target$0", "Target$2");
        Tuple B310 = t_tuple(fac, "Book$3", "Target$1", "Target$0");
        Tuple B312 = t_tuple(fac, "Book$3", "Target$1", "Target$2");
        if (sol == null && B000 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.9", "Book$0", "", "this/Book", "", "Target$0", "", "this/Alias", "", "", "this/Group", "", "", "this/Addr", "", B000, "", "this/Book", "addr" });
        if (sol == null && B001 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.10", "Book$0", "", "this/Book", "", "", "this/Alias", "", "Target$0", "", "this/Group", "", "Target$1", "Target$2", "", "this/Addr", "", B001, B002, "", "this/Book", "addr" });
        if (sol == null && B001 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.11", "Book$0", "", "this/Book", "", "Target$0", "", "this/Alias", "", "", "this/Group", "", "Target$1", "Target$2", "", "this/Addr", "", B001, B002, "", "this/Book", "addr" });
        if (sol == null && B001 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.12", "Book$0", "", "this/Book", "", "Target$0", "", "this/Alias", "", "Target$1", "", "this/Group", "", "", "this/Addr", "", B001, "", "this/Book", "addr" });
        if (sol == null && B010 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.13", "Book$0", "Book$1", "", "this/Book", "", "", "this/Alias", "", "Target$0", "Target$1", "", "this/Group", "", "Target$2", "", "this/Addr", "", B010, B110, B102, "", "this/Book", "addr" });
        if (sol == null && B312 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.15", "Book$0", "Book$1", "Book$2", "Book$3", "", "this/Book", "", "", "this/Alias", "", "Target$0", "Target$1", "", "this/Group", "", "Target$2", "", "this/Addr", "", B102, B210, B202, B212, B302, B312, "", "this/Book", "addr" });
        if (sol == null && B101 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.16", "Book$0", "Book$1", "Book$2", "Book$3", "", "this/Book", "", "Target$1", "", "this/Alias", "", "Target$0", "", "this/Group", "", "", "this/Addr", "", B101, "", "this/Book", "addr" });
        if (sol == null && B102 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.17", "Book$0", "Book$1", "Book$2", "Book$3", "", "this/Book", "", "Target$0", "", "this/Alias", "", "Target$1", "", "this/Group", "", "Target$2", "", "this/Addr", "", B102, B210, B310, B302, "", "this/Book", "addr" });
        if (sol == null && B0N0A0 != null && check)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.6", "Book$0", "Book$1", "", "this/Book", "", "Addr$0", "", "this/Addr", "", "Name$0", "", "this/Name", "", B0N0A0, "", "this/Book", "addr" });
        if (sol == null && B1N0A0 != null && !check)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.4", "Book$0", "Book$1", "", "this/Book", "", "Addr$0", "", "this/Addr", "", "Name$0", "", "this/Name", "", B1N0A0, "", "this/Book", "addr" });
        if (sol == null && B0N2A1 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.5", "Book$0", "Book$1", "", "this/Book", "", "Addr$0", "Addr$1", "", "this/Addr", "", "Name$0", "Name$1", "Name$2", "", "this/Name", "", B0N2A1, B0N1A1, B1N2A1, B1N1A1, B1N0A0, "", "this/Book", "addr" });
        if (sol == null && B0N0A0 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.1", "Book$0", "", "this/Book", "", "Addr$0", "", "this/Addr", "", "Name$0", "", "this/Name", "", B0N0A0, "", "this/Book", "addr" });
        if (sol == null && B0N0A0 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.2", "Book$0", "", "this/Book", "", "Addr$0", "", "this/Addr", "", "Name$0", "Name$1", "Name$2", "", "this/Name", "", B0N0A0, B0N1A0, B0N2A0, "", "this/Book", "addr" });
        if (sol == null && B0N0A0 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 2.3", "Book$0", "", "this/Book", "", "Addr$0", "Addr$1", "", "this/Addr", "", "Name$0", "Name$1", "Name$2", "", "this/Name", "", B0N0A0, B0N1A0, B0N2A1, "", "this/Book", "addr" });
        if (sol == null && B001 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 5.2", "Book$0", "Book$1", "", "this/Book", "", "Target$0", "", "this/Name", "", "Target$1", "", "this/Addr", "", B001, B101, "", "this/Book", "addr" });
        if (sol == null && B102 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 5.3", "Book$0", "Book$1", "", "this/Book", "", "Target$0", "Target$1", "", "this/Name", "", "Target$2", "", "this/Addr", "", B010, B110, B102, "", "this/Book", "addr" });
    } else if (hasSig(sigs, "this/Woman") != null) {
        Tuple man0_woman0 = t_tuple(fac, "Person$1", "Person$0");
        Tuple man1_woman0 = t_tuple(fac, "Person$2", "Person$0");
        Tuple man0_woman1 = t_tuple(fac, "Person$1", "Person$3");
        Tuple man1_woman1 = t_tuple(fac, "Person$2", "Person$3");
        if (sol == null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 4.2", "Person$1", "", "this/Man", "", "Person$0", "", "this/Woman", "", man0_woman0, "", "this/Man", "wife", man0_woman0, "", "this/Person", "mother", "", "this/Person", "father" });
        if (sol == null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 4.3", "Person$1", "Person$2", "", "this/Man", "", "Person$0", "Person$3", "", "this/Woman", "", man1_woman0, man0_woman1, "", "this/Man", "wife", man1_woman1, man0_woman0, "", "this/Person", "mother", "", "this/Person", "father" });
    } else if (hasSig(sigs, "this/Process") != null) {
        String p0 = "Process$0", p1 = "Process$1", p2 = "Process$2";
        String t0 = "Time$0", t1 = "Time$1", t2 = "Time$2", t3 = "Time$3";
        Tuple s20 = t_tuple(fac, p2, p0), s01 = t_tuple(fac, p0, p1), s12 = t_tuple(fac, p1, p2);
        Tuple d000 = t_tuple(fac, p0, p0, t0), d110 = t_tuple(fac, p1, p1, t0), d220 = t_tuple(fac, p2, p2, t0);
        Tuple d001 = t_tuple(fac, p0, p0, t1), d021 = t_tuple(fac, p0, p2, t1), d111 = t_tuple(fac, p1, p1, t1);
        Tuple d002 = t_tuple(fac, p0, p0, t2), d112 = t_tuple(fac, p1, p1, t2), d122 = t_tuple(fac, p1, p2, t2);
        Tuple d003 = t_tuple(fac, p0, p0, t3), d113 = t_tuple(fac, p1, p1, t3), d223 = t_tuple(fac, p2, p2, t3);
        if (sol == null && d000 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 6.4", s20, s01, s12, "", "this/Process", "succ", d000, d110, d220, d001, d021, d111, d002, d112, d122, d003, d113, d223, "", "this/Process", "toSend", t_tuple(fac, p2, t3), "", "this/Process", "elected" });
    } else if (hasSig(sigs, "this/Desk") != null) {
        String g0 = "Guest$0", g1 = "Guest$1", r = "Room$0", k0 = "Key$0", k1 = "Key$1";
        String t0 = "Time$0", t1 = "Time$1", t2 = "Time$2", t3 = "Time$3", t4 = "Time$4", t5 = "Time$5";
        String c0 = "Card$0", c1 = "Card$1";
        if (sol == null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig E.3", t_tuple(fac, c0, k0), t_tuple(fac, c1, k1), "", "this/Card", "fst", t_tuple(fac, c0, k1), t_tuple(fac, c1, k0), "", "this/Card", "snd", t_tuple(fac, g0, c0, t1), t_tuple(fac, g0, c0, t2), t_tuple(fac, g1, c1, t2), t_tuple(fac, g0, c0, t3), t_tuple(fac, g1, c1, t3), t_tuple(fac, g0, c0, t4), t_tuple(fac, g1, c1, t4), t_tuple(fac, g0, c0, t5), t_tuple(fac, g1, c1, t5), "", "this/Guest", "cards", t_tuple(fac, r, k0, t0), t_tuple(fac, r, k0, t1), t_tuple(fac, r, k0, t2), t_tuple(fac, r, k1, t3), t_tuple(fac, r, k0, t4), t_tuple(fac, r, k1, t5), "", "this/Room", "key", t_tuple(fac, k1, t1), t_tuple(fac, k0, t2), t_tuple(fac, k1, t2), t_tuple(fac, k0, t3), t_tuple(fac, k1, t3), t_tuple(fac, k0, t4), t_tuple(fac, k1, t4), t_tuple(fac, k0, t5), t_tuple(fac, k1, t5), "", "this/Desk", "issued", t_tuple(fac, r, k0, t0), t_tuple(fac, r, k1, t1), t_tuple(fac, r, k0, t2), t_tuple(fac, r, k0, t3), t_tuple(fac, r, k0, t4), t_tuple(fac, r, k0, t5), "", "this/Desk", "prev" });
    } else if (hasSig(sigs, "this/FrontDesk") != null) {
        String g0 = "Guest$0", g1 = "Guest$1", r = "Room$0", k0 = "Key$0", k1 = "Key$1", k2 = "Key$2";
        String t0 = "Time$0", t1 = "Time$1", t2 = "Time$2", t3 = "Time$3", t4 = "Time$4";
        Tuple G0 = t_tuple(fac, g0), G1 = t_tuple(fac, g1);
        Tuple K0 = t_tuple(fac, r, k0), K1 = t_tuple(fac, r, k1), K2 = t_tuple(fac, r, k2);
        Tuple K0T0 = t_tuple(fac, r, k0, t0), K0T1 = t_tuple(fac, r, k0, t1), K0T2 = t_tuple(fac, r, k0, t2);
        Tuple K0T3 = t_tuple(fac, r, k0, t3), K1T4 = t_tuple(fac, r, k1, t4);
        Tuple F1 = t_tuple(fac, r, k0, t0), F2 = t_tuple(fac, r, k1, t1), F3 = t_tuple(fac, r, k1, t2);
        Tuple F4 = t_tuple(fac, r, k2, t3), F5 = t_tuple(fac, r, k2, t4);
        Tuple GK1 = t_tuple(fac, g0, k1, t1), GK2 = t_tuple(fac, g0, k1, t2), GK3 = t_tuple(fac, g0, k1, t3);
        Tuple GK4 = t_tuple(fac, g1, k2, t3), GK5 = t_tuple(fac, g0, k1, t4), GK6 = t_tuple(fac, g1, k2, t4);
        Tuple O1 = t_tuple(fac, r, g0, t1), O2 = t_tuple(fac, r, g1, t3), O3 = t_tuple(fac, r, g1, t4);
        if (sol == null && K0T0 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 6.13", G0, G1, "", "this/Guest", "", K0, K1, K2, "", "this/Room", "keys", K0T0, K0T1, K0T2, K0T3, K1T4, "", "this/Room", "currentKey", F1, F2, F3, F4, F5, "", "this/FrontDesk", "lastKey", GK1, GK2, GK3, GK4, GK5, GK6, "", "this/Guest", "keys", O1, O2, O3, "", "this/FrontDesk", "occupant", "Event$0", "Event$1", "", "this/Checkin", "", "Event$2", "", "this/Checkout", "", "Event$3", "", "this/Entry", "", t_tuple(fac, "Event$0", t0), t_tuple(fac, "Event$2", t1), t_tuple(fac, "Event$1", t2), t_tuple(fac, "Event$3", t3), "", "this/Event", "pre" });
        if (sol == null && K0T0 != null)
            sol = trial(rep, fac, solver, sigs, formula, frame, new Object[] { "Fig 6.6", G0, G1, "", "this/Guest", "", K0, K1, K2, "", "this/Room", "keys", K0T0, K0T1, K0T2, K0T3, K1T4, "", "this/Room", "currentKey", F1, F2, F3, F4, F5, "", "this/FrontDesk", "lastKey", GK1, GK2, GK3, GK4, GK5, GK6, "", "this/Guest", "keys", O1, O2, O3, "", "this/FrontDesk", "occupant" });
    }
    return sol;
}
Also used : Sig(edu.mit.csail.sdg.ast.Sig) TupleFactory(kodkod.instance.TupleFactory) Solution(kodkod.engine.Solution) Tuple(kodkod.instance.Tuple)

Example 8 with Tuple

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

the class BugTests method testGreg_01192006.

public final void testGreg_01192006() {
    // circular linked list
    Relation Entry = Relation.unary("Entry");
    Relation head = Relation.unary("head");
    Relation next = Relation.binary("next");
    Formula nextFun = next.function(Entry, Entry);
    // bijection between indices and entries in linked list
    Relation Index = Relation.unary("Index");
    Relation index2Entry = Relation.binary("index2Entry");
    Expression entries = head.join(next.closure());
    Variable e = Variable.unary("e");
    Expression preImage = index2Entry.join(e);
    Formula index2EntryBij = e.in(entries).implies(preImage.one()).and(e.in(entries).not().implies(preImage.no())).forAll(e.oneOf(Entry));
    // try to force list to have three distinct entries
    Variable e1 = Variable.unary("e1");
    Variable e2 = Variable.unary("e2");
    Variable e3 = Variable.unary("e3");
    Formula threeEntries = e1.eq(e2).not().and(e1.eq(e3).not()).and(e2.eq(e3).not()).forSome(e1.oneOf(entries).and(e2.oneOf(entries).and(e3.oneOf(entries))));
    Formula simulate = head.one().and(nextFun).and(index2EntryBij).and(threeEntries);
    Object Entry0 = "Entry0";
    Object Entry1 = "Entry1";
    Object Entry2 = "Entry2";
    Object Entry3 = "Entry3";
    Object Index0 = "Index0";
    Object Index1 = "Index1";
    Object Index2 = "Index2";
    Object Index3 = "Index3";
    Universe univ = new Universe(Arrays.asList(Entry0, Entry1, Entry2, Entry3, Index0, Index1, Index2, Index3));
    TupleFactory factory = univ.factory();
    TupleSet entryTuples = factory.setOf(Entry0, Entry1, Entry2, Entry3);
    TupleSet indexTuples = factory.setOf(Index0, Index1, Index2, Index3);
    Instance instance = new Instance(univ);
    instance.add(Entry, entryTuples);
    instance.add(head, factory.setOf(Entry0));
    instance.add(Index, indexTuples);
    Tuple next0 = factory.tuple(Entry0, Entry1);
    Tuple next1 = factory.tuple(Entry1, Entry2);
    Tuple next2 = factory.tuple(Entry2, Entry3);
    Tuple next3 = factory.tuple(Entry3, Entry0);
    instance.add(next, factory.setOf(next0, next1, next2, next3));
    Tuple i2e0 = factory.tuple(Index0, Entry0);
    Tuple i2e1 = factory.tuple(Index1, Entry1);
    Tuple i2e2 = factory.tuple(Index2, Entry2);
    Tuple i2e3 = factory.tuple(Index3, Entry3);
    instance.add(index2Entry, factory.setOf(i2e0, i2e1, i2e2, i2e3));
    Evaluator eval = new Evaluator(instance);
    assertTrue(eval.evaluate(simulate));
    Bounds bounds = new Bounds(univ);
    bounds.boundExactly(Entry, entryTuples);
    bounds.bound(head, entryTuples);
    bounds.bound(next, entryTuples.product(entryTuples));
    bounds.bound(Index, indexTuples);
    bounds.bound(index2Entry, indexTuples.product(entryTuples));
    // Solver solver = new Solver(SATSolverName.Default);
    // System.out.println(simulate);
    // System.out.println(bounds);
    // System.out.println(instance);
    instance = solver.solve(simulate, bounds).instance();
    // System.out.println(instance);
    assertNotNull(instance);
}
Also used : Formula(kodkod.ast.Formula) TupleSet(kodkod.instance.TupleSet) Relation(kodkod.ast.Relation) Variable(kodkod.ast.Variable) IntExpression(kodkod.ast.IntExpression) Expression(kodkod.ast.Expression) Instance(kodkod.instance.Instance) Bounds(kodkod.instance.Bounds) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe) Evaluator(kodkod.engine.Evaluator) Tuple(kodkod.instance.Tuple)

Example 9 with Tuple

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

the class EvaluatorTest method testEvalTransitiveClosure.

public final void testEvalTransitiveClosure() {
    // // ^(Hilary->Jocelyn) = Hilary->Jocelyn
    // assertEquals(eval(hilary.product(jocelyn).closure()),
    // eval(hilary.product(jocelyn)));
    // // ^spouse = spouse + spouse.spouse
    // assertEquals(eval(spouse.closure()),
    // eval(spouse.union(spouse.join(spouse))));
    // // Hilary.^shaken = univ - (univ - Person.shaken)
    // assertEquals(eval(hilary.join(shaken.closure())),
    // eval(univ.difference(univ.difference(person.join(shaken)))));
    // try {
    // eval(person.closure());
    // fail("Expected IllegalArgumentException");
    // } catch (IllegalArgumentException iae) {}
    // ^r = value(^r)
    final Relation r = Relation.binary("r");
    final Universe u = evaluator.instance().universe();
    final TupleFactory f = u.factory();
    final Instance instance = new Instance(u);
    // value(r) = u[0]->u[1] + u[1]->u[2] + u[2]->u[3] + u[3]->u[4]
    TupleSet s = f.noneOf(r.arity());
    for (int i = 0; i < 4; i++) s.add(f.tuple(u.atom(i), u.atom(i + 1)));
    instance.add(r, s);
    // value(^r) = value(r) + u[0]->u[2] + u[0]->u[3] + u[0]->u[4] +
    // u[1]->u[3] u[1]->u[4] + u[2]->u[4]
    Set<Tuple> result = new HashSet<Tuple>();
    for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 5; j++) {
            result.add(f.tuple(u.atom(i), u.atom(j)));
        }
    }
    assertEquals((new Evaluator(instance)).evaluate(r.closure()), result);
    // value(*r) = value(^r) + iden
    for (int i = 0; i < 10; i++) {
        result.add(f.tuple(u.atom(i), u.atom(i)));
    }
    assertEquals((new Evaluator(instance)).evaluate(r.reflexiveClosure()), result);
}
Also used : TupleSet(kodkod.instance.TupleSet) Relation(kodkod.ast.Relation) Instance(kodkod.instance.Instance) TupleFactory(kodkod.instance.TupleFactory) Universe(kodkod.instance.Universe) Evaluator(kodkod.engine.Evaluator) Tuple(kodkod.instance.Tuple) HashSet(java.util.HashSet)

Example 10 with Tuple

use of kodkod.instance.Tuple 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)

Aggregations

Tuple (kodkod.instance.Tuple)18 TupleSet (kodkod.instance.TupleSet)12 Relation (kodkod.ast.Relation)8 TupleFactory (kodkod.instance.TupleFactory)8 Bounds (kodkod.instance.Bounds)6 Instance (kodkod.instance.Instance)5 Solution (kodkod.engine.Solution)4 Universe (kodkod.instance.Universe)4 Sig (edu.mit.csail.sdg.ast.Sig)3 ArrayList (java.util.ArrayList)3 Formula (kodkod.ast.Formula)3 Evaluator (kodkod.engine.Evaluator)3 Field (edu.mit.csail.sdg.ast.Sig.Field)2 PrimSig (edu.mit.csail.sdg.ast.Sig.PrimSig)2 Type (edu.mit.csail.sdg.ast.Type)2 Expression (kodkod.ast.Expression)2 Variable (kodkod.ast.Variable)2 A4Reporter (edu.mit.csail.sdg.alloy4.A4Reporter)1 ConstList (edu.mit.csail.sdg.alloy4.ConstList)1 ConstMap (edu.mit.csail.sdg.alloy4.ConstMap)1