public Expression negate() {
// Apply de Morgan's laws
if (operator == Token.AND) {
// not(A and B) ==> not(A) or not(B)
BooleanFn not0 = (BooleanFn)SystemFunction.makeSystemFunction("not", new Expression[]{operand0});
BooleanFn not1 = (BooleanFn)SystemFunction.makeSystemFunction("not", new Expression[]{operand1});
return new BooleanExpression(not0, Token.OR, not1);
} else {
// not(A or B) => not(A) and not(B)
BooleanFn not0 = (BooleanFn)SystemFunction.makeSystemFunction("not", new Expression[]{operand0});
BooleanFn not1 = (BooleanFn)SystemFunction.makeSystemFunction("not", new Expression[]{operand1});
return new BooleanExpression(not0, Token.AND, not1);
}
}