use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.
the class OverflowSigTest method createFacts.
/**
* all v: S | <int_op>[#s.sa, #s.sb] = #s.sc <int_op> = {plus, minus, times,
* div, mod}
*/
protected void createFacts(IntOperator intOp) {
Variable vs = Variable.unary("vs");
Formula body = applyIntOp(intOp, vs.join(sa).count(), vs.join(sb).count()).eq(vs.join(sc).count());
this.facts = body.forAll(vs.oneOf(s));
}
use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.
the class OverflowTheoremTest method testCardinality1.
/**
* all s : set univ | (some s) iff #s > 0
*/
@Test
public void testCardinality1() {
Variable s = Variable.unary("s");
Formula f = s.some().iff(s.count().gt(IntConstant.constant(0))).forAll(s.setOf(Expression.UNIV));
checkTrue(f);
}
use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.
the class OverflowTheoremTest method testCardinality2.
/**
* all s, t : set univ | #(s + t) >= #s && #(s + t) >= #t
*/
@Test
public void testCardinality2() {
Variable s = Variable.unary("s");
Variable t = Variable.unary("t");
IntExpression sutCnt = s.union(t).count();
Decls dcls = s.setOf(Expression.UNIV).and(t.setOf(Expression.UNIV));
Formula f = sutCnt.gte(s.count()).and(sutCnt.gte(t.count())).forAll(dcls);
checkTrue(f);
}
use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.
the class OverflowTheoremTest method testCardinality0.
/**
* all s : set univ | #s >= 0 !some(s : set univ | #s < 0)
*/
@Test
public void testCardinality0() {
Variable s = Variable.unary("s");
Formula f = (s.count().gte(IntConstant.constant(0))).forAll(s.setOf(Expression.UNIV));
checkTrue(f);
f = (s.count().lt(IntConstant.constant(0))).forSome(s.setOf(Expression.UNIV)).not();
checkTrue(f);
}
use of kodkod.ast.Variable in project org.alloytools.alloy by AlloyTools.
the class OverflowTheoremTest method testCardinality3.
/**
* 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);
}
Aggregations