Search in sources :

Example 66 with Expression

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

the class MED001 method insulin_effect.

/**
 * Returns the insulin_effect axiom.
 *
 * @return insulin_effect
 */
public final Formula insulin_effect() {
    final Variable x0 = Variable.unary("X0");
    final Expression x1 = UNIV.difference(x0.join(gt));
    return x1.in(drugi).implies(x1.in(uptakelg.intersection(uptakepg))).forAll(x0.oneOf(UNIV));
}
Also used : Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 67 with Expression

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

the class MED001 method sulfonylurea_effect.

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

Example 68 with Expression

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

the class NUM374 method wilkie.

/**
 * Returns the wilkie conjecture.
 *
 * @return wilkie
 */
public final Formula wilkie() {
    // ! [C,P,Q,R,S,A,B] :
    // ( ( C = product(A,A)
    // & P = sum(n1,A)
    // & Q = sum(P,C)
    // & R = sum(n1,product(A,C))
    // & S = sum(sum(n1,C),product(C,C)) )
    // =>
    // product(exponent(sum(exponent(P,A),exponent(Q,A)),B),exponent(sum(exponent(R,B),exponent(S,B)),A))
    // =
    // product(exponent(sum(exponent(P,B),exponent(Q,B)),A),exponent(sum(exponent(R,A),exponent(S,A)),B))
    // ) )).
    final Variable c = Variable.unary("C");
    final Variable p = Variable.unary("P");
    final Variable q = Variable.unary("Q");
    final Variable r = Variable.unary("R");
    final Variable s = Variable.unary("S");
    final Variable a = Variable.unary("A");
    final Variable b = Variable.unary("B");
    final Formula f0 = c.eq(product(a, a));
    final Formula f1 = p.eq(sum(n1, a));
    final Formula f2 = q.eq(sum(p, c));
    final Formula f3 = r.eq(sum(n1, product(a, c)));
    final Formula f4 = s.eq(sum(sum(n1, c), product(c, c)));
    final Expression e0 = product(exponent(sum(exponent(p, a), exponent(q, a)), b), exponent(sum(exponent(r, b), exponent(s, b)), a));
    final Expression e1 = product(exponent(sum(exponent(p, b), exponent(q, b)), a), exponent(sum(exponent(r, a), exponent(s, a)), b));
    final Formula f5 = e0.eq(e1);
    return (f0.and(f1).and(f2).and(f3).and(f4)).implies(f5).forAll(c.oneOf(UNIV).and(p.oneOf(UNIV)).and(q.oneOf(UNIV)).and(r.oneOf(UNIV)).and(s.oneOf(UNIV)).and(a.oneOf(UNIV)).and(b.oneOf(UNIV)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 69 with Expression

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

the class TOP020 method product_top.

/**
 * Returns product_top axiom.
 *
 * @return product_top
 */
public final Formula product_top() {
    final Variable s = Variable.unary("S");
    final Variable t = Variable.unary("T");
    final Variable x = Variable.unary("X");
    final Formula f0 = a_member_of(x, coerce_to_class(the_product_top_space_of(s, t)));
    final Expression e0 = member.join(coerce_to_class(s));
    final Expression e1 = member.join(coerce_to_class(t));
    final Formula f1 = ordered.intersection(e0.product(e1).product(x)).some();
    return f0.implies(f1).forAll(s.oneOf(UNIV).and(t.oneOf(UNIV)).and(x.oneOf(UNIV)));
}
Also used : Formula(kodkod.ast.Formula) Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 70 with Expression

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

the class BoundsComputer method allocatePrimSig.

// ==============================================================================================================//
/**
 * Allocate relations for nonbuiltin PrimSigs bottom-up.
 */
private Expression allocatePrimSig(PrimSig sig) throws Err {
    // Recursively allocate all children expressions, and form the union of
    // them
    Expression sum = null;
    for (PrimSig child : sig.children()) {
        Expression childexpr = allocatePrimSig(child);
        if (sum == null) {
            sum = childexpr;
            continue;
        }
        // subsigs are disjoint
        sol.addFormula(sum.intersection(childexpr).no(), child.isSubsig);
        sum = sum.union(childexpr);
    }
    TupleSet lower = lb.get(sig).clone(), upper = ub.get(sig).clone();
    if (sum == null) {
        // If sig doesn't have children, then sig should make a fresh
        // relation for itself
        sum = sol.addRel(sig.label, lower, upper);
    } else if (sig.isAbstract == null) {
        // relation to act as the remainder.
        for (PrimSig child : sig.children()) {
            // Remove atoms that are KNOWN to be in a subsig;
            // it's okay to mistakenly leave some atoms in, since we will
            // never solve for the "remainder" relation directly;
            // instead, we union the remainder with the children, then solve
            // for the combined solution.
            // (Thus, the more we can remove, the more efficient it gets,
            // but it is not crucial for correctness)
            TupleSet childTS = sol.query(false, sol.a2k(child), false);
            lower.removeAll(childTS);
            upper.removeAll(childTS);
        }
        sum = sum.union(sol.addRel(sig.label + " remainder", lower, upper));
    }
    sol.addSig(sig, sum);
    return sum;
}
Also used : TupleSet(kodkod.instance.TupleSet) Expression(kodkod.ast.Expression) PrimSig(edu.mit.csail.sdg.ast.Sig.PrimSig)

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