kodkod.ast.Expression Java Examples

The following examples show how to use kodkod.ast.Expression. 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: PrettyPrinter.java    From quetzal with Eclipse Public License 2.0 6 votes vote down vote up
/** @return true if e is (a product of) Expression.NONE*/
private boolean isEmpty(Expression e) { 
	if (e==Expression.NONE) return true;
	else if (e instanceof BinaryExpression) { 
		final BinaryExpression b = (BinaryExpression) e;
		return b.op()==ExprOperator.PRODUCT && isEmpty(b.left()) && isEmpty(b.right());
	} else if (e instanceof NaryExpression) { 
		final NaryExpression n = (NaryExpression) e;
		if (n.op()==ExprOperator.PRODUCT) { 
			for(int i = 0, max = n.size(); i < max; i++) { 
				if (!isEmpty(n.child(i))) return false;
			}
			return true;
		}
	}
	return false;
}
 
Example #2
Source File: Bigconfig.java    From kodkod with MIT License 6 votes vote down vote up
/**
 * Returns the connectedSites predicate.
 * @return pred connectedSites(sites: set Site) {
 *  -- all sites in the given set are connected to each other  
 *  all s: sites | sites - s in ((site.s).^link).site
 *  }
 */
public Formula connectedSites(Expression sites) {
	final Variable s = Variable.unary("s");
	Expression closed;
	if (closureApprox > 0) {
		closed = link;
		for(int i = 1; i < closureApprox; i *= 2) {
			closed = closed.union(closed.join(closed));
		}
	} else {
		closed = link.closure();
	}
	
	final Expression sreachable = site.join(s).join(closed).join(site);
	final Formula f = sites.difference(s).in(sreachable);
	return f.forAll(s.oneOf(sites));
}
 
Example #3
Source File: ALG197.java    From org.alloytools.alloy with Apache License 2.0 6 votes vote down vote up
/**
 * Parametrization of axioms 14 and 15.
 *
 * @requires e's are unary, op is ternary
 */
@Override
Formula ax14and15(Relation[] e, Relation op) {
    final Expression expr0 = e[6].join(op); // op(e6,...)
    final Expression expr1 = e[6].join(expr0); // op(e6,e6)
    final Expression expr2 = expr1.join(expr1.join(op)); // op(op(e6,e6),op(e6,e6))
    final Expression expr3 = expr2.join(expr0); // op(e6,op(op(e6,e6),op(e6,e6)))
    // 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);
}
 
Example #4
Source File: TranslatorTest.java    From kodkod with MIT License 6 votes vote down vote up
@Test
public final void testTranslateProjection() {
	
	assertTrue(isSatisfiable(r3[0].eq(
			r2[0].project(IntConstant.constant(0), IntConstant.constant(1), IntConstant.constant(0)))));
	
	assertTrue(isSatisfiable(r2[1].in(r3[0].project(r1[3].count(), r1[2].count()))));

	final Variable v = Variable.nary("r", 2);
	assertFalse(isSatisfiable(v.transpose().
			eq(v.project(IntConstant.constant(1), IntConstant.constant(0))).not().
			forSome(v.setOf(r2[0]))));
	
	bounds.boundExactly(r3[0], bounds.upperBound(r3[0]));
	bounds.boundExactly(r2[0], bounds.upperBound(r2[0]));
	
	assertTrue(isSatisfiable(r3[0].project(IntConstant.constant(0), IntConstant.constant(1)).eq(r2[0])));
	assertTrue(isSatisfiable(r3[0].project(IntConstant.constant(0), IntConstant.constant(4), IntConstant.constant(2)).
			eq(Expression.NONE.product(Expression.NONE).product(Expression.NONE))));
	assertTrue(isSatisfiable(r3[0].project(IntConstant.constant(0), IntConstant.constant(-1), IntConstant.constant(2)).
			eq(Expression.NONE.product(Expression.NONE).product(Expression.NONE))));
	
}
 
