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

The following examples show how to use kodkod.ast.Expression#product() . 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: Bounds.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
public Expression ts2expr(TupleSet tset) {
    if (tset == null)
        return Expression.NONE;
    Expression tsetExpr = null;
    for (Tuple t : tset) {
        Expression tupleExpr = null;
        for (int i = 0; i < t.arity(); i++) {
            Expression atomRel = ensureAtomExpr(t.atom(i));
            tupleExpr = tupleExpr == null ? atomRel : tupleExpr.product(atomRel);
        }
        tsetExpr = tsetExpr == null ? tupleExpr : tsetExpr.union(tupleExpr);
    }
    return (tsetExpr == null) ? Expression.NONE : tsetExpr;
}
 
Example 2
Source File: AbstractWorldDefinitions.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the application of the XiAbPurse predicate.
 *
 * @return application of the XiAbPurse predicate.
 */
public Formula XiAbPurse(Expression s, Expression sprime, Expression a) {
    final Expression aRestrict = a.product(Expression.UNIV);
    final Formula f0 = aRestrict.intersection(abBalance.join(s)).eq(aRestrict.intersection(abBalance.join(sprime)));
    final Formula f1 = aRestrict.intersection(abLost.join(s)).eq(aRestrict.intersection(abLost.join(sprime)));
    return f0.and(f1);
}
 
Example 3
Source File: AbstractWorldDefinitions.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Returns the application of the XiAbPurse predicate.
 * @return application of the XiAbPurse predicate.
 */
public Formula XiAbPurse(Expression s, Expression sprime, Expression a) {
	final Expression aRestrict = a.product(Expression.UNIV);
	final Formula f0 = aRestrict.intersection(abBalance.join(s)).eq(aRestrict.intersection(abBalance.join(sprime)));
	final Formula f1 = aRestrict.intersection(abLost.join(s)).eq(aRestrict.intersection(abLost.join(sprime)));
	return f0.and(f1);
}
 
Example 4
Source File: ListEncoding.java    From kodkod with MIT License 5 votes vote down vote up
Formula post() { 				
	Expression nodes = thisList.join(head).join(next.reflexiveClosure());				// assert let nodes = this.head.*next, 
	Expression nodesPrime = thisList.join(head0()).join(next3().reflexiveClosure());	//   nodes' = this.head0.*next3, 
	Expression ns = nodes.difference(nil);												//   ns = nodes - nil | 
	Expression ns2 = ns.product(ns);
	return Formula.and(	invariants(thisList, next3(), data, head0()),					//   invariants(this, next3, data, head0) &&  
						nodesPrime.eq(nodes),											//   nodes' = nodes &&
						next3().intersection(ns2).										//   next3 & (ns -> ns) = ~(next & (ns -> ns))
							eq(next.intersection(ns2).transpose())); 
}
 
Example 5
Source File: JenaTranslator.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
private Expression restrictExistsWithFilter(Set<Variable> lhsVars, Pair<Relation, List<Pair<Variable, Domain>>> rightRelation, Formula filters, Expression tuples) {
	Expression t = null;
	Decls d = null;
	Set<Variable> filterVars = filters==null? Collections.<Variable>emptySet(): ASTUtils.gatherVariables(filters);
	for(Pair<Variable,Domain> v : rightRelation.snd) {
		if (lhsVars.contains(v.fst) || filterVars.contains(v.fst)) {
			t = t==null? v.fst: t.product(v.fst);
			if (!lhsVars.contains(v.fst)) {
				Decl x = v.fst.oneOf(QuadTableRelations.nodes.union(NULL));
				d = d==null? x: d.and(x);
			}
		}
	}
	return t.in(tuples).and(filters).comprehension(d);
}
 
Example 6
Source File: BoundsComputer.java    From org.alloytools.alloy with Apache License 2.0 4 votes vote down vote up
/**
 * If ex is a simple combination of Relations, then return that combination,
 * else return null.
 */
private Expression sim(Expr ex) {
    while (ex instanceof ExprUnary) {
        ExprUnary u = (ExprUnary) ex;
        if (u.op != ExprUnary.Op.NOOP && u.op != ExprUnary.Op.EXACTLYOF)
            break;
        ex = u.sub;
    }
    if (ex instanceof ExprBinary) {
        ExprBinary b = (ExprBinary) ex;
        if (b.op == ExprBinary.Op.ARROW || b.op == ExprBinary.Op.PLUS || b.op == ExprBinary.Op.JOIN) {
            Expression left = sim(b.left);
            if (left == null)
                return null;
            Expression right = sim(b.right);
            if (right == null)
                return null;
            if (b.op == ExprBinary.Op.ARROW)
                return left.product(right);
            if (b.op == ExprBinary.Op.PLUS)
                return left.union(right);
            else
                return left.join(right);
        }
    }
    if (ex instanceof ExprConstant) {
        switch (((ExprConstant) ex).op) {
            case EMPTYNESS :
                return Expression.NONE;
        }
    }
    if (ex == Sig.NONE)
        return Expression.NONE;
    if (ex == Sig.SIGINT)
        return Expression.INTS;
    if (ex instanceof Sig)
        return sol.a2k((Sig) ex);
    if (ex instanceof Field)
        return sol.a2k((Field) ex);
    return null;
}
 
Example 7
Source File: Netconfig.java    From kodkod with MIT License 4 votes vote down vote up
/**
 * Returns the addLineOfSightLink predicate.
 * @return addLineOfSightLink
 */
public Formula addLineOfSightLink(Expression r1, Expression r2, Expression t) {
	final Expression link = r1.product(r2);
	return link.in(satellite.join(tick.join(t))).and(link.in(lineOfSight.join(t)));
}
 
Example 8
Source File: Netconfig.java    From kodkod with MIT License 4 votes vote down vote up
/**
 * Returns the continuedConnection predicate.
 * @return continuedConnection
 */
public Formula continuedConnection(Expression r1, Expression r2, Expression t) {
	final Expression link = r1.product(r2);
	return link.intersection(lineOfSight.join(tick.join(t))).eq(link.intersection(lineOfSight.join(t)));
}
 
Example 9
Source File: Netconfig.java    From kodkod with MIT License 4 votes vote down vote up
/** 
 * Returns the lostConnection predicate.
 * @return lostConnection
 */
public Formula lostConnection(Expression r1, Expression r2, Expression t) {
	final Expression link = r1.product(r2);
	return link.in(lineOfSight.join(tick.join(t))).and(link.intersection(lineOfSight.join(t)).no());
}
 
Example 10
Source File: Netconfig.java    From org.alloytools.alloy with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the addLineOfSightLink predicate.
 *
 * @return addLineOfSightLink
 */
public Formula addLineOfSightLink(Expression r1, Expression r2, Expression t) {
    final Expression link = r1.product(r2);
    return link.in(satellite.join(tick.join(t))).and(link.in(lineOfSight.join(t)));
}
 
Example 11
Source File: Netconfig.java    From org.alloytools.alloy with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the continuedConnection predicate.
 *
 * @return continuedConnection
 */
public Formula continuedConnection(Expression r1, Expression r2, Expression t) {
    final Expression link = r1.product(r2);
    return link.intersection(lineOfSight.join(tick.join(t))).eq(link.intersection(lineOfSight.join(t)));
}
 
Example 12
Source File: Netconfig.java    From org.alloytools.alloy with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the lostConnection predicate.
 *
 * @return lostConnection
 */
public Formula lostConnection(Expression r1, Expression r2, Expression t) {
    final Expression link = r1.product(r2);
    return link.in(lineOfSight.join(tick.join(t))).and(link.intersection(lineOfSight.join(t)).no());
}