use of kodkod.engine.bool.BooleanValue in project org.alloytools.alloy by AlloyTools.
the class FOL2BoolTranslator method visit.
/**
* Calls lookup(not) and returns the cached value, if any. If a translation has
* not been cached, translates the formula, calls cache(...) on it and returns
* it.
*
* @return let t = lookup(not) | some t => t, cache(not,
* !not.formula.accept(this))
*/
@Override
public final BooleanValue visit(NotFormula not) {
BooleanValue ret = lookup(not);
if (ret != null)
return ret;
env.negate();
ret = cache(not, interpreter.factory().not(not.formula().accept(this)));
env.negate();
return ret;
}
use of kodkod.engine.bool.BooleanValue in project org.alloytools.alloy by AlloyTools.
the class BooleanCircuitTest method testMultiGateWithVariableArgument.
private final void testMultiGateWithVariableArgument(Operator.Nary op) {
// variable / variable
testIdentityContradictionExcludedMiddle(op, v[0]);
testIdentityContradictionExcludedMiddle(op, v[3]);
testCommutativityAndAssociativity(op, v[4], v[6], v[8], v[2]);
testIdempotencyAbsorptionContraction(op, v[1], v[5]);
// variable / negation
final BooleanValue v101214 = compose(op, v[10], compose(op.complement(), v[12], v[14]));
final BooleanValue v151311 = compose(op.complement(), v[15], compose(op, v[13], v[11]));
testCommutativityAndAssociativity(op, v[10], f.not(v151311), v[14], f.not(v101214));
testIdempotencyAbsorptionContraction(op, v[11], f.not(v151311));
// variable / multigate
final BooleanValue v191618 = compose(op.complement(), v[19], compose(op.complement(), v[16], v[18])), v101712 = compose(op, v[10], compose(op, v[17], v[12])), v141815 = compose(op.complement(), v[14], compose(op, v[18], v[15])), v121716 = compose(op, v[12], compose(op.complement(), v[17], v[16]));
testCommutativityAndAssociativity(op, v[10], v[12], v191618, v141815);
// fails due to not extensively checking for sharing, which is ok for
// now
// testCommutativityAndAssociativity(op, v[10], v[12], v121716,
// v101712);
testCommutativityAndAssociativity(op, v[9], v[18], v[16], v121716);
testIdempotencyAbsorptionContraction(op, v[10], v101712);
testIdempotencyAbsorptionContraction(op, v[14], v141815);
}
use of kodkod.engine.bool.BooleanValue in project org.alloytools.alloy by AlloyTools.
the class BooleanCircuitTest method testMultiGateWithMultiGateArgument.
private final void testMultiGateWithMultiGateArgument(Operator.Nary op) {
final BooleanValue v842 = compose(op.complement(), v[8], compose(op.complement(), v[4], v[2])), v191015 = compose(op, v[19], compose(op, v[10], v[15])), v027 = compose(op.complement(), v[0], compose(op, v[2], v[7])), v15104 = compose(op, v[15], compose(op.complement(), v[10], v[4]));
testIdentityContradictionExcludedMiddle(op, v027);
testIdentityContradictionExcludedMiddle(op, v191015);
testCommutativityAndAssociativity(op, v842, v191015, v027, v15104);
testCommutativityAndAssociativity(op, v842, v191015, v027, compose(op, v[18], v[1]));
testIdempotencyAbsorptionContraction(op, v842, v15104);
}
use of kodkod.engine.bool.BooleanValue in project org.alloytools.alloy by AlloyTools.
the class BooleanCircuitTest method testITE.
public final void testITE() {
final BooleanValue a12 = f.and(v[1], v[2]), na12 = f.not(a12), a45 = f.and(v[4], v[5]), o67 = f.or(v[6], v[7]), no67 = f.not(o67), o89 = f.or(v[8], v[9]), no89 = f.not(o89);
assertSame(a12, f.ite(TRUE, a12, a45));
assertSame(a45, f.ite(FALSE, a12, a45));
assertSame(f.or(o89, a12), f.ite(a12, TRUE, o89));
assertSame(f.and(o89, na12), f.ite(a12, FALSE, o89));
assertSame(f.or(no67, a45), f.ite(o67, a45, TRUE));
assertSame(f.and(no89, no67), f.ite(no89, no67, FALSE));
assertSame(o67, f.ite(o89, o67, o67));
assertSame(f.or(a12, o67), f.ite(a12, a12, o67));
assertSame(f.and(o89, na12), f.ite(a12, na12, o89));
assertSame(f.or(no67, a45), f.ite(o67, a45, no67));
assertSame(f.and(no89, no67), f.ite(no89, no67, no89));
assertSame(f.ite(f.and(v[1], v[2]), o67, a45), f.ite(a12, f.or(v[6], v[7]), a45));
}
Aggregations