Example #5
Source File: BlockedNQueens.java    From kodkod with MIT License 6 votes vote down vote up
/**
	 * Prints the given solution using the given options to the console
	 */
	void print(Instance instance, Options options) {
		final Evaluator eval = new Evaluator(instance, options);
		final int n = instance.tuples(queen).size();
		for(int i = 0; i < n; i++) { 
			Expression ci = IntConstant.constant(i).toExpression();
			for(int j = 0; j < n; j++) { 
				Expression cj = IntConstant.constant(j).toExpression();
				if (eval.evaluate(x.join(ci).intersection(y.join(cj)).some())) { 
					System.out.print(" Q");
				} else {
					System.out.print(" .");
				}
			}
			System.out.println();
		}
//		System.out.println(instance); 
	}
 
Example #6
Source File: RegressionTests.java    From kodkod with MIT License 6 votes vote down vote up
@Test
public final void testGreg_02192006() {
	Relation r1 = Relation.unary("r1");
	Relation r2 = Relation.unary("r2");
	Relation r3 = Relation.unary("r3");
	Expression e = r1.in(r2).thenElse(r2, r1);
	Formula f = e.eq(r2).and(e.in(r3));
	Object o1 = "o1";
	Object o2 = "o2";	
	Universe univ = new Universe(Arrays.asList(o1, o2));
	TupleFactory factory = univ.factory();
	TupleSet set1 = factory.setOf(o1);
	TupleSet set2 = factory.setOf(o2);
	Bounds bounds = new Bounds(univ);
	bounds.bound(r1, set1);
	bounds.boundExactly(r2, set2);
	bounds.bound(r3, set1);

	assertEquals(Solution.Outcome.TRIVIALLY_UNSATISFIABLE, solver.solve(f, bounds).outcome());


}
 
Example #7
Source File: ALG197.java    From kodkod with MIT License 6 votes vote down vote up
/**
 * Parametrization of axioms 16-22.
 * @requires e is unary, h is binary
 */
Formula ax16_22(Relation e, Relation h) {
	final Expression expr0 = e.join(op2); // op2(e,...)
	final Expression expr1 = e.join(expr0); // op2(e,e)
	final Expression expr2 = expr1.join(expr1.join(op2)); // op2(op2(e,e),op2(e,e))
	final Expression expr3 = expr2.join(expr0); // op2(e,op2(op2(e,e),op2(e,e)))
	//  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);
}
 
Example #8
Source File: ALG195_1.java    From kodkod with MIT License 6 votes vote down vote up
/**
 * Parametrization of axioms 14 and 15.
 * @requires e's are unary, op is ternary
 */
Formula ax14and15(Relation[] e, Relation op) {
	final Expression expr0 = e[5].join(op); // op(e5,...)
	final Expression expr1 = e[5].join(expr0); // op(e5,e5)
	final Expression expr2 = expr1.join(expr0); // op(e5,op(e5,e5))
	final Expression expr3 = expr2.join(expr2.join(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))),...)
	final Expression expr4 = e[5].join(expr3a); // op(op(op(e5,op(e5,e5)),op(e5,op(e5,e5))),e5)
	// 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));
	// e1 = op(e5,e5)
	final Formula f1 = e[1].eq(expr1);
	// 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 f0.and(f1).and(f2).and(f3).and(f4).and(f6);
}
 
Example #9
Source File: AbstractReplacer.java    From kodkod with MIT License 6 votes vote down vote up
/** 
 * Calls lookup(expr) and returns the cached value, if any.  
 * If a replacement has not been cached, visits the expr's 
 * children.  If nothing changes, the argument is cached and
 * returned, otherwise a replacement expr is cached and returned.
 * @return { e: Expression | e.op = expr.op && #e.children = #expr.children && all i: [0..expr.children) | e.child(i) = expr.child(i).accept(this) }
 */
public Expression visit(NaryExpression expr) {
	Expression ret = lookup(expr);
	if (ret!=null) return ret;
	
	final Expression[] visited = new Expression[expr.size()];
	boolean allSame = true;
	for(int i = 0 ; i < visited.length; i++) { 
		final Expression child = expr.child(i);
		visited[i] = child.accept(this);
		allSame = allSame && visited[i]==child;
	}
	
	ret = allSame ? expr : Expression.compose(expr.op(), visited);
	return cache(expr,ret);
}
 
