Java Code Examples for kodkod.ast.Expression#no()

The following examples show how to use kodkod.ast.Expression#no() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractWorldDefinitions.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * 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);
}
 
Example 2
Source File: BoundsComputer.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method that returns the constraint that the sig has exactly "n"
 * elements, or at most "n" elements
 */
private Formula size(Sig sig, int n, boolean exact) {
    Expression a = sol.a2k(sig);
    if (n <= 0)
        return a.no();
    if (n == 1)
        return exact ? a.one() : a.lone();
    Formula f = exact ? Formula.TRUE : null;
    Decls d = null;
    Expression sum = null;
    while (n > 0) {
        n--;
        Variable v = Variable.unary("v" + Integer.toString(TranslateAlloyToKodkod.cnt++));
        kodkod.ast.Decl dd = v.oneOf(a);
        if (d == null)
            d = dd;
        else
            d = dd.and(d);
        if (sum == null)
            sum = v;
        else {
            if (f != null)
                f = v.intersection(sum).no().and(f);
            sum = v.union(sum);
        }
    }
    if (f != null)
        return sum.eq(a).and(f).forSome(d);
    else
        return a.no().or(sum.eq(a).forSome(d));
}
 
Example 3
Source File: AbstractWorldDefinitions.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * 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);
}