use of kodkod.ast.Formula 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.Formula in project org.alloytools.alloy by AlloyTools.
the class OverflowTheoremTest method testSat.
/**
* SAT: all a: Int | all b: Int | b = MAXINT => (a = MAXINT => a+a = b+b) SAT:
* !(some a: Int | some b: Int | !(b = MAXINT => (a = MAXINT => a+a = b+b))
*/
public void testSat() {
Formula body = bs.eq(MAXINT).implies(as.eq(MAXINT).implies(as.plus(as).eq(bs.plus(bs))));
checkSat(body.forAll(b.oneOf(Expression.INTS)).forAll(a.oneOf(Expression.INTS)));
checkSat(body.not().forSome(b.oneOf(Expression.INTS)).forSome(a.oneOf(Expression.INTS)).not());
}
use of kodkod.ast.Formula 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.Formula 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.Formula 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);
}
Aggregations