Example #10
Source File: FOL2BoolTranslator.java    From org.alloytools.alloy with Apache License 2.0 6 votes vote down vote up
/**
 * Calls lookup(unaryExpr) and returns the cached value, if any. If a
 * translation has not been cached, translates the expression, calls cache(...)
 * on it and returns it.
 *
 * @return let t = lookup(unaryExpr) | some t => t, let op =
 *         (unaryExpr.op).(TRANSPOSE->transpose + CLOSURE->closure +
 *         REFLEXIVE_CLOSURE->(lambda(m)(m.closure().or(iden))) |
 *         cache(unaryExpr, op(unaryExpr.child))
 */
@Override
public final BooleanMatrix visit(UnaryExpression unaryExpr) {
    BooleanMatrix ret = lookup(unaryExpr);
    if (ret != null)
        return ret;

    final BooleanMatrix child = unaryExpr.expression().accept(this);
    final ExprOperator op = unaryExpr.op();

    switch (op) {
        case TRANSPOSE :
            ret = child.transpose();
            break;
        case CLOSURE :
            ret = child.closure();
            break;
        case REFLEXIVE_CLOSURE :
            ret = child.closure().or(visit((ConstantExpression) Expression.IDEN));
            break;
        default :
            throw new IllegalArgumentException("Unknown operator: " + op);
    }
    return cache(unaryExpr, ret);
}
 
Example #11
Source File: RegressionTests.java    From kodkod with MIT License 5 votes vote down vote up
@Test
public final void testFelix_10182006() {
	//(some x: one { y: one SIG | true } | true)
	Relation sig = Relation.unary("SIG");
	final Variable x = Variable.unary("x");
	final Variable y = Variable.unary("y");
	final Expression e0 = Formula.TRUE.comprehension(y.oneOf(sig));
	final Formula f0 = Formula.TRUE.forSome(x.oneOf(e0));
	final Universe u = new Universe(Arrays.asList("a0"));
	final Bounds bounds = new Bounds(u);
	bounds.bound(sig, u.factory().allOf(1));
	final Solution s = solver.solve(f0, bounds);
	assertEquals(Solution.Outcome.SATISFIABLE, s.outcome());
}
 
Example #12
Source File: GEO092.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Returns the conjecture proposition_2_14_1.
 * @return proposition_2_14_1
 */
public final Formula proposition2141() {	
	// all c1, c2: curve, p: point | 
	//  p->c1->c2 in meet && c1->c2 in sum.open => 
	//  all q: point - p | c1 + c2 !in q.incident
	final Variable c1 = Variable.unary("C1");
	final Variable c2 = Variable.unary("C2");
	final Variable p = Variable.unary("P");
	final Variable q = Variable.unary("Q");
	final Expression e0 = c1.product(c2);
	final Formula f0 = p.product(e0).in(meet).and(e0.in(sum.join(open)));
	final Formula f1 = c1.union(c2).in(q.join(incident)).not().forAll(q.oneOf(point.difference(p)));
	return f0.implies(f1).forAll(c1.oneOf(curve).and(c2.oneOf(curve)).and(p.oneOf(point)));
}
 
Example #13
Source File: JenaTranslator.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
private Expression constrainDomain(Expression e, Domain d) {
	if (e instanceof Variable) {
		if (context.getDomain((Variable)e) != null) {
			if (! d.equals(context.getDomain((Variable)e))) {
				context.setDomain((Variable)e, new And(d, context.getDomain((Variable)e)));
			}
		} else {
			context.setDomain((Variable)e, d);
		}
		if (DEBUG) System.err.println("constraining " + e + " to be " + context.getDomain((Variable)e));
	}
	return e;
}
 
Example #14
Source File: OverflowTheoremTest.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
@Override
protected void setUp() throws Exception {
    super.setUp();
    setupOptions();
    setupBounds();

    ZERO = IntConstant.constant(0);
    MININT = IntConstant.constant(min(bw));
    MAXINT = IntConstant.constant(max(bw));
    a = Variable.unary("a");
    b = Variable.unary("b");
    as = a.sum();
    bs = b.sum();
    decls = a.oneOf(Expression.INTS).and(b.oneOf(Expression.INTS));
}
 
Example #15
Source File: GEO159.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the between_c_defn axiom.
 *
 * @return between_c_defn
 */
