Search in sources :

Example 91 with Expression

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

the class GEO158 method innerPointDefn.

/**
 * Returns the inner_point_defn axiom.
 *
 * @return inner_point_defn
 */
public final Formula innerPointDefn() {
    // all P: Point, C: Curve | P->C in innerPoint iff
    // (P->C in incident && no P->C & endPoint)
    final Variable c = Variable.unary("C");
    final Variable p = Variable.unary("P");
    final Expression e0 = p.product(c);
    final Formula f0 = e0.in(innerPoint);
    final Formula f1 = e0.in(incident).and(e0.intersection(endPoint).no());
    return f0.iff(f1).forAll(p.oneOf(point).and(c.oneOf(curve)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 92 with Expression

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

the class AbstractWorldDefinitions method Abstract.

/**
 * Returns the application of the Abstract predicate.
 *
 * @return application of the Abstract predicate.
 */
public Formula Abstract(Expression s) {
    final Expression e0 = s.join(abAuthPurse).join(abBalance).join(s).intersection(s.join(abAuthPurse).join(abLost).join(s));
    final Formula f0 = e0.no();
    final Expression e1 = s.join(abAuthPurse).product(Expression.UNIV);
    final Expression e2 = e1.intersection((abBalance.union(abLost)).join(s));
    final Formula f1 = e2.in(AbPurse.product(Coin));
    final Variable c = Variable.unary("c");
    final Formula f2 = e2.join(c).lone().forAll(c.oneOf(Coin));
    return Formula.and(f0, f1, f2);
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 93 with Expression

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

the class Dijkstra method releaseMutex.

/**
 * Returns the GrabMutex predicate for states s1, s2, process p and mutex m.
 *
 * @return
 *
 *         <pre>
 * pred State.ReleaseMutex (p: Process, m: Mutex, s': State) {
 *   !this::IsStalled(p)
 *   m in p.(this.holds)
 *   p.(s'.holds) = p.(this.holds) - m
 *   no p.(s'.waits)
 *   no m.~(this.waits) => {
 *       no m.~(s'.holds)
 *       no m.~(s'.waits)
 *    } else {
 *       some lucky: m.~(this.waits) | {
 *       m.~(s'.waits) = m.~(this.waits) - lucky
 *     m.~(s'.holds) = lucky
 *    }
 *   }
 *   all mu: Mutex - m {
 *     mu.~(s'.waits) = mu.~(this.waits)
 *     mu.~(s'.holds)= mu.~(this.holds)
 *   }
 * }
 *         </pre>
 */
public Formula releaseMutex(Expression s1, Expression s2, Expression p, Expression m) {
    final Formula f1 = isStalled(s1, p).not().and(m.in(p.join(s1.join(holds))));
    final Formula f2 = p.join(s2.join(holds)).eq(p.join(s1.join(holds)).difference(m));
    final Formula f3 = p.join(s2.join(waits)).no();
    final Expression cexpr = m.join((s1.join(waits)).transpose());
    final Formula f4 = m.join(s2.join(holds).transpose()).no();
    final Formula f5 = m.join(s2.join(waits).transpose()).no();
    final Formula f6 = cexpr.no().implies(f4.and(f5));
    final Variable lucky = Variable.unary("lucky");
    final Formula f7 = m.join(s2.join(waits).transpose()).eq(m.join(s1.join(waits).transpose()).difference(lucky));
    final Formula f8 = m.join(s2.join(holds).transpose()).eq(lucky);
    final Formula f9 = f7.and(f8).forSome(lucky.oneOf(m.join(s1.join(waits).transpose())));
    final Formula f10 = cexpr.some().implies(f9);
    final Variable mu = Variable.unary("mu");
    final Formula f11 = mu.join(s2.join(waits).transpose()).eq(mu.join(s1.join(waits).transpose()));
    final Formula f12 = mu.join(s2.join(holds).transpose()).eq(mu.join(s1.join(holds).transpose()));
    final Formula f13 = f11.and(f12).forAll(mu.oneOf(Mutex.difference(m)));
    return Formula.and(f1, f2, f3, f6, f10, f13);
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 94 with Expression

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

the class MED001 method bg_completion.

/**
 * Returns the bg_completion axiom.
 *
 * @return bg_completion
 */
public final Formula bg_completion() {
    final Variable x0 = Variable.unary("X0");
    final Expression x1 = UNIV.difference(x0.join(gt));
    final Formula f0 = x1.in(releaselg).not();
    return f0.implies(x1.in(drugbg)).forAll(x0.oneOf(UNIV));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 95 with Expression

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

the class MED001 method liver_glucose.

/**
 * Returns the liver_glucose axiom.
 *
 * @return liver_glucose
 */
public final Formula liver_glucose() {
    final Variable x0 = Variable.unary("X0");
    final Expression x1 = UNIV.difference(x0.join(gt));
    return x1.in(uptakelg).implies(x1.in(releaselg).not()).forAll(x0.oneOf(UNIV));
}
Also used : Variable(kodkod.ast.Variable) 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