Search in sources :

Example 1 with Expression

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

the class RingElection method defineElected.

/**
 * Return DefineElected fact.
 *
 * @return
 *
 *         <pre>
 * fact DefineElected {
 *  no elected.TO/first()
 *  all t: Time - TO/first()|
 *   elected.t = {p: Process | p in p.toSend.t - p.toSend.(TO/prev(t))} }
 *         </pre>
 */
public Formula defineElected() {
    final Variable t = Variable.unary("t");
    final Formula f1 = elected.join(tfirst).no();
    final Variable p = Variable.unary("p");
    final Formula c = p.in(p.join(toSend).join(t).difference(p.join(toSend).join(t.join(tord.transpose()))));
    final Expression comprehension = c.comprehension(p.oneOf(Process));
    final Formula f2 = elected.join(t).eq(comprehension).forAll(t.oneOf(Time.difference(tfirst)));
    return f1.and(f2);
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 2 with Expression

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

the class RingElection method step.

/**
 * Returns the step predicate.
 *
 * @return
 *
 *         <pre>
 * pred step (t, t': Time, p: Process) {
 *  let from = p.toSend, to = p.succ.toSend |
 *   some id: from.t {
 *    from.t' = from.t - id
 *    to.t' = to.t + (id - PO/prevs(p.succ)) } }
 *         </pre>
 */
public Formula step(Expression t1, Expression t2, Expression p) {
    final Expression from = p.join(toSend);
    final Expression to = p.join(succ).join(toSend);
    final Variable id = Variable.unary("id");
    final Expression prevs = (p.join(succ)).join((pord.transpose()).closure());
    final Formula f1 = from.join(t2).eq(from.join(t1).difference(id));
    final Formula f2 = to.join(t2).eq(to.join(t1).union(id.difference(prevs)));
    return f1.and(f2).forSome(id.oneOf(from.join(t1)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 3 with Expression

use of kodkod.ast.Expression 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 4 with Expression

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

the class AbstractWorldDefinitions method AbTransferOkay.

/**
 * Returns the application of the AbTransferOkay predicate.
 *
 * @return application of the AbTransferOkay predicate.
 */
public Formula AbTransferOkay(Expression s, Expression sprime, Expression a_in, Expression a_out) {
    final Expression e0 = a_in.join(from);
    final Expression e1 = a_in.join(to);
    final Formula f0 = AbWorldSecureOp(s, sprime, a_in, a_out);
    final Formula f1 = Authentic(s, e0);
    final Formula f2 = Authentic(s, e1);
    final Formula f3 = SufficientFundsProperty(s, a_in);
    final Formula f4 = e0.intersection(e1).no();
    final Formula f5 = e0.join(abBalance).join(sprime).eq(e0.join(abBalance).join(s).difference(a_in.join(value)));
    final Formula f6 = e0.join(abLost).join(sprime).eq(e0.join(abLost).join(s));
    final Formula f7 = e1.join(abBalance).join(sprime).eq(e1.join(abBalance).join(s).union(a_in.join(value)));
    final Formula f8 = e1.join(abLost).join(sprime).eq(e1.join(abLost).join(s));
    final Formula f9 = Authentic(sprime, e0);
    final Formula f10 = Authentic(sprime, e1);
    return Formula.and(f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10);
}
Also used : Formula(kodkod.ast.Formula) Expression(kodkod.ast.Expression)

Example 5 with Expression

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

the class AbstractWorldDefinitions method AbWorldSecureOp.

/**
 * Returns the application of the AbWorldSecureOp predicate.
 *
 * @return application of the AbWorldSecureOp predicate.
 */
public Formula AbWorldSecureOp(Expression s, Expression sprime, Expression a_in, Expression a_out) {
    final Formula f0 = AbOp(a_out);
    final Formula f1 = a_in.in(TransferDetails);
    final Expression e0 = a_in.join(from);
    final Expression e1 = a_in.join(to);
    final Expression e2 = s.join(abAuthPurse).difference(e0).difference(e1);
    final Expression e3 = sprime.join(abAuthPurse).difference(e0).difference(e1);
    final Formula f2 = e2.eq(e3);
    final Formula f3 = XiAbPurse(s, sprime, e2);
    return Formula.and(f0, f1, f2, f3);
}
Also used : Formula(kodkod.ast.Formula) Expression(kodkod.ast.Expression)

Aggregations

Expression (kodkod.ast.Expression)127 Formula (kodkod.ast.Formula)95 Variable (kodkod.ast.Variable)80 IntExpression (kodkod.ast.IntExpression)49 Relation (kodkod.ast.Relation)26 BinaryExpression (kodkod.ast.BinaryExpression)22 Decls (kodkod.ast.Decls)22 Bounds (kodkod.instance.Bounds)21 TupleSet (kodkod.instance.TupleSet)20 Universe (kodkod.instance.Universe)20 SumExpression (kodkod.ast.SumExpression)19 TupleFactory (kodkod.instance.TupleFactory)19 Solution (kodkod.engine.Solution)17 QuantifiedFormula (kodkod.ast.QuantifiedFormula)14 Solver (kodkod.engine.Solver)14 BinaryIntExpression (kodkod.ast.BinaryIntExpression)13 ConstantExpression (kodkod.ast.ConstantExpression)13 IfExpression (kodkod.ast.IfExpression)13 IfIntExpression (kodkod.ast.IfIntExpression)13 NaryExpression (kodkod.ast.NaryExpression)13