public final Formula betweenDefn() {
    // all c, p, q, r: point |
    // c->p->q->r in between <=> p != r && some p.endPoint & r.endPoint &
    // q.innerPoint & partOf.c
    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 Expression e = p.join(endPoint).intersection(r.join(endPoint)).intersection(q.join(innerPoint)).intersection(partOf.join(c));
    final Formula f0 = c.product(p).product(q).product(r).in(between);
    final Formula f1 = p.eq(q).not().and(e.some());
    return f0.iff(f1).forAll(p.oneOf(point).and(q.oneOf(point)).and(r.oneOf(point)).and(c.oneOf(curve)));
}
 
Example #16
Source File: GEO158.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Returns the c6 axiom.
 * @return c6
 */
public final Formula c6() {
	//  all C: Curve, P: endPoint.C | some endPoint.C - P
	final Variable c = Variable.unary("C");
	final Variable p = Variable.unary("P");
	final Expression e0 = endPoint.join(c);
	return e0.difference(p).some().forAll(c.oneOf(curve).and(p.oneOf(e0)));
}
 
Example #17
Source File: ReductionAndProofTest.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
public final void testReduction() {
    Formula f0, f1, f2, f3, f4, f5, f6;

    f0 = a.difference(b).eq(a); // T
    assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, solver.solve(f0, bounds).outcome());

    f1 = a2b.join(b2a).some();
    assertEquals(Solution.Outcome.TRIVIALLY_SATISFIABLE, solver.solve(f0.or(f1), bounds).outcome());

    f2 = total.totalOrder(ordered, first, last);
    f3 = first.join(total).no(); // F

    Set<Formula> reduction = reduce(f3.and(f0).and(f1).and(f2));
    assertEquals(1, reduction.size());
    assertTrue(reduction.contains(f3));

    f4 = total.acyclic();
    f5 = total.closure().intersection(Expression.IDEN).some(); // F

    reduction = reduce(f4.and(f1).and(f0).and(f5));
    assertEquals(1, reduction.size());
    assertTrue(reduction.contains(f5));

    bounds.boundExactly(a2b, bounds.upperBound(a2b));
    bounds.boundExactly(a, bounds.upperBound(a));
    bounds.boundExactly(b, bounds.upperBound(b));
    f6 = a2b.function(a, b); // F

    reduction = reduce(f1.and(f2).and(f6));
    assertEquals(1, reduction.size());
    assertTrue(reduction.contains(f6));

}
 
Example #18
Source File: JenaTranslator.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
private Formula existentialScope(Collection<Variable> projectedVars, Formula f, Expression dynamicBinding) {
	Pair<Formula,Decls> x = scopeInternal(f, dynamicBinding, Collections.emptySet(), projectedVars);
	if (x.snd == null) {
		return x.fst;
	} else {
		return x.fst.forSome(x.snd);
	}
}
 
Example #19
Source File: Toughnut.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * Returns the covering predicate.  Note that we don't 
 * need to specify the first two lines of the predicate,
 * since they can be expressed as bounds constraints.
 * @return the covering predicate
 */
public Formula checkBelowTooDoublePrime() {
	final Variable x = Variable.unary("x");
	final Variable y = Variable.unary("y");
	final Decls d = x.oneOf(Cell).and(y.oneOf(Cell));
	final Expression xy = y.join(x.join(covered));
	// covering relation is symmetric
	Formula symm = xy.product(x.product(y)).in(covered).forAll(d);
	// each pair of cells on the board should be covered
	// by a domino, which also covers ONE of its neighbors
	Expression xNeighbors = (prev(x).union(next(x))).product(y);
	Expression yNeighbors = x.product(prev(y).union(next(y)));
	Formula covering = (xy.one().and(xy.in(xNeighbors.union(yNeighbors)))).forAll(d);
	return symm.and(covering);
}
 
Example #20
Source File: LAT258.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the greatest_lower_bound_meet axiom.
 *
 * @return the greatest_lower_bound_meet axiom.
 */
public final Formula greatestLowerBoundMeet() {
    final Variable a = Variable.unary("A"), b = Variable.unary("B");
    final Expression e0 = b.join(a.join(meet));
    final Formula f0 = e0.some().implies(lessThan.join(a).intersection(lessThan.join(b)).in(lessThan.join(e0)));
    return f0.forAll(a.oneOf(UNIV).and(b.oneOf(UNIV)));
}
 
