From 3bd3789c2009fc9976d6b2ab5d0cb716c3d35dc3 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 19 Feb 2015 14:07:33 +0000 Subject: Teach ExprSMTLIBPrinter to use SMTLIBv2's distinct function rather than writing "(not (= a b))". This makes the code simpler and queries slightly simpler. --- lib/Expr/ExprSMTLIBPrinter.cpp | 43 +++++++----------------------------------- 1 file changed, 7 insertions(+), 36 deletions(-) (limited to 'lib/Expr') diff --git a/lib/Expr/ExprSMTLIBPrinter.cpp b/lib/Expr/ExprSMTLIBPrinter.cpp index c4a6876e..c780ae90 100644 --- a/lib/Expr/ExprSMTLIBPrinter.cpp +++ b/lib/Expr/ExprSMTLIBPrinter.cpp @@ -230,22 +230,19 @@ void ExprSMTLIBPrinter::printFullExpression( printCastExpr(cast(e)); return; - case Expr::Ne: - printNotEqualExpr(cast(e)); - return; - case Expr::Select: // the if-then-else expression. printSelectExpr(cast(e), expectedSort); return; case Expr::Eq: - /* The "=" operator is special in that it can take any sort but we must - * enforce that both arguments are the same sort. We do this in a lazy way - * by enforcing the second argument is of the same type as the first. + case Expr::Ne: + /* The "=" and distinct operators are special in that it can take any sort + * but we must enforce that both arguments are the same sort. We do this in + * a lazy way by enforcing the second argument is of the same type as the + * first. */ printSortArgsExpr(e, getSort(e->getKid(0))); - return; case Expr::And: @@ -337,32 +334,6 @@ void ExprSMTLIBPrinter::printCastExpr(const ref &e) { *p << ")"; } -void ExprSMTLIBPrinter::printNotEqualExpr(const ref &e) { - *p << "(not ("; - p->pushIndent(); - *p << "=" - << " "; - p->pushIndent(); - printSeperator(); - - /* The "=" operators allows both sorts. We assume - * that the second argument sort should be forced to be the same sort as the - * first argument - */ - SMTLIB_SORT s = getSort(e->getKid(0)); - - printExpression(e->getKid(0), s); - printSeperator(); - printExpression(e->getKid(1), s); - p->popIndent(); - printSeperator(); - - *p << ")"; - p->popIndent(); - printSeperator(); - *p << ")"; -} - const char *ExprSMTLIBPrinter::getSMTLIBKeyword(const ref &e) { switch (e->getKind()) { @@ -407,8 +378,8 @@ const char *ExprSMTLIBPrinter::getSMTLIBKeyword(const ref &e) { case Expr::Eq: return "="; - - // Not Equal does not exist directly in SMTLIBv2 + case Expr::Ne: + return "distinct"; case Expr::Ult: return "bvult"; -- cgit 1.4.1