Search in sources :

Example 16 with Variable

use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.

the class AbstractWorldDefinitions method AbOp_total.

/**
 * Returns the AbOp_total assertion.
 *
 * @return AbOp_total assertion
 */
public Formula AbOp_total() {
    final Variable a = Variable.unary("a");
    final Variable a_in = Variable.unary("a_in");
    final Formula f0 = Abstract(a).implies(AbIgnore(a, a, aNullOut).and(AbTransfer(a, a, a_in, aNullOut)));
    final Formula f1 = f0.forAll(a.oneOf(AbWorld).and(a_in.oneOf(AIN)));
    return f1;
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Example 17 with Variable

use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.

the class DNACuts method declarations.

/**
 * Returns declarations constraints.
 *
 * @return declarations constraints.
 */
public Formula declarations() {
    final Variable l = Variable.unary("l");
    final Formula f0 = l.join(base).one().forAll(l.oneOf(Link));
    final Formula f1 = CutLink.union(JoinLink).eq(Link);
    final Formula f2 = CutLink.intersection(JoinLink).no();
    return f0.and(f1).and(f2);
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Example 18 with Variable

use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.

the class DNACuts method cutChainLength.

/**
 * Returns the cutChainLength constraint. (Similar to CutChainsAtMost6BasesLong
 * fact, but with the cut chain length as specified during construction.)
 *
 * @return the cutChainLength constraint
 */
public Formula cutChainLength() {
    Formula ret = Formula.FALSE;
    final Variable c = Variable.unary("c");
    for (int i = 0; i < neighbor.length; i++) {
        ret = ret.or(c.join(neighbor[i]).in(JoinLink));
    }
    return ret.forAll(c.oneOf(CutLink));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Example 19 with Variable

use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.

the class DNACuts method cutLinkUniqueness.

/**
 * Returns the cutLinkUniqueness constraint.
 *
 * @return the cutLinkUniqueness constraint.
 */
public Formula cutLinkUniqueness() {
    final Variable c1 = Variable.unary("c1");
    final Variable c2 = Variable.unary("c2");
    final Formula f0 = c1.eq(c2).not().and(next.join(c1).in(JoinLink)).and(next.join(c2).in(JoinLink));
    Formula f = c1.join(base).in(c2.join(base).union(c2.join(base).join(partner))).not();
    for (int i = 0; i < neighbor.length; i++) {
        Expression c1n = c1.join(neighbor[i]), c2n = c2.join(neighbor[i]);
        f = f.or(c1n.in(JoinLink)).or(c2n.in(JoinLink));
        f = f.or(c1n.join(base).in(c2n.join(base).union(c2n.join(base).join(partner))).not());
    }
    return f0.implies(f).forAll(c1.oneOf(CutLink).and(c2.oneOf(CutLink)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 20 with Variable

use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.

the class Dijkstra method grabOrRelease.

/**
 * Returns the GrabOrRelease predicate.
 *
 * @return
 *
 *         <pre>
 * pred GrabOrRelease () {
 *    Initial(so/first()) &&
 *    (
 *    all pre: State - so/last () | let post = so/next (pre) |
 *       (post.holds = pre.holds && post.waits = pre.waits)
 *        ||
 *       (some p: Process, m: Mutex | pre::GrabMutex (p, m, post))
 *        ||
 *       (some p: Process, m: Mutex | pre::ReleaseMutex (p, m, post))
 *
 *    )
 * }
 *         </pre>
 */
public Formula grabOrRelease() {
    final Variable pre = Variable.unary("pre");
    final Expression post = pre.join(sord);
    final Formula f1 = post.join(holds).eq(pre.join(holds));
    final Formula f2 = post.join(waits).eq(pre.join(waits));
    final Variable p = Variable.unary("p");
    final Variable m = Variable.unary("m");
    final Decls d = p.oneOf(Process).and(m.oneOf(Mutex));
    final Formula f3 = grabMutex(pre, post, p, m).forSome(d);
    final Formula f4 = releaseMutex(pre, post, p, m).forSome(d);
    return initial(sfirst).and(((f1.and(f2)).or(f3).or(f4)).forAll(pre.oneOf(State.difference(slast))));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Decls(kodkod.ast.Decls) Expression(kodkod.ast.Expression)

Aggregations

Variable (kodkod.ast.Variable)221 Formula (kodkod.ast.Formula)151 Expression (kodkod.ast.Expression)80 Decls (kodkod.ast.Decls)24 Solution (kodkod.engine.Solution)24 Relation (kodkod.ast.Relation)23 IntExpression (kodkod.ast.IntExpression)22 Bounds (kodkod.instance.Bounds)21 Universe (kodkod.instance.Universe)21 ArrayList (java.util.ArrayList)19 TupleFactory (kodkod.instance.TupleFactory)19 TupleSet (kodkod.instance.TupleSet)15 Solver (kodkod.engine.Solver)14 Decl (kodkod.ast.Decl)12 QuantifiedFormula (kodkod.ast.QuantifiedFormula)10 Test (org.junit.Test)10 Instance (kodkod.instance.Instance)8 BinaryExpression (kodkod.ast.BinaryExpression)5 SumExpression (kodkod.ast.SumExpression)3 Expr (edu.mit.csail.sdg.ast.Expr)2