Example #21
Source File: OverflowTheoremTest.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * all a, b: set univ | a in b => #a <= #b
 */
@Test
public void testCardinality3() {
    Variable a = Variable.unary("a");
    Variable b = Variable.unary("b");
    Decls dcls = a.setOf(Expression.UNIV).and(b.setOf(Expression.UNIV));
    Formula pre = a.in(b);
    Formula post = a.count().lte(b.count());
    checkTrue(pre, post, dcls);
}
 
Example #22
Source File: FOL2BoolCache.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * @see kodkod.engine.fol2sat.FOL2BoolCache.Record#get(kodkod.engine.fol2sat.Environment)
 */
@Override
Object get(Environment<BooleanMatrix,Expression> e) {
    if (translation == null)
        return null;
    for (int i = 0; i < vars.length; i++) {
        if (e.lookup(vars[i]).get(tuples[i]) != BooleanConstant.TRUE)
            return null;
    }
    return translation;
}
 
Example #23
Source File: TranslateAlloyToKodkod.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public Object visit(Sig x) throws Err {
    Expression ans = a2k(x);
    if (ans == null)
        throw new ErrorFatal(x.pos, "Sig \"" + x + "\" is not bound to a legal value during translation.\n");
    return ans;
}
 
Example #24
Source File: TranslateAlloyToKodkod.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the expression corresponding to the given string literal.
 */
private Expression s2k(String x) throws Err {
    if (s2k != null)
        return s2k.get(x);
    else
        return frame.a2k(x);
}
 
Example #25
Source File: Simplifier.java    From quetzal with Eclipse Public License 2.0 5 votes vote down vote up
public Expression visit(BinaryExpression expr) { 
	Expression ret = lookup(expr);
	if (ret!=null) return ret;
	final ExprOperator op = expr.op();
	final Expression left = expr.left().accept(this);
	final Expression right = expr.right().accept(this);
	
	ret = simplify(op, left, right);
	
	if (ret==null) {
		ret = left==expr.left()&&right==expr.right() ? expr : left.compose(op, right);
	}
	
	return cache(expr,ret);
}
 
Example #26
Source File: MED001.java    From kodkod with MIT License 5 votes vote down vote up
/**
 * 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));
}
 
Example #27
Source File: MED001.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the ex_cure axiom.
 *
 * @return ex_cure
 */
public final Formula ex_cure() {
    final Variable x0 = Variable.unary("X0");
    final Expression x1 = UNIV.difference(x0.join(gt));
    final Formula f0 = x1.in(uptakelg).and(x1.in(uptakepg)).and(x0.in(bcapacityex).not()).and(x0.join(gt).in(conditionhyper));
    return f0.implies(x1.in(conditionnormo.union(conditionhypo))).forAll(x0.oneOf(UNIV));
}
 
Example #28
Source File: HOLSome4AllTest.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
@Test
public void testE6() {
    // SAT: some s: ints |
    // s > 1 || (all ns: set Node | #ns > s)
    Formula cnd = si.gt(I1);
    Formula f = cnd.or(ns.count().gt(si).forAll(ns.setOf(Node))).forSome(s.oneOf(Expression.INTS));
    Solution sol = solve(f);
    assertTrue(sol.sat());
}
 
Example #29
Source File: A4Solution.java    From org.alloytools.alloy with Apache License 2.0 5 votes vote down vote up
/**
 * Add a new sig to this solution and associate it with the given expression
 * (and if s.isTopLevel then add this expression into Sig.UNIV). <br>
 * The expression must contain only constant Relations or Relations that are
 * already bound in this solution. <br>
 * (If the sig was already added by a previous call to addSig(), then this call
 * will return immediately without altering what it is associated with)
 */
void addSig(Sig s, Expression expr) throws ErrorFatal {
    if (solved)
        throw new ErrorFatal("Cannot add an additional sig since solve() has completed.");
    if (expr.arity() != 1)
        throw new ErrorFatal("Sig " + s + " must be associated with a unary relational value.");
    if (a2k.containsKey(s))
        return;
    a2k.put(s, expr);
    sigs.add(s);
    if (s.isTopLevel())
        a2k.put(UNIV, a2k.get(UNIV).union(expr));
}
 
Example #30
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);
}