Search in sources :

Example 11 with Variable

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

the class RingElection method progress.

/**
 * Returns the progress predicate.
 *
 * @return
 *
 *         <pre>
 * pred progress () {
 *  all t: Time - TO/last() | let t' = TO/next (t) |
 *   some Process.toSend.t => some p: Process | not skip (t, t', p) }
 *         </pre>
 */
public Formula progress() {
    final Variable t1 = Variable.unary("t");
    final Expression t2 = t1.join(tord);
    final Variable p = Variable.unary("p");
    final Formula f1 = Process.join(toSend).join(t1).some().implies(skip(t1, t2, p).not().forSome(p.oneOf(Process)));
    return f1.forAll(t1.oneOf(Time.difference(tlast)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 12 with Variable

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

the class RingElection method looplessPath.

/**
 * Returns the looplessPath predicate
 *
 * @return
 *
 *         <pre>
 * pred looplessPath () {no disj t, t': Time | toSend.t = toSend.t'}
 *         </pre>
 */
public Formula looplessPath() {
    final Variable t1 = Variable.unary("t");
    final Variable t2 = Variable.unary("t'");
    // all t, t': Time | some t&t' || !(toSend.t = toSend.t')
    final Formula f1 = t1.intersection(t2).some().or(toSend.join(t1).eq(toSend.join(t2)).not());
    return f1.forAll(t1.oneOf(Time).and(t2.oneOf(Time)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Example 13 with Variable

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

the class Trees method statement5.

/**
 * Returns statement 5.
 *
 * @return
 *
 *         <pre>
 * pred Statement5() {
 * Acyclic() and
 * all u,v: V | (u->v) not in E implies Cyclic(E + (u->v) + (v->u))
 * }
 *         </pre>
 */
public final Formula statement5() {
    final Variable u = Variable.unary("u");
    final Variable v = Variable.unary("v");
    final Formula f0 = u.product(v).in(E).not().implies(cyclic(E.union(u.product(v).union(v.product(u)))));
    final Formula f1 = f0.forAll(u.oneOf(V).and(v.oneOf(V)));
    return acyclic().and(f1);
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Example 14 with Variable

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

the class Trees method inCycle.

/**
 * Returns the inCycle predicate.
 *
 * @return
 *
 *         <pre>
 * pred InCycle(v: V, c: V -> V) {
 * v in v.c or
 * some v': v.c | v' in v.^(c - v->v' - v'->v)
 * }
 *         </pre>
 */
public final Formula inCycle(Expression v, Expression c) {
    final Formula f0 = v.in(v.join(c));
    final Variable vp = Variable.unary("v'");
    final Formula f1 = vp.in(v.join((c.difference(v.product(vp)).difference(vp.product(v))).closure()));
    return f0.or(f1.forSome(vp.oneOf(v.join(c))));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

Example 15 with Variable

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

the class Trees method statement2.

/**
 * Returns statement 2.
 *
 * @return
 *
 *         <pre>
 * pred Statement2() {
 * Connected(E) and
 * all u: V | all v: u.E | not Connected( E - (u->v) - (v->u) )
 * }
 *         </pre>
 */
public final Formula statement2() {
    final Variable u = Variable.unary("u");
    final Variable v = Variable.unary("v");
    final Formula f0 = connected(E);
    final Formula f1 = connected(E.difference(u.product(v)).difference(v.product(u))).not();
    final Formula f2 = f1.forAll(v.oneOf(u.join(E))).forAll(u.oneOf(V));
    return f0.and(f2);
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable)

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