}
: /* a built-in operator application */
LPAREN_TOK builtinOp[kind] termList[args,expr] RPAREN_TOK
- { if( !PARSER_STATE->strictModeEnabled() &&
+ {
+ if( kind == CVC4::kind::EQUAL &&
+ args.size() > 0 &&
+ args[0].getType() == EXPR_MANAGER->booleanType() ) {
+ /* Use IFF for boolean equalities. */
+ kind = CVC4::kind::IFF;
+ }
+
+ if( !PARSER_STATE->strictModeEnabled() &&
(kind == CVC4::kind::AND || kind == CVC4::kind::OR) &&
args.size() == 1) {
/* Unary AND/OR can be replaced with the argument.
class EqualityTypeRule {
public:
inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) throw (TypeCheckingExceptionPrivate) {
+ TypeNode booleanType = nodeManager->booleanType();
+
if( check ) {
- if (n[0].getType(check) != n[1].getType(check)) {
+ TypeNode lhsType = n[0].getType(check);
+ TypeNode rhsType = n[1].getType(check);
+
+ if ( lhsType != rhsType ) {
throw TypeCheckingExceptionPrivate(n, "Left and right hand side of the equation are not of the same type");
}
+
+ if ( lhsType == booleanType ) {
+ throw TypeCheckingExceptionPrivate(n, "equality between two boolean terms (use IFF instead)");
+ }
}
- return nodeManager->booleanType();
+ return booleanType;
}
};
return theoryOf(n.getType());
} else if(k == kind::EQUAL) {
// equality is special: use LHS
- return theoryOf(n[0].getType());
+ return theoryOf(n[0]);
} else {
// use our Kind-to-Theory mapping
return d_theoryOfTable[k];