Search in sources :

Example 86 with Expression

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

the class ALG195_1 method ax3and6.

/**
 * Parametrization of axioms 3 and 6.
 *
 * @requires s is unary, op is ternary
 */
private static Formula ax3and6(Relation[] e, Relation op) {
    Formula f = Formula.TRUE;
    for (Relation x : e) {
        for (Relation y : e) {
            // op(y,x)
            Expression expr0 = x.join(y.join(op));
            // op(op(y,x),y)
            Expression expr1 = y.join(expr0.join(op));
            // op(op(op(y,x),y),y)
            Expression expr2 = y.join(expr1.join(op));
            f = f.and(expr2.eq(x));
        }
    }
    return f;
}
Also used : Formula(kodkod.ast.Formula) Relation(kodkod.ast.Relation) Expression(kodkod.ast.Expression)

Example 87 with Expression

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

the class ALG212 method associativity.

/**
 * Returns the associativity axiom.
 *
 * @return associativity
 */
public final Formula associativity() {
    // all w, x, y, z: A | f[f[x][w][y]][w][z] = f[x][w][f[y][w][z]]
    final Variable w = Variable.unary("w");
    final Variable x = Variable.unary("x");
    final Variable y = Variable.unary("y");
    final Variable z = Variable.unary("z");
    final Expression e0 = y.join(w.join(x.join(f)));
    final Expression e1 = z.join(w.join(e0.join(f)));
    final Expression e2 = z.join(w.join(y.join(f)));
    final Expression e3 = e2.join(w.join(x.join(f)));
    return e1.eq(e3).forAll(w.oneOf(UNIV).and(x.oneOf(UNIV)).and(y.oneOf(UNIV)).and(z.oneOf(UNIV)));
}
Also used : Variable(kodkod.ast.Variable) Expression(kodkod.ast.Expression)

Example 88 with Expression

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

the class ALG195 method ax14and15.

/**
 * Parametrization of axioms 14 and 15.
 *
 * @requires e's are unary, op is ternary
 */
@Override
Formula ax14and15(Relation[] e, Relation op) {
    // op(e5,...)
    final Expression expr0 = e[5].join(op);
    // op(e5,e5)
    final Expression expr1 = e[5].join(expr0);
    // op(e5,op(e5,e5))
    final Expression expr2 = expr1.join(expr0);
    // op(op(e5,op(e5,e5)),op(e5,op(e5,e5)))
    final Expression expr3 = expr2.join(expr2.join(op));
    // op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),...)
    final Expression expr3a = expr3.join(op);
    // op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5)
    final Expression expr4 = e[5].join(expr3a);
    // e0 = op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),op(e5,op(e5,e5)))
    final Formula f0 = e[0].eq(expr2.join(expr3a));
    // e2 = op(op(e5,op(e5,e5)),op(e5,op(e5,e5)))
    final Formula f2 = e[2].eq(expr3);
    // e3 = op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5)
    final Formula f3 = e[3].eq(expr4);
    // e4 = op(e5,op(e5,e5))
    final Formula f4 = e[4].eq(expr2);
    // e6 =
    // op(op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5),op(e5,op(e5,e5)))
    final Formula f6 = e[6].eq(expr2.join(expr4.join(op)));
    return and(f0, f2, f3, f4, f6);
}
Also used : Formula(kodkod.ast.Formula) Expression(kodkod.ast.Expression)

Example 89 with Expression

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

the class ALG197 method ax16_22.

/**
 * Parametrization of axioms 16-22.
 *
 * @requires e is unary, h is binary
 */
@Override
Formula ax16_22(Relation e, Relation h) {
    // op2(e,...)
    final Expression expr0 = e.join(op2);
    // op2(e,e)
    final Expression expr1 = e.join(expr0);
    // op2(op2(e,e),op2(e,e))
    final Expression expr2 = expr1.join(expr1.join(op2));
    // op2(e,op2(op2(e,e),op2(e,e)))
    final Expression expr3 = expr2.join(expr0);
    // h(e10) = op2(e,op2(e,e))
    final Formula f0 = e1[0].join(h).eq(expr1.join(expr0));
    // h(e11) = op2(op2(e,e),op2(e,e))
    final Formula f1 = e1[1].join(h).eq(expr2);
    // h(e12) = op2(op2(op2(e,e),op2(e,e)),op2(e,e))
    final Formula f2 = e1[2].join(h).eq(expr1.join(expr2.join(op2)));
    // h(e13) = op2(e,op2(op2(e,e),op2(e,e)))
    final Formula f3 = e1[3].join(h).eq(expr3);
    // h(e14) = op2(e,op2(e,op2(op2(e,e),op2(e,e))))
    final Formula f4 = e1[4].join(h).eq(expr3.join(expr0));
    // h(e15) = op2(e,e)
    final Formula f5 = e1[5].join(h).eq(expr1);
    return Formula.and(f0, f1, f2, f3, f4, f5);
}
Also used : Formula(kodkod.ast.Formula) Expression(kodkod.ast.Expression)

Example 90 with Expression

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

the class ALG197 method ax14and15.

/**
 * Parametrization of axioms 14 and 15.
 *
 * @requires e's are unary, op is ternary
 */
@Override
Formula ax14and15(Relation[] e, Relation op) {
    // op(e6,...)
    final Expression expr0 = e[6].join(op);
    // op(e6,e6)
    final Expression expr1 = e[6].join(expr0);
    // op(op(e6,e6),op(e6,e6))
    final Expression expr2 = expr1.join(expr1.join(op));
    // op(e6,op(op(e6,e6),op(e6,e6)))
    final Expression expr3 = expr2.join(expr0);
    // e0 = op(e6,op(e6,e6))
    final Formula f0 = e[0].eq(expr1.join(expr0));
    // e1 = op(op(e6,e6),op(e6,e6))
    final Formula f1 = e[1].eq(expr2);
    // e2 = op(op(op(e6,e6),op(e6,e6)),op(e6,e6))
    final Formula f2 = e[2].eq(expr1.join(expr2.join(op)));
    // e3 = op(e6,op(op(e6,e6),op(e6,e6)))
    final Formula f3 = e[3].eq(expr3);
    // e4 = op(e6,op(e6,op(op(e6,e6),op(e6,e6))))
    final Formula f4 = e[4].eq(expr3.join(expr0));
    return Formula.and(f0, f1, f2, f3, f4);
}
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