From: Mathias Preiner Date: Wed, 30 Oct 2019 22:27:10 +0000 (-0700) Subject: Unify CVC4_CHECK/CVC4_DCHECK/AlwaysAssert/Assert. (#3366) X-Git-Tag: cvc5-1.0.0~3868 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=43ab3f4cd1aa5549cb1aa3c20a2d589614bcb8fc;p=cvc5.git Unify CVC4_CHECK/CVC4_DCHECK/AlwaysAssert/Assert. (#3366) --- diff --git a/src/api/cvc4cpp.cpp b/src/api/cvc4cpp.cpp index aed443197..3b0b16345 100644 --- a/src/api/cvc4cpp.cpp +++ b/src/api/cvc4cpp.cpp @@ -33,9 +33,8 @@ #include "api/cvc4cpp.h" +#include "base/check.h" #include "base/configuration.h" -#include "base/cvc4_assert.h" -#include "base/cvc4_check.h" #include "expr/expr.h" #include "expr/expr_manager.h" #include "expr/expr_manager_scope.h" diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt index 8df40a6ff..000aa331c 100644 --- a/src/base/CMakeLists.txt +++ b/src/base/CMakeLists.txt @@ -10,13 +10,11 @@ add_custom_target(gen-gitinfo #-----------------------------------------------------------------------------# libcvc4_add_sources( + check.cpp + check.h configuration.cpp configuration.h configuration_private.h - cvc4_assert.cpp - cvc4_assert.h - cvc4_check.cpp - cvc4_check.h exception.cpp exception.h listener.cpp diff --git a/src/base/check.cpp b/src/base/check.cpp new file mode 100644 index 000000000..10ecad191 --- /dev/null +++ b/src/base/check.cpp @@ -0,0 +1,212 @@ +/********************* */ +/*! \file check.cpp + ** \verbatim + ** Top contributors (to current version): + ** Tim King + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS + ** in the top-level source directory) and their institutional affiliations. + ** All rights reserved. See the file COPYING in the top-level source + ** directory for licensing information.\endverbatim + ** + ** \brief Assertion utility classes, functions and macros. + ** + ** Implementation of assertion utility classes, functions and macros. + **/ + +#include "base/check.h" + +#include +#include + +namespace CVC4 { + +FatalStream::FatalStream(const char* function, const char* file, int line) +{ + stream() << "Fatal failure within " << function << " at " << file << ":" + << line << "\n"; +} + +FatalStream::~FatalStream() +{ + Flush(); + abort(); +} + +std::ostream& FatalStream::stream() { return std::cerr; } + +void FatalStream::Flush() +{ + stream() << std::endl; + stream().flush(); +} + +void AssertArgumentException::construct(const char* header, + const char* extra, + const char* function, + const char* file, + unsigned line, + const char* fmt, + va_list args) +{ + // try building the exception msg with a smallish buffer first, + // then with a larger one if sprintf tells us to. + int n = 512; + char* buf; + buf = new char[n]; + + for (;;) + { + int size; + if (extra == NULL) + { + size = snprintf(buf, n, "%s\n%s\n%s:%d\n", header, function, file, line); + } + else + { + size = snprintf(buf, + n, + "%s\n%s\n%s:%d:\n\n %s\n", + header, + function, + file, + line, + extra); + } + + if (size < n) + { + va_list args_copy; + va_copy(args_copy, args); + size += vsnprintf(buf + size, n - size, fmt, args_copy); + va_end(args_copy); + + if (size < n) + { + break; + } + } + + if (size >= n) + { + // try again with a buffer that's large enough + n = size + 1; + delete[] buf; + buf = new char[n]; + } + } + + setMessage(std::string(buf)); + +#ifdef CVC4_DEBUG + LastExceptionBuffer* buffer = LastExceptionBuffer::getCurrent(); + if (buffer != NULL) + { + if (buffer->getContents() == NULL) + { + buffer->setContents(buf); + } + } +#endif /* CVC4_DEBUG */ + delete[] buf; +} + +void AssertArgumentException::construct(const char* header, + const char* extra, + const char* function, + const char* file, + unsigned line) +{ + // try building the exception msg with a smallish buffer first, + // then with a larger one if sprintf tells us to. + int n = 256; + char* buf; + + for (;;) + { + buf = new char[n]; + + int size; + if (extra == NULL) + { + size = snprintf(buf, n, "%s.\n%s\n%s:%d\n", header, function, file, line); + } + else + { + size = snprintf(buf, + n, + "%s.\n%s\n%s:%d:\n\n %s\n", + header, + function, + file, + line, + extra); + } + + if (size < n) + { + break; + } + else + { + // try again with a buffer that's large enough + n = size + 1; + delete[] buf; + } + } + + setMessage(std::string(buf)); + +#ifdef CVC4_DEBUG + LastExceptionBuffer* buffer = LastExceptionBuffer::getCurrent(); + if (buffer != NULL) + { + if (buffer->getContents() == NULL) + { + buffer->setContents(buf); + } + } +#endif /* CVC4_DEBUG */ + delete[] buf; +} + +AssertArgumentException::AssertArgumentException(const char* condStr, + const char* argDesc, + const char* function, + const char* file, + unsigned line, + const char* fmt, + ...) + : Exception() +{ + va_list args; + va_start(args, fmt); + construct("Illegal argument detected", + (std::string("`") + argDesc + "' is a bad argument; expected " + + condStr + " to hold") + .c_str(), + function, + file, + line, + fmt, + args); + va_end(args); +} + +AssertArgumentException::AssertArgumentException(const char* condStr, + const char* argDesc, + const char* function, + const char* file, + unsigned line) + : Exception() +{ + construct("Illegal argument detected", + (std::string("`") + argDesc + "' is a bad argument; expected " + + condStr + " to hold") + .c_str(), + function, + file, + line); +} + +} // namespace CVC4 diff --git a/src/base/check.h b/src/base/check.h new file mode 100644 index 000000000..915f6e4cb --- /dev/null +++ b/src/base/check.h @@ -0,0 +1,240 @@ +/********************* */ +/*! \file check.h + ** \verbatim + ** Top contributors (to current version): + ** Tim King + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS + ** in the top-level source directory) and their institutional affiliations. + ** All rights reserved. See the file COPYING in the top-level source + ** directory for licensing information.\endverbatim + ** + ** \brief Assertion utility classes, functions and macros. + ** + ** The AlwaysAssert utility classes, functions and macros. + ** + ** The main usage in the file is the AlwaysAssert macros. The AlwaysAssert + ** macros assert a condition and aborts()'s the process if the condition is + ** not satisfied. The macro leaves a hanging ostream for the user to specify + ** additional information about the failure. Example usage: + ** AlwaysAssert(x >= 0) << "x must be positive."; + ** + ** Assert is a AlwaysAssert that is only enabled in debug builds. + ** Assert(pointer != nullptr); + ** + ** CVC4_FATAL() can be used to indicate unreachable code. + ** + ** The AlwaysAssert and Assert macros are not safe for use in + ** signal-handling code. In future, a a signal-handling safe version of + ** AlwaysAssert may be added. + **/ + +#include "cvc4_private.h" + +#ifndef CVC4__CHECK_H +#define CVC4__CHECK_H + +#include +#include + +#include "base/exception.h" + +// Define CVC4_NO_RETURN macro replacement for [[noreturn]]. +#if defined(SWIG) +#define CVC4_NO_RETURN +// SWIG does not yet support [[noreturn]] so emit nothing instead. +#else +#define CVC4_NO_RETURN [[noreturn]] +// Not checking for whether the compiler supports [[noreturn]] using +// __has_cpp_attribute as GCC 4.8 is too widespread and does not support this. +// We instead assume this is C++11 (or later) and [[noreturn]] is available. +#endif // defined(SWIG) + +// Define CVC4_PREDICT_FALSE(x) that helps the compiler predict that x will be +// false (if there is compiler support). +#ifdef __has_builtin +#if __has_builtin(__builtin_expect) +#define CVC4_PREDICT_FALSE(x) (__builtin_expect(x, false)) +#define CVC4_PREDICT_TRUE(x) (__builtin_expect(x, true)) +#else +#define CVC4_PREDICT_FALSE(x) x +#define CVC4_PREDICT_TRUE(x) x +#endif +#else +#define CVC4_PREDICT_FALSE(x) x +#define CVC4_PREDICT_TRUE(x) x +#endif + +namespace CVC4 { + +// Implementation notes: +// To understand FatalStream and OStreamVoider, it is useful to understand +// how a AlwaysAssert is structured. AlwaysAssert(cond) is roughly the following +// pattern: +// cond ? (void)0 : OstreamVoider() & FatalStream().stream() +// This is a carefully crafted message to achieve a hanging ostream using +// operator precedence. The line `AlwaysAssert(cond) << foo << bar;` will bind +// as follows: +// `cond ? ((void)0) : (OSV() & ((FS().stream() << foo) << bar));` +// Once the expression is evaluated, the destructor ~FatalStream() of the +// temporary object is then run, which abort()'s the process. The role of the +// OStreamVoider() is to match the void type of the true branch. + +// Class that provides an ostream and whose destructor aborts! Direct usage of +// this class is discouraged. +class FatalStream +{ + public: + FatalStream(const char* function, const char* file, int line); + CVC4_NO_RETURN ~FatalStream(); + + std::ostream& stream(); + + private: + void Flush(); +}; + +// Helper class that changes the type of an std::ostream& into a void. See +// "Implementation notes" for more information. +class OstreamVoider +{ + public: + OstreamVoider() {} + // The operator precedence between operator& and operator<< is critical here. + void operator&(std::ostream&) {} +}; + +// CVC4_FATAL() always aborts a function and provides a convenient way of +// formatting error messages. This can be used instead of a return type. +// +// Example function that returns a type Foo: +// Foo bar(T t) { +// switch(t.type()) { +// ... +// default: +// CVC4_FATAL() << "Unknown T type " << t.enum(); +// } +// } +#define CVC4_FATAL() \ + FatalStream(__PRETTY_FUNCTION__, __FILE__, __LINE__).stream() + +/* GCC <= 9.2 ignores CVC4_NO_RETURN of ~FatalStream() if + * used in template classes (e.g., CDHashMap::save()). As a workaround we + * explicitly call abort() to let the compiler know that the + * corresponding function call will not return. */ +#define SuppressWrongNoReturnWarning abort() + +// If `cond` is true, log an error message and abort the process. +// Otherwise, does nothing. This leaves a hanging std::ostream& that can be +// inserted into. +#define CVC4_FATAL_IF(cond, function, file, line) \ + CVC4_PREDICT_FALSE(!(cond)) \ + ? (void)0 : OstreamVoider() & FatalStream(function, file, line).stream() + +// If `cond` is false, log an error message and abort()'s the process. +// Otherwise, does nothing. This leaves a hanging std::ostream& that can be +// inserted into using operator<<. Example usages: +// AlwaysAssert(x >= 0); +// AlwaysAssert(x >= 0) << "x must be positive"; +// AlwaysAssert(x >= 0) << "expected a positive value. Got " << x << " +// instead"; +#define AlwaysAssert(cond) \ + CVC4_FATAL_IF(!(cond), __PRETTY_FUNCTION__, __FILE__, __LINE__) \ + << "Check failure\n\n " << #cond << "\n" + +// Assert is a variant of AlwaysAssert() that is only checked when +// CVC4_ASSERTIONS is defined. We rely on the optimizer to remove the deadcode. +#ifdef CVC4_ASSERTIONS +#define Assert(cond) AlwaysAssert(cond) +#else +#define Assert(cond) \ + CVC4_FATAL_IF(false, __PRETTY_FUNCTION__, __FILE__, __LINE__) +#endif /* CVC4_DEBUG */ + +class AssertArgumentException : public Exception +{ + protected: + AssertArgumentException() : Exception() {} + + void construct(const char* header, + const char* extra, + const char* function, + const char* file, + unsigned line, + const char* fmt, + va_list args); + + void construct(const char* header, + const char* extra, + const char* function, + const char* file, + unsigned line); + + public: + AssertArgumentException(const char* condStr, + const char* argDesc, + const char* function, + const char* file, + unsigned line, + const char* fmt, + ...); + + AssertArgumentException(const char* condStr, + const char* argDesc, + const char* function, + const char* file, + unsigned line); + +}; /* class AssertArgumentException */ + +#define Unreachable() CVC4_FATAL() << "Unreachable code reached" + +#define Unhandled() CVC4_FATAL() << "Unhandled case encountered" + +#define Unimplemented() CVC4_FATAL() << "Unimplemented code encountered" + +#define InternalError() CVC4_FATAL() << "Internal error detected" + +#define IllegalArgument(arg, msg...) \ + throw ::CVC4::IllegalArgumentException( \ + "", \ + #arg, \ + __PRETTY_FUNCTION__, \ + ::CVC4::IllegalArgumentException::formatVariadic(msg).c_str()); +// This cannot use check argument directly as this forces +// CheckArgument to use a va_list. This is unsupported in Swig. +#define PrettyCheckArgument(cond, arg, msg...) \ + do \ + { \ + if (__builtin_expect((!(cond)), false)) \ + { \ + throw ::CVC4::IllegalArgumentException( \ + #cond, \ + #arg, \ + __PRETTY_FUNCTION__, \ + ::CVC4::IllegalArgumentException::formatVariadic(msg).c_str()); \ + } \ + } while (0) +#define AlwaysAssertArgument(cond, arg, msg...) \ + do \ + { \ + if (__builtin_expect((!(cond)), false)) \ + { \ + throw ::CVC4::AssertArgumentException( \ + #cond, #arg, __PRETTY_FUNCTION__, __FILE__, __LINE__, ##msg); \ + } \ + } while (0) + +#ifdef CVC4_ASSERTIONS +#define AssertArgument(cond, arg, msg...) AlwaysAssertArgument(cond, arg, ##msg) +#define DebugCheckArgument(cond, arg, msg...) CheckArgument(cond, arg, ##msg) +#else /* ! CVC4_ASSERTIONS */ +#define AssertArgument(cond, arg, msg...) /*__builtin_expect( ( cond ), true \ + )*/ +#define DebugCheckArgument( \ + cond, arg, msg...) /*__builtin_expect( ( cond ), true )*/ +#endif /* CVC4_ASSERTIONS */ + +} // namespace CVC4 + +#endif /* CVC4__CHECK_H */ diff --git a/src/base/cvc4_assert.cpp b/src/base/cvc4_assert.cpp deleted file mode 100644 index 1150f41f1..000000000 --- a/src/base/cvc4_assert.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/********************* */ -/*! \file cvc4_assert.cpp - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters, Tim King, Chad Brewbaker - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Assertion utility classes, functions, and exceptions. - ** - ** Assertion utility classes, functions, and exceptions. Implementation. - **/ - -#include -#include -#include - -#include "base/cvc4_assert.h" -#include "base/output.h" - -using namespace std; - -namespace CVC4 { - -#ifdef CVC4_DEBUG -//thread_local const char* s_debugLastException = NULL; -#endif /* CVC4_DEBUG */ - - -void AssertionException::construct(const char* header, const char* extra, - const char* function, const char* file, - unsigned line, const char* fmt, - va_list args) { - // try building the exception msg with a smallish buffer first, - // then with a larger one if sprintf tells us to. - int n = 512; - char* buf; - buf = new char[n]; - - for(;;) { - - int size; - if(extra == NULL) { - size = snprintf(buf, n, "%s\n%s\n%s:%d\n", - header, function, file, line); - } else { - size = snprintf(buf, n, "%s\n%s\n%s:%d:\n\n %s\n", - header, function, file, line, extra); - } - - if(size < n) { - va_list args_copy; - va_copy(args_copy, args); - size += vsnprintf(buf + size, n - size, fmt, args_copy); - va_end(args_copy); - - if(size < n) { - break; - } - } - - if(size >= n) { - // try again with a buffer that's large enough - n = size + 1; - delete [] buf; - buf = new char[n]; - } - } - - setMessage(string(buf)); - -#ifdef CVC4_DEBUG - LastExceptionBuffer* buffer = LastExceptionBuffer::getCurrent(); - if(buffer != NULL){ - if(buffer->getContents() == NULL) { - buffer->setContents(buf); - } - } -#endif /* CVC4_DEBUG */ - delete [] buf; -} - -void AssertionException::construct(const char* header, const char* extra, - const char* function, const char* file, - unsigned line) { - // try building the exception msg with a smallish buffer first, - // then with a larger one if sprintf tells us to. - int n = 256; - char* buf; - - for(;;) { - buf = new char[n]; - - int size; - if(extra == NULL) { - size = snprintf(buf, n, "%s.\n%s\n%s:%d\n", - header, function, file, line); - } else { - size = snprintf(buf, n, "%s.\n%s\n%s:%d:\n\n %s\n", - header, function, file, line, extra); - } - - if(size < n) { - break; - } else { - // try again with a buffer that's large enough - n = size + 1; - delete [] buf; - } - } - - setMessage(string(buf)); - - -#ifdef CVC4_DEBUG - LastExceptionBuffer* buffer = LastExceptionBuffer::getCurrent(); - if(buffer != NULL){ - if(buffer->getContents() == NULL) { - buffer->setContents(buf); - } - } -#endif /* CVC4_DEBUG */ - delete [] buf; -} - -#ifdef CVC4_DEBUG - -/** - * Special assertion failure handling in debug mode; in non-debug - * builds, the exception is thrown from the macro. We factor out this - * additional logic so as not to bloat the code at every Assert() - * expansion. - * - * Note this name is prefixed with "debug" because it is included in - * debug builds only; in debug builds, it handles all assertion - * failures (even those that exist in non-debug builds). - */ -void debugAssertionFailed(const AssertionException& thisException, - const char* propagatingException) { - static thread_local bool alreadyFired = false; - - if(__builtin_expect( ( !std::uncaught_exception() ), true ) || alreadyFired) { - throw thisException; - } - - alreadyFired = true; - - // propagatingException is the propagating exception, but can be - // NULL if the propagating exception is not a CVC4::Exception. - Warning() << "===========================================" << std::endl - << "An assertion failed during stack unwinding:" << std::endl; - if(propagatingException != NULL) { - Warning() << "The propagating exception is:" << std::endl - << propagatingException << std::endl - << "===========================================" << std::endl; - Warning() << "The newly-thrown exception is:" << std::endl; - } else { - Warning() << "The propagating exception is unknown." << std::endl; - } - Warning() << thisException << std::endl - << "===========================================" << std::endl; - - terminate(); -} - -#endif /* CVC4_DEBUG */ - -}/* CVC4 namespace */ diff --git a/src/base/cvc4_assert.h b/src/base/cvc4_assert.h deleted file mode 100644 index a29e6f545..000000000 --- a/src/base/cvc4_assert.h +++ /dev/null @@ -1,320 +0,0 @@ -/********************* */ -/*! \file cvc4_assert.h - ** \verbatim - ** Top contributors (to current version): - ** Morgan Deters, Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Assertion utility classes, functions, exceptions, and macros. - ** - ** Assertion utility classes, functions, exceptions, and macros. - **/ - -#include "cvc4_private.h" - -#ifndef CVC4__ASSERT_H -#define CVC4__ASSERT_H - -#include -#include -#include -#include -#include - -#include "base/exception.h" - -// output.h not strictly needed for this header, but it _is_ needed to -// actually _use_ anything in this header, so let's include it. -// Tim : Disabling this and moving it into cvc4_assert.cpp -//#include "util/output.h" - -namespace CVC4 { - -class AssertionException : public Exception { - protected: - void construct(const char* header, const char* extra, const char* function, - const char* file, unsigned line, const char* fmt, ...) { - va_list args; - va_start(args, fmt); - construct(header, extra, function, file, line, fmt, args); - va_end(args); - } - - void construct(const char* header, const char* extra, const char* function, - const char* file, unsigned line, const char* fmt, - va_list args); - - void construct(const char* header, const char* extra, const char* function, - const char* file, unsigned line); - - AssertionException() : Exception() {} - - public: - AssertionException(const char* extra, const char* function, const char* file, - unsigned line, const char* fmt, ...) - : Exception() { - va_list args; - va_start(args, fmt); - construct("Assertion failure", extra, function, file, line, fmt, args); - va_end(args); - } - - AssertionException(const char* extra, const char* function, const char* file, - unsigned line) - : Exception() { - construct("Assertion failure", extra, function, file, line); - } -}; /* class AssertionException */ - -class UnreachableCodeException : public AssertionException { - protected: - UnreachableCodeException() : AssertionException() {} - - public: - UnreachableCodeException(const char* function, const char* file, - unsigned line, const char* fmt, ...) - : AssertionException() { - va_list args; - va_start(args, fmt); - construct("Unreachable code reached", NULL, function, file, line, fmt, - args); - va_end(args); - } - - UnreachableCodeException(const char* function, const char* file, - unsigned line) - : AssertionException() { - construct("Unreachable code reached", NULL, function, file, line); - } -}; /* class UnreachableCodeException */ - -class UnhandledCaseException : public UnreachableCodeException { - protected: - UnhandledCaseException() : UnreachableCodeException() {} - - public: - UnhandledCaseException(const char* function, const char* file, unsigned line, - const char* fmt, ...) - : UnreachableCodeException() { - va_list args; - va_start(args, fmt); - construct("Unhandled case encountered", NULL, function, file, line, fmt, - args); - va_end(args); - } - - template - UnhandledCaseException(const char* function, const char* file, unsigned line, - T theCase) - : UnreachableCodeException() { - std::stringstream sb; - sb << theCase; - construct("Unhandled case encountered", NULL, function, file, line, - "The case was: %s", sb.str().c_str()); - } - - UnhandledCaseException(const char* function, const char* file, unsigned line) - : UnreachableCodeException() { - construct("Unhandled case encountered", NULL, function, file, line); - } -}; /* class UnhandledCaseException */ - -class UnimplementedOperationException : public AssertionException { - protected: - UnimplementedOperationException() : AssertionException() {} - - public: - UnimplementedOperationException(const char* function, const char* file, - unsigned line, const char* fmt, ...) - : AssertionException() { - va_list args; - va_start(args, fmt); - construct("Unimplemented code encountered", NULL, function, file, line, fmt, - args); - va_end(args); - } - - UnimplementedOperationException(const char* function, const char* file, - unsigned line) - : AssertionException() { - construct("Unimplemented code encountered", NULL, function, file, line); - } -}; /* class UnimplementedOperationException */ - -class AssertArgumentException : public AssertionException { - protected: - AssertArgumentException() : AssertionException() {} - - public: - AssertArgumentException(const char* argDesc, const char* function, - const char* file, unsigned line, const char* fmt, ...) - : AssertionException() { - va_list args; - va_start(args, fmt); - construct("Illegal argument detected", - (std::string("`") + argDesc + "' is a bad argument").c_str(), - function, file, line, fmt, args); - va_end(args); - } - - AssertArgumentException(const char* argDesc, const char* function, - const char* file, unsigned line) - : AssertionException() { - construct("Illegal argument detected", - (std::string("`") + argDesc + "' is a bad argument").c_str(), - function, file, line); - } - - AssertArgumentException(const char* condStr, const char* argDesc, - const char* function, const char* file, unsigned line, - const char* fmt, ...) - : AssertionException() { - va_list args; - va_start(args, fmt); - construct("Illegal argument detected", - (std::string("`") + argDesc + "' is a bad argument; expected " + - condStr + " to hold") - .c_str(), - function, file, line, fmt, args); - va_end(args); - } - - AssertArgumentException(const char* condStr, const char* argDesc, - const char* function, const char* file, unsigned line) - : AssertionException() { - construct("Illegal argument detected", - (std::string("`") + argDesc + "' is a bad argument; expected " + - condStr + " to hold") - .c_str(), - function, file, line); - } -}; /* class AssertArgumentException */ - -class InternalErrorException : public AssertionException { - protected: - InternalErrorException() : AssertionException() {} - - public: - InternalErrorException(const char* function, const char* file, unsigned line) - : AssertionException() { - construct("Internal error detected", "", function, file, line); - } - - InternalErrorException(const char* function, const char* file, unsigned line, - const char* fmt, ...) - : AssertionException() { - va_list args; - va_start(args, fmt); - construct("Internal error detected", "", function, file, line, fmt, args); - va_end(args); - } - - InternalErrorException(const char* function, const char* file, unsigned line, - std::string fmt, ...) - : AssertionException() { - va_list args; - va_start(args, fmt); - construct("Internal error detected", "", function, file, line, fmt.c_str(), - args); - va_end(args); - } - -}; /* class InternalErrorException */ - -#ifdef CVC4_DEBUG - -/** - * Special assertion failure handling in debug mode; in non-debug - * builds, the exception is thrown from the macro. We factor out this - * additional logic so as not to bloat the code at every Assert() - * expansion. - * - * Note this name is prefixed with "debug" because it is included in - * debug builds only; in debug builds, it handles all assertion - * failures (even those that exist in non-debug builds). - */ -void debugAssertionFailed(const AssertionException& thisException, - const char* lastException); - -// If we're currently handling an exception, print a warning instead; -// otherwise std::terminate() is called by the runtime and we lose -// details of the exception -#define AlwaysAssert(cond, msg...) \ - do { \ - if (__builtin_expect((!(cond)), false)) { \ - /* save the last assertion failure */ \ - ::CVC4::LastExceptionBuffer* buffer = \ - ::CVC4::LastExceptionBuffer::getCurrent(); \ - const char* lastException = \ - (buffer == NULL) ? NULL : buffer->getContents(); \ - ::CVC4::AssertionException exception(#cond, __PRETTY_FUNCTION__, \ - __FILE__, __LINE__, ##msg); \ - ::CVC4::debugAssertionFailed(exception, lastException); \ - } \ - } while (0) - -#else /* CVC4_DEBUG */ -// These simpler (but less useful) versions for non-debug builds fails -// will terminate() if thrown during stack unwinding. -#define AlwaysAssert(cond, msg...) \ - do { \ - if (__builtin_expect((!(cond)), false)) { \ - throw ::CVC4::AssertionException(#cond, __PRETTY_FUNCTION__, __FILE__, \ - __LINE__, ##msg); \ - } \ - } while (0) -#endif /* CVC4_DEBUG */ - -#define Unreachable(msg...) \ - throw ::CVC4::UnreachableCodeException(__PRETTY_FUNCTION__, __FILE__, \ - __LINE__, ##msg) -#define Unhandled(msg...) \ - throw ::CVC4::UnhandledCaseException(__PRETTY_FUNCTION__, __FILE__, \ - __LINE__, ##msg) -#define Unimplemented(msg...) \ - throw ::CVC4::UnimplementedOperationException(__PRETTY_FUNCTION__, __FILE__, \ - __LINE__, ##msg) -#define InternalError(msg...) \ - throw ::CVC4::InternalErrorException(__PRETTY_FUNCTION__, __FILE__, \ - __LINE__, ##msg) -#define IllegalArgument(arg, msg...) \ - throw ::CVC4::IllegalArgumentException( \ - "", #arg, __PRETTY_FUNCTION__, \ - ::CVC4::IllegalArgumentException::formatVariadic(msg).c_str()); -// This cannot use check argument directly as this forces -// CheckArgument to use a va_list. This is unsupported in Swig. -#define PrettyCheckArgument(cond, arg, msg...) \ - do { \ - if (__builtin_expect((!(cond)), false)) { \ - throw ::CVC4::IllegalArgumentException( \ - #cond, #arg, __PRETTY_FUNCTION__, \ - ::CVC4::IllegalArgumentException::formatVariadic(msg).c_str()); \ - } \ - } while (0) -#define AlwaysAssertArgument(cond, arg, msg...) \ - do { \ - if (__builtin_expect((!(cond)), false)) { \ - throw ::CVC4::AssertArgumentException(#cond, #arg, __PRETTY_FUNCTION__, \ - __FILE__, __LINE__, ##msg); \ - } \ - } while (0) - -#ifdef CVC4_ASSERTIONS -#define Assert(cond, msg...) AlwaysAssert(cond, ##msg) -#define AssertArgument(cond, arg, msg...) AlwaysAssertArgument(cond, arg, ##msg) -#define DebugCheckArgument(cond, arg, msg...) CheckArgument(cond, arg, ##msg) -#else /* ! CVC4_ASSERTIONS */ -#define Assert(cond, msg...) /*__builtin_expect( ( cond ), true )*/ -#define AssertArgument(cond, arg, msg...) /*__builtin_expect( ( cond ), true \ - )*/ -#define DebugCheckArgument(cond, arg, \ - msg...) /*__builtin_expect( ( cond ), true )*/ -#endif /* CVC4_ASSERTIONS */ - -} /* CVC4 namespace */ - -#endif /* CVC4__ASSERT_H */ diff --git a/src/base/cvc4_check.cpp b/src/base/cvc4_check.cpp deleted file mode 100644 index f0b602849..000000000 --- a/src/base/cvc4_check.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/********************* */ -/*! \file cvc4_check.cpp - ** \verbatim - ** Top contributors (to current version): - ** Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Assertion utility classes, functions and macros. - ** - ** Implementation of assertion utility classes, functions and macros. - **/ - -#include "base/cvc4_check.h" - -#include -#include - -namespace CVC4 { - -FatalStream::FatalStream(const char* function, const char* file, int line) -{ - stream() << "Fatal failure within " << function << " at " << file << ":" - << line << "\n"; -} - -FatalStream::~FatalStream() -{ - Flush(); - abort(); -} - -std::ostream& FatalStream::stream() { return std::cerr; } - -void FatalStream::Flush() -{ - stream() << std::endl; - stream().flush(); -} - -} // namespace CVC4 diff --git a/src/base/cvc4_check.h b/src/base/cvc4_check.h deleted file mode 100644 index b18e62303..000000000 --- a/src/base/cvc4_check.h +++ /dev/null @@ -1,149 +0,0 @@ -/********************* */ -/*! \file cvc4_check.h - ** \verbatim - ** Top contributors (to current version): - ** Tim King - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Assertion utility classes, functions and macros. - ** - ** The CVC4_CHECK utility classes, functions and macros are related to the - ** Assert() macros defined in base/cvc4_assert.h. The major distinguishing - ** attribute is the CVC4_CHECK's abort() the process on failures while - ** Assert() statements throw C++ exceptions. - ** - ** The main usage in the file is the CVC4_CHECK macros. The CVC4_CHECK macros - ** assert a condition and aborts()'s the process if the condition is not - ** satisfied. The macro leaves a hanging ostream for the user to specify - ** additional information about the failure. Example usage: - ** CVC4_CHECK(x >= 0) << "x must be positive."; - ** - ** CVC4_DCHECK is a CVC4_CHECK that is only enabled in debug builds. - ** CVC4_DCHECK(pointer != nullptr); - ** - ** CVC4_FATAL() can be used to indicate unreachable code. - ** - ** The CVC4_CHECK and CVC4_DCHECK macros are not safe for use in - ** signal-handling code. In future, a a signal-handling safe version of - ** CVC4_CHECK may be added. - **/ - -#include "cvc4_private.h" - -#ifndef CVC4__CHECK_H -#define CVC4__CHECK_H - -#include - -// Define CVC4_NO_RETURN macro replacement for [[noreturn]]. -#if defined(SWIG) -#define CVC4_NO_RETURN -// SWIG does not yet support [[noreturn]] so emit nothing instead. -#else -#define CVC4_NO_RETURN [[noreturn]] -// Not checking for whether the compiler supports [[noreturn]] using -// __has_cpp_attribute as GCC 4.8 is too widespread and does not support this. -// We instead assume this is C++11 (or later) and [[noreturn]] is available. -#endif // defined(SWIG) - -// Define CVC4_PREDICT_FALSE(x) that helps the compiler predict that x will be -// false (if there is compiler support). -#ifdef __has_builtin -#if __has_builtin(__builtin_expect) -#define CVC4_PREDICT_FALSE(x) (__builtin_expect(x, false)) -#define CVC4_PREDICT_TRUE(x) (__builtin_expect(x, true)) -#else -#define CVC4_PREDICT_FALSE(x) x -#define CVC4_PREDICT_TRUE(x) x -#endif -#else -#define CVC4_PREDICT_FALSE(x) x -#define CVC4_PREDICT_TRUE(x) x -#endif - -namespace CVC4 { - -// Implementation notes: -// To understand FatalStream and OStreamVoider, it is useful to understand -// how a CVC4_CHECK is structured. CVC4_CHECK(cond) is roughly the following -// pattern: -// cond ? (void)0 : OstreamVoider() & FatalStream().stream() -// This is a carefully crafted message to achieve a hanging ostream using -// operator precedence. The line `CVC4_CHECK(cond) << foo << bar;` will bind as -// follows: -// `cond ? ((void)0) : (OSV() & ((FS().stream() << foo) << bar));` -// Once the expression is evaluated, the destructor ~FatalStream() of the -// temporary object is then run, which abort()'s the process. The role of the -// OStreamVoider() is to match the void type of the true branch. - -// Class that provides an ostream and whose destructor aborts! Direct usage of -// this class is discouraged. -class FatalStream -{ - public: - FatalStream(const char* function, const char* file, int line); - CVC4_NO_RETURN ~FatalStream(); - - std::ostream& stream(); - - private: - void Flush(); -}; - -// Helper class that changes the type of an std::ostream& into a void. See -// "Implementation notes" for more information. -class OstreamVoider -{ - public: - OstreamVoider() {} - // The operator precedence between operator& and operator<< is critical here. - void operator&(std::ostream&) {} -}; - -// CVC4_FATAL() always aborts a function and provides a convenient way of -// formatting error messages. This can be used instead of a return type. -// -// Example function that returns a type Foo: -// Foo bar(T t) { -// switch(t.type()) { -// ... -// default: -// CVC4_FATAL() << "Unknown T type " << t.enum(); -// } -// } -#define CVC4_FATAL() \ - FatalStream(__PRETTY_FUNCTION__, __FILE__, __LINE__).stream() - -// If `cond` is true, log an error message and abort the process. -// Otherwise, does nothing. This leaves a hanging std::ostream& that can be -// inserted into. -#define CVC4_FATAL_IF(cond, function, file, line) \ - CVC4_PREDICT_FALSE(!(cond)) \ - ? (void)0 : OstreamVoider() & FatalStream(function, file, line).stream() - -// If `cond` is false, log an error message and abort()'s the process. -// Otherwise, does nothing. This leaves a hanging std::ostream& that can be -// inserted into using operator<<. Example usages: -// CVC4_CHECK(x >= 0); -// CVC4_CHECK(x >= 0) << "x must be positive"; -// CVC4_CHECK(x >= 0) << "expected a positive value. Got " << x << " instead"; -#define CVC4_CHECK(cond) \ - CVC4_FATAL_IF(!(cond), __PRETTY_FUNCTION__, __FILE__, __LINE__) \ - << "Check failure\n\n " << #cond << "\n" - -// CVC4_DCHECK is a variant of CVC4_CHECK() that is only checked when -// CVC4_ASSERTIONS is defined. We rely on the optimizer to remove the deadcode. -#ifdef CVC4_ASSERTIONS -#define CVC4_DCHECK(cond) CVC4_CHECK(cond) -#else -#define CVC4_DCHECK(cond) \ - CVC4_FATAL_IF(false, __PRETTY_FUNCTION__, __FILE__, __LINE__) -#endif /* CVC4_DEBUG */ - -} // namespace CVC4 - -#endif /* CVC4__CHECK_H */ diff --git a/src/base/exception.cpp b/src/base/exception.cpp index 44d9b10bc..cd10f9eb8 100644 --- a/src/base/exception.cpp +++ b/src/base/exception.cpp @@ -22,7 +22,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" using namespace std; diff --git a/src/base/listener.cpp b/src/base/listener.cpp index 44e5563e7..4a59058e6 100644 --- a/src/base/listener.cpp +++ b/src/base/listener.cpp @@ -18,7 +18,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" namespace CVC4 { diff --git a/src/base/map_util.h b/src/base/map_util.h index 786e22ae0..67f369ce7 100644 --- a/src/base/map_util.h +++ b/src/base/map_util.h @@ -38,7 +38,7 @@ #ifndef CVC4__BASE__MAP_UTIL_H #define CVC4__BASE__MAP_UTIL_H -#include "base/cvc4_check.h" +#include "base/check.h" namespace CVC4 { @@ -88,7 +88,7 @@ template const MapMappedTypeT& FindOrDie(const M& map, const MapKeyTypeT& key) { auto it = map.find(key); - CVC4_CHECK(it != map.end()) << "The map does not contain the key."; + AlwaysAssert(it != map.end()) << "The map does not contain the key."; return (*it).second; } diff --git a/src/context/backtrackable.h b/src/context/backtrackable.h index 5d358941f..85281e7fa 100644 --- a/src/context/backtrackable.h +++ b/src/context/backtrackable.h @@ -160,7 +160,7 @@ template void List::concat (List* other) { bck->checkConsistency(); bck->notifyConcat(this, other); - Assert(tail->next==NULL); + Assert(tail->next == NULL); tail->next = other->head; Assert(other->ptr_to_head == NULL); other->ptr_to_head = tail; diff --git a/src/context/cdhashmap.h b/src/context/cdhashmap.h index 05d68ead5..fc42c0e85 100644 --- a/src/context/cdhashmap.h +++ b/src/context/cdhashmap.h @@ -88,9 +88,9 @@ #include #include -#include "base/cvc4_assert.h" -#include "context/context.h" +#include "base/check.h" #include "context/cdhashmap_forward.h" +#include "context/context.h" namespace CVC4 { namespace context { @@ -278,7 +278,11 @@ class CDHashMap : public ContextObj { Context* d_context; // Nothing to save; the elements take care of themselves - ContextObj* save(ContextMemoryManager* pCMM) override { Unreachable(); } + ContextObj* save(ContextMemoryManager* pCMM) override + { + Unreachable(); + SuppressWrongNoReturnWarning; + } // Similarly, nothing to restore void restore(ContextObj* data) override { Unreachable(); } diff --git a/src/context/cdhashset.h b/src/context/cdhashset.h index a35ecae88..57cd101a9 100644 --- a/src/context/cdhashset.h +++ b/src/context/cdhashset.h @@ -19,10 +19,9 @@ #ifndef CVC4__CONTEXT__CDHASHSET_H #define CVC4__CONTEXT__CDHASHSET_H -#include "base/cvc4_assert.h" -#include "context/context.h" +#include "base/check.h" #include "context/cdinsert_hashmap.h" - +#include "context/context.h" namespace CVC4 { namespace context { @@ -51,7 +50,7 @@ public: } static void operator delete(void* pMem) { - AlwaysAssert(false, "It is not allowed to delete a ContextObj this way!"); + AlwaysAssert(false) << "It is not allowed to delete a ContextObj this way!"; } CDHashSet(Context* context) : diff --git a/src/context/cdinsert_hashmap.h b/src/context/cdinsert_hashmap.h index f15c418eb..0b3c713d2 100644 --- a/src/context/cdinsert_hashmap.h +++ b/src/context/cdinsert_hashmap.h @@ -38,13 +38,12 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" -#include "context/context.h" #include "context/cdinsert_hashmap_forward.h" +#include "context/context.h" #include "expr/node.h" - #pragma once namespace CVC4 { diff --git a/src/context/cdlist.h b/src/context/cdlist.h index dda88a0fd..95501df8e 100644 --- a/src/context/cdlist.h +++ b/src/context/cdlist.h @@ -25,10 +25,10 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" +#include "context/cdlist_forward.h" #include "context/context.h" #include "context/context_mm.h" -#include "context/cdlist_forward.h" namespace CVC4 { namespace context { @@ -139,8 +139,8 @@ private: size_t newSize = GROWTH_FACTOR * d_sizeAlloc; if(newSize > d_allocator.max_size()) { newSize = d_allocator.max_size(); - Assert(newSize > d_sizeAlloc, - "cannot request larger list due to allocator limits"); + Assert(newSize > d_sizeAlloc) + << "cannot request larger list due to allocator limits"; } T* newList = d_allocator.allocate(newSize); Debug("cdlist") << "2x grow of cdlist " << this @@ -306,7 +306,7 @@ public: * Access to the ith item in the list. */ const T& operator[](size_t i) const { - Assert(i < d_size, "index out of bounds in CDList::operator[]"); + Assert(i < d_size) << "index out of bounds in CDList::operator[]"; return d_list[i]; } @@ -314,7 +314,7 @@ public: * Returns the most recent item added to the list. */ const T& back() const { - Assert(d_size > 0, "CDList::back() called on empty list"); + Assert(d_size > 0) << "CDList::back() called on empty list"; return d_list[d_size - 1]; } diff --git a/src/context/cdo.h b/src/context/cdo.h index fe588afb0..b7d32d856 100644 --- a/src/context/cdo.h +++ b/src/context/cdo.h @@ -19,7 +19,6 @@ #ifndef CVC4__CONTEXT__CDO_H #define CVC4__CONTEXT__CDO_H -#include "base/cvc4_assert.h" #include "context/context.h" diff --git a/src/context/cdqueue.h b/src/context/cdqueue.h index 6ad0e9339..079d2265c 100644 --- a/src/context/cdqueue.h +++ b/src/context/cdqueue.h @@ -125,21 +125,21 @@ public: * function. */ void pop(){ - Assert(!empty(), "Attempting to pop from an empty queue."); + Assert(!empty()) << "Attempting to pop from an empty queue."; ParentType::makeCurrent(); d_iter = d_iter + 1; if (empty() && d_lastsave != ParentType::d_size) { // Some elements have been enqueued and dequeued in the same // context and now the queue is empty we can destruct them. ParentType::truncateList(d_lastsave); - Assert(ParentType::d_size == d_lastsave); + Assert(ParentType::d_size == d_lastsave); d_iter = d_lastsave; } } /** Returns a reference to the next element on the queue. */ const T& front() const{ - Assert(!empty(), "No front in an empty queue."); + Assert(!empty()) << "No front in an empty queue."; return ParentType::d_list[d_iter]; } @@ -147,7 +147,7 @@ public: * Returns the most recent item added to the queue. */ const T& back() const { - Assert(!empty(), "CDQueue::back() called on empty list"); + Assert(!empty()) << "CDQueue::back() called on empty list"; return ParentType::d_list[ParentType::d_size - 1]; } diff --git a/src/context/cdtrail_queue.h b/src/context/cdtrail_queue.h index ad2bef54c..4042c4223 100644 --- a/src/context/cdtrail_queue.h +++ b/src/context/cdtrail_queue.h @@ -74,7 +74,7 @@ public: /** Moves the iterator for the queue forward. */ void dequeue(){ - Assert(!empty(), "Attempting to queue from an empty queue."); + Assert(!empty()) << "Attempting to queue from an empty queue."; d_iter = d_iter + 1; } diff --git a/src/context/context.cpp b/src/context/context.cpp index 310f88b04..e1de944fe 100644 --- a/src/context/context.cpp +++ b/src/context/context.cpp @@ -18,7 +18,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/context.h" @@ -72,7 +72,7 @@ void Context::push() { void Context::pop() { - Assert(getLevel() > 0, "Cannot pop below level 0"); + Assert(getLevel() > 0) << "Cannot pop below level 0"; // Notify the (pre-pop) ContextNotifyObj objects ContextNotifyObj* pCNO = d_pCNOpre; @@ -149,11 +149,11 @@ void ContextObj::update() << *getContext() << std::endl; // Check that base class data was saved - Assert( ( pContextObjSaved->d_pContextObjNext == d_pContextObjNext && - pContextObjSaved->d_ppContextObjPrev == d_ppContextObjPrev && - pContextObjSaved->d_pContextObjRestore == d_pContextObjRestore && - pContextObjSaved->d_pScope == d_pScope ), - "save() did not properly copy information in base class" ); + Assert((pContextObjSaved->d_pContextObjNext == d_pContextObjNext + && pContextObjSaved->d_ppContextObjPrev == d_ppContextObjPrev + && pContextObjSaved->d_pContextObjRestore == d_pContextObjRestore + && pContextObjSaved->d_pScope == d_pScope)) + << "save() did not properly copy information in base class"; // Link the "saved" object in place of this ContextObj in the scope // we're moving it FROM. @@ -204,8 +204,8 @@ ContextObj* ContextObj::restoreAndContinue() // might not be bottom scope, since objects allocated in context // memory don't get linked to scope 0 // - // Assert(d_pScope == d_pScope->getContext()->getBottomScope(), - // "Expected bottom scope"); + // Assert(d_pScope == d_pScope->getContext()->getBottomScope()) << + // "Expected bottom scope"; Debug("context") << "NULL restore object! " << this << std::endl; pContextObjNext = d_pContextObjNext; @@ -270,8 +270,7 @@ ContextObj::ContextObj(Context* pContext) : d_pContextObjRestore(NULL), d_pContextObjNext(NULL), d_ppContextObjPrev(NULL) { - - Assert(pContext != NULL, "NULL context pointer"); + Assert(pContext != NULL) << "NULL context pointer"; Debug("context") << "create new ContextObj(" << this << " inCMM=false)" << std::endl; d_pScope = pContext->getBottomScope(); @@ -284,8 +283,7 @@ ContextObj::ContextObj(bool allocatedInCMM, Context* pContext) : d_pContextObjRestore(NULL), d_pContextObjNext(NULL), d_ppContextObjPrev(NULL) { - - Assert(pContext != NULL, "NULL context pointer"); + Assert(pContext != NULL) << "NULL context pointer"; Debug("context") << "create new ContextObj(" << this << " inCMM=" << allocatedInCMM << ")" << std::endl; if(allocatedInCMM) { @@ -341,16 +339,16 @@ std::ostream& operator<<(std::ostream& out, const Scope& scope) { out << "Scope " << scope.d_level << " [" << &scope << "]:"; ContextObj* pContextObj = scope.d_pContextObjList; - Assert(pContextObj == NULL || - pContextObj->prev() == &scope.d_pContextObjList); + Assert(pContextObj == NULL + || pContextObj->prev() == &scope.d_pContextObjList); while(pContextObj != NULL) { out << " <--> " << pContextObj; if(pContextObj->d_pScope != &scope) { out << " XXX bad scope" << std::endl; } Assert(pContextObj->d_pScope == &scope); - Assert(pContextObj->next() == NULL || - pContextObj->next()->prev() == &pContextObj->next()); + Assert(pContextObj->next() == NULL + || pContextObj->next()->prev() == &pContextObj->next()); pContextObj = pContextObj->next(); } return out << " --> NULL"; diff --git a/src/context/context.h b/src/context/context.h index d9d73f770..2bfc83a43 100644 --- a/src/context/context.h +++ b/src/context/context.h @@ -27,7 +27,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "context/context_mm.h" @@ -135,10 +135,10 @@ public: } ~ScopedPush() noexcept(false) { d_context->pop(); - AlwaysAssert(d_context->getTopScope() == d_scope, - "Context::ScopedPush observed an uneven Context (at pop, " - "top scope doesn't match what it was at the time the " - "ScopedPush was applied)"); + AlwaysAssert(d_context->getTopScope() == d_scope) + << "Context::ScopedPush observed an uneven Context (at pop, " + "top scope doesn't match what it was at the time the " + "ScopedPush was applied)"; } };/* Context::ScopedPush */ @@ -569,7 +569,7 @@ class ContextObj { * calling deleteSelf(). */ static void operator delete(void* pMem) { - AlwaysAssert(false, "It is not allowed to delete a ContextObj this way!"); + AlwaysAssert(false) << "It is not allowed to delete a ContextObj this way!"; } /** diff --git a/src/context/context_mm.cpp b/src/context/context_mm.cpp index 76a2168d1..a9186f5f9 100644 --- a/src/context/context_mm.cpp +++ b/src/context/context_mm.cpp @@ -24,7 +24,7 @@ #include #endif /* CVC4_VALGRIND */ -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "context/context_mm.h" @@ -37,8 +37,8 @@ void ContextMemoryManager::newChunk() { // Increment index to chunk list ++d_indexChunkList; - Assert(d_chunkList.size() == d_indexChunkList, - "Index should be at the end of the list"); + Assert(d_chunkList.size() == d_indexChunkList) + << "Index should be at the end of the list"; // Create new chunk if no free chunk available if(d_freeChunks.empty()) { @@ -105,8 +105,8 @@ void* ContextMemoryManager::newData(size_t size) { newChunk(); res = (void*)d_nextFree; d_nextFree += size; - AlwaysAssert(d_nextFree <= d_endChunk, - "Request is bigger than memory chunk size"); + AlwaysAssert(d_nextFree <= d_endChunk) + << "Request is bigger than memory chunk size"; } Debug("context") << "ContextMemoryManager::newData(" << size << ") returning " << res << " at level " diff --git a/src/decision/decision_engine.h b/src/decision/decision_engine.h index 73d7e2a31..41d439d4f 100644 --- a/src/decision/decision_engine.h +++ b/src/decision/decision_engine.h @@ -118,10 +118,10 @@ public: /** Gets the next decision based on strategies that are enabled */ SatLiteral getNext(bool &stopSearch) { NodeManager::currentResourceManager()->spendResource(options::decisionStep()); - Assert(d_cnfStream != NULL, - "Forgot to set cnfStream for decision engine?"); - Assert(d_satSolver != NULL, - "Forgot to set satSolver for decision engine?"); + Assert(d_cnfStream != NULL) + << "Forgot to set cnfStream for decision engine?"; + Assert(d_satSolver != NULL) + << "Forgot to set satSolver for decision engine?"; SatLiteral ret = undefSatLiteral; for(unsigned i = 0; @@ -157,7 +157,7 @@ public: case SAT_VALUE_TRUE: return Result(Result::SAT); case SAT_VALUE_FALSE: return Result(Result::UNSAT); case SAT_VALUE_UNKNOWN: return Result(Result::SAT_UNKNOWN, Result::UNKNOWN_REASON); - default: Assert(false, "d_result is garbage"); + default: Assert(false) << "d_result is garbage"; } return Result(); } diff --git a/src/decision/justification_heuristic.cpp b/src/decision/justification_heuristic.cpp index 043ec10f2..f7e5b84fc 100644 --- a/src/decision/justification_heuristic.cpp +++ b/src/decision/justification_heuristic.cpp @@ -68,8 +68,8 @@ CVC4::prop::SatLiteral JustificationHeuristic::getNext(bool &stopSearch) bool stopSearchTmp = false; SatLiteral lit = getNextThresh(stopSearchTmp, options::decisionThreshold()); if(lit != undefSatLiteral) { - Assert(stopSearchTmp == false); - return lit; + Assert(stopSearchTmp == false); + return lit; } Assert(stopSearchTmp == true); } @@ -441,12 +441,12 @@ JustificationHeuristic::findSplitterRec(TNode node, SatValue desiredVal) SatValue litVal = tryGetSatValue(node); /* You'd better know what you want */ - Assert(desiredVal != SAT_VALUE_UNKNOWN, "expected known value"); + Assert(desiredVal != SAT_VALUE_UNKNOWN) << "expected known value"; /* Good luck, hope you can get what you want */ // See bug 374 - // Assert(litVal == desiredVal || litVal == SAT_VALUE_UNKNOWN, - // "invariant violated"); + // Assert(litVal == desiredVal || litVal == SAT_VALUE_UNKNOWN) << + // "invariant violated"; /* What type of node is this */ Kind k = node.getKind(); @@ -494,7 +494,7 @@ JustificationHeuristic::findSplitterRec(TNode node, SatValue desiredVal) case kind::CONST_BOOLEAN: Assert(node.getConst() == false || desiredVal == SAT_VALUE_TRUE); - Assert(node.getConst() == true || desiredVal == SAT_VALUE_FALSE); + Assert(node.getConst() == true || desiredVal == SAT_VALUE_FALSE); break; case kind::AND: @@ -535,9 +535,7 @@ JustificationHeuristic::findSplitterRec(TNode node, SatValue desiredVal) ret = handleITE(node, desiredVal); break; - default: - Assert(false, "Unexpected Boolean operator"); - break; + default: Assert(false) << "Unexpected Boolean operator"; break; }//end of switch(k) if(ret == DONT_KNOW) { @@ -545,8 +543,8 @@ JustificationHeuristic::findSplitterRec(TNode node, SatValue desiredVal) } if(ret == NO_SPLITTER) { - Assert( litPresent == false || litVal == desiredVal, - "Output should be justified"); + Assert(litPresent == false || litVal == desiredVal) + << "Output should be justified"; setJustified(node); } return ret; @@ -555,8 +553,8 @@ JustificationHeuristic::findSplitterRec(TNode node, SatValue desiredVal) JustificationHeuristic::SearchResult JustificationHeuristic::handleAndOrEasy(TNode node, SatValue desiredVal) { - Assert( (node.getKind() == kind::AND and desiredVal == SAT_VALUE_FALSE) or - (node.getKind() == kind::OR and desiredVal == SAT_VALUE_TRUE) ); + Assert((node.getKind() == kind::AND and desiredVal == SAT_VALUE_FALSE) + or (node.getKind() == kind::OR and desiredVal == SAT_VALUE_TRUE)); int numChildren = node.getNumChildren(); SatValue desiredValInverted = invertValue(desiredVal); @@ -569,7 +567,7 @@ JustificationHeuristic::handleAndOrEasy(TNode node, SatValue desiredVal) } } } - Assert(d_curThreshold != 0, "handleAndOrEasy: No controlling input found"); + Assert(d_curThreshold != 0) << "handleAndOrEasy: No controlling input found"; return DONT_KNOW; } @@ -582,8 +580,8 @@ void JustificationHeuristic::saveStartIndex(TNode node, int val) { JustificationHeuristic::SearchResult JustificationHeuristic::handleAndOrHard(TNode node, SatValue desiredVal) { - Assert( (node.getKind() == kind::AND and desiredVal == SAT_VALUE_TRUE) or - (node.getKind() == kind::OR and desiredVal == SAT_VALUE_FALSE) ); + Assert((node.getKind() == kind::AND and desiredVal == SAT_VALUE_TRUE) + or (node.getKind() == kind::OR and desiredVal == SAT_VALUE_FALSE)); int numChildren = node.getNumChildren(); bool noSplitter = true; @@ -621,7 +619,7 @@ JustificationHeuristic::SearchResult JustificationHeuristic::handleBinaryEasy(TN if(ret != DONT_KNOW) return ret; } - Assert(d_curThreshold != 0, "handleBinaryEasy: No controlling input found"); + Assert(d_curThreshold != 0) << "handleBinaryEasy: No controlling input found"; return DONT_KNOW; } @@ -679,7 +677,7 @@ JustificationHeuristic::SearchResult JustificationHeuristic::handleITE(TNode nod if(findSplitterRec(node[0], ifDesiredVal) == FOUND_SPLITTER) return FOUND_SPLITTER; - Assert(d_curThreshold != 0, "No controlling input found (6)"); + Assert(d_curThreshold != 0) << "No controlling input found (6)"; return DONT_KNOW; } else { // Try to justify 'if' diff --git a/src/expr/array_store_all.cpp b/src/expr/array_store_all.cpp index eff2c2151..f2d9a35a9 100644 --- a/src/expr/array_store_all.cpp +++ b/src/expr/array_store_all.cpp @@ -20,7 +20,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/expr.h" #include "expr/type.h" diff --git a/src/expr/attribute.cpp b/src/expr/attribute.cpp index b9234883b..553c19f6e 100644 --- a/src/expr/attribute.cpp +++ b/src/expr/attribute.cpp @@ -79,7 +79,7 @@ void AttributeManager::deleteAttributes(const AttrIdVec& atids) { switch(tableId) { case AttrTableBool: - Unimplemented("delete attributes is unimplemented for bools"); + Unimplemented() << "delete attributes is unimplemented for bools"; break; case AttrTableUInt64: deleteAttributesFromTable(d_ints, ids); @@ -103,7 +103,8 @@ void AttributeManager::deleteAttributes(const AttrIdVec& atids) { case AttrTableCDNode: case AttrTableCDString: case AttrTableCDPointer: - Unimplemented("CDAttributes cannot be deleted. Contact Tim/Morgan if this behavior is desired."); + Unimplemented() << "CDAttributes cannot be deleted. Contact Tim/Morgan " + "if this behavior is desired."; break; case LastAttrTable: diff --git a/src/expr/attribute_internals.h b/src/expr/attribute_internals.h index e47dce434..bc34324b0 100644 --- a/src/expr/attribute_internals.h +++ b/src/expr/attribute_internals.h @@ -463,9 +463,8 @@ public: */ static inline uint64_t registerAttribute() { const uint64_t id = attr::LastAttributeId::getNextId(); - AlwaysAssert( id <= 63, - "Too many boolean node attributes registered " - "during initialization !" ); + AlwaysAssert(id <= 63) << "Too many boolean node attributes registered " + "during initialization !"; return id; } };/* class Attribute<..., bool, ...> */ diff --git a/src/expr/datatype.cpp b/src/expr/datatype.cpp index 4ec6ac36a..2356f74bc 100644 --- a/src/expr/datatype.cpp +++ b/src/expr/datatype.cpp @@ -19,7 +19,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/attribute.h" #include "expr/expr_manager.h" #include "expr/expr_manager_scope.h" @@ -67,7 +67,7 @@ const Datatype& Datatype::datatypeOf(Expr item) { case kind::TESTER_TYPE: return DatatypeType(t[0].toType()).getDatatype(); default: - Unhandled("arg must be a datatype constructor, selector, or tester"); + Unhandled() << "arg must be a datatype constructor, selector, or tester"; } } @@ -242,7 +242,7 @@ void Datatype::setRecord() { Cardinality Datatype::getCardinality(Type t) const { PrettyCheckArgument(isResolved(), this, "this datatype is not yet resolved"); - Assert( t.isDatatype() && ((DatatypeType)t).getDatatype()==*this ); + Assert(t.isDatatype() && ((DatatypeType)t).getDatatype() == *this); std::vector< Type > processing; computeCardinality( t, processing ); return d_card; @@ -275,10 +275,10 @@ Cardinality Datatype::computeCardinality(Type t, bool Datatype::isRecursiveSingleton(Type t) const { PrettyCheckArgument(isResolved(), this, "this datatype is not yet resolved"); - Assert( t.isDatatype() && ((DatatypeType)t).getDatatype()==*this ); + Assert(t.isDatatype() && ((DatatypeType)t).getDatatype() == *this); if( d_card_rec_singleton.find( t )==d_card_rec_singleton.end() ){ if( isCodatatype() ){ - Assert( d_card_u_assume[t].empty() ); + Assert(d_card_u_assume[t].empty()); std::vector< Type > processing; if( computeCardinalityRecSingleton( t, processing, d_card_u_assume[t] ) ){ d_card_rec_singleton[t] = 1; @@ -307,8 +307,8 @@ bool Datatype::isRecursiveSingleton() const unsigned Datatype::getNumRecursiveSingletonArgTypes(Type t) const { - Assert( d_card_rec_singleton.find( t )!=d_card_rec_singleton.end() ); - Assert( isRecursiveSingleton( t ) ); + Assert(d_card_rec_singleton.find(t) != d_card_rec_singleton.end()); + Assert(isRecursiveSingleton(t)); return d_card_u_assume[t].size(); } @@ -320,8 +320,8 @@ unsigned Datatype::getNumRecursiveSingletonArgTypes() const Type Datatype::getRecursiveSingletonArgType(Type t, unsigned i) const { - Assert( d_card_rec_singleton.find( t )!=d_card_rec_singleton.end() ); - Assert( isRecursiveSingleton( t ) ); + Assert(d_card_rec_singleton.find(t) != d_card_rec_singleton.end()); + Assert(isRecursiveSingleton(t)); return d_card_u_assume[t][i]; } @@ -384,7 +384,7 @@ bool Datatype::computeCardinalityRecSingleton(Type t, bool Datatype::isFinite(Type t) const { PrettyCheckArgument(isResolved(), this, "this datatype is not yet resolved"); - Assert( t.isDatatype() && ((DatatypeType)t).getDatatype()==*this ); + Assert(t.isDatatype() && ((DatatypeType)t).getDatatype() == *this); // we're using some internals, so we have to set up this library context ExprManagerScope ems(d_self); @@ -413,7 +413,7 @@ bool Datatype::isFinite() const bool Datatype::isInterpretedFinite(Type t) const { PrettyCheckArgument(isResolved(), this, "this datatype is not yet resolved"); - Assert( t.isDatatype() && ((DatatypeType)t).getDatatype()==*this ); + Assert(t.isDatatype() && ((DatatypeType)t).getDatatype() == *this); // we're using some internals, so we have to set up this library context ExprManagerScope ems(d_self); TypeNode self = TypeNode::fromType(d_self); @@ -596,10 +596,10 @@ bool Datatype::operator==(const Datatype& other) const // testing equivalence of constructors and testers is harder b/c // this constructor might not be resolved yet; only compare them // if they are both resolved - Assert(isResolved() == !(*i).d_constructor.isNull() && - isResolved() == !(*i).d_tester.isNull() && - (*i).d_constructor.isNull() == (*j).d_constructor.isNull() && - (*i).d_tester.isNull() == (*j).d_tester.isNull()); + Assert(isResolved() == !(*i).d_constructor.isNull() + && isResolved() == !(*i).d_tester.isNull() + && (*i).d_constructor.isNull() == (*j).d_constructor.isNull() + && (*i).d_tester.isNull() == (*j).d_tester.isNull()); if(!(*i).d_constructor.isNull() && (*i).d_constructor != (*j).d_constructor) { return false; } @@ -613,8 +613,8 @@ bool Datatype::operator==(const Datatype& other) const } // testing equivalence of selectors is harder b/c args might not // be resolved yet - Assert(isResolved() == (*k).isResolved() && - (*k).isResolved() == (*l).isResolved()); + Assert(isResolved() == (*k).isResolved() + && (*k).isResolved() == (*l).isResolved()); if((*k).isResolved()) { // both are resolved, so simply compare the selectors directly if((*k).d_selector != (*l).d_selector) { @@ -1121,7 +1121,7 @@ Expr DatatypeConstructor::computeGroundTerm(Type t, Expr groundTerm = getConstructor().getExprManager()->mkExpr(kind::APPLY_CONSTRUCTOR, groundTerms); if( groundTerm.getType()!=t ){ - Assert( Datatype::datatypeOf( d_constructor ).isParametric() ); + Assert(Datatype::datatypeOf(d_constructor).isParametric()); //type is ambiguous, must apply type ascription Debug("datatypes-gt") << "ambiguous type for " << groundTerm << ", ascribe to " << t << std::endl; groundTerms[0] = getConstructor().getExprManager()->mkExpr(kind::APPLY_TYPE_ASCRIPTION, @@ -1140,8 +1140,8 @@ void DatatypeConstructor::computeSharedSelectors( Type domainType ) const { }else{ ctype = TypeNode::fromType( d_constructor.getType() ); } - Assert( ctype.isConstructor() ); - Assert( ctype.getNumChildren()-1==getNumArgs() ); + Assert(ctype.isConstructor()); + Assert(ctype.getNumChildren() - 1 == getNumArgs()); //compute the shared selectors const Datatype& dt = Datatype::datatypeOf(d_constructor); std::map< TypeNode, unsigned > counter; @@ -1149,7 +1149,8 @@ void DatatypeConstructor::computeSharedSelectors( Type domainType ) const { TypeNode t = ctype[j]; Expr ss = dt.getSharedSelector( domainType, t.toType(), counter[t] ); d_shared_selectors[domainType].push_back( ss ); - Assert( d_shared_selector_index[domainType].find( ss )==d_shared_selector_index[domainType].end() ); + Assert(d_shared_selector_index[domainType].find(ss) + == d_shared_selector_index[domainType].end()); d_shared_selector_index[domainType][ss] = j; counter[t]++; } @@ -1226,7 +1227,7 @@ Expr DatatypeConstructor::getSelectorInternal( Type domainType, size_t index ) c PrettyCheckArgument(index < getNumArgs(), index, "index out of bounds"); if( options::dtSharedSelectors() ){ computeSharedSelectors( domainType ); - Assert( d_shared_selectors[domainType].size()==getNumArgs() ); + Assert(d_shared_selectors[domainType].size() == getNumArgs()); return d_shared_selectors[domainType][index]; }else{ return d_args[index].getSelector(); @@ -1236,7 +1237,7 @@ Expr DatatypeConstructor::getSelectorInternal( Type domainType, size_t index ) c int DatatypeConstructor::getSelectorIndexInternal( Expr sel ) const { PrettyCheckArgument(isResolved(), this, "cannot get an internal selector index for an unresolved datatype constructor"); if( options::dtSharedSelectors() ){ - Assert( sel.getType().isSelector() ); + Assert(sel.getType().isSelector()); Type domainType = ((SelectorType)sel.getType()).getDomain(); computeSharedSelectors( domainType ); std::map< Expr, unsigned >::iterator its = d_shared_selector_index[domainType].find( sel ); diff --git a/src/expr/expr_manager_template.cpp b/src/expr/expr_manager_template.cpp index bc3d450d0..09555da1b 100644 --- a/src/expr/expr_manager_template.cpp +++ b/src/expr/expr_manager_template.cpp @@ -578,7 +578,7 @@ FunctionType ExprManager::mkFunctionType(Type domain, Type range) { /** Make a function type with input types from argTypes. */ FunctionType ExprManager::mkFunctionType(const std::vector& argTypes, Type range) { NodeManagerScope nms(d_nodeManager); - Assert( argTypes.size() >= 1 ); + Assert(argTypes.size() >= 1); std::vector argTypeNodes; for (unsigned i = 0, i_end = argTypes.size(); i < i_end; ++ i) { argTypeNodes.push_back(*argTypes[i].d_typeNode); @@ -588,7 +588,7 @@ FunctionType ExprManager::mkFunctionType(const std::vector& argTypes, Type FunctionType ExprManager::mkFunctionType(const std::vector& sorts) { NodeManagerScope nms(d_nodeManager); - Assert( sorts.size() >= 2 ); + Assert(sorts.size() >= 2); std::vector sortNodes; for (unsigned i = 0, i_end = sorts.size(); i < i_end; ++ i) { sortNodes.push_back(*sorts[i].d_typeNode); @@ -598,7 +598,7 @@ FunctionType ExprManager::mkFunctionType(const std::vector& sorts) { FunctionType ExprManager::mkPredicateType(const std::vector& sorts) { NodeManagerScope nms(d_nodeManager); - Assert( sorts.size() >= 1 ); + Assert(sorts.size() >= 1); std::vector sortNodes; for (unsigned i = 0, i_end = sorts.size(); i < i_end; ++ i) { sortNodes.push_back(*sorts[i].d_typeNode); @@ -735,7 +735,7 @@ std::vector ExprManager::mkMutualDatatypeTypes( if( (*i).isSort() ) { name = SortType(*i).getName(); } else { - Assert( (*i).isSortConstructor() ); + Assert((*i).isSortConstructor()); name = SortConstructorType(*i).getName(); } std::map::const_iterator resolver = @@ -753,7 +753,7 @@ std::vector ExprManager::mkMutualDatatypeTypes( placeholders.push_back(*i); replacements.push_back( (*resolver).second ); } else { - Assert( (*i).isSortConstructor() ); + Assert((*i).isSortConstructor()); paramTypes.push_back( SortConstructorType(*i) ); paramReplacements.push_back( (*resolver).second ); } @@ -794,31 +794,31 @@ void ExprManager::checkResolvedDatatype(DatatypeType dtt) const { ++i) { const DatatypeConstructor& c = *i; Type testerType CVC4_UNUSED = c.getTester().getType(); - Assert(c.isResolved() && - testerType.isTester() && - TesterType(testerType).getDomain() == dtt && - TesterType(testerType).getRangeType() == booleanType(), - "malformed tester in datatype post-resolution"); + Assert(c.isResolved() && testerType.isTester() + && TesterType(testerType).getDomain() == dtt + && TesterType(testerType).getRangeType() == booleanType()) + << "malformed tester in datatype post-resolution"; Type ctorType CVC4_UNUSED = c.getConstructor().getType(); - Assert(ctorType.isConstructor() && - ConstructorType(ctorType).getArity() == c.getNumArgs() && - ConstructorType(ctorType).getRangeType() == dtt, - "malformed constructor in datatype post-resolution"); + Assert(ctorType.isConstructor() + && ConstructorType(ctorType).getArity() == c.getNumArgs() + && ConstructorType(ctorType).getRangeType() == dtt) + << "malformed constructor in datatype post-resolution"; // for all selectors... for(DatatypeConstructor::const_iterator j = c.begin(), j_end = c.end(); j != j_end; ++j) { const DatatypeConstructorArg& a = *j; Type selectorType = a.getType(); - Assert(a.isResolved() && - selectorType.isSelector() && - SelectorType(selectorType).getDomain() == dtt, - "malformed selector in datatype post-resolution"); + Assert(a.isResolved() && selectorType.isSelector() + && SelectorType(selectorType).getDomain() == dtt) + << "malformed selector in datatype post-resolution"; // This next one's a "hard" check, performed in non-debug builds // as well; the other ones should all be guaranteed by the // CVC4::Datatype class, but this actually needs to be checked. - AlwaysAssert(!SelectorType(selectorType).getRangeType().d_typeNode->isFunctionLike(), - "cannot put function-like things in datatypes"); + AlwaysAssert(!SelectorType(selectorType) + .getRangeType() + .d_typeNode->isFunctionLike()) + << "cannot put function-like things in datatypes"; } } } @@ -892,7 +892,9 @@ Type ExprManager::getType(Expr e, bool check) } Expr ExprManager::mkVar(const std::string& name, Type type, uint32_t flags) { - Assert(NodeManager::currentNM() == NULL, "ExprManager::mkVar() should only be called externally, not from within CVC4 code. Please use mkSkolem()."); + Assert(NodeManager::currentNM() == NULL) + << "ExprManager::mkVar() should only be called externally, not from " + "within CVC4 code. Please use mkSkolem()."; NodeManagerScope nms(d_nodeManager); Node* n = d_nodeManager->mkVarPtr(name, *type.d_typeNode, flags); Debug("nm") << "set " << name << " on " << *n << std::endl; @@ -901,7 +903,9 @@ Expr ExprManager::mkVar(const std::string& name, Type type, uint32_t flags) { } Expr ExprManager::mkVar(Type type, uint32_t flags) { - Assert(NodeManager::currentNM() == NULL, "ExprManager::mkVar() should only be called externally, not from within CVC4 code. Please use mkSkolem()."); + Assert(NodeManager::currentNM() == NULL) + << "ExprManager::mkVar() should only be called externally, not from " + "within CVC4 code. Please use mkSkolem()."; NodeManagerScope nms(d_nodeManager); INC_STAT_VAR(type, false); return Expr(this, d_nodeManager->mkVarPtr(*type.d_typeNode, flags)); @@ -974,8 +978,8 @@ Expr ExprManager::mkAssociative(Kind kind, /* It would be really weird if this happened (it would require * min > 2, for one thing), but let's make sure. */ - AlwaysAssert( newChildren.size() >= min, - "Too few new children in mkAssociative" ); + AlwaysAssert(newChildren.size() >= min) + << "Too few new children in mkAssociative"; // recurse return mkAssociative(kind, newChildren); @@ -1085,8 +1089,8 @@ TypeNode exportTypeInternal(TypeNode n, NodeManager* from, NodeManager* to, Expr }/* CVC4::expr namespace */ Type ExprManager::exportType(const Type& t, ExprManager* em, ExprManagerMapCollection& vmap) { - Assert(t.d_nodeManager != em->d_nodeManager, - "Can't export a Type to the same ExprManager"); + Assert(t.d_nodeManager != em->d_nodeManager) + << "Can't export a Type to the same ExprManager"; NodeManagerScope ems(t.d_nodeManager); return Type(em->d_nodeManager, new TypeNode(expr::exportTypeInternal(*t.d_typeNode, t.d_nodeManager, em->d_nodeManager, vmap))); diff --git a/src/expr/expr_template.cpp b/src/expr/expr_template.cpp index 2338a7320..998f58d0c 100644 --- a/src/expr/expr_template.cpp +++ b/src/expr/expr_template.cpp @@ -20,7 +20,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/expr_manager_scope.h" #include "expr/node.h" #include "expr/node_algorithm.h" @@ -306,15 +306,15 @@ public: Expr Expr::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap, uint32_t flags /* = 0 */) const { - Assert(d_exprManager != exprManager, - "No sense in cloning an Expr in the same ExprManager"); + Assert(d_exprManager != exprManager) + << "No sense in cloning an Expr in the same ExprManager"; ExprManagerScope ems(*this); return Expr(exprManager, new Node(expr::ExportPrivate(d_exprManager, exprManager, variableMap, flags).exportInternal(*d_node))); } Expr& Expr::operator=(const Expr& e) { - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); - Assert(e.d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; + Assert(e.d_node != NULL) << "Unexpected NULL expression pointer!"; if(this != &e) { if(d_exprManager == e.d_exprManager) { @@ -342,8 +342,8 @@ bool Expr::operator==(const Expr& e) const { return false; } ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); - Assert(e.d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; + Assert(e.d_node != NULL) << "Unexpected NULL expression pointer!"; return *d_node == *e.d_node; } @@ -352,8 +352,8 @@ bool Expr::operator!=(const Expr& e) const { } bool Expr::operator<(const Expr& e) const { - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); - Assert(e.d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; + Assert(e.d_node != NULL) << "Unexpected NULL expression pointer!"; if(isNull() && !e.isNull()) { return true; } @@ -362,8 +362,8 @@ bool Expr::operator<(const Expr& e) const { } bool Expr::operator>(const Expr& e) const { - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); - Assert(e.d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; + Assert(e.d_node != NULL) << "Unexpected NULL expression pointer!"; if(isNull() && !e.isNull()) { return true; } @@ -374,38 +374,38 @@ bool Expr::operator>(const Expr& e) const { uint64_t Expr::getId() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->getId(); } Kind Expr::getKind() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->getKind(); } size_t Expr::getNumChildren() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->getNumChildren(); } Expr Expr::operator[](unsigned i) const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); - Assert(i >= 0 && i < d_node->getNumChildren(), "Child index out of bounds"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; + Assert(i >= 0 && i < d_node->getNumChildren()) << "Child index out of bounds"; return Expr(d_exprManager, new Node((*d_node)[i])); } bool Expr::hasOperator() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->hasOperator(); } Expr Expr::getOperator() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; PrettyCheckArgument(d_node->hasOperator(), *this, "Expr::getOperator() called on an Expr with no operator"); return Expr(d_exprManager, new Node(d_node->getOperator())); @@ -414,14 +414,14 @@ Expr Expr::getOperator() const { bool Expr::isParameterized() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->getMetaKind() == kind::metakind::PARAMETERIZED; } Type Expr::getType(bool check) const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; PrettyCheckArgument(!d_node->isNull(), this, "Can't get type of null expression!"); return d_exprManager->getType(*this, check); @@ -553,32 +553,32 @@ Expr::const_iterator Expr::end() const { std::string Expr::toString() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->toString(); } bool Expr::isNull() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->isNull(); } bool Expr::isVariable() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->getMetaKind() == kind::metakind::VARIABLE; } bool Expr::isConst() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return d_node->isConst(); } bool Expr::hasFreeVariable() const { ExprManagerScope ems(*this); - Assert(d_node != NULL, "Unexpected NULL expression pointer!"); + Assert(d_node != NULL) << "Unexpected NULL expression pointer!"; return expr::hasFreeVar(*d_node); } @@ -591,30 +591,30 @@ void Expr::toStream(std::ostream& out, int depth, bool types, size_t dag, Node Expr::getNode() const { return *d_node; } TNode Expr::getTNode() const { return *d_node; } Expr Expr::notExpr() const { - Assert(d_exprManager != NULL, - "Don't have an expression manager for this expression!"); + Assert(d_exprManager != NULL) + << "Don't have an expression manager for this expression!"; return d_exprManager->mkExpr(NOT, *this); } Expr Expr::andExpr(const Expr& e) const { - Assert(d_exprManager != NULL, - "Don't have an expression manager for this expression!"); + Assert(d_exprManager != NULL) + << "Don't have an expression manager for this expression!"; PrettyCheckArgument(d_exprManager == e.d_exprManager, e, "Different expression managers!"); return d_exprManager->mkExpr(AND, *this, e); } Expr Expr::orExpr(const Expr& e) const { - Assert(d_exprManager != NULL, - "Don't have an expression manager for this expression!"); + Assert(d_exprManager != NULL) + << "Don't have an expression manager for this expression!"; PrettyCheckArgument(d_exprManager == e.d_exprManager, e, "Different expression managers!"); return d_exprManager->mkExpr(OR, *this, e); } Expr Expr::xorExpr(const Expr& e) const { - Assert(d_exprManager != NULL, - "Don't have an expression manager for this expression!"); + Assert(d_exprManager != NULL) + << "Don't have an expression manager for this expression!"; PrettyCheckArgument(d_exprManager == e.d_exprManager, e, "Different expression managers!"); return d_exprManager->mkExpr(XOR, *this, e); @@ -622,16 +622,16 @@ Expr Expr::xorExpr(const Expr& e) const { Expr Expr::eqExpr(const Expr& e) const { - Assert(d_exprManager != NULL, - "Don't have an expression manager for this expression!"); + Assert(d_exprManager != NULL) + << "Don't have an expression manager for this expression!"; PrettyCheckArgument(d_exprManager == e.d_exprManager, e, "Different expression managers!"); return d_exprManager->mkExpr(EQUAL, *this, e); } Expr Expr::impExpr(const Expr& e) const { - Assert(d_exprManager != NULL, - "Don't have an expression manager for this expression!"); + Assert(d_exprManager != NULL) + << "Don't have an expression manager for this expression!"; PrettyCheckArgument(d_exprManager == e.d_exprManager, e, "Different expression managers!"); return d_exprManager->mkExpr(IMPLIES, *this, e); @@ -639,8 +639,8 @@ Expr Expr::impExpr(const Expr& e) const { Expr Expr::iteExpr(const Expr& then_e, const Expr& else_e) const { - Assert(d_exprManager != NULL, - "Don't have an expression manager for this expression!"); + Assert(d_exprManager != NULL) + << "Don't have an expression manager for this expression!"; PrettyCheckArgument(d_exprManager == then_e.d_exprManager, then_e, "Different expression managers!"); PrettyCheckArgument(d_exprManager == else_e.d_exprManager, else_e, @@ -684,7 +684,7 @@ static Node exportConstant(TNode n, NodeManager* to, ExprManagerMapCollection& v switch(n.getKind()) { ${exportConstant_cases} - default: Unhandled(n.getKind()); +default: Unhandled() << n.getKind(); } }/* exportConstant() */ diff --git a/src/expr/kind_map.h b/src/expr/kind_map.h index a5ae73802..3b49ad51a 100644 --- a/src/expr/kind_map.h +++ b/src/expr/kind_map.h @@ -23,7 +23,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/kind.h" namespace CVC4 { diff --git a/src/expr/matcher.h b/src/expr/matcher.h index 95ece7d23..9a2dad7d0 100644 --- a/src/expr/matcher.h +++ b/src/expr/matcher.h @@ -24,7 +24,6 @@ #include #include -#include "base/cvc4_assert.h" #include "expr/node.h" #include "expr/type_node.h" diff --git a/src/expr/metakind_template.cpp b/src/expr/metakind_template.cpp index 5116392cb..83c7e6e2c 100644 --- a/src/expr/metakind_template.cpp +++ b/src/expr/metakind_template.cpp @@ -52,13 +52,14 @@ ${metakind_constantMaps} namespace kind { namespace metakind { -size_t NodeValueCompare::constHash(const ::CVC4::expr::NodeValue* nv) { +size_t NodeValueCompare::constHash(const ::CVC4::expr::NodeValue* nv) +{ Assert(nv->getMetaKind() == kind::metakind::CONSTANT); - switch(nv->d_kind) { + switch (nv->d_kind) + { ${metakind_constHashes} - default: - Unhandled(::CVC4::expr::NodeValue::dKindToKind(nv->d_kind)); + default: Unhandled() << ::CVC4::expr::NodeValue::dKindToKind(nv->d_kind); } } @@ -69,11 +70,12 @@ bool NodeValueCompare::compare(const ::CVC4::expr::NodeValue* nv1, return false; } - if(nv1->getMetaKind() == kind::metakind::CONSTANT) { - switch(nv1->d_kind) { + if (nv1->getMetaKind() == kind::metakind::CONSTANT) + { + switch (nv1->d_kind) + { ${metakind_compares} - default: - Unhandled(::CVC4::expr::NodeValue::dKindToKind(nv1->d_kind)); + default: Unhandled() << ::CVC4::expr::NodeValue::dKindToKind(nv1->d_kind); } } @@ -105,10 +107,10 @@ void NodeValueConstPrinter::toStream(std::ostream& out, const ::CVC4::expr::NodeValue* nv) { Assert(nv->getMetaKind() == kind::metakind::CONSTANT); - switch(nv->d_kind) { + switch (nv->d_kind) + { ${metakind_constPrinters} - default: - Unhandled(::CVC4::expr::NodeValue::dKindToKind(nv->d_kind)); + default: Unhandled() << ::CVC4::expr::NodeValue::dKindToKind(nv->d_kind); } } @@ -135,10 +137,10 @@ void NodeValueConstPrinter::toStream(std::ostream& out, TNode n) { void deleteNodeValueConstant(::CVC4::expr::NodeValue* nv) { Assert(nv->getMetaKind() == kind::metakind::CONSTANT); - switch(nv->d_kind) { + switch (nv->d_kind) + { ${metakind_constDeleters} - default: - Unhandled(::CVC4::expr::NodeValue::dKindToKind(nv->d_kind)); + default: Unhandled() << ::CVC4::expr::NodeValue::dKindToKind(nv->d_kind); } } diff --git a/src/expr/metakind_template.h b/src/expr/metakind_template.h index 1615d461b..c4d35b7dc 100644 --- a/src/expr/metakind_template.h +++ b/src/expr/metakind_template.h @@ -21,7 +21,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/kind.h" namespace CVC4 { diff --git a/src/expr/mkkind b/src/expr/mkkind index a8a74b5a6..8e45b94ba 100755 --- a/src/expr/mkkind +++ b/src/expr/mkkind @@ -274,7 +274,7 @@ function register_sort { fi else type_constant_groundterms="${type_constant_groundterms}#line $lineno \"$kf\" - case $id: Unhandled(tc); + case $id: Unhandled() << tc; " fi } @@ -323,7 +323,7 @@ function register_wellfoundedness { " else type_groundterms="${type_groundterms}#line $lineno \"$kf\" - case $id: Unhandled(typeNode); + case $id: Unhandled() << typeNode; " fi if [ -n "$header" ]; then diff --git a/src/expr/node.h b/src/expr/node.h index e0231bef6..cd3c99a78 100644 --- a/src/expr/node.h +++ b/src/expr/node.h @@ -33,15 +33,15 @@ #include #include +#include "base/check.h" #include "base/configuration.h" -#include "base/cvc4_assert.h" #include "base/exception.h" #include "base/output.h" -#include "expr/type.h" -#include "expr/kind.h" -#include "expr/metakind.h" #include "expr/expr.h" #include "expr/expr_iomanip.h" +#include "expr/kind.h" +#include "expr/metakind.h" +#include "expr/type.h" #include "options/language.h" #include "options/set_language.h" #include "util/hash.h" @@ -226,7 +226,7 @@ class NodeTemplate { inline void assertTNodeNotExpired() const { if(!ref_count) { - Assert( d_nv->d_rc > 0, "TNode pointing to an expired NodeValue" ); + Assert(d_nv->d_rc > 0) << "TNode pointing to an expired NodeValue"; } } @@ -1022,9 +1022,9 @@ template template inline typename AttrKind::value_type NodeTemplate:: getAttribute(const AttrKind&) const { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; assertTNodeNotExpired(); @@ -1035,9 +1035,9 @@ template template inline bool NodeTemplate:: hasAttribute(const AttrKind&) const { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; assertTNodeNotExpired(); @@ -1048,9 +1048,9 @@ template template inline bool NodeTemplate::getAttribute(const AttrKind&, typename AttrKind::value_type& ret) const { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; assertTNodeNotExpired(); @@ -1061,9 +1061,9 @@ template template inline void NodeTemplate:: setAttribute(const AttrKind&, const typename AttrKind::value_type& value) { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; assertTNodeNotExpired(); @@ -1080,12 +1080,12 @@ NodeTemplate NodeTemplate::s_null(&expr::NodeValue::null() template NodeTemplate::NodeTemplate(const expr::NodeValue* ev) : d_nv(const_cast (ev)) { - Assert(d_nv != NULL, "Expecting a non-NULL expression value!"); + Assert(d_nv != NULL) << "Expecting a non-NULL expression value!"; if(ref_count) { d_nv->inc(); } else { - Assert(d_nv->d_rc > 0 || d_nv == &expr::NodeValue::null(), - "TNode constructed from NodeValue with rc == 0"); + Assert(d_nv->d_rc > 0 || d_nv == &expr::NodeValue::null()) + << "TNode constructed from NodeValue with rc == 0"; } } @@ -1095,37 +1095,37 @@ NodeTemplate::NodeTemplate(const expr::NodeValue* ev) : template NodeTemplate::NodeTemplate(const NodeTemplate& e) { - Assert(e.d_nv != NULL, "Expecting a non-NULL expression value!"); + Assert(e.d_nv != NULL) << "Expecting a non-NULL expression value!"; d_nv = e.d_nv; if(ref_count) { - Assert(d_nv->d_rc > 0, "Node constructed from TNode with rc == 0"); + Assert(d_nv->d_rc > 0) << "Node constructed from TNode with rc == 0"; d_nv->inc(); } else { // shouldn't ever fail - Assert(d_nv->d_rc > 0, "TNode constructed from Node with rc == 0"); + Assert(d_nv->d_rc > 0) << "TNode constructed from Node with rc == 0"; } } template NodeTemplate::NodeTemplate(const NodeTemplate& e) { - Assert(e.d_nv != NULL, "Expecting a non-NULL expression value!"); + Assert(e.d_nv != NULL) << "Expecting a non-NULL expression value!"; d_nv = e.d_nv; if(ref_count) { // shouldn't ever fail - Assert(d_nv->d_rc > 0, "Node constructed from Node with rc == 0"); + Assert(d_nv->d_rc > 0) << "Node constructed from Node with rc == 0"; d_nv->inc(); } else { - Assert(d_nv->d_rc > 0, "TNode constructed from TNode with rc == 0"); + Assert(d_nv->d_rc > 0) << "TNode constructed from TNode with rc == 0"; } } template NodeTemplate::NodeTemplate(const Expr& e) { - Assert(e.d_node != NULL, "Expecting a non-NULL expression value!"); - Assert(e.d_node->d_nv != NULL, "Expecting a non-NULL expression value!"); + Assert(e.d_node != NULL) << "Expecting a non-NULL expression value!"; + Assert(e.d_node->d_nv != NULL) << "Expecting a non-NULL expression value!"; d_nv = e.d_node->d_nv; // shouldn't ever fail - Assert(d_nv->d_rc > 0, "Node constructed from Expr with rc == 0"); + Assert(d_nv->d_rc > 0) << "Node constructed from Expr with rc == 0"; if(ref_count) { d_nv->inc(); } @@ -1133,10 +1133,10 @@ NodeTemplate::NodeTemplate(const Expr& e) { template NodeTemplate::~NodeTemplate() { - Assert(d_nv != NULL, "Expecting a non-NULL expression value!"); + Assert(d_nv != NULL) << "Expecting a non-NULL expression value!"; if(ref_count) { // shouldn't ever fail - Assert(d_nv->d_rc > 0, "Node reference count would be negative"); + Assert(d_nv->d_rc > 0) << "Node reference count would be negative"; d_nv->dec(); } } @@ -1147,29 +1147,28 @@ void NodeTemplate::assignNodeValue(expr::NodeValue* ev) { if(ref_count) { d_nv->inc(); } else { - Assert(d_nv->d_rc > 0, "TNode assigned to NodeValue with rc == 0"); + Assert(d_nv->d_rc > 0) << "TNode assigned to NodeValue with rc == 0"; } } template NodeTemplate& NodeTemplate:: operator=(const NodeTemplate& e) { - Assert(d_nv != NULL, "Expecting a non-NULL expression value!"); - Assert(e.d_nv != NULL, "Expecting a non-NULL expression value on RHS!"); + Assert(d_nv != NULL) << "Expecting a non-NULL expression value!"; + Assert(e.d_nv != NULL) << "Expecting a non-NULL expression value on RHS!"; if(__builtin_expect( ( d_nv != e.d_nv ), true )) { if(ref_count) { // shouldn't ever fail - Assert(d_nv->d_rc > 0, - "Node reference count would be negative"); + Assert(d_nv->d_rc > 0) << "Node reference count would be negative"; d_nv->dec(); } d_nv = e.d_nv; if(ref_count) { // shouldn't ever fail - Assert(d_nv->d_rc > 0, "Node assigned from Node with rc == 0"); + Assert(d_nv->d_rc > 0) << "Node assigned from Node with rc == 0"; d_nv->inc(); } else { - Assert(d_nv->d_rc > 0, "TNode assigned from TNode with rc == 0"); + Assert(d_nv->d_rc > 0) << "TNode assigned from TNode with rc == 0"; } } return *this; @@ -1178,21 +1177,21 @@ operator=(const NodeTemplate& e) { template NodeTemplate& NodeTemplate:: operator=(const NodeTemplate& e) { - Assert(d_nv != NULL, "Expecting a non-NULL expression value!"); - Assert(e.d_nv != NULL, "Expecting a non-NULL expression value on RHS!"); + Assert(d_nv != NULL) << "Expecting a non-NULL expression value!"; + Assert(e.d_nv != NULL) << "Expecting a non-NULL expression value on RHS!"; if(__builtin_expect( ( d_nv != e.d_nv ), true )) { if(ref_count) { // shouldn't ever fail - Assert(d_nv->d_rc > 0, "Node reference count would be negative"); + Assert(d_nv->d_rc > 0) << "Node reference count would be negative"; d_nv->dec(); } d_nv = e.d_nv; if(ref_count) { - Assert(d_nv->d_rc > 0, "Node assigned from TNode with rc == 0"); + Assert(d_nv->d_rc > 0) << "Node assigned from TNode with rc == 0"; d_nv->inc(); } else { // shouldn't ever happen - Assert(d_nv->d_rc > 0, "TNode assigned from Node with rc == 0"); + Assert(d_nv->d_rc > 0) << "TNode assigned from Node with rc == 0"; } } return *this; @@ -1273,9 +1272,9 @@ NodeTemplate::printAst(std::ostream& out, int indent) const { */ template NodeTemplate NodeTemplate::getOperator() const { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; assertTNodeNotExpired(); @@ -1301,8 +1300,7 @@ NodeTemplate NodeTemplate::getOperator() const { case kind::metakind::NULLARY_OPERATOR: IllegalArgument(*this, "getOperator() called on Node with NULLARY_OPERATOR-kinded kind"); - default: - Unhandled(mk); + default: Unhandled() << mk; } } @@ -1319,9 +1317,9 @@ inline bool NodeTemplate::hasOperator() const { template TypeNode NodeTemplate::getType(bool check) const { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; assertTNodeNotExpired(); @@ -1409,8 +1407,9 @@ NodeTemplate::substitute(Iterator1 nodesBegin, } // otherwise compute - Assert( std::distance(nodesBegin, nodesEnd) == std::distance(replacementsBegin, replacementsEnd), - "Substitution iterator ranges must be equal size" ); + Assert(std::distance(nodesBegin, nodesEnd) + == std::distance(replacementsBegin, replacementsEnd)) + << "Substitution iterator ranges must be equal size"; Iterator1 j = find(nodesBegin, nodesEnd, TNode(*this)); if(j != nodesEnd) { Iterator2 b = replacementsBegin; diff --git a/src/expr/node_algorithm.cpp b/src/expr/node_algorithm.cpp index 59e3d3b03..eda4dadd2 100644 --- a/src/expr/node_algorithm.cpp +++ b/src/expr/node_algorithm.cpp @@ -436,8 +436,8 @@ Node substituteCaptureAvoiding(TNode n, std::vector visit; TNode curr; visit.push_back(n); - Assert(src.size() == dest.size(), - "Substitution domain and range must be equal size"); + Assert(src.size() == dest.size()) + << "Substitution domain and range must be equal size"; do { curr = visit.back(); diff --git a/src/expr/node_builder.h b/src/expr/node_builder.h index b5e99c6fd..b6594a933 100644 --- a/src/expr/node_builder.h +++ b/src/expr/node_builder.h @@ -170,13 +170,12 @@ namespace CVC4 { class NodeManager; }/* CVC4 namespace */ -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "expr/kind.h" #include "expr/metakind.h" #include "expr/node_value.h" - namespace CVC4 { // Sometimes it's useful for debugging to output a NodeBuilder that @@ -231,10 +230,9 @@ class NodeBuilder { * Set this NodeBuilder to the `used' state. */ inline void setUsed() { - Assert(!isUsed(), "Internal error: bad `used' state in NodeBuilder!"); - Assert(d_inlineNv.d_nchildren == 0 && - d_nvMaxChildren == nchild_thresh, - "Internal error: bad `inline' state in NodeBuilder!"); + Assert(!isUsed()) << "Internal error: bad `used' state in NodeBuilder!"; + Assert(d_inlineNv.d_nchildren == 0 && d_nvMaxChildren == nchild_thresh) + << "Internal error: bad `inline' state in NodeBuilder!"; d_nv = NULL; } @@ -243,10 +241,9 @@ class NodeBuilder { * from clear(). */ inline void setUnused() { - Assert(isUsed(), "Internal error: bad `used' state in NodeBuilder!"); - Assert(d_inlineNv.d_nchildren == 0 && - d_nvMaxChildren == nchild_thresh, - "Internal error: bad `inline' state in NodeBuilder!"); + Assert(isUsed()) << "Internal error: bad `used' state in NodeBuilder!"; + Assert(d_inlineNv.d_nchildren == 0 && d_nvMaxChildren == nchild_thresh) + << "Internal error: bad `inline' state in NodeBuilder!"; d_nv = &d_inlineNv; } @@ -381,9 +378,8 @@ public: d_nv(&d_inlineNv), d_nm(NodeManager::currentNM()), d_nvMaxChildren(nchild_thresh) { - - Assert(k != kind::NULL_EXPR && k != kind::UNDEFINED_KIND, - "illegal Node-building kind"); + Assert(k != kind::NULL_EXPR && k != kind::UNDEFINED_KIND) + << "illegal Node-building kind"; d_inlineNv.d_id = 1; // have a kind already d_inlineNv.d_rc = 0; @@ -406,9 +402,8 @@ public: d_nv(&d_inlineNv), d_nm(nm), d_nvMaxChildren(nchild_thresh) { - - Assert(k != kind::NULL_EXPR && k != kind::UNDEFINED_KIND, - "illegal Node-building kind"); + Assert(k != kind::NULL_EXPR && k != kind::UNDEFINED_KIND) + << "illegal Node-building kind"; d_inlineNv.d_id = 1; // have a kind already d_inlineNv.d_rc = 0; @@ -461,48 +456,48 @@ public: /** Get the begin-const-iterator of this Node-under-construction. */ inline const_iterator begin() const { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() != kind::UNDEFINED_KIND, - "Iterators over NodeBuilder<> are undefined " - "until a Kind is set"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() != kind::UNDEFINED_KIND) + << "Iterators over NodeBuilder<> are undefined " + "until a Kind is set"; return d_nv->begin< NodeTemplate >(); } /** Get the end-const-iterator of this Node-under-construction. */ inline const_iterator end() const { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() != kind::UNDEFINED_KIND, - "Iterators over NodeBuilder<> are undefined " - "until a Kind is set"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() != kind::UNDEFINED_KIND) + << "Iterators over NodeBuilder<> are undefined " + "until a Kind is set"; return d_nv->end< NodeTemplate >(); } /** Get the kind of this Node-under-construction. */ inline Kind getKind() const { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; return d_nv->getKind(); } /** Get the kind of this Node-under-construction. */ inline kind::MetaKind getMetaKind() const { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() != kind::UNDEFINED_KIND, - "The metakind of a NodeBuilder<> is undefined " - "until a Kind is set"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() != kind::UNDEFINED_KIND) + << "The metakind of a NodeBuilder<> is undefined " + "until a Kind is set"; return d_nv->getMetaKind(); } /** Get the current number of children of this Node-under-construction. */ inline unsigned getNumChildren() const { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() != kind::UNDEFINED_KIND, - "The number of children of a NodeBuilder<> is undefined " - "until a Kind is set"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() != kind::UNDEFINED_KIND) + << "The number of children of a NodeBuilder<> is undefined " + "until a Kind is set"; return d_nv->getNumChildren(); } @@ -512,15 +507,15 @@ public: * that is of PARAMETERIZED metakind. */ inline Node getOperator() const { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() != kind::UNDEFINED_KIND, - "NodeBuilder<> operator access is not permitted " - "until a Kind is set"); - Assert(getMetaKind() == kind::metakind::PARAMETERIZED, - "NodeBuilder<> operator access is only permitted " - "on parameterized kinds, not `%s'", - kind::kindToString(getKind()).c_str()); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() != kind::UNDEFINED_KIND) + << "NodeBuilder<> operator access is not permitted " + "until a Kind is set"; + Assert(getMetaKind() == kind::metakind::PARAMETERIZED) + << "NodeBuilder<> operator access is only permitted " + "on parameterized kinds, not `" + << getKind() << "'"; return Node(d_nv->getOperator()); } @@ -529,13 +524,13 @@ public: * if this NodeBuilder is unused and has a defined kind. */ inline Node getChild(int i) const { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() != kind::UNDEFINED_KIND, - "NodeBuilder<> child access is not permitted " - "until a Kind is set"); - Assert(i >= 0 && unsigned(i) < d_nv->getNumChildren(), - "index out of range for NodeBuilder::getChild()"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() != kind::UNDEFINED_KIND) + << "NodeBuilder<> child access is not permitted " + "until a Kind is set"; + Assert(i >= 0 && unsigned(i) < d_nv->getNumChildren()) + << "index out of range for NodeBuilder::getChild()"; return Node(d_nv->getChild(i)); } @@ -562,12 +557,12 @@ public: /** Set the Kind of this Node-under-construction. */ inline NodeBuilder& operator<<(const Kind& k) { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() == kind::UNDEFINED_KIND || d_nv->d_id == 0, - "can't redefine the Kind of a NodeBuilder"); - Assert(d_nv->d_id == 0, - "internal inconsistency with NodeBuilder: d_id != 0"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() == kind::UNDEFINED_KIND || d_nv->d_id == 0) + << "can't redefine the Kind of a NodeBuilder"; + Assert(d_nv->d_id == 0) + << "internal inconsistency with NodeBuilder: d_id != 0"; AssertArgument(k != kind::UNDEFINED_KIND && k != kind::NULL_EXPR && k < kind::LAST_KIND, @@ -592,8 +587,8 @@ public: * append the given Node as a child. Otherwise, simply append. */ NodeBuilder& operator<<(TNode n) { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; // This test means: we didn't have a Kind at the beginning (on // NodeBuilder construction or at the last clear()), but we do // now. That means we appended a Kind with operator<<(Kind), @@ -611,8 +606,8 @@ public: * append the given Node as a child. Otherwise, simply append. */ NodeBuilder& operator<<(TypeNode n) { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; // This test means: we didn't have a Kind at the beginning (on // NodeBuilder construction or at the last clear()), but we do // now. That means we appended a Kind with operator<<(Kind), @@ -628,8 +623,8 @@ public: /** Append a sequence of children to this TypeNode-under-construction. */ inline NodeBuilder& append(const std::vector& children) { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; return append(children.begin(), children.end()); } @@ -637,16 +632,16 @@ public: template inline NodeBuilder& append(const std::vector >& children) { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; return append(children.begin(), children.end()); } /** Append a sequence of children to this Node-under-construction. */ template NodeBuilder& append(const Iterator& begin, const Iterator& end) { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; for(Iterator i = begin; i != end; ++i) { append(*i); } @@ -655,9 +650,9 @@ public: /** Append a child to this Node-under-construction. */ NodeBuilder& append(TNode n) { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(!n.isNull(), "Cannot use NULL Node as a child of a Node"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(!n.isNull()) << "Cannot use NULL Node as a child of a Node"; if(n.getKind() == kind::BUILTIN) { return *this << NodeManager::operatorToKind(n); } @@ -671,9 +666,9 @@ public: /** Append a child to this Node-under-construction. */ NodeBuilder& append(const TypeNode& typeNode) { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(!typeNode.isNull(), "Cannot use NULL Node as a child of a Node"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(!typeNode.isNull()) << "Cannot use NULL Node as a child of a Node"; allocateNvIfNecessaryForAppend(); expr::NodeValue* nv = typeNode.d_nv; nv->inc(); @@ -751,7 +746,7 @@ namespace CVC4 { template void NodeBuilder::clear(Kind k) { - Assert(k != kind::NULL_EXPR, "illegal Node-building clear kind"); + Assert(k != kind::NULL_EXPR) << "illegal Node-building clear kind"; if(__builtin_expect( ( nvIsAllocated() ), false )) { dealloc(); @@ -774,13 +769,11 @@ void NodeBuilder::clear(Kind k) { template void NodeBuilder::realloc(size_t toSize) { - AlwaysAssert(toSize > d_nvMaxChildren, - "attempt to realloc() a NodeBuilder to a smaller/equal size!"); - Assert(toSize < (static_cast(1) << expr::NodeValue::NBITS_NCHILDREN), - "attempt to realloc() a NodeBuilder to size %lu (beyond hard limit of " - "%u)", - toSize, - expr::NodeValue::MAX_CHILDREN); + AlwaysAssert(toSize > d_nvMaxChildren) + << "attempt to realloc() a NodeBuilder to a smaller/equal size!"; + Assert(toSize < (static_cast(1) << expr::NodeValue::NBITS_NCHILDREN)) + << "attempt to realloc() a NodeBuilder to size " << toSize + << " (beyond hard limit of " << expr::NodeValue::MAX_CHILDREN << ")"; if(__builtin_expect( ( nvIsAllocated() ), false )) { // Ensure d_nv is not modified on allocation failure @@ -793,7 +786,7 @@ void NodeBuilder::realloc(size_t toSize) { throw std::bad_alloc(); } d_nvMaxChildren = toSize; - Assert(d_nvMaxChildren == toSize);//overflow check + Assert(d_nvMaxChildren == toSize); // overflow check // Here, the copy (between two heap-allocated buffers) has already // been done for us by the std::realloc(). d_nv = newBlock; @@ -806,7 +799,7 @@ void NodeBuilder::realloc(size_t toSize) { throw std::bad_alloc(); } d_nvMaxChildren = toSize; - Assert(d_nvMaxChildren == toSize);//overflow check + Assert(d_nvMaxChildren == toSize); // overflow check d_nv = newBlock; d_nv->d_id = d_inlineNv.d_id; @@ -825,9 +818,9 @@ void NodeBuilder::realloc(size_t toSize) { template void NodeBuilder::dealloc() { - Assert( nvIsAllocated(), - "Internal error: NodeBuilder: dealloc() called without a " - "private NodeBuilder-allocated buffer" ); + Assert(nvIsAllocated()) + << "Internal error: NodeBuilder: dealloc() called without a " + "private NodeBuilder-allocated buffer"; for(expr::NodeValue::nv_iterator i = d_nv->nv_begin(); i != d_nv->nv_end(); @@ -842,9 +835,9 @@ void NodeBuilder::dealloc() { template void NodeBuilder::decrRefCounts() { - Assert( !nvIsAllocated(), - "Internal error: NodeBuilder: decrRefCounts() called with a " - "private NodeBuilder-allocated buffer" ); + Assert(!nvIsAllocated()) + << "Internal error: NodeBuilder: decrRefCounts() called with a " + "private NodeBuilder-allocated buffer"; for(expr::NodeValue::nv_iterator i = d_inlineNv.nv_begin(); i != d_inlineNv.nv_end(); @@ -918,10 +911,10 @@ NodeBuilder::operator TypeNode() const { template expr::NodeValue* NodeBuilder::constructNV() { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() != kind::UNDEFINED_KIND, - "Can't make an expression of an undefined kind!"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() != kind::UNDEFINED_KIND) + << "Can't make an expression of an undefined kind!"; // NOTE: The comments in this function refer to the cases in the // file comments at the top of this file. @@ -933,12 +926,12 @@ expr::NodeValue* NodeBuilder::constructNV() { * and we don't keep VARIABLE-kinded Nodes in the NodeManager * pool. */ - Assert( ! nvIsAllocated(), - "internal NodeBuilder error: " - "VARIABLE-kinded NodeBuilder is heap-allocated !?" ); - Assert( d_inlineNv.d_nchildren == 0, - "improperly-formed VARIABLE-kinded NodeBuilder: " - "no children permitted" ); + Assert(!nvIsAllocated()) + << "internal NodeBuilder error: " + "VARIABLE-kinded NodeBuilder is heap-allocated !?"; + Assert(d_inlineNv.d_nchildren == 0) + << "improperly-formed VARIABLE-kinded NodeBuilder: " + "no children permitted"; // we have to copy the inline NodeValue out expr::NodeValue* nv = (expr::NodeValue*) @@ -963,20 +956,20 @@ expr::NodeValue* NodeBuilder::constructNV() { } // check that there are the right # of children for this kind - Assert(getMetaKind() != kind::metakind::CONSTANT, - "Cannot make Nodes with NodeBuilder that have CONSTANT-kinded kinds"); - Assert(getNumChildren() >= kind::metakind::getLowerBoundForKind(getKind()), - "Nodes with kind %s must have at least %u children (the one under " - "construction has %u)", - kind::kindToString(getKind()).c_str(), - kind::metakind::getLowerBoundForKind(getKind()), - getNumChildren()); - Assert(getNumChildren() <= kind::metakind::getUpperBoundForKind(getKind()), - "Nodes with kind %s must have at most %u children (the one under " - "construction has %u)", - kind::kindToString(getKind()).c_str(), - kind::metakind::getUpperBoundForKind(getKind()), - getNumChildren()); + Assert(getMetaKind() != kind::metakind::CONSTANT) + << "Cannot make Nodes with NodeBuilder that have CONSTANT-kinded kinds"; + Assert(getNumChildren() >= kind::metakind::getLowerBoundForKind(getKind())) + << "Nodes with kind " << getKind() << " must have at least " + << kind::metakind::getLowerBoundForKind(getKind()) + << " children (the one under " + "construction has " + << getNumChildren() << ")"; + Assert(getNumChildren() <= kind::metakind::getUpperBoundForKind(getKind())) + << "Nodes with kind " << getKind() << " must have at most " + << kind::metakind::getUpperBoundForKind(getKind()) + << " children (the one under " + "construction has " + << getNumChildren() << ")"; // Implementation differs depending on whether the NodeValue was // malloc'ed or not and whether or not it's in the already-been-seen @@ -1098,10 +1091,10 @@ expr::NodeValue* NodeBuilder::constructNV() { // CONST VERSION OF NODE EXTRACTOR template expr::NodeValue* NodeBuilder::constructNV() const { - Assert(!isUsed(), "NodeBuilder is one-shot only; " - "attempt to access it after conversion"); - Assert(getKind() != kind::UNDEFINED_KIND, - "Can't make an expression of an undefined kind!"); + Assert(!isUsed()) << "NodeBuilder is one-shot only; " + "attempt to access it after conversion"; + Assert(getKind() != kind::UNDEFINED_KIND) + << "Can't make an expression of an undefined kind!"; // NOTE: The comments in this function refer to the cases in the // file comments at the top of this file. @@ -1113,12 +1106,12 @@ expr::NodeValue* NodeBuilder::constructNV() const { * and we don't keep VARIABLE-kinded Nodes in the NodeManager * pool. */ - Assert( ! nvIsAllocated(), - "internal NodeBuilder error: " - "VARIABLE-kinded NodeBuilder is heap-allocated !?" ); - Assert( d_inlineNv.d_nchildren == 0, - "improperly-formed VARIABLE-kinded NodeBuilder: " - "no children permitted" ); + Assert(!nvIsAllocated()) + << "internal NodeBuilder error: " + "VARIABLE-kinded NodeBuilder is heap-allocated !?"; + Assert(d_inlineNv.d_nchildren == 0) + << "improperly-formed VARIABLE-kinded NodeBuilder: " + "no children permitted"; // we have to copy the inline NodeValue out expr::NodeValue* nv = (expr::NodeValue*) @@ -1138,29 +1131,27 @@ expr::NodeValue* NodeBuilder::constructNV() const { } // check that there are the right # of children for this kind - Assert(getMetaKind() != kind::metakind::CONSTANT, - "Cannot make Nodes with NodeBuilder that have CONSTANT-kinded kinds"); - Assert(getNumChildren() >= kind::metakind::getLowerBoundForKind(getKind()), - "Nodes with kind %s must have at least %u children (the one under " - "construction has %u)", - kind::kindToString(getKind()).c_str(), - kind::metakind::getLowerBoundForKind(getKind()), - getNumChildren()); - Assert(getNumChildren() <= kind::metakind::getUpperBoundForKind(getKind()), - "Nodes with kind %s must have at most %u children (the one under " - "construction has %u)", - kind::kindToString(getKind()).c_str(), - kind::metakind::getUpperBoundForKind(getKind()), - getNumChildren()); + Assert(getMetaKind() != kind::metakind::CONSTANT) + << "Cannot make Nodes with NodeBuilder that have CONSTANT-kinded kinds"; + Assert(getNumChildren() >= kind::metakind::getLowerBoundForKind(getKind())) + << "Nodes with kind " << getKind() << " must have at least " + << kind::metakind::getLowerBoundForKind(getKind()) + << " children (the one under " + "construction has " + << getNumChildren() << ")"; + Assert(getNumChildren() <= kind::metakind::getUpperBoundForKind(getKind())) + << "Nodes with kind " << getKind() << " must have at most " + << kind::metakind::getUpperBoundForKind(getKind()) + << " children (the one under " + "construction has " + << getNumChildren() << ")"; #if 0 // if the kind is PARAMETERIZED, check that the operator is correctly-kinded Assert(kind::metaKindOf(getKind()) != kind::metakind::PARAMETERIZED || - NodeManager::operatorToKind(getOperator()) == getKind(), - "Attempted to construct a parameterized kind `%s' with " - "incorrectly-kinded operator `%s'", - kind::kindToString(getKind()).c_str(), - kind::kindToString(getOperator().getKind()).c_str()); + NodeManager::operatorToKind(getOperator()) == getKind()) << + "Attempted to construct a parameterized kind `"<< getKind() <<"' with " + "incorrectly-kinded operator `"<< getOperator().getKind() <<"'"; #endif /* 0 */ // Implementation differs depending on whether the NodeValue was @@ -1298,10 +1289,12 @@ void NodeBuilder::internalCopy(const NodeBuilder& nb) { Assert(nb.d_nvMaxChildren <= d_nvMaxChildren); Assert(nb.d_nv->nv_end() >= nb.d_nv->nv_begin()); - Assert((size_t)(nb.d_nv->nv_end() - nb.d_nv->nv_begin()) <= d_nvMaxChildren, "realloced:%s, d_nvMax:%u, size:%u, nc:%u", realloced ? "true" : "false", d_nvMaxChildren, nb.d_nv->nv_end() - nb.d_nv->nv_begin(), nb.d_nv->getNumChildren()); - std::copy(nb.d_nv->nv_begin(), - nb.d_nv->nv_end(), - d_nv->nv_begin()); + Assert((size_t)(nb.d_nv->nv_end() - nb.d_nv->nv_begin()) <= d_nvMaxChildren) + << "realloced:" << (realloced ? "true" : "false") + << ", d_nvMax:" << d_nvMaxChildren + << ", size:" << nb.d_nv->nv_end() - nb.d_nv->nv_begin() + << ", nc:" << nb.d_nv->getNumChildren(); + std::copy(nb.d_nv->nv_begin(), nb.d_nv->nv_end(), d_nv->nv_begin()); d_nv->d_nchildren = nb.d_nv->d_nchildren; diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp index 66d597a36..d66225961 100644 --- a/src/expr/node_manager.cpp +++ b/src/expr/node_manager.cpp @@ -21,7 +21,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/listener.h" #include "expr/attribute.h" #include "expr/node_manager_attributes.h" @@ -29,8 +29,8 @@ #include "expr/type_checker.h" #include "options/options.h" #include "options/smt_options.h" -#include "util/statistics_registry.h" #include "util/resource_manager.h" +#include "util/statistics_registry.h" using namespace std; using namespace CVC4::expr; @@ -195,7 +195,7 @@ NodeManager::~NodeManager() { } d_ownedDatatypes.clear(); - Assert(!d_attrManager->inGarbageCollection() ); + Assert(!d_attrManager->inGarbageCollection()); std::vector order = TopologicalSort(d_maxedOut); d_maxedOut.clear(); @@ -253,7 +253,7 @@ unsigned NodeManager::registerDatatype(Datatype* dt) { } const Datatype & NodeManager::getDatatypeForIndex( unsigned index ) const{ - Assert( index& children, uint32_t flags) { - Assert(constructor.getKind() == kind::SORT_TYPE && - constructor.getNumChildren() == 0, - "expected a sort constructor"); - Assert(children.size() > 0, "expected non-zero # of children"); - Assert( hasAttribute(constructor.d_nv, expr::SortArityAttr()) && - hasAttribute(constructor.d_nv, expr::VarNameAttr()), - "expected a sort constructor" ); + Assert(constructor.getKind() == kind::SORT_TYPE + && constructor.getNumChildren() == 0) + << "expected a sort constructor"; + Assert(children.size() > 0) << "expected non-zero # of children"; + Assert(hasAttribute(constructor.d_nv, expr::SortArityAttr()) + && hasAttribute(constructor.d_nv, expr::VarNameAttr())) + << "expected a sort constructor"; std::string name = getAttribute(constructor.d_nv, expr::VarNameAttr()); - Assert(getAttribute(constructor.d_nv, expr::SortArityAttr()) == children.size(), - "arity mismatch in application of sort constructor"); + Assert(getAttribute(constructor.d_nv, expr::SortArityAttr()) + == children.size()) + << "arity mismatch in application of sort constructor"; NodeBuilder<> nb(this, kind::SORT_TYPE); Node sortTag = Node(constructor.d_nv->d_children[0]); nb << sortTag; @@ -706,7 +708,7 @@ Node* NodeManager::mkBoundVarPtr(const std::string& name, } Node NodeManager::getBoundVarListForFunctionType( TypeNode tn ) { - Assert( tn.isFunction() ); + Assert(tn.isFunction()); Node bvl = tn.getAttribute(LambdaBoundVarListAttr()); if( bvl.isNull() ){ std::vector< Node > vars; @@ -777,7 +779,7 @@ Node NodeManager::mkNullaryOperator(const TypeNode& type, Kind k) { setAttribute(n, TypeAttr(), type); //setAttribute(n, TypeCheckedAttr(), true); d_unique_vars[k][type] = n; - Assert( n.getMetaKind() == kind::metakind::NULLARY_OPERATOR ); + Assert(n.getMetaKind() == kind::metakind::NULLARY_OPERATOR); return n; }else{ return it->second; diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h index 510e6d585..a3fd50d8c 100644 --- a/src/expr/node_manager.h +++ b/src/expr/node_manager.h @@ -32,6 +32,7 @@ #include #include +#include "base/check.h" #include "expr/kind.h" #include "expr/metakind.h" #include "expr/node_value.h" @@ -411,14 +412,16 @@ public: /** Subscribe to NodeManager events */ void subscribeEvents(NodeManagerListener* listener) { - Assert(std::find(d_listeners.begin(), d_listeners.end(), listener) == d_listeners.end(), "listener already subscribed"); + Assert(std::find(d_listeners.begin(), d_listeners.end(), listener) + == d_listeners.end()) + << "listener already subscribed"; d_listeners.push_back(listener); } /** Unsubscribe from NodeManager events */ void unsubscribeEvents(NodeManagerListener* listener) { std::vector::iterator elt = std::find(d_listeners.begin(), d_listeners.end(), listener); - Assert(elt != d_listeners.end(), "listener not subscribed"); + Assert(elt != d_listeners.end()) << "listener not subscribed"; d_listeners.erase(elt); } @@ -1177,14 +1180,14 @@ inline expr::NodeValue* NodeManager::poolLookup(expr::NodeValue* nv) const { } inline void NodeManager::poolInsert(expr::NodeValue* nv) { - Assert(d_nodeValuePool.find(nv) == d_nodeValuePool.end(), - "NodeValue already in the pool!"); + Assert(d_nodeValuePool.find(nv) == d_nodeValuePool.end()) + << "NodeValue already in the pool!"; d_nodeValuePool.insert(nv);// FIXME multithreading } inline void NodeManager::poolRemove(expr::NodeValue* nv) { - Assert(d_nodeValuePool.find(nv) != d_nodeValuePool.end(), - "NodeValue is not in the pool!"); + Assert(d_nodeValuePool.find(nv) != d_nodeValuePool.end()) + << "NodeValue is not in the pool!"; d_nodeValuePool.erase(nv);// FIXME multithreading } @@ -1240,8 +1243,7 @@ inline bool NodeManager::hasOperator(Kind k) { case kind::metakind::CONSTANT: return false; - default: - Unhandled(mk); + default: Unhandled() << mk; } } diff --git a/src/expr/node_self_iterator.h b/src/expr/node_self_iterator.h index 7e0478acc..79df7691c 100644 --- a/src/expr/node_self_iterator.h +++ b/src/expr/node_self_iterator.h @@ -21,7 +21,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/node.h" namespace CVC4 { @@ -53,12 +53,12 @@ public: };/* class NodeSelfIterator */ inline NodeSelfIterator NodeSelfIterator::self(TNode n) { - Assert(!n.isNull(), "Self-iteration over null nodes not permitted."); + Assert(!n.isNull()) << "Self-iteration over null nodes not permitted."; return NodeSelfIterator(n); } inline NodeSelfIterator NodeSelfIterator::selfEnd(TNode n) { - Assert(!n.isNull(), "Self-iteration over null nodes not permitted."); + Assert(!n.isNull()) << "Self-iteration over null nodes not permitted."; return NodeSelfIterator(n.end()); } @@ -70,13 +70,13 @@ inline NodeSelfIterator::NodeSelfIterator() : inline NodeSelfIterator::NodeSelfIterator(Node node) : d_node(node), d_child() { - Assert(!node.isNull(), "Self-iteration over null nodes not permitted."); + Assert(!node.isNull()) << "Self-iteration over null nodes not permitted."; } inline NodeSelfIterator::NodeSelfIterator(TNode node) : d_node(node), d_child() { - Assert(!node.isNull(), "Self-iteration over null nodes not permitted."); + Assert(!node.isNull()) << "Self-iteration over null nodes not permitted."; } inline NodeSelfIterator::NodeSelfIterator(const NodeSelfIterator& i) : diff --git a/src/expr/node_value.h b/src/expr/node_value.h index 9d1a4f98e..2c52c46be 100644 --- a/src/expr/node_value.h +++ b/src/expr/node_value.h @@ -421,18 +421,18 @@ inline void NodeValue::decrRefCounts() { } inline void NodeValue::inc() { - Assert(!isBeingDeleted(), - "NodeValue is currently being deleted " - "and increment is being called on it. Don't Do That!"); + Assert(!isBeingDeleted()) + << "NodeValue is currently being deleted " + "and increment is being called on it. Don't Do That!"; // FIXME multithreading if (__builtin_expect((d_rc < MAX_RC - 1), true)) { ++d_rc; } else if (__builtin_expect((d_rc == MAX_RC - 1), false)) { ++d_rc; - Assert(NodeManager::currentNM() != NULL, - "No current NodeManager on incrementing of NodeValue: " + Assert(NodeManager::currentNM() != NULL) + << "No current NodeManager on incrementing of NodeValue: " "maybe a public CVC4 interface function is missing a " - "NodeManagerScope ?"); + "NodeManagerScope ?"; NodeManager::currentNM()->markRefCountMaxedOut(this); } } @@ -442,10 +442,10 @@ inline void NodeValue::dec() { if(__builtin_expect( ( d_rc < MAX_RC ), true )) { --d_rc; if(__builtin_expect( ( d_rc == 0 ), false )) { - Assert(NodeManager::currentNM() != NULL, - "No current NodeManager on destruction of NodeValue: " + Assert(NodeManager::currentNM() != NULL) + << "No current NodeManager on destruction of NodeValue: " "maybe a public CVC4 interface function is missing a " - "NodeManagerScope ?"); + "NodeManagerScope ?"; NodeManager::currentNM()->markForDeletion(this); } } diff --git a/src/expr/record.cpp b/src/expr/record.cpp index 0303ff705..074205d04 100644 --- a/src/expr/record.cpp +++ b/src/expr/record.cpp @@ -16,7 +16,7 @@ #include "expr/record.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "expr/expr.h" #include "expr/type.h" diff --git a/src/expr/type_checker_template.cpp b/src/expr/type_checker_template.cpp index 9ca5f00cc..375fbd515 100644 --- a/src/expr/type_checker_template.cpp +++ b/src/expr/type_checker_template.cpp @@ -48,7 +48,7 @@ ${typerules} default: Debug("getType") << "FAILURE" << std::endl; - Unhandled(n.getKind()); + Unhandled() << n.getKind(); } nodeManager->setAttribute(n, TypeAttr(), typeNode); @@ -61,14 +61,16 @@ ${typerules} bool TypeChecker::computeIsConst(NodeManager* nodeManager, TNode n) { - Assert(n.getMetaKind() == kind::metakind::OPERATOR || n.getMetaKind() == kind::metakind::PARAMETERIZED || n.getMetaKind() == kind::metakind::NULLARY_OPERATOR); + Assert(n.getMetaKind() == kind::metakind::OPERATOR + || n.getMetaKind() == kind::metakind::PARAMETERIZED + || n.getMetaKind() == kind::metakind::NULLARY_OPERATOR); switch(n.getKind()) { ${construles} -#line 70 "${template}" +#line 72 "${template}" - default:; + default:; } return false; @@ -77,14 +79,16 @@ ${construles} bool TypeChecker::neverIsConst(NodeManager* nodeManager, TNode n) { - Assert(n.getMetaKind() == kind::metakind::OPERATOR || n.getMetaKind() == kind::metakind::PARAMETERIZED || n.getMetaKind() == kind::metakind::NULLARY_OPERATOR); + Assert(n.getMetaKind() == kind::metakind::OPERATOR + || n.getMetaKind() == kind::metakind::PARAMETERIZED + || n.getMetaKind() == kind::metakind::NULLARY_OPERATOR); switch(n.getKind()) { ${neverconstrules} -#line 86 "${template}" +#line 90 "${template}" - default:; + default:; } return true; diff --git a/src/expr/type_node.cpp b/src/expr/type_node.cpp index 9db29f115..b3c8592ed 100644 --- a/src/expr/type_node.cpp +++ b/src/expr/type_node.cpp @@ -377,14 +377,14 @@ bool TypeNode::isRecord() const { size_t TypeNode::getTupleLength() const { Assert(isTuple()); const Datatype& dt = getDatatype(); - Assert(dt.getNumConstructors()==1); + Assert(dt.getNumConstructors() == 1); return dt[0].getNumArgs(); } vector TypeNode::getTupleTypes() const { Assert(isTuple()); const Datatype& dt = getDatatype(); - Assert(dt.getNumConstructors()==1); + Assert(dt.getNumConstructors() == 1); vector types; for(unsigned i = 0; i < dt[0].getNumArgs(); ++i) { types.push_back(TypeNode::fromType(dt[0][i].getRangeType())); @@ -444,9 +444,9 @@ TypeNode TypeNode::mostCommonTypeNode(TypeNode t0, TypeNode t1){ } TypeNode TypeNode::commonTypeNode(TypeNode t0, TypeNode t1, bool isLeast) { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; Assert(!t0.isNull()); Assert(!t1.isNull()); @@ -506,15 +506,17 @@ TypeNode TypeNode::commonTypeNode(TypeNode t0, TypeNode t1, bool isLeast) { } } case kind::SEXPR_TYPE: - Unimplemented("haven't implemented leastCommonType for symbolic expressions yet"); + Unimplemented() + << "haven't implemented leastCommonType for symbolic expressions yet"; default: - Unimplemented("don't have a commonType for types `%s' and `%s'", t0.toString().c_str(), t1.toString().c_str()); + Unimplemented() << "don't have a commonType for types `" << t0 << "' and `" + << t1 << "'"; } } Node TypeNode::getEnsureTypeCondition( Node n, TypeNode tn ) { TypeNode ntn = n.getType(); - Assert( ntn.isComparableTo( tn ) ); + Assert(ntn.isComparableTo(tn)); if( !ntn.isSubtypeOf( tn ) ){ if( tn.isInteger() ){ if( tn.isSubtypeOf( ntn ) ){ diff --git a/src/expr/type_node.h b/src/expr/type_node.h index c5e1f400c..1fcd64fc7 100644 --- a/src/expr/type_node.h +++ b/src/expr/type_node.h @@ -29,7 +29,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/kind.h" #include "expr/metakind.h" #include "util/cardinality.h" @@ -752,8 +752,8 @@ TypeNode TypeNode::substitute(Iterator1 typesBegin, } // otherwise compute - Assert( typesEnd - typesBegin == replacementsEnd - replacementsBegin, - "Substitution iterator ranges must be equal size" ); + Assert(typesEnd - typesBegin == replacementsEnd - replacementsBegin) + << "Substitution iterator ranges must be equal size"; Iterator1 j = find(typesBegin, typesEnd, *this); if(j != typesEnd) { TypeNode tn = *(replacementsBegin + (j - typesBegin)); @@ -792,18 +792,18 @@ inline const T& TypeNode::getConst() const { inline TypeNode::TypeNode(const expr::NodeValue* ev) : d_nv(const_cast (ev)) { - Assert(d_nv != NULL, "Expecting a non-NULL expression value!"); + Assert(d_nv != NULL) << "Expecting a non-NULL expression value!"; d_nv->inc(); } inline TypeNode::TypeNode(const TypeNode& typeNode) { - Assert(typeNode.d_nv != NULL, "Expecting a non-NULL expression value!"); + Assert(typeNode.d_nv != NULL) << "Expecting a non-NULL expression value!"; d_nv = typeNode.d_nv; d_nv->inc(); } inline TypeNode::~TypeNode() { - Assert(d_nv != NULL, "Expecting a non-NULL expression value!"); + Assert(d_nv != NULL) << "Expecting a non-NULL expression value!"; d_nv->dec(); } @@ -813,9 +813,9 @@ inline void TypeNode::assignNodeValue(expr::NodeValue* ev) { } inline TypeNode& TypeNode::operator=(const TypeNode& typeNode) { - Assert(d_nv != NULL, "Expecting a non-NULL expression value!"); - Assert(typeNode.d_nv != NULL, - "Expecting a non-NULL expression value on RHS!"); + Assert(d_nv != NULL) << "Expecting a non-NULL expression value!"; + Assert(typeNode.d_nv != NULL) + << "Expecting a non-NULL expression value on RHS!"; if(__builtin_expect( ( d_nv != typeNode.d_nv ), true )) { d_nv->dec(); d_nv = typeNode.d_nv; @@ -827,35 +827,35 @@ inline TypeNode& TypeNode::operator=(const TypeNode& typeNode) { template inline typename AttrKind::value_type TypeNode:: getAttribute(const AttrKind&) const { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; return NodeManager::currentNM()->getAttribute(d_nv, AttrKind()); } template inline bool TypeNode:: hasAttribute(const AttrKind&) const { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; return NodeManager::currentNM()->hasAttribute(d_nv, AttrKind()); } template inline bool TypeNode::getAttribute(const AttrKind&, typename AttrKind::value_type& ret) const { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; return NodeManager::currentNM()->getAttribute(d_nv, AttrKind(), ret); } template inline void TypeNode:: setAttribute(const AttrKind&, const typename AttrKind::value_type& value) { - Assert( NodeManager::currentNM() != NULL, - "There is no current CVC4::NodeManager associated to this thread.\n" - "Perhaps a public-facing function is missing a NodeManagerScope ?" ); + Assert(NodeManager::currentNM() != NULL) + << "There is no current CVC4::NodeManager associated to this thread.\n" + "Perhaps a public-facing function is missing a NodeManagerScope ?"; NodeManager::currentNM()->setAttribute(d_nv, AttrKind(), value); } @@ -1022,7 +1022,7 @@ inline const Datatype& TypeNode::getDatatype() const { DatatypeIndexConstant dic = getConst(); return NodeManager::currentNM()->getDatatypeForIndex( dic.getIndex() ); }else{ - Assert( getKind() == kind::PARAMETRIC_DATATYPE ); + Assert(getKind() == kind::PARAMETRIC_DATATYPE); return (*this)[0].getDatatype(); } } @@ -1035,8 +1035,8 @@ inline unsigned TypeNode::getFloatingPointExponentSize() const { /** Get the significand size of this floating-point type */ inline unsigned TypeNode::getFloatingPointSignificandSize() const { - Assert(isFloatingPoint()); - return getConst().significand(); + Assert(isFloatingPoint()); + return getConst().significand(); } /** Get the size of this bit-vector type */ diff --git a/src/expr/type_properties_template.h b/src/expr/type_properties_template.h index 88447a125..6f1297f16 100644 --- a/src/expr/type_properties_template.h +++ b/src/expr/type_properties_template.h @@ -23,15 +23,15 @@ #include -#include "base/cvc4_assert.h" -#include "options/language.h" -#include "expr/type_node.h" -#include "expr/kind.h" +#include "base/check.h" #include "expr/expr.h" +#include "expr/kind.h" +#include "expr/type_node.h" +#include "options/language.h" ${type_properties_includes} -#line 35 "${template}" +#line 36 "${template}" namespace CVC4 { namespace kind { @@ -42,17 +42,15 @@ namespace kind { * "kinds" files, so includes contributions from each theory regarding * that theory's types. */ -inline Cardinality getCardinality(TypeConstant tc) { - switch(tc) { +inline Cardinality getCardinality(TypeConstant tc) +{ + switch (tc) + { ${type_constant_cardinalities} -#line 49 "${template}" - default: { - std::stringstream ss; - ss << "No cardinality known for type constant " << tc; - InternalError(ss.str()); - } +#line 51 "${template}" + default: InternalError() << "No cardinality known for type constant " << tc; } -}/* getCardinality(TypeConstant) */ +} /* getCardinality(TypeConstant) */ /** * Return the cardinality of the type represented by the TypeNode @@ -66,26 +64,21 @@ inline Cardinality getCardinality(TypeNode typeNode) { case TYPE_CONSTANT: return getCardinality(typeNode.getConst()); ${type_cardinalities} -#line 70 "${template}" - default: { - std::stringstream ss; - ss << "A theory kinds file did not provide a cardinality " - << "or cardinality computer for type:\n" << typeNode - << "\nof kind " << k; - InternalError(ss.str()); - } +#line 68 "${template}" + default: + InternalError() << "A theory kinds file did not provide a cardinality " + << "or cardinality computer for type:\n" + << typeNode << "\nof kind " << k; } }/* getCardinality(TypeNode) */ inline bool isWellFounded(TypeConstant tc) { switch(tc) { ${type_constant_wellfoundednesses} -#line 84 "${template}" - default: { - std::stringstream ss; - ss << "No well-foundedness status known for type constant: " << tc; - InternalError(ss.str()); - } +#line 79 "${template}" +default: + InternalError() << "No well-foundedness status known for type constant: " + << tc; } }/* isWellFounded(TypeConstant) */ @@ -95,45 +88,40 @@ inline bool isWellFounded(TypeNode typeNode) { case TYPE_CONSTANT: return isWellFounded(typeNode.getConst()); ${type_wellfoundednesses} -#line 99 "${template}" - default: { - std::stringstream ss; - ss << "A theory kinds file did not provide a well-foundedness " - << "or well-foundedness computer for type:\n" << typeNode - << "\nof kind " << k; - InternalError(ss.str()); - } +#line 92 "${template}" + default: + InternalError() << "A theory kinds file did not provide a well-foundedness " + << "or well-foundedness computer for type:\n" + << typeNode << "\nof kind " << k; } }/* isWellFounded(TypeNode) */ -inline Node mkGroundTerm(TypeConstant tc) { - switch(tc) { +inline Node mkGroundTerm(TypeConstant tc) +{ + switch (tc) + { ${type_constant_groundterms} -#line 113 "${template}" - default: { - std::stringstream ss; - ss << "No ground term known for type constant: " << tc; - InternalError(ss.str()); +#line 105 "${template}" + default: + InternalError() << "No ground term known for type constant: " << tc; } - } -}/* mkGroundTerm(TypeConstant) */ +} /* mkGroundTerm(TypeConstant) */ -inline Node mkGroundTerm(TypeNode typeNode) { +inline Node mkGroundTerm(TypeNode typeNode) +{ AssertArgument(!typeNode.isNull(), typeNode); - switch(Kind k = typeNode.getKind()) { - case TYPE_CONSTANT: - return mkGroundTerm(typeNode.getConst()); + switch (Kind k = typeNode.getKind()) + { + case TYPE_CONSTANT: + return mkGroundTerm(typeNode.getConst()); ${type_groundterms} -#line 128 "${template}" - default: { - std::stringstream ss; - ss << "A theory kinds file did not provide a ground term " - << "or ground term computer for type:\n" << typeNode - << "\nof kind " << k; - InternalError(ss.str()); - } +#line 119 "${template}" + default: + InternalError() << "A theory kinds file did not provide a ground term " + << "or ground term computer for type:\n" + << typeNode << "\nof kind " << k; } -}/* mkGroundTerm(TypeNode) */ +} /* mkGroundTerm(TypeNode) */ }/* CVC4::kind namespace */ }/* CVC4 namespace */ diff --git a/src/expr/uninterpreted_constant.cpp b/src/expr/uninterpreted_constant.cpp index 64180c377..574580259 100644 --- a/src/expr/uninterpreted_constant.cpp +++ b/src/expr/uninterpreted_constant.cpp @@ -21,7 +21,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" using namespace std; diff --git a/src/options/argument_extender_implementation.cpp b/src/options/argument_extender_implementation.cpp index 0d789c626..1073521ca 100644 --- a/src/options/argument_extender_implementation.cpp +++ b/src/options/argument_extender_implementation.cpp @@ -20,7 +20,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "options/argument_extender.h" diff --git a/src/options/options_handler.cpp b/src/options/options_handler.cpp index 3f5cfc0a0..9fd49864b 100644 --- a/src/options/options_handler.cpp +++ b/src/options/options_handler.cpp @@ -22,9 +22,9 @@ #include "cvc4autoconfig.h" +#include "base/check.h" #include "base/configuration.h" #include "base/configuration_private.h" -#include "base/cvc4_assert.h" #include "base/exception.h" #include "base/modal_exception.h" #include "base/output.h" @@ -35,9 +35,9 @@ #include "options/base_options.h" #include "options/bv_bitblast_mode.h" #include "options/bv_options.h" +#include "options/datatypes_modes.h" #include "options/decision_mode.h" #include "options/decision_options.h" -#include "options/datatypes_modes.h" #include "options/didyoumean.h" #include "options/language.h" #include "options/option_exception.h" diff --git a/src/options/options_template.cpp b/src/options/options_template.cpp index 9e18dcb51..dad4f13a1 100644 --- a/src/options/options_template.cpp +++ b/src/options/options_template.cpp @@ -48,7 +48,7 @@ extern int optreset; #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/exception.h" #include "base/output.h" #include "options/argument_extender.h" diff --git a/src/preprocessing/passes/ackermann.cpp b/src/preprocessing/passes/ackermann.cpp index 7ba689d0a..4b5873e80 100644 --- a/src/preprocessing/passes/ackermann.cpp +++ b/src/preprocessing/passes/ackermann.cpp @@ -23,6 +23,7 @@ #include "preprocessing/passes/ackermann.h" +#include "base/check.h" #include "options/options.h" using namespace CVC4; @@ -169,9 +170,8 @@ void collectFunctionsAndLemmas(FunctionToArgsMap& fun_to_args, } else { - AlwaysAssert( - term.getKind() != kind::STORE, - "Cannot use Ackermannization on formula with stores to arrays"); + AlwaysAssert(term.getKind() != kind::STORE) + << "Cannot use Ackermannization on formula with stores to arrays"; /* add children to the vector, so that they are processed later */ for (TNode n : term) { diff --git a/src/preprocessing/passes/apply_to_const.cpp b/src/preprocessing/passes/apply_to_const.cpp index 12591db0b..e8681e40c 100644 --- a/src/preprocessing/passes/apply_to_const.cpp +++ b/src/preprocessing/passes/apply_to_const.cpp @@ -67,12 +67,11 @@ Node ApplyToConst::rewriteApplyToConst(TNode n, NodeMap& cache) Trace("rewriteApplyToConst") << "made :: " << newvar << std::endl; return newvar; } - stringstream ss; - ss << "The rewrite-apply-to-const preprocessor is currently limited;\n" - << "it only works if all function symbols are unary and with Integer\n" - << "domain, and all applications are to integer values.\n" - << "Found application: " << n; - Unhandled(ss.str()); + Unhandled() + << "The rewrite-apply-to-const preprocessor is currently limited;\n" + << "it only works if all function symbols are unary and with Integer\n" + << "domain, and all applications are to integer values.\n" + << "Found application: " << n; } NodeBuilder<> builder(n.getKind()); diff --git a/src/preprocessing/passes/bv_gauss.cpp b/src/preprocessing/passes/bv_gauss.cpp index 09d963ba3..0f2674680 100644 --- a/src/preprocessing/passes/bv_gauss.cpp +++ b/src/preprocessing/passes/bv_gauss.cpp @@ -264,7 +264,7 @@ BVGauss::Result BVGauss::gaussElim(Integer prime, #ifdef CVC4_ASSERTIONS for (size_t i = 1; i < nrows; ++i) Assert(lhs[i].size() == ncols); - #endif +#endif /* (1) if element in pivot column is non-zero and != 1, divide row elements * by element in pivot column modulo prime, i.e., multiply row with * multiplicative inverse of element in pivot column modulo prime @@ -284,7 +284,10 @@ BVGauss::Result BVGauss::gaussElim(Integer prime, for (size_t j = prow; j < nrows; ++j) { #ifdef CVC4_ASSERTIONS - for (size_t k = 0; k < pcol; ++k) { Assert(lhs[j][k] == 0); } + for (size_t k = 0; k < pcol; ++k) + { + Assert(lhs[j][k] == 0); + } #endif /* normalize element in pivot column to modulo prime */ lhs[j][pcol] = lhs[j][pcol].euclidianDivideRemainder(prime); @@ -571,7 +574,10 @@ BVGauss::Result BVGauss::gaussElimRewriteForUrem( Assert(nvars); size_t nrows = vars.begin()->second.size(); #ifdef CVC4_ASSERTIONS - for (const auto& p : vars) { Assert(p.second.size() == nrows); } + for (const auto& p : vars) + { + Assert(p.second.size() == nrows); + } #endif if (nrows < 1) @@ -588,7 +594,10 @@ BVGauss::Result BVGauss::gaussElimRewriteForUrem( } #ifdef CVC4_ASSERTIONS - for (const auto& row : lhs) { Assert(row.size() == nvars); } + for (const auto& row : lhs) + { + Assert(row.size() == nvars); + } Assert(lhs.size() == rhs.size()); #endif diff --git a/src/preprocessing/passes/miplib_trick.cpp b/src/preprocessing/passes/miplib_trick.cpp index 37bc363f8..d6259294a 100644 --- a/src/preprocessing/passes/miplib_trick.cpp +++ b/src/preprocessing/passes/miplib_trick.cpp @@ -447,7 +447,7 @@ PreprocessingPassResult MipLibTrick::applyInternal( { // exclude single-var case; nothing to check there uint64_t sz = (uint64_t(1) << checks[pos_var].size()) - 1; sz = (sz == 0) ? -1 : sz; // fix for overflow - Assert(sz == mark, "expected size %u == mark %u", sz, mark); + Assert(sz == mark) << "expected size " << sz << " == mark " << mark; for (size_t k = 0; k < checks[pos_var].size(); ++k) { if ((k & (k - 1)) != 0) @@ -476,14 +476,11 @@ PreprocessingPassResult MipLibTrick::applyInternal( } else { - Assert(checks[pos_var][k] == 0, - "checks[(%s,%s)][%u] should be 0, but it's %s", - pos.toString().c_str(), - var.toString().c_str(), - k, - checks[pos_var][k] - .toString() - .c_str()); // we never set for single-positive-var + Assert(checks[pos_var][k] == 0) + << "checks[(" << pos << "," << var << ")][" << k + << "] should be 0, but it's " + << checks[pos_var] + [k]; // we never set for single-positive-var } } } @@ -529,15 +526,15 @@ PreprocessingPassResult MipLibTrick::applyInternal( SubstitutionMap nullMap(&fakeContext); Theory::PPAssertStatus status CVC4_UNUSED; // just for assertions status = te->solve(geq, nullMap); - Assert(status == Theory::PP_ASSERT_STATUS_UNSOLVED, - "unexpected solution from arith's ppAssert()"); - Assert(nullMap.empty(), - "unexpected substitution from arith's ppAssert()"); + Assert(status == Theory::PP_ASSERT_STATUS_UNSOLVED) + << "unexpected solution from arith's ppAssert()"; + Assert(nullMap.empty()) + << "unexpected substitution from arith's ppAssert()"; status = te->solve(leq, nullMap); - Assert(status == Theory::PP_ASSERT_STATUS_UNSOLVED, - "unexpected solution from arith's ppAssert()"); - Assert(nullMap.empty(), - "unexpected substitution from arith's ppAssert()"); + Assert(status == Theory::PP_ASSERT_STATUS_UNSOLVED) + << "unexpected solution from arith's ppAssert()"; + Assert(nullMap.empty()) + << "unexpected substitution from arith's ppAssert()"; te->getModel()->addSubstitution(*ii, newVar.eqNode(one)); newVars.push_back(newVar); varRef = newVar; diff --git a/src/preprocessing/passes/quantifier_macros.cpp b/src/preprocessing/passes/quantifier_macros.cpp index 0f71943c9..1d834ce60 100644 --- a/src/preprocessing/passes/quantifier_macros.cpp +++ b/src/preprocessing/passes/quantifier_macros.cpp @@ -199,7 +199,7 @@ bool QuantifierMacros::isGroundUfTerm( Node f, Node n ) { } bool QuantifierMacros::isBoundVarApplyUf( Node n ) { - Assert( n.getKind()==APPLY_UF ); + Assert(n.getKind() == APPLY_UF); TypeNode tno = n.getOperator().getType(); std::map< Node, bool > vars; // allow if a vector of unique variables of the same type as UF arguments @@ -437,7 +437,7 @@ Node QuantifierMacros::simplify( Node n ){ }else if( !etc.isConst() ){ cond.push_back( etc ); } - Assert( children[i].getType().isSubtypeOf( tno[i] ) ); + Assert(children[i].getType().isSubtypeOf(tno[i])); } if( success ){ //do substitution if necessary diff --git a/src/preprocessing/preprocessing_pass_registry.cpp b/src/preprocessing/preprocessing_pass_registry.cpp index 82132774b..5df449237 100644 --- a/src/preprocessing/preprocessing_pass_registry.cpp +++ b/src/preprocessing/preprocessing_pass_registry.cpp @@ -20,7 +20,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/map_util.h" #include "base/output.h" #include "preprocessing/passes/ackermann.h" diff --git a/src/printer/cvc/cvc_printer.cpp b/src/printer/cvc/cvc_printer.cpp index 0b7c569b7..b11ee77a7 100644 --- a/src/printer/cvc/cvc_printer.cpp +++ b/src/printer/cvc/cvc_printer.cpp @@ -434,7 +434,7 @@ void CvcPrinter::toStream( } break; case kind::APPLY_TESTER: { - Assert( !n.getType().isTuple() && !n.getType().isRecord() ); + Assert(!n.getType().isTuple() && !n.getType().isRecord()); op << "is_"; unsigned cindex = Datatype::indexOf(n.getOperator().toExpr()); const Datatype& dt = Datatype::datatypeOf(n.getOperator().toExpr()); diff --git a/src/printer/dagification_visitor.cpp b/src/printer/dagification_visitor.cpp index 67c5aa7e5..5463b1c22 100644 --- a/src/printer/dagification_visitor.cpp +++ b/src/printer/dagification_visitor.cpp @@ -132,7 +132,7 @@ void DagificationVisitor::visit(TNode current, TNode parent) { } void DagificationVisitor::start(TNode node) { - AlwaysAssert(!d_done, "DagificationVisitor cannot be re-used"); + AlwaysAssert(!d_done) << "DagificationVisitor cannot be re-used"; d_top = node; } @@ -175,18 +175,22 @@ void DagificationVisitor::done(TNode node) { // apply previous substitutions to the rhs, enabling cascading LETs Node n = d_substitutions->apply(*i); - Assert(! d_substitutions->hasSubstitution(n)); + Assert(!d_substitutions->hasSubstitution(n)); d_substitutions->addSubstitution(n, letvar); } } const theory::SubstitutionMap& DagificationVisitor::getLets() { - AlwaysAssert(d_done, "DagificationVisitor must be used as a visitor before getting the dagified version out!"); + AlwaysAssert(d_done) + << "DagificationVisitor must be used as a visitor before " + "getting the dagified version out!"; return *d_substitutions; } Node DagificationVisitor::getDagifiedBody() { - AlwaysAssert(d_done, "DagificationVisitor must be used as a visitor before getting the dagified version out!"); + AlwaysAssert(d_done) + << "DagificationVisitor must be used as a visitor before " + "getting the dagified version out!"; #ifdef CVC4_TRACING # ifdef CVC4_DEBUG diff --git a/src/printer/printer.cpp b/src/printer/printer.cpp index cacdd6694..28471de72 100644 --- a/src/printer/printer.cpp +++ b/src/printer/printer.cpp @@ -77,8 +77,7 @@ unique_ptr Printer::makePrinter(OutputLanguage lang) return unique_ptr( new printer::cvc::CvcPrinter(/* cvc3-mode = */ true)); - default: - Unhandled(lang); + default: Unhandled() << lang; } } diff --git a/src/printer/smt2/smt2_printer.cpp b/src/printer/smt2/smt2_printer.cpp index 013288880..0d3bab3d0 100644 --- a/src/printer/smt2/smt2_printer.cpp +++ b/src/printer/smt2/smt2_printer.cpp @@ -195,7 +195,8 @@ void Smt2Printer::toStream(std::ostream& out, case roundTowardNegative : out << "roundTowardNegative"; break; case roundTowardZero : out << "roundTowardZero"; break; default : - Unreachable("Invalid value of rounding mode constant (%d)",n.getConst()); + Unreachable() << "Invalid value of rounding mode constant (" + << n.getConst() << ")"; } break; case kind::CONST_BOOLEAN: @@ -982,7 +983,7 @@ void Smt2Printer::toStream(std::ostream& out, force_child_type[1] = NodeManager::currentNM()->mkSetType( elemType ); }else{ // APPLY_UF, APPLY_CONSTRUCTOR, etc. - Assert( n.hasOperator() ); + Assert(n.hasOperator()); TypeNode opt = n.getOperator().getType(); if (n.getKind() == kind::APPLY_CONSTRUCTOR) { @@ -996,7 +997,7 @@ void Smt2Printer::toStream(std::ostream& out, opt = TypeNode::fromType(dt[ci].getSpecializedConstructorType(tn)); } } - Assert( opt.getNumChildren() == n.getNumChildren() + 1 ); + Assert(opt.getNumChildren() == n.getNumChildren() + 1); for(size_t i = 0; i < n.getNumChildren(); ++i ) { force_child_type[i] = opt[i]; } @@ -1350,7 +1351,7 @@ void Smt2Printer::toStream(std::ostream& out, const UnsatCore& core) const { out << "(" << std::endl; SmtEngine * smt = core.getSmtEngine(); - Assert( smt!=NULL ); + Assert(smt != NULL); for(UnsatCore::const_iterator i = core.begin(); i != core.end(); ++i) { std::string name; if (smt->getExpressionName(*i,name)) { diff --git a/src/printer/tptp/tptp_printer.cpp b/src/printer/tptp/tptp_printer.cpp index 3ed642805..72fdfe41d 100644 --- a/src/printer/tptp/tptp_printer.cpp +++ b/src/printer/tptp/tptp_printer.cpp @@ -73,7 +73,7 @@ void TptpPrinter::toStream(std::ostream& out, const UnsatCore& core) const { out << "% SZS output start UnsatCore " << std::endl; SmtEngine * smt = core.getSmtEngine(); - Assert( smt!=NULL ); + Assert(smt != NULL); for(UnsatCore::const_iterator i = core.begin(); i != core.end(); ++i) { std::string name; if (smt->getExpressionName(*i, name)) { diff --git a/src/proof/arith_proof.cpp b/src/proof/arith_proof.cpp index 8b55c29db..77f4b1630 100644 --- a/src/proof/arith_proof.cpp +++ b/src/proof/arith_proof.cpp @@ -236,7 +236,8 @@ Node ProofArith::toStreamRecLFSC(std::ostream& out, out << ss.str(); out << ") (pred_eq_f _ " << ProofManager::getLitName(n2[0]) << ")) t_t_neq_f))" << std::endl; } else { - Assert((n1[0] == n2[0][0] && n1[1] == n2[0][1]) || (n1[1] == n2[0][0] && n1[0] == n2[0][1])); + Assert((n1[0] == n2[0][0] && n1[1] == n2[0][1]) + || (n1[1] == n2[0][0] && n1[0] == n2[0][1])); if(n1[1] == n2[0][0]) { out << "(symm _ _ _ " << ss.str() << ")"; } else { @@ -256,12 +257,17 @@ Node ProofArith::toStreamRecLFSC(std::ostream& out, pf2->d_id == theory::eq::MERGED_THROUGH_CONGRUENCE; pf2 = pf2->d_children[0].get()) { Assert(!pf2->d_node.isNull()); - Assert(pf2->d_node.getKind() == kind::PARTIAL_APPLY_UF || pf2->d_node.getKind() == kind::BUILTIN || pf2->d_node.getKind() == kind::APPLY_UF || pf2->d_node.getKind() == kind::SELECT || pf2->d_node.getKind() == kind::STORE); + Assert(pf2->d_node.getKind() == kind::PARTIAL_APPLY_UF + || pf2->d_node.getKind() == kind::BUILTIN + || pf2->d_node.getKind() == kind::APPLY_UF + || pf2->d_node.getKind() == kind::SELECT + || pf2->d_node.getKind() == kind::STORE); Assert(pf2->d_children.size() == 2); out << "(cong _ _ _ _ _ _ "; stk.push(pf2); } - Assert(stk.top()->d_children[0]->d_id != theory::eq::MERGED_THROUGH_CONGRUENCE); + Assert(stk.top()->d_children[0]->d_id + != theory::eq::MERGED_THROUGH_CONGRUENCE); NodeBuilder<> b1(kind::PARTIAL_APPLY_UF), b2(kind::PARTIAL_APPLY_UF); const theory::eq::EqProof* pf2 = stk.top(); stk.pop(); @@ -322,7 +328,12 @@ Node ProofArith::toStreamRecLFSC(std::ostream& out, b2 << n2[1-side]; out << ss.str(); } else { - Assert(pf2->d_node[b1.getNumChildren() - (pf2->d_node.getMetaKind() == kind::metakind::PARAMETERIZED ? 0 : 1)] == n2[1-side]); + Assert(pf2->d_node[b1.getNumChildren() + - (pf2->d_node.getMetaKind() + == kind::metakind::PARAMETERIZED + ? 0 + : 1)] + == n2[1 - side]); b1 << n2[1-side]; b2 << n2[side]; out << "(symm _ _ _ " << ss.str() << ")"; @@ -349,7 +360,7 @@ Node ProofArith::toStreamRecLFSC(std::ostream& out, b2 << n2[1-side]; out << ss.str(); } else { - Assert(pf2->d_node[b1.getNumChildren()] == n2[1-side]); + Assert(pf2->d_node[b1.getNumChildren()] == n2[1 - side]); b1 << n2[1-side]; b2 << n2[side]; out << "(symm _ _ _ " << ss.str() << ")"; @@ -677,7 +688,7 @@ void LFSCArithProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetM // !d_realMode <--> term.getType().isInteger() - Assert (theory::Theory::theoryOf(term) == theory::THEORY_ARITH); + Assert(theory::Theory::theoryOf(term) == theory::THEORY_ARITH); switch (term.getKind()) { case kind::CONST_RATIONAL: @@ -899,9 +910,8 @@ void LFSCArithProof::printLinearPolynomialNormalizer(std::ostream& o, } default: #ifdef CVC4_ASSERTIONS - std::ostringstream msg; - msg << "Invalid operation " << n.getKind() << " in linear polynomial"; - Unreachable(msg.str().c_str()); + Unreachable() << "Invalid operation " << n.getKind() + << " in linear polynomial"; #endif // CVC4_ASSERTIONS break; } @@ -914,13 +924,11 @@ void LFSCArithProof::printLinearMonomialNormalizer(std::ostream& o, { case kind::MULT: { #ifdef CVC4_ASSERTIONS - std::ostringstream s; - s << "node " << n << " is not a linear monomial"; - s << " " << n[0].getKind() << " " << n[1].getKind(); Assert((n[0].getKind() == kind::CONST_RATIONAL && (n[1].getKind() == kind::VARIABLE - || n[1].getKind() == kind::SKOLEM)), - s.str().c_str()); + || n[1].getKind() == kind::SKOLEM))) + << "node " << n << " is not a linear monomial" + << " " << n[0].getKind() << " " << n[1].getKind(); #endif // CVC4_ASSERTIONS o << "\n (pn_mul_c_L _ _ _ "; @@ -946,9 +954,8 @@ void LFSCArithProof::printLinearMonomialNormalizer(std::ostream& o, } default: #ifdef CVC4_ASSERTIONS - std::ostringstream msg; - msg << "Invalid operation " << n.getKind() << " in linear monomial"; - Unreachable(msg.str().c_str()); + Unreachable() << "Invalid operation " << n.getKind() + << " in linear monomial"; #endif // CVC4_ASSERTIONS break; } @@ -963,18 +970,16 @@ void LFSCArithProof::printConstRational(std::ostream& o, const Node& n) void LFSCArithProof::printVariableNormalizer(std::ostream& o, const Node& n) { - std::ostringstream msg; - msg << "Invalid variable kind " << n.getKind() << " in linear monomial"; - Assert(n.getKind() == kind::VARIABLE || n.getKind() == kind::SKOLEM, - msg.str().c_str()); + Assert(n.getKind() == kind::VARIABLE || n.getKind() == kind::SKOLEM) + << "Invalid variable kind " << n.getKind() << " in linear monomial"; o << "(pn_var " << n << ")"; } void LFSCArithProof::printLinearPolynomialPredicateNormalizer(std::ostream& o, const Node& n) { - Assert(n.getKind() == kind::GEQ, - "can only print normalization witnesses for (>=) nodes"); + Assert(n.getKind() == kind::GEQ) + << "can only print normalization witnesses for (>=) nodes"; Assert(n[1].getKind() == kind::CONST_RATIONAL); o << "(poly_formula_norm_>= _ _ _ "; o << "\n (pn_- _ _ _ _ _ "; diff --git a/src/proof/array_proof.cpp b/src/proof/array_proof.cpp index 131fcd3b6..ec2f85829 100644 --- a/src/proof/array_proof.cpp +++ b/src/proof/array_proof.cpp @@ -152,7 +152,8 @@ Node ProofArray::toStreamRecLFSC(std::ostream& out, out << ss.str(); out << ") (pred_eq_f _ " << ProofManager::getLitName(n2[0]) << ")) t_t_neq_f))" << std::endl; } else { - Assert((n1[0] == n2[0][0] && n1[1] == n2[0][1]) || (n1[1] == n2[0][0] && n1[0] == n2[0][1])); + Assert((n1[0] == n2[0][0] && n1[1] == n2[0][1]) + || (n1[1] == n2[0][0] && n1[0] == n2[0][1])); if(n1[1] == n2[0][0]) { out << "(symm _ _ _ " << ss.str() << ")"; } else { @@ -166,7 +167,8 @@ Node ProofArray::toStreamRecLFSC(std::ostream& out, } else { Node n2 = pf.d_node; Assert(n2.getKind() == kind::EQUAL); - Assert((n1[0] == n2[0] && n1[1] == n2[1]) || (n1[1] == n2[0] && n1[0] == n2[1])); + Assert((n1[0] == n2[0] && n1[1] == n2[1]) + || (n1[1] == n2[0] && n1[0] == n2[1])); out << ss.str(); out << " "; @@ -323,10 +325,15 @@ Node ProofArray::toStreamRecLFSC(std::ostream& out, b2 << n2[1-side]; out << ss.str(); } else { - Assert(pf2->d_node[b1.getNumChildren() + - (n1[side].getKind() == kind::PARTIAL_SELECT_0 ? 1 : 0) + - (n1[side].getKind() == kind::PARTIAL_SELECT_1 ? 1 : 0) - - (pf2->d_node.getMetaKind() == kind::metakind::PARAMETERIZED ? 0 : 1)] == n2[1-side]); + Assert( + pf2->d_node[b1.getNumChildren() + + (n1[side].getKind() == kind::PARTIAL_SELECT_0 ? 1 : 0) + + (n1[side].getKind() == kind::PARTIAL_SELECT_1 ? 1 : 0) + - (pf2->d_node.getMetaKind() + == kind::metakind::PARAMETERIZED + ? 0 + : 1)] + == n2[1 - side]); b1 << n2[1-side]; b2 << n2[side]; out << "(symm _ _ _ " << ss.str() << ")"; @@ -359,7 +366,7 @@ Node ProofArray::toStreamRecLFSC(std::ostream& out, b2 << n2[1-side]; out << ss.str(); } else { - Assert(pf2->d_node[b1.getNumChildren()] == n2[1-side]); + Assert(pf2->d_node[b1.getNumChildren()] == n2[1 - side]); b1 << n2[1-side]; b2 << n2[side]; out << "(symm _ _ _ " << ss.str() << ")"; @@ -383,7 +390,8 @@ Node ProofArray::toStreamRecLFSC(std::ostream& out, Debug("mgd") << "n1.getNumChildren() + 1 = " << n1.getNumChildren() + 1 << std::endl; - Assert(!((n1.getKind() == kind::PARTIAL_SELECT_0 && n1.getNumChildren() == 2))); + Assert(!( + (n1.getKind() == kind::PARTIAL_SELECT_0 && n1.getNumChildren() == 2))); if (n1.getKind() == kind::PARTIAL_SELECT_1 && n1.getNumChildren() == 2) { Debug("mgd") << "Finished a SELECT. Updating.." << std::endl; b1.clear(kind::SELECT); @@ -410,7 +418,8 @@ Node ProofArray::toStreamRecLFSC(std::ostream& out, Debug("mgd") << "n2.getNumChildren() + 1 = " << n2.getNumChildren() + 1 << std::endl; - Assert(!((n2.getKind() == kind::PARTIAL_SELECT_0 && n2.getNumChildren() == 2))); + Assert(!( + (n2.getKind() == kind::PARTIAL_SELECT_0 && n2.getNumChildren() == 2))); if (n2.getKind() == kind::PARTIAL_SELECT_1 && n2.getNumChildren() == 2) { Debug("mgd") << "Finished a SELECT. Updating.." << std::endl; b2.clear(kind::SELECT); @@ -1115,7 +1124,7 @@ std::string ArrayProof::skolemToLiteral(Expr skolem) { } void LFSCArrayProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetMap& map) { - Assert (theory::Theory::theoryOf(term) == theory::THEORY_ARRAYS); + Assert(theory::Theory::theoryOf(term) == theory::THEORY_ARRAYS); if (theory::Theory::theoryOf(term) != theory::THEORY_ARRAYS) { // We can get here, for instance, if there's a (select ite ...), e.g. a non-array term @@ -1129,7 +1138,10 @@ void LFSCArrayProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetM return; } - Assert ((term.getKind() == kind::SELECT) || (term.getKind() == kind::PARTIAL_SELECT_0) || (term.getKind() == kind::PARTIAL_SELECT_1) || (term.getKind() == kind::STORE)); + Assert((term.getKind() == kind::SELECT) + || (term.getKind() == kind::PARTIAL_SELECT_0) + || (term.getKind() == kind::PARTIAL_SELECT_1) + || (term.getKind() == kind::STORE)); switch (term.getKind()) { case kind::SELECT: { @@ -1196,7 +1208,7 @@ void LFSCArrayProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetM void LFSCArrayProof::printOwnedSort(Type type, std::ostream& os) { Debug("pf::array") << std::endl << "(pf::array) LFSCArrayProof::printOwnedSort: type is: " << type << std::endl; - Assert (type.isArray() || type.isSort()); + Assert(type.isArray() || type.isSort()); if (type.isArray()){ ArrayType array_type(type); diff --git a/src/proof/bitvector_proof.cpp b/src/proof/bitvector_proof.cpp index 18e46a292..98f57e25f 100644 --- a/src/proof/bitvector_proof.cpp +++ b/src/proof/bitvector_proof.cpp @@ -224,16 +224,16 @@ void BitVectorProof::printOwnedTerm(Expr term, void BitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER, - "the BV theory should only be proving bottom directly in the eager " - "bitblasting mode"); + Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + << "the BV theory should only be proving bottom directly in the eager " + "bitblasting mode"; } void BitVectorProof::printBitOf(Expr term, std::ostream& os, const ProofLetMap& map) { - Assert (term.getKind() == kind::BITVECTOR_BITOF); + Assert(term.getKind() == kind::BITVECTOR_BITOF); unsigned bit = term.getOperator().getConst().bitIndex; Expr var = term[0]; @@ -247,7 +247,7 @@ void BitVectorProof::printBitOf(Expr term, void BitVectorProof::printConstant(Expr term, std::ostream& os) { - Assert (term.isConst()); + Assert(term.isConst()); os << "(a_bv " << utils::getSize(term) << " "; if (d_useConstantLetification) { @@ -336,7 +336,7 @@ void BitVectorProof::printOperatorParametric(Expr term, os << high <<" " << low << " " << utils::getSize(term[0]); } os <<" "; - Assert (term.getNumChildren() == 1); + Assert(term.getNumChildren() == 1); d_proofEngine->printBoundTerm(term[0], os, map); os <<")"; } @@ -346,7 +346,7 @@ void BitVectorProof::printOwnedSort(Type type, std::ostream& os) Debug("pf::bv") << std::endl << "(pf::bv) BitVectorProof::printOwnedSort( " << type << " )" << std::endl; - Assert (type.isBitVector()); + Assert(type.isBitVector()); unsigned width = utils::getSize(type); os << "(BitVec " << width << ")"; } @@ -433,7 +433,7 @@ void BitVectorProof::printTermBitblasting(Expr term, std::ostream& os) { // TODO: once we have the operator elimination rules remove those that we // eliminated - Assert (term.getType().isBitVector()); + Assert(term.getType().isBitVector()); Kind kind = term.getKind(); if (theory::Theory::isLeafOf(term, theory::THEORY_BV) && !term.isConst()) @@ -568,7 +568,7 @@ void BitVectorProof::printTermBitblasting(Expr term, std::ostream& os) return; } - default: Unreachable("BitVectorProof Unknown operator"); + default: Unreachable() << "BitVectorProof Unknown operator"; } } @@ -601,7 +601,7 @@ void BitVectorProof::printAtomBitblasting(Expr atom, return; } - default: Unreachable("BitVectorProof Unknown atom kind"); + default: Unreachable() << "BitVectorProof Unknown atom kind"; } } @@ -739,9 +739,9 @@ bool BitVectorProof::hasAlias(Expr expr) void BitVectorProof::printConstantDisequalityProof( std::ostream& os, Expr c1, Expr c2, const ProofLetMap& globalLetMap) { - Assert (c1.isConst()); - Assert (c2.isConst()); - Assert (utils::getSize(c1) == utils::getSize(c2)); + Assert(c1.isConst()); + Assert(c2.isConst()); + Assert(utils::getSize(c1) == utils::getSize(c2)); os << "(bv_disequal_constants " << utils::getSize(c1) << " "; diff --git a/src/proof/clausal_bitvector_proof.cpp b/src/proof/clausal_bitvector_proof.cpp index 4e700a832..bb9213b4b 100644 --- a/src/proof/clausal_bitvector_proof.cpp +++ b/src/proof/clausal_bitvector_proof.cpp @@ -175,13 +175,13 @@ void ClausalBitVectorProof::optimizeDratProof() optFormulaFilename, optDratFilename, drat2er::options::QUIET); - AlwaysAssert( - dratTrimExitCode == 0, "drat-trim exited with %d", dratTrimExitCode); + AlwaysAssert(dratTrimExitCode == 0) + << "drat-trim exited with " << dratTrimExitCode; } #else - Unimplemented( - "Proof production when using CryptoMiniSat requires drat2er.\n" - "Run contrib/get-drat2er, reconfigure with --drat2er, and rebuild"); + Unimplemented() + << "Proof production when using CryptoMiniSat requires drat2er.\n" + << "Run contrib/get-drat2er, reconfigure with --drat2er, and rebuild"; #endif { @@ -314,9 +314,9 @@ void LfscClausalBitVectorProof::printTheoryLemmaProof(std::vector& lemma, std::ostream& paren, const ProofLetMap& map) { - Unreachable( - "Clausal bit-vector proofs should only be used in combination with eager " - "bitblasting, which **does not use theory lemmas**"); + Unreachable() << "Clausal bit-vector proofs should only be used in " + "combination with eager " + "bitblasting, which **does not use theory lemmas**"; } void LfscClausalBitVectorProof::printBBDeclarationAndCnf(std::ostream& os, @@ -339,9 +339,9 @@ void LfscClausalBitVectorProof::printBBDeclarationAndCnf(std::ostream& os, void LfscDratBitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER, - "the BV theory should only be proving bottom directly in the eager " - "bitblasting mode"); + Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + << "the BV theory should only be proving bottom directly in the eager " + "bitblasting mode"; os << "\n;; Proof of input to SAT solver\n"; os << "(@ proofOfSatInput "; @@ -366,9 +366,9 @@ void LfscDratBitVectorProof::printEmptyClauseProof(std::ostream& os, void LfscLratBitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER, - "the BV theory should only be proving bottom directly in the eager " - "bitblasting mode"); + Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + << "the BV theory should only be proving bottom directly in the eager " + "bitblasting mode"; os << "\n;; Proof of input to SAT solver\n"; os << "(@ proofOfCMap "; @@ -396,9 +396,9 @@ void LfscLratBitVectorProof::printEmptyClauseProof(std::ostream& os, void LfscErBitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER, - "the BV theory should only be proving bottom directly in the eager " - "bitblasting mode"); + Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + << "the BV theory should only be proving bottom directly in the eager " + "bitblasting mode"; d_dratTranslationStatistics.d_totalTime.start(); er::ErProof pf = diff --git a/src/proof/cnf_proof.cpp b/src/proof/cnf_proof.cpp index 9c263e08f..c8284762c 100644 --- a/src/proof/cnf_proof.cpp +++ b/src/proof/cnf_proof.cpp @@ -57,7 +57,7 @@ bool CnfProof::isDefinition(Node node) { } ProofRule CnfProof::getProofRule(Node node) { - Assert (isAssertion(node)); + Assert(isAssertion(node)); NodeToProofRule::iterator it = d_assertionToProofRule.find(node); return (*it).second; } @@ -69,27 +69,26 @@ ProofRule CnfProof::getProofRule(ClauseId clause) { Node CnfProof::getAssertionForClause(ClauseId clause) { ClauseIdToNode::const_iterator it = d_clauseToAssertion.find(clause); - Assert (it != d_clauseToAssertion.end()); + Assert(it != d_clauseToAssertion.end()); return (*it).second; } Node CnfProof::getDefinitionForClause(ClauseId clause) { ClauseIdToNode::const_iterator it = d_clauseToDefinition.find(clause); - Assert (it != d_clauseToDefinition.end()); + Assert(it != d_clauseToDefinition.end()); return (*it).second; } void CnfProof::registerConvertedClause(ClauseId clause, bool explanation) { - Assert (clause != ClauseIdUndef && - clause != ClauseIdError && - clause != ClauseIdEmpty); + Assert(clause != ClauseIdUndef && clause != ClauseIdError + && clause != ClauseIdEmpty); // Explanations do not need a CNF conversion proof since they are in CNF // (they will only need a theory proof as they are theory valid) if (explanation) { Debug("proof:cnf") << "CnfProof::registerConvertedClause " << clause << " explanation? " << explanation << std::endl; - Assert (d_explanations.find(clause) == d_explanations.end()); + Assert(d_explanations.find(clause) == d_explanations.end()); d_explanations.insert(clause); return; } @@ -180,7 +179,7 @@ void CnfProof::setCnfDependence(Node from, Node to) { << "from " << from << std::endl << " to " << to << std::endl; - Assert (from != to); + Assert(from != to); d_cnfDeps.insert(std::make_pair(from, to)); } @@ -196,7 +195,7 @@ void CnfProof::pushCurrentAssertion(Node assertion) { } void CnfProof::popCurrentAssertion() { - Assert (d_currentAssertionStack.size()); + Assert(d_currentAssertionStack.size()); Debug("proof:cnf") << "CnfProof::popCurrentAssertion " << d_currentAssertionStack.back() << std::endl; @@ -209,7 +208,7 @@ void CnfProof::popCurrentAssertion() { } Node CnfProof::getCurrentAssertion() { - Assert (d_currentAssertionStack.size()); + Assert(d_currentAssertionStack.size()); return d_currentAssertionStack.back(); } @@ -227,7 +226,7 @@ void CnfProof::pushCurrentDefinition(Node definition) { } void CnfProof::popCurrentDefinition() { - Assert (d_currentDefinitionStack.size()); + Assert(d_currentDefinitionStack.size()); Debug("proof:cnf") << "CnfProof::popCurrentDefinition " << d_currentDefinitionStack.back() << std::endl; @@ -236,7 +235,7 @@ void CnfProof::popCurrentDefinition() { } Node CnfProof::getCurrentDefinition() { - Assert (d_currentDefinitionStack.size()); + Assert(d_currentDefinitionStack.size()); return d_currentDefinitionStack.back(); } @@ -295,7 +294,7 @@ void CnfProof::collectAtomsAndRewritesForLemmas(const IdToSatClause& lemmaClause Node node = getAtom(lit.getSatVariable()); Expr atom = node.toExpr(); if (atom.isConst()) { - Assert (atom == utils::mkTrue()); + Assert(atom == utils::mkTrue()); continue; } clause_expr_nodes.insert(lit.isNegated() ? node.notNode() : node); @@ -462,7 +461,7 @@ void LFSCCnfProof::printCnfProofForClause(ClauseId id, // return; - Assert( clause->size()>0 ); + Assert(clause->size() > 0); // If the clause contains x v ~x, it's easy! // @@ -639,10 +638,10 @@ void LFSCCnfProof::printCnfProofForClause(ClauseId id, Node iatom; if (is_in_clause) { - Assert( assertion.getNumChildren()==2 ); + Assert(assertion.getNumChildren() == 2); iatom = assertion[ base_index==0 ? 1 : 0]; } else { - Assert( assertion.getNumChildren()==1 ); + Assert(assertion.getNumChildren() == 1); iatom = assertion[0]; } @@ -753,7 +752,7 @@ void LFSCCnfProof::printCnfProofForClause(ClauseId id, Trace("cnf-pf-debug") << "CALLING getlitname" << std::endl; os_base_n << ProofManager::getLitName(lit1, d_name) << " "; } - Assert( elimNum!=0 ); + Assert(elimNum != 0); os_base_n << "(" << ( k==kind::EQUAL ? "iff" : "xor" ) << "_elim_" << elimNum << " _ _ "; if( !base_pol ){ os_base_n << "(not_" << ( base_assertion.getKind()==kind::EQUAL ? "iff" : "xor" ) << "_elim _ _ " << os_base.str() << ")"; diff --git a/src/proof/dimacs.cpp b/src/proof/dimacs.cpp index cced98660..fd5b79383 100644 --- a/src/proof/dimacs.cpp +++ b/src/proof/dimacs.cpp @@ -16,7 +16,7 @@ #include "proof/dimacs.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include diff --git a/src/proof/drat/drat_proof.cpp b/src/proof/drat/drat_proof.cpp index 5a01ffdfd..162efc3e5 100644 --- a/src/proof/drat/drat_proof.cpp +++ b/src/proof/drat/drat_proof.cpp @@ -158,7 +158,9 @@ void DratInstruction::outputAsText(std::ostream& os) const os << '0' << std::endl; break; } - default: { Unreachable("Unknown DRAT instruction kind"); + default: + { + Unreachable() << "Unknown DRAT instruction kind"; } } } @@ -267,7 +269,9 @@ void DratProof::outputAsLfsc(std::ostream& os, uint8_t indentation) const os << "DRATProofd "; break; } - default: { Unreachable("Unrecognized DRAT instruction kind"); + default: + { + Unreachable() << "Unrecognized DRAT instruction kind"; } } for (const SatLiteral& l : i.d_clause) diff --git a/src/proof/er/er_proof.cpp b/src/proof/er/er_proof.cpp index 9f22e236b..19c838e2d 100644 --- a/src/proof/er/er_proof.cpp +++ b/src/proof/er/er_proof.cpp @@ -29,7 +29,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/map_util.h" #include "proof/dimacs.h" #include "proof/lfsc_proof_printer.h" @@ -114,9 +114,9 @@ ErProof ErProof::fromBinaryDratProof( drat2er::options::QUIET, false); #else - Unimplemented( - "ER proof production requires drat2er.\n" - "Run contrib/get-drat2er, reconfigure with --drat2er, and rebuild"); + Unimplemented() + << "ER proof production requires drat2er.\n" + << "Run contrib/get-drat2er, reconfigure with --drat2er, and rebuild"; #endif } @@ -184,8 +184,8 @@ ErProof::ErProof(const std::unordered_map& clauses, size_t nLinesForThisDef = 2 + otherLiterals.size(); // Look at the negation of the second literal in the second clause to get // the old literal - AlwaysAssert(d_tracecheck.d_lines.size() > i + 1, - "Malformed definition in TRACECHECK proof from drat2er"); + AlwaysAssert(d_tracecheck.d_lines.size() > i + 1) + << "Malformed definition in TRACECHECK proof from drat2er"; d_definitions.emplace_back(newVar, ~d_tracecheck.d_lines[i + 1].d_clause[1], std::move(otherLiterals)); @@ -299,8 +299,8 @@ void ErProof::outputAsLfsc(std::ostream& os) const } // Write proof of bottom - Assert(d_tracecheck.d_lines.back().d_clause.size() == 0, - "The TRACECHECK proof from drat2er did not prove bottom."); + Assert(d_tracecheck.d_lines.back().d_clause.size() == 0) + << "The TRACECHECK proof from drat2er did not prove bottom."; os << "\n er.c" << d_tracecheck.d_lines.back().d_idx << " ; (holds cln)\n"; diff --git a/src/proof/lemma_proof.cpp b/src/proof/lemma_proof.cpp index 6bb2c2854..f4249f3d5 100644 --- a/src/proof/lemma_proof.cpp +++ b/src/proof/lemma_proof.cpp @@ -147,7 +147,8 @@ bool LemmaProofRecipe::wasRewritten(Node assertion) const { } Node LemmaProofRecipe::getExplanation(Node assertion) const { - Assert(d_assertionToExplanation.find(assertion) != d_assertionToExplanation.end()); + Assert(d_assertionToExplanation.find(assertion) + != d_assertionToExplanation.end()); return d_assertionToExplanation.find(assertion)->second; } diff --git a/src/proof/lrat/lrat_proof.cpp b/src/proof/lrat/lrat_proof.cpp index 1685ad1c3..4a19f07be 100644 --- a/src/proof/lrat/lrat_proof.cpp +++ b/src/proof/lrat/lrat_proof.cpp @@ -24,7 +24,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "proof/dimacs.h" #include "proof/lfsc_proof_printer.h" @@ -151,9 +151,9 @@ LratProof LratProof::fromDratProof( drat2er::drat_trim::CheckAndConvertToLRAT( formulaFilename, dratFilename, lratFilename, drat2er::options::QUIET); #else - Unimplemented( - "LRAT proof production requires drat2er.\n" - "Run contrib/get-drat2er, reconfigure with --drat2er, and rebuild"); + Unimplemented() + << "LRAT proof production requires drat2er.\n" + << "Run contrib/get-drat2er, reconfigure with --drat2er, and rebuild"; #endif } @@ -221,7 +221,8 @@ LratProof::LratProof(std::istream& textualProof) SatLiteral lit; firstS >> lit; Trace("pf::lrat") << "First lit: " << lit << std::endl; - Assert(!firstS.fail(), "Couldn't parse first literal from addition line"); + Assert(!firstS.fail()) + << "Couldn't parse first literal from addition line"; SatClause clause; for (; lit != 0; textualProof >> lit) diff --git a/src/proof/proof_manager.cpp b/src/proof/proof_manager.cpp index f68d5937c..fa4c1ecb5 100644 --- a/src/proof/proof_manager.cpp +++ b/src/proof/proof_manager.cpp @@ -17,7 +17,7 @@ #include "proof/proof_manager.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/context.h" #include "options/bv_options.h" #include "options/proof_options.h" @@ -97,52 +97,52 @@ const Proof& ProofManager::getProof(SmtEngine* smt) } CoreSatProof* ProofManager::getSatProof() { - Assert (currentPM()->d_satProof); + Assert(currentPM()->d_satProof); return currentPM()->d_satProof; } CnfProof* ProofManager::getCnfProof() { - Assert (currentPM()->d_cnfProof); + Assert(currentPM()->d_cnfProof); return currentPM()->d_cnfProof; } TheoryProofEngine* ProofManager::getTheoryProofEngine() { - Assert (currentPM()->d_theoryProof != NULL); + Assert(currentPM()->d_theoryProof != NULL); return currentPM()->d_theoryProof; } UFProof* ProofManager::getUfProof() { - Assert (options::proof()); + Assert(options::proof()); TheoryProof* pf = getTheoryProofEngine()->getTheoryProof(theory::THEORY_UF); return (UFProof*)pf; } proof::ResolutionBitVectorProof* ProofManager::getBitVectorProof() { - Assert (options::proof()); + Assert(options::proof()); TheoryProof* pf = getTheoryProofEngine()->getTheoryProof(theory::THEORY_BV); return static_cast(pf); } ArrayProof* ProofManager::getArrayProof() { - Assert (options::proof()); + Assert(options::proof()); TheoryProof* pf = getTheoryProofEngine()->getTheoryProof(theory::THEORY_ARRAYS); return (ArrayProof*)pf; } ArithProof* ProofManager::getArithProof() { - Assert (options::proof()); + Assert(options::proof()); TheoryProof* pf = getTheoryProofEngine()->getTheoryProof(theory::THEORY_ARITH); return (ArithProof*)pf; } SkolemizationManager* ProofManager::getSkolemizationManager() { - Assert (options::proof() || options::unsatCores()); + Assert(options::proof() || options::unsatCores()); return &(currentPM()->d_skolemizationManager); } void ProofManager::initSatProof(Minisat::Solver* solver) { - Assert (currentPM()->d_satProof == NULL); + Assert(currentPM()->d_satProof == NULL); Assert(currentPM()->d_format == LFSC); currentPM()->d_satProof = new CoreSatProof(solver, d_context, ""); } @@ -151,8 +151,8 @@ void ProofManager::initCnfProof(prop::CnfStream* cnfStream, context::Context* ctx) { ProofManager* pm = currentPM(); Assert(pm->d_satProof != NULL); - Assert (pm->d_cnfProof == NULL); - Assert (pm->d_format == LFSC); + Assert(pm->d_cnfProof == NULL); + Assert(pm->d_format == LFSC); CnfProof* cnf = new LFSCCnfProof(cnfStream, ctx, ""); pm->d_cnfProof = cnf; @@ -175,8 +175,8 @@ void ProofManager::initCnfProof(prop::CnfStream* cnfStream, } void ProofManager::initTheoryProofEngine() { - Assert (currentPM()->d_theoryProof == NULL); - Assert (currentPM()->d_format == LFSC); + Assert(currentPM()->d_theoryProof == NULL); + Assert(currentPM()->d_format == LFSC); currentPM()->d_theoryProof = new LFSCTheoryProofEngine(); } @@ -250,7 +250,7 @@ bool ProofManager::hasLitName(TNode lit) { } std::string ProofManager::sanitize(TNode node) { - Assert (node.isVar() || node.isConst()); + Assert(node.isVar() || node.isConst()); std::string name = node.toString(); if (node.isVar()) { @@ -282,7 +282,9 @@ void ProofManager::traceDeps(TNode n, ExprSet* coreAssertions) { Debug("cores") << " -- Could not track cause assertion. Failing silently." << std::endl; return; } - InternalError("Cannot trace dependence information back to input assertion:\n`%s'", n.toString().c_str()); + InternalError() + << "Cannot trace dependence information back to input assertion:\n`" + << n << "'"; } Assert(d_deps.find(n) != d_deps.end()); std::vector deps = (*d_deps.find(n)).second; @@ -312,7 +314,9 @@ void ProofManager::traceDeps(TNode n, CDExprSet* coreAssertions) { Debug("cores") << " -- Could not track cause assertion. Failing silently." << std::endl; return; } - InternalError("Cannot trace dependence information back to input assertion:\n`%s'", n.toString().c_str()); + InternalError() + << "Cannot trace dependence information back to input assertion:\n`" + << n << "'"; } Assert(d_deps.find(n) != d_deps.end()); std::vector deps = (*d_deps.find(n)).second; @@ -327,7 +331,7 @@ void ProofManager::traceDeps(TNode n, CDExprSet* coreAssertions) { } void ProofManager::traceUnsatCore() { - Assert (options::unsatCores()); + Assert(options::unsatCores()); d_satProof->refreshProof(); IdToSatClause used_lemmas; IdToSatClause used_inputs; @@ -375,8 +379,9 @@ void ProofManager::constructSatProof() { } void ProofManager::getLemmasInUnsatCore(theory::TheoryId theory, std::vector &lemmas) { - Assert(PROOF_ON(), "Cannot compute unsat core when proofs are off"); - Assert(unsatCoreAvailable(), "Cannot get unsat core at this time. Mabye the input is SAT?" ); + Assert(PROOF_ON()) << "Cannot compute unsat core when proofs are off"; + Assert(unsatCoreAvailable()) + << "Cannot get unsat core at this time. Mabye the input is SAT?"; constructSatProof(); @@ -425,8 +430,9 @@ std::set ProofManager::satClauseToNodeSet(prop::SatClause* clause) { } Node ProofManager::getWeakestImplicantInUnsatCore(Node lemma) { - Assert(PROOF_ON(), "Cannot compute unsat core when proofs are off"); - Assert(unsatCoreAvailable(), "Cannot get unsat core at this time. Mabye the input is SAT?" ); + Assert(PROOF_ON()) << "Cannot compute unsat core when proofs are off"; + Assert(unsatCoreAvailable()) + << "Cannot get unsat core at this time. Mabye the input is SAT?"; // If we're doing aggressive minimization, work on all lemmas, not just conjunctions. if (!options::aggressiveCoreMin() && (lemma.getKind() != kind::AND)) @@ -531,7 +537,7 @@ void ProofManager::addDependence(TNode n, TNode dep) { } void ProofManager::addUnsatCore(Expr formula) { - Assert (d_inputCoreFormulas.find(formula) != d_inputCoreFormulas.end()); + Assert(d_inputCoreFormulas.find(formula) != d_inputCoreFormulas.end()); d_outputCoreFormulas.insert(formula); } @@ -912,7 +918,8 @@ void LFSCProof::checkUnrewrittenAssertion(const NodeSet& rewrites) const for (rewrite = rewrites.begin(); rewrite != rewrites.end(); ++rewrite) { Debug("pf::pm") << "LFSCProof::checkUnrewrittenAssertion: handling " << *rewrite << std::endl; if (ProofManager::currentPM()->have_input_assertion((*rewrite).toExpr())) { - Assert(ProofManager::currentPM()->have_input_assertion((*rewrite).toExpr())); + Assert( + ProofManager::currentPM()->have_input_assertion((*rewrite).toExpr())); Debug("pf::pm") << "LFSCProof::checkUnrewrittenAssertion: this assertion was NOT rewritten!" << std::endl << "\tAdding filter: " << ProofManager::getPreprocessedAssertionName(*rewrite, "") @@ -947,7 +954,8 @@ Node ProofManager::mkOp(TNode n) { Node& op = d_ops[n]; if(op.isNull()) { - Assert((n.getConst() == kind::SELECT) || (n.getConst() == kind::STORE)); + Assert((n.getConst() == kind::SELECT) + || (n.getConst() == kind::STORE)); Debug("mgd-pm-mkop") << "making an op for " << n << "\n"; @@ -1036,12 +1044,12 @@ std::ostream& operator<<(std::ostream& out, CVC4::ProofRule k) { } void ProofManager::registerRewrite(unsigned ruleId, Node original, Node result){ - Assert (currentPM()->d_theoryProof != NULL); + Assert(currentPM()->d_theoryProof != NULL); currentPM()->d_rewriteLog.push_back(RewriteLogEntry(ruleId, original, result)); } void ProofManager::clearRewriteLog() { - Assert (currentPM()->d_theoryProof != NULL); + Assert(currentPM()->d_theoryProof != NULL); currentPM()->d_rewriteLog.clear(); } diff --git a/src/proof/proof_output_channel.cpp b/src/proof/proof_output_channel.cpp index 449e12225..aa2175e66 100644 --- a/src/proof/proof_output_channel.cpp +++ b/src/proof/proof_output_channel.cpp @@ -17,7 +17,7 @@ #include "proof/proof_output_channel.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "theory/term_registration_visitor.h" #include "theory/valuation.h" @@ -55,8 +55,8 @@ theory::LemmaStatus ProofOutputChannel::lemma(TNode n, ProofRule rule, bool, // following assertion cannot be enabled due to // "test/regress/regress0/arrays/swap_t1_np_nf_ai_00005_007.cvc.smt". // Assert( - // d_lemma.isNull(), - // "Multiple calls to ProofOutputChannel::lemma() are not supported."); + // d_lemma.isNull()) << + // "Multiple calls to ProofOutputChannel::lemma() are not supported."; d_lemma = n; return theory::LemmaStatus(TNode::null(), 0); } diff --git a/src/proof/proof_utils.h b/src/proof/proof_utils.h index cb509063d..66e20069d 100644 --- a/src/proof/proof_utils.h +++ b/src/proof/proof_utils.h @@ -107,7 +107,7 @@ inline unsigned getSize(Type type) { inline unsigned getSize(Expr node) { - Assert (node.getType().isBitVector()); + Assert(node.getType().isBitVector()); return getSize(node.getType()); } @@ -147,7 +147,7 @@ inline Expr mkConst(const BitVector& value) { inline Expr mkOr(const std::vector& nodes) { std::set all; all.insert(nodes.begin(), nodes.end()); - Assert(all.size() != 0 ); + Assert(all.size() != 0); if (all.size() == 1) { // All the same, or just one @@ -220,8 +220,7 @@ inline Expr mkSortedExpr(Kind kind, const std::vector& children) { }/* mkSortedNode() */ inline const bool getBit(Expr expr, unsigned i) { - Assert (i < utils::getSize(expr) && - expr.isConst()); + Assert(i < utils::getSize(expr) && expr.isConst()); Integer bit = expr.getConst().extract(i, i).getValue(); return (bit == 1u); } diff --git a/src/proof/resolution_bitvector_proof.cpp b/src/proof/resolution_bitvector_proof.cpp index 505500d5e..f4ced1748 100644 --- a/src/proof/resolution_bitvector_proof.cpp +++ b/src/proof/resolution_bitvector_proof.cpp @@ -513,9 +513,9 @@ void LfscResolutionBitVectorProof::printBBDeclarationAndCnf(std::ostream& os, void LfscResolutionBitVectorProof::printEmptyClauseProof(std::ostream& os, std::ostream& paren) { - Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER, - "the BV theory should only be proving bottom directly in the eager " - "bitblasting mode"); + Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) + << "the BV theory should only be proving bottom directly in the eager " + "bitblasting mode"; proof::LFSCProofPrinter::printResolutionEmptyClause( d_resolutionProof.get(), os, paren); } diff --git a/src/proof/skolemization_manager.cpp b/src/proof/skolemization_manager.cpp index b0397d08c..44ca08fa6 100644 --- a/src/proof/skolemization_manager.cpp +++ b/src/proof/skolemization_manager.cpp @@ -37,13 +37,14 @@ bool SkolemizationManager::hasSkolem(Node disequality) { Node SkolemizationManager::getSkolem(Node disequality) { Debug("pf::pm") << "SkolemizationManager: getSkolem( "; - Assert (d_disequalityToSkolem.find(disequality) != d_disequalityToSkolem.end()); + Assert(d_disequalityToSkolem.find(disequality) + != d_disequalityToSkolem.end()); Debug("pf::pm") << disequality << " ) = " << d_disequalityToSkolem[disequality] << std::endl; return d_disequalityToSkolem[disequality]; } Node SkolemizationManager::getDisequality(Node skolem) { - Assert (d_skolemToDisequality.find(skolem) != d_skolemToDisequality.end()); + Assert(d_skolemToDisequality.find(skolem) != d_skolemToDisequality.end()); return d_skolemToDisequality[skolem]; } diff --git a/src/proof/theory_proof.cpp b/src/proof/theory_proof.cpp index c66aa59e4..1f3e6abf1 100644 --- a/src/proof/theory_proof.cpp +++ b/src/proof/theory_proof.cpp @@ -16,7 +16,7 @@ **/ #include "proof/theory_proof.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/context.h" #include "options/bv_options.h" #include "options/proof_options.h" @@ -103,7 +103,9 @@ void TheoryProofEngine::registerTheory(theory::Theory* th) { bvp = new proof::LfscErBitVectorProof(thBv, this); break; } - default: { Unreachable("Invalid BvProofFormat"); + default: + { + Unreachable() << "Invalid BvProofFormat"; } }; d_theoryProofTable[id] = bvp; @@ -154,9 +156,9 @@ TheoryProof* TheoryProofEngine::getTheoryProof(theory::TheoryId id) { } if (d_theoryProofTable.find(id) == d_theoryProofTable.end()) { - std::stringstream ss; - ss << "Error! Proofs not yet supported for the following theory: " << id << std::endl; - InternalError(ss.str().c_str()); + InternalError() + << "Error! Proofs not yet supported for the following theory: " << id + << std::endl; } return d_theoryProofTable[id]; @@ -221,7 +223,7 @@ theory::TheoryId TheoryProofEngine::getTheoryForLemma(const prop::SatClause* cla Node node = pm->getCnfProof()->getAtom(lit.getSatVariable()); Expr atom = node.toExpr(); if (atom.isConst()) { - Assert (atom == utils::mkTrue()); + Assert(atom == utils::mkTrue()); continue; } @@ -229,7 +231,7 @@ theory::TheoryId TheoryProofEngine::getTheoryForLemma(const prop::SatClause* cla } // Ensure that the lemma is in the database. - Assert (pm->getCnfProof()->haveProofRecipe(nodes)); + Assert(pm->getCnfProof()->haveProofRecipe(nodes)); return pm->getCnfProof()->getProofRecipe(nodes).getTheory(); } @@ -257,7 +259,7 @@ void LFSCTheoryProofEngine::printLetTerm(Expr term, std::ostream& os) { Expr current_expr = let_order[i].expr; unsigned let_id = let_order[i].id; ProofLetMap::const_iterator it = map.find(current_expr); - Assert (it != map.end()); + Assert(it != map.end()); unsigned let_count = it->second.count; Assert(let_count); // skip terms that only appear once @@ -387,8 +389,8 @@ void LFSCTheoryProofEngine::printLemmaRewrites(NodePairSet& rewrites, Node n1 = it->first; Node n2 = it->second; - Assert(n1.toExpr() == utils::mkFalse() || - theory::Theory::theoryOf(n1) == theory::Theory::theoryOf(n2)); + Assert(n1.toExpr() == utils::mkFalse() + || theory::Theory::theoryOf(n1) == theory::Theory::theoryOf(n2)); std::ostringstream rewriteRule; rewriteRule << ".lrr" << d_assertionToRewrite.size(); @@ -462,7 +464,7 @@ void LFSCTheoryProofEngine::dumpTheoryLemmas(const IdToSatClause& lemmas) { prop::SatLiteral lit = (*clause)[i]; Node node = pm->getCnfProof()->getAtom(lit.getSatVariable()); if (node.isConst()) { - Assert (node.toExpr() == utils::mkTrue()); + Assert(node.toExpr() == utils::mkTrue()); continue; } nodes.insert(lit.isNegated() ? node.notNode() : node); @@ -493,8 +495,8 @@ void LFSCTheoryProofEngine::finalizeBvConflicts(const IdToSatClause& lemmas, std // The literals (true) and (not false) are omitted from conflicts if (atom.isConst()) { - Assert (atom == utils::mkTrue() || - (atom == utils::mkFalse() && lit.isNegated())); + Assert(atom == utils::mkTrue() + || (atom == utils::mkFalse() && lit.isNegated())); continue; } @@ -584,7 +586,7 @@ void LFSCTheoryProofEngine::printTheoryLemmas(const IdToSatClause& lemmas, ProofManager::getBitVectorProof()->printBBDeclarationAndCnf(os, paren, map); if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) { - Assert (lemmas.size() == 1); + Assert(lemmas.size() == 1); // nothing more to do (no combination with eager so far) return; } @@ -606,7 +608,7 @@ void LFSCTheoryProofEngine::printTheoryLemmas(const IdToSatClause& lemmas, Node node = pm->getCnfProof()->getAtom(lit.getSatVariable()); Expr atom = node.toExpr(); if (atom.isConst()) { - Assert (atom == utils::mkTrue()); + Assert(atom == utils::mkTrue()); continue; } Expr expr_lit = lit.isNegated() ? atom.notExpr(): atom; @@ -922,7 +924,7 @@ void LFSCTheoryProofEngine::printCoreTerm(Expr term, std::ostream& os, const Pro case kind::DISTINCT: // Distinct nodes can have any number of chidlren. - Assert (term.getNumChildren() >= 2); + Assert(term.getNumChildren() >= 2); if (term.getNumChildren() == 2) { os << "(not (= "; @@ -999,8 +1001,7 @@ void LFSCTheoryProofEngine::printCoreTerm(Expr term, std::ostream& os, const Pro return; } - default: - Unhandled(k); + default: Unhandled() << k; } } @@ -1010,7 +1011,7 @@ void TheoryProof::printTheoryLemmaProof(std::vector& lemma, std::ostream& paren, const ProofLetMap& map) { // Default method for replaying proofs: assert (negated) literals back to a fresh copy of the theory - Assert(d_theory!=NULL); + Assert(d_theory != NULL); context::UserContext fakeContext; ProofOutputChannel oc; @@ -1032,7 +1033,8 @@ void TheoryProof::printTheoryLemmaProof(std::vector& lemma, os << " (clausify_false trust)"; return; } else { - InternalError(std::string("can't generate theory-proof for ") + ProofManager::currentPM()->getLogic()); + InternalError() << "can't generate theory-proof for " + << ProofManager::currentPM()->getLogic(); } Debug("pf::tp") << "TheoryProof::printTheoryLemmaProof - calling th->ProduceProofs()" << std::endl; @@ -1122,7 +1124,7 @@ BooleanProof::BooleanProof(TheoryProofEngine* proofEngine) {} void BooleanProof::registerTerm(Expr term) { - Assert (term.getType().isBoolean()); + Assert(term.getType().isBoolean()); if (term.isVariable() && d_declarations.find(term) == d_declarations.end()) { d_declarations.insert(term); @@ -1149,7 +1151,7 @@ void LFSCBooleanProof::printConstantDisequalityProof(std::ostream& os, Expr c1, } void LFSCBooleanProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetMap& map) { - Assert (term.getType().isBoolean()); + Assert(term.getType().isBoolean()); if (term.isVariable()) { os << ProofManager::sanitize(term); return; @@ -1224,14 +1226,13 @@ void LFSCBooleanProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLe os << (term.getConst() ? "true" : "false"); return; - default: - Unhandled(k); + default: Unhandled() << k; } } void LFSCBooleanProof::printOwnedSort(Type type, std::ostream& os) { - Assert (type.isBoolean()); + Assert(type.isBoolean()); os << "Bool"; } @@ -1262,7 +1263,7 @@ void LFSCBooleanProof::printTheoryLemmaProof(std::vector& lemma, std::ostream& os, std::ostream& paren, const ProofLetMap& map) { - Unreachable("No boolean lemmas yet!"); + Unreachable() << "No boolean lemmas yet!"; } bool LFSCBooleanProof::printsAsBool(const Node &n) diff --git a/src/proof/uf_proof.cpp b/src/proof/uf_proof.cpp index 10823693d..b88f7dc33 100644 --- a/src/proof/uf_proof.cpp +++ b/src/proof/uf_proof.cpp @@ -119,7 +119,8 @@ Node ProofUF::toStreamRecLFSC(std::ostream& out, } else if (n2[0].getKind() == kind::BOOLEAN_TERM_VARIABLE) { out << ss.str() << " " << ProofManager::getLitName(n2[0]) << "))"; } else { - Assert((n1[0] == n2[0][0] && n1[1] == n2[0][1]) || (n1[1] == n2[0][0] && n1[0] == n2[0][1])); + Assert((n1[0] == n2[0][0] && n1[1] == n2[0][1]) + || (n1[1] == n2[0][0] && n1[0] == n2[0][1])); if(n1[1] == n2[0][0]) { out << "(symm _ _ _ " << ss.str() << ")"; } else { @@ -130,7 +131,8 @@ Node ProofUF::toStreamRecLFSC(std::ostream& out, } else { Node n2 = pf.d_node; Assert(n2.getKind() == kind::EQUAL); - Assert((n1[0] == n2[0] && n1[1] == n2[1]) || (n1[1] == n2[0] && n1[0] == n2[1])); + Assert((n1[0] == n2[0] && n1[1] == n2[1]) + || (n1[1] == n2[0] && n1[0] == n2[1])); out << ss.str(); out << " "; @@ -160,7 +162,8 @@ Node ProofUF::toStreamRecLFSC(std::ostream& out, out << "(cong _ _ _ _ _ _ "; stk.push(pf2); } - Assert(stk.top()->d_children[0]->d_id != theory::eq::MERGED_THROUGH_CONGRUENCE); + Assert(stk.top()->d_children[0]->d_id + != theory::eq::MERGED_THROUGH_CONGRUENCE); NodeBuilder<> b1(kind::PARTIAL_APPLY_UF), b2(kind::PARTIAL_APPLY_UF); const theory::eq::EqProof* pf2 = stk.top(); stk.pop(); @@ -231,7 +234,12 @@ Node ProofUF::toStreamRecLFSC(std::ostream& out, b2 << n2[1-side]; out << ss.str(); } else { - Assert(pf2->d_node[b1.getNumChildren() - (pf2->d_node.getMetaKind() == kind::metakind::PARAMETERIZED ? 0 : 1)] == n2[1-side]); + Assert(pf2->d_node[b1.getNumChildren() + - (pf2->d_node.getMetaKind() + == kind::metakind::PARAMETERIZED + ? 0 + : 1)] + == n2[1 - side]); b1 << n2[1-side]; b2 << n2[side]; out << "(symm _ _ _ " << ss.str() << ")"; @@ -258,7 +266,7 @@ Node ProofUF::toStreamRecLFSC(std::ostream& out, b2 << n2[1-side]; out << ss.str(); } else { - Assert(pf2->d_node[b1.getNumChildren()] == n2[1-side]); + Assert(pf2->d_node[b1.getNumChildren()] == n2[1 - side]); b1 << n2[1-side]; b2 << n2[side]; out << "(symm _ _ _ " << ss.str() << ")"; @@ -618,7 +626,7 @@ void UFProof::registerTerm(Expr term) { void LFSCUFProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetMap& map) { Debug("pf::uf") << std::endl << "(pf::uf) LFSCUfProof::printOwnedTerm: term = " << term << std::endl; - Assert (theory::Theory::theoryOf(term) == theory::THEORY_UF); + Assert(theory::Theory::theoryOf(term) == theory::THEORY_UF); if (term.getKind() == kind::VARIABLE || term.getKind() == kind::SKOLEM || @@ -627,7 +635,7 @@ void LFSCUFProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetMap& return; } - Assert (term.getKind() == kind::APPLY_UF); + Assert(term.getKind() == kind::APPLY_UF); if(term.getType().isBoolean()) { os << "(p_app "; @@ -653,7 +661,7 @@ void LFSCUFProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetMap& void LFSCUFProof::printOwnedSort(Type type, std::ostream& os) { Debug("pf::uf") << std::endl << "(pf::uf) LFSCArrayProof::printOwnedSort: type is: " << type << std::endl; - Assert (type.isSort()); + Assert(type.isSort()); os << type; } @@ -705,7 +713,7 @@ void LFSCUFProof::printTermDeclarations(std::ostream& os, std::ostream& paren) { } os << fparen.str() << "))\n"; } else { - Assert (term.isVariable()); + Assert(term.isVariable()); os << type << ")\n"; } paren << ")"; diff --git a/src/proof/unsat_core.cpp b/src/proof/unsat_core.cpp index 4212331af..0776197cb 100644 --- a/src/proof/unsat_core.cpp +++ b/src/proof/unsat_core.cpp @@ -16,7 +16,7 @@ #include "proof/unsat_core.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/expr_iomanip.h" #include "options/base_options.h" #include "printer/printer.h" diff --git a/src/prop/bvminisat/bvminisat.cpp b/src/prop/bvminisat/bvminisat.cpp index 76d473395..f1e2955da 100644 --- a/src/prop/bvminisat/bvminisat.cpp +++ b/src/prop/bvminisat/bvminisat.cpp @@ -66,7 +66,7 @@ ClauseId BVMinisatSatSolver::addClause(SatClause& clause, // } ClauseId clause_id = ClauseIdError; d_minisat->addClause(minisat_clause, clause_id); - THEORY_PROOF(Assert (clause_id != ClauseIdError);); + THEORY_PROOF(Assert(clause_id != ClauseIdError);); return clause_id; } diff --git a/src/prop/bvminisat/bvminisat.h b/src/prop/bvminisat/bvminisat.h index ca9c553d9..70e0b9157 100644 --- a/src/prop/bvminisat/bvminisat.h +++ b/src/prop/bvminisat/bvminisat.h @@ -74,7 +74,7 @@ public: ClauseId addXorClause(SatClause& clause, bool rhs, bool removable) override { - Unreachable("Minisat does not support native XOR reasoning"); + Unreachable() << "Minisat does not support native XOR reasoning"; } SatValue propagate() override; diff --git a/src/prop/bvminisat/core/Solver.cc b/src/prop/bvminisat/core/Solver.cc index a877f20c3..04658fc38 100644 --- a/src/prop/bvminisat/core/Solver.cc +++ b/src/prop/bvminisat/core/Solver.cc @@ -235,10 +235,10 @@ bool Solver::addClause_(vec& ps, ClauseId& id) clause_added = true; Assert(falseLiteralsCount == 0 || THEORY_PROOF_ON()); - + if(falseLiteralsCount == 0) { if (ps.size() == 0) { - Assert (!THEORY_PROOF_ON()); + Assert(!THEORY_PROOF_ON()); return ok = false; } else if (ps.size() == 1){ @@ -282,10 +282,10 @@ bool Solver::addClause_(vec& ps, ClauseId& id) // Check if it propagates if (ps.size() == falseLiteralsCount + 1) { Clause& cl = ca[cr]; - - Assert (value(cl[0]) == l_Undef); + + Assert(value(cl[0]) == l_Undef); uncheckedEnqueue(cl[0], cr); - Assert (cl.size() > 1); + Assert(cl.size() > 1); CRef confl = propagate(); ok = (confl == CRef_Undef); if(!ok) { @@ -658,7 +658,7 @@ void Solver::analyzeFinal(Lit p, vec& out_conflict) if(d_bvp){ if (level(var(p)) == 0 && d_bvp->isAssumptionConflict()) { - Assert ( marker[var(p)] == 2); + Assert(marker[var(p)] == 2); if (reason(var(p)) == CRef_Undef) { d_bvp->startBVConflict(p); } @@ -775,8 +775,8 @@ lbool Solver::assertAssumption(Lit p, bool propagate) { } void Solver::addMarkerLiteral(Var var) { - // make sure it wasn't already marked - Assert(marker[var] == 0); + // make sure it wasn't already marked + Assert(marker[var] == 0); marker[var] = 1; if(d_bvp){d_bvp->getSatProof()->registerAssumption(var);} } @@ -1284,7 +1284,7 @@ void Solver::explain(Lit p, std::vector& explanation) { assert(level(x) > 0); explanation.push_back(trail[i]); } else { - Assert (level(x) == 0); + Assert(level(x) == 0); if(d_bvp){ d_bvp->getSatProof()->resolveOutUnit(~(trail[i])); } } diff --git a/src/prop/cadical.cpp b/src/prop/cadical.cpp index 479ec2414..f35c343bd 100644 --- a/src/prop/cadical.cpp +++ b/src/prop/cadical.cpp @@ -90,7 +90,7 @@ ClauseId CadicalSolver::addXorClause(SatClause& clause, bool rhs, bool removable) { - Unreachable("CaDiCaL does not support adding XOR clauses."); + Unreachable() << "CaDiCaL does not support adding XOR clauses."; } SatVariable CadicalSolver::newVar(bool isTheoryAtom, @@ -148,7 +148,7 @@ SatValue CadicalSolver::modelValue(SatLiteral l) unsigned CadicalSolver::getAssertionLevel() const { - Unreachable("CaDiCal does not support assertion levels."); + Unreachable() << "CaDiCaL does not support assertion levels."; } bool CadicalSolver::ok() const { return d_okay; } diff --git a/src/prop/cnf_stream.cpp b/src/prop/cnf_stream.cpp index dc4722fa1..7df5fb492 100644 --- a/src/prop/cnf_stream.cpp +++ b/src/prop/cnf_stream.cpp @@ -19,7 +19,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "expr/expr.h" #include "expr/node.h" @@ -138,12 +138,14 @@ void TseitinCnfStream::ensureLiteral(TNode n, bool noPreregistration) { return; } - AlwaysAssertArgument(n.getType().isBoolean(), n, - "CnfStream::ensureLiteral() requires a node of Boolean type.\n" - "got node: %s\n" - "its type: %s\n", - n.toString().c_str(), - n.getType().toString().c_str()); + AlwaysAssertArgument( + n.getType().isBoolean(), + n, + "CnfStream::ensureLiteral() requires a node of Boolean type.\n" + "got node: %s\n" + "its type: %s\n", + n.toString().c_str(), + n.getType().toString().c_str()); bool negated CVC4_UNUSED = false; SatLiteral lit; @@ -231,14 +233,14 @@ void CnfStream::getBooleanVariables(std::vector& outputVariables) const { } void CnfStream::setProof(CnfProof* proof) { - Assert (d_cnfProof == NULL); + Assert(d_cnfProof == NULL); d_cnfProof = proof; } SatLiteral CnfStream::convertAtom(TNode node, bool noPreregistration) { Debug("cnf") << "convertAtom(" << node << ")" << endl; - Assert(!hasLiteral(node), "atom already mapped!"); + Assert(!hasLiteral(node)) << "atom already mapped!"; bool theoryLiteral = false; bool canEliminate = true; @@ -260,11 +262,10 @@ SatLiteral CnfStream::convertAtom(TNode node, bool noPreregistration) { } SatLiteral CnfStream::getLiteral(TNode node) { - Assert(!node.isNull(), "CnfStream: can't getLiteral() of null node"); + Assert(!node.isNull()) << "CnfStream: can't getLiteral() of null node"; - Assert(d_nodeToLiteralMap.contains(node), - "Literal not in the CNF Cache: %s\n", - node.toString().c_str()); + Assert(d_nodeToLiteralMap.contains(node)) + << "Literal not in the CNF Cache: " << node << "\n"; SatLiteral literal = d_nodeToLiteralMap[node]; Debug("cnf") << "CnfStream::getLiteral(" << node << ") => " << literal << std::endl; @@ -272,10 +273,10 @@ SatLiteral CnfStream::getLiteral(TNode node) { } SatLiteral TseitinCnfStream::handleXor(TNode xorNode) { - Assert(!hasLiteral(xorNode), "Atom already mapped!"); - Assert(xorNode.getKind() == XOR, "Expecting an XOR expression!"); - Assert(xorNode.getNumChildren() == 2, "Expecting exactly 2 children!"); - Assert(!d_removable, "Removable clauses can not contain Boolean structure"); + Assert(!hasLiteral(xorNode)) << "Atom already mapped!"; + Assert(xorNode.getKind() == XOR) << "Expecting an XOR expression!"; + Assert(xorNode.getNumChildren() == 2) << "Expecting exactly 2 children!"; + Assert(!d_removable) << "Removable clauses can not contain Boolean structure"; SatLiteral a = toCNF(xorNode[0]); SatLiteral b = toCNF(xorNode[1]); @@ -291,10 +292,10 @@ SatLiteral TseitinCnfStream::handleXor(TNode xorNode) { } SatLiteral TseitinCnfStream::handleOr(TNode orNode) { - Assert(!hasLiteral(orNode), "Atom already mapped!"); - Assert(orNode.getKind() == OR, "Expecting an OR expression!"); - Assert(orNode.getNumChildren() > 1, "Expecting more then 1 child!"); - Assert(!d_removable, "Removable clauses can not contain Boolean structure"); + Assert(!hasLiteral(orNode)) << "Atom already mapped!"; + Assert(orNode.getKind() == OR) << "Expecting an OR expression!"; + Assert(orNode.getNumChildren() > 1) << "Expecting more then 1 child!"; + Assert(!d_removable) << "Removable clauses can not contain Boolean structure"; // Number of children unsigned n_children = orNode.getNumChildren(); @@ -328,10 +329,10 @@ SatLiteral TseitinCnfStream::handleOr(TNode orNode) { } SatLiteral TseitinCnfStream::handleAnd(TNode andNode) { - Assert(!hasLiteral(andNode), "Atom already mapped!"); - Assert(andNode.getKind() == AND, "Expecting an AND expression!"); - Assert(andNode.getNumChildren() > 1, "Expecting more than 1 child!"); - Assert(!d_removable, "Removable clauses can not contain Boolean structure"); + Assert(!hasLiteral(andNode)) << "Atom already mapped!"; + Assert(andNode.getKind() == AND) << "Expecting an AND expression!"; + Assert(andNode.getNumChildren() > 1) << "Expecting more than 1 child!"; + Assert(!d_removable) << "Removable clauses can not contain Boolean structure"; // Number of children unsigned n_children = andNode.getNumChildren(); @@ -365,10 +366,11 @@ SatLiteral TseitinCnfStream::handleAnd(TNode andNode) { } SatLiteral TseitinCnfStream::handleImplies(TNode impliesNode) { - Assert(!hasLiteral(impliesNode), "Atom already mapped!"); - Assert(impliesNode.getKind() == IMPLIES, "Expecting an IMPLIES expression!"); - Assert(impliesNode.getNumChildren() == 2, "Expecting exactly 2 children!"); - Assert(!d_removable, "Removable clauses can not contain Boolean structure"); + Assert(!hasLiteral(impliesNode)) << "Atom already mapped!"; + Assert(impliesNode.getKind() == IMPLIES) + << "Expecting an IMPLIES expression!"; + Assert(impliesNode.getNumChildren() == 2) << "Expecting exactly 2 children!"; + Assert(!d_removable) << "Removable clauses can not contain Boolean structure"; // Convert the children to cnf SatLiteral a = toCNF(impliesNode[0]); @@ -391,9 +393,9 @@ SatLiteral TseitinCnfStream::handleImplies(TNode impliesNode) { SatLiteral TseitinCnfStream::handleIff(TNode iffNode) { - Assert(!hasLiteral(iffNode), "Atom already mapped!"); - Assert(iffNode.getKind() == EQUAL, "Expecting an EQUAL expression!"); - Assert(iffNode.getNumChildren() == 2, "Expecting exactly 2 children!"); + Assert(!hasLiteral(iffNode)) << "Atom already mapped!"; + Assert(iffNode.getKind() == EQUAL) << "Expecting an EQUAL expression!"; + Assert(iffNode.getNumChildren() == 2) << "Expecting exactly 2 children!"; Debug("cnf") << "handleIff(" << iffNode << ")" << endl; @@ -423,9 +425,9 @@ SatLiteral TseitinCnfStream::handleIff(TNode iffNode) { SatLiteral TseitinCnfStream::handleNot(TNode notNode) { - Assert(!hasLiteral(notNode), "Atom already mapped!"); - Assert(notNode.getKind() == NOT, "Expecting a NOT expression!"); - Assert(notNode.getNumChildren() == 1, "Expecting exactly 1 child!"); + Assert(!hasLiteral(notNode)) << "Atom already mapped!"; + Assert(notNode.getKind() == NOT) << "Expecting a NOT expression!"; + Assert(notNode.getNumChildren() == 1) << "Expecting exactly 1 child!"; SatLiteral notLit = ~toCNF(notNode[0]); @@ -435,7 +437,7 @@ SatLiteral TseitinCnfStream::handleNot(TNode notNode) { SatLiteral TseitinCnfStream::handleIte(TNode iteNode) { Assert(iteNode.getKind() == ITE); Assert(iteNode.getNumChildren() == 3); - Assert(!d_removable, "Removable clauses can not contain Boolean structure"); + Assert(!d_removable) << "Removable clauses can not contain Boolean structure"; Debug("cnf") << "handleIte(" << iteNode[0] << " " << iteNode[1] << " " << iteNode[2] << ")" << endl; @@ -539,7 +541,7 @@ void TseitinCnfStream::convertAndAssertAnd(TNode node, bool negated) { SatClause clause(nChildren); TNode::const_iterator disjunct = node.begin(); for(int i = 0; i < nChildren; ++ disjunct, ++ i) { - Assert( disjunct != node.end() ); + Assert(disjunct != node.end()); clause[i] = toCNF(*disjunct, true); } Assert(disjunct == node.end()); @@ -555,7 +557,7 @@ void TseitinCnfStream::convertAndAssertOr(TNode node, bool negated) { SatClause clause(nChildren); TNode::const_iterator disjunct = node.begin(); for(int i = 0; i < nChildren; ++ disjunct, ++ i) { - Assert( disjunct != node.end() ); + Assert(disjunct != node.end()); clause[i] = toCNF(*disjunct, false); } Assert(disjunct == node.end()); diff --git a/src/prop/cryptominisat.cpp b/src/prop/cryptominisat.cpp index 62e2c5a43..8a70bedce 100644 --- a/src/prop/cryptominisat.cpp +++ b/src/prop/cryptominisat.cpp @@ -149,7 +149,7 @@ bool CryptoMinisatSolver::ok() const { SatVariable CryptoMinisatSolver::newVar(bool isTheoryAtom, bool preRegister, bool canErase){ d_solver->new_var(); ++d_numVariables; - Assert (d_numVariables == d_solver->nVars()); + Assert(d_numVariables == d_solver->nVars()); return d_numVariables - 1; } @@ -179,7 +179,8 @@ SatValue CryptoMinisatSolver::solve(){ SatValue CryptoMinisatSolver::solve(long unsigned int& resource) { // CMSat::SalverConf conf = d_solver->getConf(); - Unreachable("Not sure how to set different limits for calls to solve in Cryptominisat"); + Unreachable() << "Not sure how to set different limits for calls to solve in " + "Cryptominisat"; return solve(); } @@ -198,7 +199,7 @@ SatValue CryptoMinisatSolver::solve(const std::vector& assumptions) SatValue CryptoMinisatSolver::value(SatLiteral l){ const std::vector model = d_solver->get_model(); CMSatVar var = l.getSatVariable(); - Assert (var < model.size()); + Assert(var < model.size()); CMSat::lbool value = model[var]; return toSatLiteralValue(value); } @@ -208,7 +209,7 @@ SatValue CryptoMinisatSolver::modelValue(SatLiteral l){ } unsigned CryptoMinisatSolver::getAssertionLevel() const { - Unreachable("No interface to get assertion level in Cryptominisat"); + Unreachable() << "No interface to get assertion level in Cryptominisat"; return -1; } diff --git a/src/prop/minisat/core/Solver.cc b/src/prop/minisat/core/Solver.cc index c8a2e16c2..5b097dc39 100644 --- a/src/prop/minisat/core/Solver.cc +++ b/src/prop/minisat/core/Solver.cc @@ -210,7 +210,7 @@ Var Solver::newVar(bool sign, bool dvar, bool isTheoryAtom, bool preRegister, bo void Solver::resizeVars(int newSize) { assert(enable_incremental); assert(decisionLevel() == 0); - Assert(newSize >= 2, "always keep true/false"); + Assert(newSize >= 2) << "always keep true/false"; if (newSize < nVars()) { int shrinkSize = nVars() - newSize; @@ -626,7 +626,8 @@ Lit Solver::pickBranchLit() return lit_Undef; } if(nextLit != lit_Undef) { - Assert(value(var(nextLit)) == l_Undef, "literal to decide already has value"); + Assert(value(var(nextLit)) == l_Undef) + << "literal to decide already has value"; decisions++; Var next = var(nextLit); if(polarity[next] & 0x2) { @@ -1736,7 +1737,7 @@ CRef Solver::updateLemmas() { // If it's an empty lemma, we have a conflict at zero level if (lemma.size() == 0) { - Assert (! PROOF_ON()); + Assert(!PROOF_ON()); conflict = CRef_Lazy; backtrackLevel = 0; Debug("minisat::lemmas") << "Solver::updateLemmas(): found empty clause" << std::endl; @@ -1766,7 +1767,7 @@ CRef Solver::updateLemmas() { // Last index in the trail int backtrack_index = trail.size(); - PROOF(Assert (lemmas.size() == (int)lemmas_cnf_assertion.size());); + PROOF(Assert(lemmas.size() == (int)lemmas_cnf_assertion.size());); // Attach all the clauses and enqueue all the propagations for (int i = 0; i < lemmas.size(); ++ i) @@ -1839,7 +1840,7 @@ CRef Solver::updateLemmas() { } } - PROOF(Assert (lemmas.size() == (int)lemmas_cnf_assertion.size());); + PROOF(Assert(lemmas.size() == (int)lemmas_cnf_assertion.size());); // Clear the lemmas lemmas.clear(); lemmas_cnf_assertion.clear(); @@ -1881,7 +1882,7 @@ void ClauseAllocator::reloc(CRef& cr, inline bool Solver::withinBudget(uint64_t amount) const { - Assert (proxy); + Assert(proxy); // spendResource sets async_interrupt or throws UnsafeInterruptException // depending on whether hard-limit is enabled proxy->spendResource(amount); diff --git a/src/prop/minisat/minisat.cpp b/src/prop/minisat/minisat.cpp index 4995a60dd..3cdd6b654 100644 --- a/src/prop/minisat/minisat.cpp +++ b/src/prop/minisat/minisat.cpp @@ -151,7 +151,7 @@ ClauseId MinisatSatSolver::addClause(SatClause& clause, bool removable) { return ClauseIdUndef; } d_minisat->addClause(minisat_clause, removable, clause_id); - PROOF( Assert (clause_id != ClauseIdError);); + PROOF(Assert(clause_id != ClauseIdError);); return clause_id; } diff --git a/src/prop/minisat/minisat.h b/src/prop/minisat/minisat.h index d4720def5..3cc0ed120 100644 --- a/src/prop/minisat/minisat.h +++ b/src/prop/minisat/minisat.h @@ -44,7 +44,7 @@ public: ClauseId addClause(SatClause& clause, bool removable) override; ClauseId addXorClause(SatClause& clause, bool rhs, bool removable) override { - Unreachable("Minisat does not support native XOR reasoning"); + Unreachable() << "Minisat does not support native XOR reasoning"; } SatVariable newVar(bool isTheoryAtom, diff --git a/src/prop/prop_engine.cpp b/src/prop/prop_engine.cpp index 55d8f7222..8a0cc9f15 100644 --- a/src/prop/prop_engine.cpp +++ b/src/prop/prop_engine.cpp @@ -20,7 +20,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "decision/decision_engine.h" #include "expr/expr.h" @@ -30,13 +30,12 @@ #include "options/options.h" #include "options/smt_options.h" #include "proof/proof_manager.h" -#include "proof/proof_manager.h" #include "prop/cnf_stream.h" #include "prop/sat_solver.h" #include "prop/sat_solver_factory.h" #include "prop/theory_proxy.h" -#include "smt/smt_statistics_registry.h" #include "smt/command.h" +#include "smt/smt_statistics_registry.h" #include "theory/theory_engine.h" #include "theory/theory_registrar.h" #include "util/resource_manager.h" @@ -119,7 +118,7 @@ PropEngine::~PropEngine() { } void PropEngine::assertFormula(TNode node) { - Assert(!d_inCheckSat, "Sat solver in solve()!"); + Assert(!d_inCheckSat) << "Sat solver in solve()!"; Debug("prop") << "assertFormula(" << node << ")" << endl; // Assert as non-removable d_cnfStream->convertAndAssert(node, false, false, RULE_GIVEN); @@ -170,7 +169,7 @@ void PropEngine::printSatisfyingAssignment(){ } Result PropEngine::checkSat() { - Assert(!d_inCheckSat, "Sat solver in solve()!"); + Assert(!d_inCheckSat) << "Sat solver in solve()!"; Debug("prop") << "PropEngine::checkSat()" << endl; // Mark that we are in the checkSat @@ -261,13 +260,13 @@ void PropEngine::ensureLiteral(TNode n) { } void PropEngine::push() { - Assert(!d_inCheckSat, "Sat solver in solve()!"); + Assert(!d_inCheckSat) << "Sat solver in solve()!"; d_satSolver->push(); Debug("prop") << "push()" << endl; } void PropEngine::pop() { - Assert(!d_inCheckSat, "Sat solver in solve()!"); + Assert(!d_inCheckSat) << "Sat solver in solve()!"; d_satSolver->pop(); Debug("prop") << "pop()" << endl; } diff --git a/src/prop/sat_solver.h b/src/prop/sat_solver.h index 45bfca4d6..9898f3f87 100644 --- a/src/prop/sat_solver.h +++ b/src/prop/sat_solver.h @@ -83,7 +83,7 @@ public: /** Check satisfiability under assumptions */ virtual SatValue solve(const std::vector& assumptions) { - Unimplemented("Solving under assumptions not implemented"); + Unimplemented() << "Solving under assumptions not implemented"; }; /** Interrupt the solver */ diff --git a/src/prop/sat_solver_factory.cpp b/src/prop/sat_solver_factory.cpp index cfab5703c..460ab3ece 100644 --- a/src/prop/sat_solver_factory.cpp +++ b/src/prop/sat_solver_factory.cpp @@ -44,7 +44,7 @@ SatSolver* SatSolverFactory::createCryptoMinisat(StatisticsRegistry* registry, #ifdef CVC4_USE_CRYPTOMINISAT return new CryptoMinisatSolver(registry, name); #else - Unreachable("CVC4 was not compiled with Cryptominisat support."); + Unreachable() << "CVC4 was not compiled with Cryptominisat support."; #endif } @@ -54,7 +54,7 @@ SatSolver* SatSolverFactory::createCadical(StatisticsRegistry* registry, #ifdef CVC4_USE_CADICAL return new CadicalSolver(registry, name); #else - Unreachable("CVC4 was not compiled with CaDiCaL support."); + Unreachable() << "CVC4 was not compiled with CaDiCaL support."; #endif } diff --git a/src/prop/theory_proxy.cpp b/src/prop/theory_proxy.cpp index f6cd42eff..1258d2ee2 100644 --- a/src/prop/theory_proxy.cpp +++ b/src/prop/theory_proxy.cpp @@ -232,7 +232,7 @@ SatLiteral TheoryProxy::getNextReplayDecision() { void TheoryProxy::logDecision(SatLiteral lit) { #ifdef CVC4_REPLAY if(d_replayLog != NULL) { - Assert(lit != undefSatLiteral, "logging an `undef' decision ?!"); + Assert(lit != undefSatLiteral) << "logging an `undef' decision ?!"; (*d_replayLog) << d_cnfStream->getNode(lit) << std::endl; } #endif /* CVC4_REPLAY */ diff --git a/src/smt/command.cpp b/src/smt/command.cpp index 8baaeb1e9..76ce1bda9 100644 --- a/src/smt/command.cpp +++ b/src/smt/command.cpp @@ -23,7 +23,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "expr/expr_iomanip.h" #include "expr/node.h" diff --git a/src/smt/managed_ostreams.cpp b/src/smt/managed_ostreams.cpp index fbc1bb242..a73ec44f4 100644 --- a/src/smt/managed_ostreams.cpp +++ b/src/smt/managed_ostreams.cpp @@ -19,6 +19,7 @@ #include +#include "base/check.h" #include "options/open_ostream.h" #include "options/smt_options.h" #include "smt/update_ostream.h" diff --git a/src/smt/model_core_builder.cpp b/src/smt/model_core_builder.cpp index 168ded839..69cd2e7e6 100644 --- a/src/smt/model_core_builder.cpp +++ b/src/smt/model_core_builder.cpp @@ -89,10 +89,10 @@ bool ModelCoreBuilder::setModelCore(const std::vector& assertions, } else { - Unreachable("Unknown model cores mode"); + Unreachable() << "Unknown model cores mode"; } - Assert(minimized, - "cannot compute model core, since model does not satisfy input!"); + Assert(minimized) + << "cannot compute model core, since model does not satisfy input!"; if (minimized) { m->setUsingModelCore(); diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp index 29c3f9092..b934617de 100644 --- a/src/smt/smt_engine.cpp +++ b/src/smt/smt_engine.cpp @@ -29,9 +29,9 @@ #include #include +#include "base/check.h" #include "base/configuration.h" #include "base/configuration_private.h" -#include "base/cvc4_check.h" #include "base/exception.h" #include "base/listener.h" #include "base/modal_exception.h" @@ -1002,9 +1002,9 @@ void SmtEngine::finalOptionsAreSet() { // finish initialization, create the prop engine, etc. finishInit(); - AlwaysAssert( d_propEngine->getAssertionLevel() == 0, - "The PropEngine has pushed but the SmtEngine " - "hasn't finished initializing!" ); + AlwaysAssert(d_propEngine->getAssertionLevel() == 0) + << "The PropEngine has pushed but the SmtEngine " + "hasn't finished initializing!"; d_fullyInited = true; Assert(d_logic.isLocked()); @@ -1139,8 +1139,9 @@ void SmtEngine::setFilename(std::string filename) { d_filename = filename; } std::string SmtEngine::getFilename() const { return d_filename; } void SmtEngine::setLogicInternal() { - Assert(!d_fullyInited, "setting logic in SmtEngine but the engine has already" - " finished initializing for this run"); + Assert(!d_fullyInited) + << "setting logic in SmtEngine but the engine has already" + " finished initializing for this run"; d_logic.lock(); } @@ -2504,8 +2505,8 @@ CVC4::SExpr SmtEngine::getInfo(const std::string& key) const { "last result wasn't unknown!"); } } else if(key == "assertion-stack-levels") { - AlwaysAssert(d_userLevels.size() <= - std::numeric_limits::max()); + AlwaysAssert(d_userLevels.size() + <= std::numeric_limits::max()); return SExpr(static_cast(d_userLevels.size())); } else if(key == "all-options") { // get the options, like all-statistics @@ -3018,10 +3019,9 @@ bool SmtEnginePrivate::simplifyAssertions() // theory could still create a new expression that isn't // well-typed, and we don't want the C++ runtime to abort our // process without any error notice. - stringstream ss; - ss << "A bad expression was produced. Original exception follows:\n" - << tcep; - InternalError(ss.str().c_str()); + InternalError() + << "A bad expression was produced. Original exception follows:\n" + << tcep; } return true; } @@ -3357,16 +3357,17 @@ void SmtEnginePrivate::processAssertions() { //fmf-fun : assume admissible functions, applying preprocessing reduction to FMF if( options::fmfFunWellDefined() ){ quantifiers::FunDefFmf fdf; - Assert( d_smt.d_fmfRecFunctionsDefined!=NULL ); + Assert(d_smt.d_fmfRecFunctionsDefined != NULL); //must carry over current definitions (for incremental) for( context::CDList::const_iterator fit = d_smt.d_fmfRecFunctionsDefined->begin(); fit != d_smt.d_fmfRecFunctionsDefined->end(); ++fit ) { Node f = (*fit); - Assert( d_smt.d_fmfRecFunctionsAbs.find( f )!=d_smt.d_fmfRecFunctionsAbs.end() ); + Assert(d_smt.d_fmfRecFunctionsAbs.find(f) + != d_smt.d_fmfRecFunctionsAbs.end()); TypeNode ft = d_smt.d_fmfRecFunctionsAbs[f]; fdf.d_sorts[f] = ft; std::map< Node, std::vector< Node > >::iterator fcit = d_smt.d_fmfRecFunctionsConcrete.find( f ); - Assert( fcit!=d_smt.d_fmfRecFunctionsConcrete.end() ); + Assert(fcit != d_smt.d_fmfRecFunctionsConcrete.end()); for( unsigned j=0; jsecond.size(); j++ ){ fdf.d_input_arg_inj[f].push_back( fcit->second[j] ); } @@ -4233,8 +4234,8 @@ Expr SmtEngine::getValue(const Expr& ex) const // Notice that lambdas have function type, which does not respect the subtype // relation, so we ignore them here. Assert(resultNode.isNull() || resultNode.getKind() == kind::LAMBDA - || resultNode.getType().isSubtypeOf(expectedType), - "Run with -t smt for details."); + || resultNode.getType().isSubtypeOf(expectedType)) + << "Run with -t smt for details."; // Ensure it's a constant, or a lambda (for uninterpreted functions), or // a choice (for approximate values). @@ -4480,9 +4481,9 @@ std::pair SmtEngine::getSepHeapAndNilExpr(void) { return std::make_pair(heap, nil); } - InternalError( - "SmtEngine::getSepHeapAndNilExpr(): failed to obtain heap/nil " - "expressions from theory model."); + InternalError() + << "SmtEngine::getSepHeapAndNilExpr(): failed to obtain heap/nil " + "expressions from theory model."; } std::vector SmtEngine::getExpandedAssertions() @@ -4535,9 +4536,9 @@ void SmtEngine::checkProof() // lfscc_cleanup(); #else /* (IS_LFSC_BUILD && IS_PROOFS_BUILD) */ - Unreachable( - "This version of CVC4 was built without proof support; cannot check " - "proofs."); + Unreachable() + << "This version of CVC4 was built without proof support; cannot check " + "proofs."; #endif /* (IS_LFSC_BUILD && IS_PROOFS_BUILD) */ } @@ -4566,7 +4567,8 @@ UnsatCore SmtEngine::getUnsatCoreInternal() } void SmtEngine::checkUnsatCore() { - Assert(options::unsatCores(), "cannot check unsat core if unsat cores are turned off"); + Assert(options::unsatCores()) + << "cannot check unsat core if unsat cores are turned off"; Notice() << "SmtEngine::checkUnsatCore(): generating unsat core" << endl; UnsatCore core = getUnsatCore(); @@ -4598,18 +4600,21 @@ void SmtEngine::checkUnsatCore() { } Notice() << "SmtEngine::checkUnsatCore(): result is " << r << endl; if(r.asSatisfiabilityResult().isUnknown()) { - InternalError("SmtEngine::checkUnsatCore(): could not check core result unknown."); + InternalError() + << "SmtEngine::checkUnsatCore(): could not check core result unknown."; } if(r.asSatisfiabilityResult().isSat()) { - InternalError("SmtEngine::checkUnsatCore(): produced core was satisfiable."); + InternalError() + << "SmtEngine::checkUnsatCore(): produced core was satisfiable."; } } void SmtEngine::checkModel(bool hardFailure) { // --check-model implies --produce-assertions, which enables the // assertion list, so we should be ok. - Assert(d_assertionList != NULL, "don't have an assertion list to check in SmtEngine::checkModel()"); + Assert(d_assertionList != NULL) + << "don't have an assertion list to check in SmtEngine::checkModel()"; TimerStat::CodeTimer checkModelTimer(d_stats->d_checkModelTime); @@ -4681,20 +4686,21 @@ void SmtEngine::checkModel(bool hardFailure) { } ss << "so " << func << " is defined in terms of itself." << endl << "Run with `--check-models -v' for additional diagnostics."; - InternalError(ss.str()); + InternalError() << ss.str(); } } // (2) check that the value is actually a value else if (!val.isConst()) { Notice() << "SmtEngine::checkModel(): *** PROBLEM: MODEL VALUE NOT A CONSTANT ***" << endl; - stringstream ss; - ss << "SmtEngine::checkModel(): ERRORS SATISFYING ASSERTIONS WITH MODEL:" << endl - << "model value for " << func << endl - << " is " << val << endl - << "and that is not a constant (.isConst() == false)." << endl - << "Run with `--check-models -v' for additional diagnostics."; - InternalError(ss.str()); + InternalError() + << "SmtEngine::checkModel(): ERRORS SATISFYING ASSERTIONS WITH " + "MODEL:" + << endl + << "model value for " << func << endl + << " is " << val << endl + << "and that is not a constant (.isConst() == false)." << endl + << "Run with `--check-models -v' for additional diagnostics."; } // (3) check that it's the correct (sub)type @@ -4702,14 +4708,15 @@ void SmtEngine::checkModel(bool hardFailure) { // e.g. "1" is an INT, which isn't a subrange type [1..10] (etc.). else if(func.getType().isInteger() && !val.getType().isInteger()) { Notice() << "SmtEngine::checkModel(): *** PROBLEM: MODEL VALUE NOT CORRECT TYPE ***" << endl; - stringstream ss; - ss << "SmtEngine::checkModel(): ERRORS SATISFYING ASSERTIONS WITH MODEL:" << endl - << "model value for " << func << endl - << " is " << val << endl - << "value type is " << val.getType() << endl - << "should be of type " << func.getType() << endl - << "Run with `--check-models -v' for additional diagnostics."; - InternalError(ss.str()); + InternalError() + << "SmtEngine::checkModel(): ERRORS SATISFYING ASSERTIONS WITH " + "MODEL:" + << endl + << "model value for " << func << endl + << " is " << val << endl + << "value type is " << val.getType() << endl + << "should be of type " << func.getType() << endl + << "Run with `--check-models -v' for additional diagnostics."; } // (4) checks complete, add the substitution @@ -4779,7 +4786,7 @@ void SmtEngine::checkModel(bool hardFailure) { // this is necessary until preprocessing passes explicitly record how they rewrite quantified formulas if( hardFailure && !n.isConst() && n.getKind() != kind::LAMBDA ){ Notice() << "SmtEngine::checkModel(): -- relax check model wrt quantified formulas..." << endl; - AlwaysAssert( quantifiers::QuantifiersRewriter::containsQuantifiers( n ) ); + AlwaysAssert(quantifiers::QuantifiersRewriter::containsQuantifiers(n)); Warning() << "Warning : SmtEngine::checkModel(): cannot check simplified assertion : " << n << endl; continue; } @@ -4798,7 +4805,7 @@ void SmtEngine::checkModel(bool hardFailure) { << "expected `true'." << endl << "Run with `--check-models -v' for additional diagnostics."; if(hardFailure) { - InternalError(ss.str()); + InternalError() << ss.str(); } else { Warning() << ss.str() << endl; } @@ -4901,15 +4908,15 @@ void SmtEngine::checkSynthSolution() Trace("check-synth-sol") << "Satsifiability check: " << r << "\n"; if (r.asSatisfiabilityResult().isUnknown()) { - InternalError( - "SmtEngine::checkSynthSolution(): could not check solution, result " - "unknown."); + InternalError() << "SmtEngine::checkSynthSolution(): could not check " + "solution, result " + "unknown."; } else if (r.asSatisfiabilityResult().isSat()) { - InternalError( - "SmtEngine::checkSynthSolution(): produced solution leads to " - "satisfiable negated conjecture."); + InternalError() + << "SmtEngine::checkSynthSolution(): produced solution leads to " + "satisfiable negated conjecture."; } solChecker.resetAssertions(); } @@ -4974,7 +4981,7 @@ void SmtEngine::checkAbduct(Expr a) // did we get an unexpected result? if (isError) { - InternalError(serr.str().c_str()); + InternalError() << serr.str(); } } } @@ -5025,7 +5032,7 @@ void SmtEngine::printInstantiations( std::ostream& out ) { if( d_theoryEngine ){ d_theoryEngine->printInstantiations( out ); }else{ - Assert( false ); + Assert(false); } if( options::instFormatMode()==INST_FORMAT_MODE_SZS ){ out << "% SZS output end Proof for " << d_filename.c_str() << std::endl; @@ -5038,7 +5045,7 @@ void SmtEngine::printSynthSolution( std::ostream& out ) { if( d_theoryEngine ){ d_theoryEngine->printSynthSolution( out ); }else{ - Assert( false ); + Assert(false); } } @@ -5083,23 +5090,23 @@ Expr SmtEngine::doQuantifierElimination(const Expr& e, bool doFull, bool strict) e_children.push_back( n_attr ); Node nn_e = NodeManager::currentNM()->mkNode( kind::EXISTS, e_children ); Trace("smt-qe-debug") << "Query for quantifier elimination : " << nn_e << std::endl; - Assert( nn_e.getNumChildren()==3 ); + Assert(nn_e.getNumChildren() == 3); Result r = checkSatisfiability(nn_e.toExpr(), true, true); Trace("smt-qe") << "Query returned " << r << std::endl; if(r.asSatisfiabilityResult().isSat() != Result::UNSAT ) { if( r.asSatisfiabilityResult().isSat() != Result::SAT && doFull ){ - stringstream ss; - ss << "While performing quantifier elimination, unexpected result : " << r << " for query."; - InternalError(ss.str().c_str()); + InternalError() + << "While performing quantifier elimination, unexpected result : " + << r << " for query."; } std::vector< Node > inst_qs; d_theoryEngine->getInstantiatedQuantifiedFormulas( inst_qs ); - Assert( inst_qs.size()<=1 ); + Assert(inst_qs.size() <= 1); Node ret_n; if( inst_qs.size()==1 ){ Node top_q = inst_qs[0]; //Node top_q = Rewriter::rewrite( nn_e ).negate(); - Assert( top_q.getKind()==kind::FORALL ); + Assert(top_q.getKind() == kind::FORALL); Trace("smt-qe") << "Get qe for " << top_q << std::endl; ret_n = d_theoryEngine->getInstantiatedConjunction( top_q ); Trace("smt-qe") << "Returned : " << ret_n << std::endl; @@ -5252,7 +5259,7 @@ void SmtEngine::getInstantiatedQuantifiedFormulas( std::vector< Expr >& qs ) { qs.push_back( qs_n[i].toExpr() ); } }else{ - Assert( false ); + Assert(false); } } @@ -5265,7 +5272,7 @@ void SmtEngine::getInstantiations( Expr q, std::vector< Expr >& insts ) { insts.push_back( insts_n[i].toExpr() ); } }else{ - Assert( false ); + Assert(false); } } @@ -5283,7 +5290,7 @@ void SmtEngine::getInstantiationTermVectors( Expr q, std::vector< std::vector< E tvecs.push_back( tvec ); } }else{ - Assert( false ); + Assert(false); } } @@ -5641,8 +5648,8 @@ CVC4::SExpr SmtEngine::getOption(const std::string& key) const } void SmtEngine::setReplayStream(ExprStream* replayStream) { - AlwaysAssert(!d_fullyInited, - "Cannot set replay stream once fully initialized"); + AlwaysAssert(!d_fullyInited) + << "Cannot set replay stream once fully initialized"; d_replayStream = replayStream; } diff --git a/src/smt/smt_engine_scope.cpp b/src/smt/smt_engine_scope.cpp index c16278962..4b593f075 100644 --- a/src/smt/smt_engine_scope.cpp +++ b/src/smt/smt_engine_scope.cpp @@ -17,8 +17,8 @@ #include "smt/smt_engine_scope.h" +#include "base/check.h" #include "base/configuration_private.h" -#include "base/cvc4_assert.h" #include "base/output.h" #include "proof/proof.h" #include "smt/smt_engine.h" @@ -40,7 +40,8 @@ ProofManager* currentProofManager() { Assert(s_smtEngine_current != NULL); return s_smtEngine_current->d_proofManager; #else /* IS_PROOFS_BUILD */ - InternalError("proofs/unsat cores are not on, but ProofManager requested"); + InternalError() + << "proofs/unsat cores are not on, but ProofManager requested"; return NULL; #endif /* IS_PROOFS_BUILD */ } diff --git a/src/smt/update_ostream.h b/src/smt/update_ostream.h index 0427f4058..53d5e5ce0 100644 --- a/src/smt/update_ostream.h +++ b/src/smt/update_ostream.h @@ -22,12 +22,12 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "expr/expr_iomanip.h" +#include "options/base_options.h" #include "options/language.h" #include "options/set_language.h" -#include "options/base_options.h" #include "smt/dump.h" namespace CVC4 { diff --git a/src/smt_util/boolean_simplification.h b/src/smt_util/boolean_simplification.h index c1e2e4d76..f1bfe6e33 100644 --- a/src/smt_util/boolean_simplification.h +++ b/src/smt_util/boolean_simplification.h @@ -22,7 +22,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/expr_manager_scope.h" #include "expr/node.h" diff --git a/src/smt_util/nary_builder.cpp b/src/smt_util/nary_builder.cpp index 2c2256d47..6c655ad41 100644 --- a/src/smt_util/nary_builder.cpp +++ b/src/smt_util/nary_builder.cpp @@ -77,13 +77,13 @@ Node NaryBuilder::mkAssoc(Kind kind, const std::vector& children){ /* It's inconceivable we could have enough children for this to fail * (more than 2^32, in most cases?). */ - AlwaysAssert( newChildren.size() <= max, - "Too many new children in mkAssociative" ); + AlwaysAssert(newChildren.size() <= max) + << "Too many new children in mkAssociative"; /* It would be really weird if this happened (it would require * min > 2, for one thing), but let's make sure. */ - AlwaysAssert( newChildren.size() >= min, - "Too few new children in mkAssociative" ); + AlwaysAssert(newChildren.size() >= min) + << "Too few new children in mkAssociative"; return nm->mkNode(kind,newChildren); } @@ -153,7 +153,6 @@ Node RePairAssocCommutativeOperators::case_assoccomm(TNode n){ unsigned N = n.getNumChildren(); Assert(N >= 2); - Node last = rePairAssocCommutativeOperators( n[N-1]); Node nextToLast = rePairAssocCommutativeOperators(n[N-2]); diff --git a/src/theory/arith/approx_simplex.cpp b/src/theory/arith/approx_simplex.cpp index ea349a383..6b277a10a 100644 --- a/src/theory/arith/approx_simplex.cpp +++ b/src/theory/arith/approx_simplex.cpp @@ -85,7 +85,9 @@ struct VirtualBound { , d(coeff) , y(bounding) , c(orig) - { Assert(k == kind::LEQ || k == kind::GEQ); } + { + Assert(k == kind::LEQ || k == kind::GEQ); + } }; struct CutScratchPad { @@ -621,8 +623,6 @@ ApproxGLPK::ApproxGLPK(const ArithVariables& v, TreeLog& l, ApproximateStatistic Assert(numRows > 0); Assert(numCols > 0); - - glp_add_rows(d_inputProb, numRows); glp_add_cols(d_inputProb, numCols); @@ -994,7 +994,7 @@ ApproxGLPK::~ApproxGLPK(){ ApproximateSimplex::Solution ApproxGLPK::extractSolution(bool mip) const { Assert(d_solvedRelaxation); - Assert(!mip || d_solvedMIP); + Assert(!mip || d_solvedMIP); ApproximateSimplex::Solution sol; DenseSet& newBasis = sol.newBasis; @@ -1737,8 +1737,6 @@ MipResult ApproxGLPK::solveMIP(bool activelyLog){ } } - - // Node explainSet(const set& inp){ // Assert(!inp.empty()); // NodeBuilder<> nb(kind::AND); @@ -2434,7 +2432,7 @@ bool ApproxGLPK::replaceSlacksOnCuts(){ ArithVar x = *iter; SlackReplace rep = d_pad.d_slacks[x]; if(d_vars.isIntegerInput(x)){ - Assert(rep == SlackLB || rep == SlackUB); + Assert(rep == SlackLB || rep == SlackUB); Rational& a = cut.get(x); const DeltaRational& bound = (rep == SlackLB) ? @@ -2835,7 +2833,7 @@ bool ApproxGLPK::gaussianElimConstructTableRow(int nid, int M, const PrimitiveVe // r_p : 0 = -1 * other + sum a_i x_i // rid : 0 = e * other + sum b_i x_i // rid += e * r_p - // : 0 = 0 * other + ... + // : 0 = 0 * other + ... Assert(!e.getCoefficient().isZero()); Rational cp = e.getCoefficient(); diff --git a/src/theory/arith/arith_ite_utils.cpp b/src/theory/arith/arith_ite_utils.cpp index 454d6c11f..3930d7359 100644 --- a/src/theory/arith/arith_ite_utils.cpp +++ b/src/theory/arith/arith_ite_utils.cpp @@ -390,8 +390,8 @@ Node ArithIteUtils::findIteCnd(TNode tb, TNode fb) const{ bool ArithIteUtils::solveBinOr(TNode binor){ Assert(binor.getKind() == kind::OR); Assert(binor.getNumChildren() == 2); - Assert(binor[0].getKind() == kind::EQUAL); - Assert(binor[1].getKind() == kind::EQUAL); + Assert(binor[0].getKind() == kind::EQUAL); + Assert(binor[1].getKind() == kind::EQUAL); //Node n = Node n = applySubstitutions(binor); @@ -411,8 +411,8 @@ bool ArithIteUtils::solveBinOr(TNode binor){ TNode l = n[0]; TNode r = n[1]; - Assert(l.getKind() == kind::EQUAL); - Assert(r.getKind() == kind::EQUAL); + Assert(l.getKind() == kind::EQUAL); + Assert(r.getKind() == kind::EQUAL); Debug("arith::ite") << "bin or " << n << endl; diff --git a/src/theory/arith/arith_rewriter.cpp b/src/theory/arith/arith_rewriter.cpp index 86e5b3195..c8a03fab1 100644 --- a/src/theory/arith/arith_rewriter.cpp +++ b/src/theory/arith/arith_rewriter.cpp @@ -50,7 +50,7 @@ RewriteResponse ArithRewriter::rewriteVariable(TNode t){ } RewriteResponse ArithRewriter::rewriteMinus(TNode t, bool pre){ - Assert(t.getKind()== kind::MINUS); + Assert(t.getKind() == kind::MINUS); if(pre){ if(t[0] == t[1]){ @@ -70,7 +70,7 @@ RewriteResponse ArithRewriter::rewriteMinus(TNode t, bool pre){ } RewriteResponse ArithRewriter::rewriteUMinus(TNode t, bool pre){ - Assert(t.getKind()== kind::UMINUS); + Assert(t.getKind() == kind::UMINUS); if(t[0].getKind() == kind::CONST_RATIONAL){ Rational neg = -(t[0].getConst()); @@ -143,8 +143,7 @@ RewriteResponse ArithRewriter::preRewriteTerm(TNode t){ return RewriteResponse(REWRITE_DONE, t); case kind::PI: return RewriteResponse(REWRITE_DONE, t); - default: - Unhandled(k); + default: Unhandled() << k; } } } @@ -263,7 +262,7 @@ RewriteResponse ArithRewriter::postRewriteTerm(TNode t){ RewriteResponse ArithRewriter::preRewriteMult(TNode t){ - Assert(t.getKind()== kind::MULT || t.getKind()== kind::NONLINEAR_MULT); + Assert(t.getKind() == kind::MULT || t.getKind() == kind::NONLINEAR_MULT); if(t.getNumChildren() == 2){ if(t[0].getKind() == kind::CONST_RATIONAL @@ -321,7 +320,7 @@ static Node flatten(Kind k, TNode t){ } RewriteResponse ArithRewriter::preRewritePlus(TNode t){ - Assert(t.getKind()== kind::PLUS); + Assert(t.getKind() == kind::PLUS); if(canFlatten(kind::PLUS, t)){ return RewriteResponse(REWRITE_DONE, flatten(kind::PLUS, t)); @@ -331,7 +330,7 @@ RewriteResponse ArithRewriter::preRewritePlus(TNode t){ } RewriteResponse ArithRewriter::postRewritePlus(TNode t){ - Assert(t.getKind()== kind::PLUS); + Assert(t.getKind() == kind::PLUS); std::vector monomials; std::vector polynomials; @@ -357,7 +356,7 @@ RewriteResponse ArithRewriter::postRewritePlus(TNode t){ } RewriteResponse ArithRewriter::postRewriteMult(TNode t){ - Assert(t.getKind()== kind::MULT || t.getKind()==kind::NONLINEAR_MULT); + Assert(t.getKind() == kind::MULT || t.getKind() == kind::NONLINEAR_MULT); Polynomial res = Polynomial::mkOne(); @@ -462,7 +461,7 @@ RewriteResponse ArithRewriter::postRewriteTranscendental(TNode t) { pi_factor, nm->mkNode(kind::MULT, ntwo, ra_div_two)); }else{ - Assert( r.sgn()==-1 ); + Assert(r.sgn() == -1); new_pi_factor = nm->mkNode(kind::PLUS, pi_factor, @@ -671,7 +670,7 @@ Node ArithRewriter::makeSubtractionNode(TNode l, TNode r){ } RewriteResponse ArithRewriter::rewriteDiv(TNode t, bool pre){ - Assert(t.getKind() == kind::DIVISION_TOTAL || t.getKind()== kind::DIVISION); + Assert(t.getKind() == kind::DIVISION_TOTAL || t.getKind() == kind::DIVISION); Node left = t[0]; Node right = t[1]; diff --git a/src/theory/arith/arith_static_learner.cpp b/src/theory/arith/arith_static_learner.cpp index 2138b513e..e17605ead 100644 --- a/src/theory/arith/arith_static_learner.cpp +++ b/src/theory/arith/arith_static_learner.cpp @@ -163,8 +163,8 @@ void ArithStaticLearner::iteMinMax(TNode n, NodeBuilder<>& learned){ if(t == cleft && e == cright){ // t == cleft && e == cright - Assert( t == cleft ); - Assert( e == cright ); + Assert(t == cleft); + Assert(e == cright); switch(k){ case LT: // (ite (< x y) x y) case LEQ: { // (ite (<= x y) x y) @@ -270,9 +270,7 @@ void ArithStaticLearner::addBound(TNode n) { Debug("arith::static") << "adding bound " << n << endl; } break; - default: - Unhandled(k); - break; + default: Unhandled() << k; break; } } diff --git a/src/theory/arith/arith_utilities.h b/src/theory/arith/arith_utilities.h index 4588a5848..d737fefeb 100644 --- a/src/theory/arith/arith_utilities.h +++ b/src/theory/arith/arith_utilities.h @@ -207,10 +207,8 @@ inline Node negateConjunctionAsClause(TNode conjunction){ } inline Node maybeUnaryConvert(NodeBuilder<>& builder){ - Assert(builder.getKind() == kind::OR || - builder.getKind() == kind::AND || - builder.getKind() == kind::PLUS || - builder.getKind() == kind::MULT); + Assert(builder.getKind() == kind::OR || builder.getKind() == kind::AND + || builder.getKind() == kind::PLUS || builder.getKind() == kind::MULT); Assert(builder.getNumChildren() >= 1); if(builder.getNumChildren() == 1){ return builder[0]; diff --git a/src/theory/arith/attempt_solution_simplex.cpp b/src/theory/arith/attempt_solution_simplex.cpp index f269847de..8173f2cea 100644 --- a/src/theory/arith/attempt_solution_simplex.cpp +++ b/src/theory/arith/attempt_solution_simplex.cpp @@ -138,7 +138,7 @@ Result::Sat AttemptSolutionSDP::attempt(const ApproximateSimplex::Solution& sol) return Result::UNSAT; } } - Assert( d_conflictVariables.empty() ); + Assert(d_conflictVariables.empty()); if(d_errorSet.errorEmpty()){ return Result::SAT; diff --git a/src/theory/arith/bound_counts.h b/src/theory/arith/bound_counts.h index 7bd69190e..43fa4e437 100644 --- a/src/theory/arith/bound_counts.h +++ b/src/theory/arith/bound_counts.h @@ -20,7 +20,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "theory/arith/arithvar.h" #include "util/dense_map.h" @@ -66,7 +66,7 @@ public: } inline BoundCounts operator-(BoundCounts bc) const { - Assert( *this >= bc ); + Assert(*this >= bc); return BoundCounts(d_lowerBoundCount - bc.d_lowerBoundCount, d_upperBoundCount - bc.d_upperBoundCount); } diff --git a/src/theory/arith/callbacks.cpp b/src/theory/arith/callbacks.cpp index a11dd729b..158a81e8d 100644 --- a/src/theory/arith/callbacks.cpp +++ b/src/theory/arith/callbacks.cpp @@ -93,13 +93,13 @@ void FarkasConflictBuilder::reset(){ /* Adds a constraint to the constraint under construction. */ void FarkasConflictBuilder::addConstraint(ConstraintCP c, const Rational& fc){ - Assert(!PROOF_ON() || - (!underConstruction() && d_constraints.empty() && d_farkas.empty()) || - (underConstruction() && d_constraints.size() + 1 == d_farkas.size())); + Assert( + !PROOF_ON() + || (!underConstruction() && d_constraints.empty() && d_farkas.empty()) + || (underConstruction() && d_constraints.size() + 1 == d_farkas.size())); Assert(PROOF_ON() || d_farkas.empty()); Assert(c->isTrue()); - if(d_consequent == NullConstraint){ d_consequent = c; } else { @@ -136,7 +136,7 @@ void FarkasConflictBuilder::makeLastConsequent(){ d_consequentSet = true; } - Assert(! d_consequent->negationHasProof() ); + Assert(!d_consequent->negationHasProof()); Assert(d_consequentSet); } @@ -144,9 +144,10 @@ void FarkasConflictBuilder::makeLastConsequent(){ ConstraintCP FarkasConflictBuilder::commitConflict(){ Assert(underConstruction()); Assert(!d_constraints.empty()); - Assert(!PROOF_ON() || - (!underConstruction() && d_constraints.empty() && d_farkas.empty()) || - (underConstruction() && d_constraints.size() + 1 == d_farkas.size())); + Assert( + !PROOF_ON() + || (!underConstruction() && d_constraints.empty() && d_farkas.empty()) + || (underConstruction() && d_constraints.size() + 1 == d_farkas.size())); Assert(PROOF_ON() || d_farkas.empty()); Assert(d_consequentSet); @@ -156,7 +157,7 @@ ConstraintCP FarkasConflictBuilder::commitConflict(){ reset(); Assert(!underConstruction()); - Assert( not_c->inConflict() ); + Assert(not_c->inConflict()); Assert(!d_consequentSet); return not_c; } diff --git a/src/theory/arith/congruence_manager.cpp b/src/theory/arith/congruence_manager.cpp index ce45141ef..5a6bf6f31 100644 --- a/src/theory/arith/congruence_manager.cpp +++ b/src/theory/arith/congruence_manager.cpp @@ -489,7 +489,7 @@ bool ArithCongruenceManager::fixpointInfer() { explain( eq_exp, assumptions ); }else{ //eq_exp should be true - Assert( eq_exp==d_true ); + Assert(eq_exp == d_true); } Node req_exp; if( assumptions.empty() ){ diff --git a/src/theory/arith/constraint.cpp b/src/theory/arith/constraint.cpp index c7251d4c4..e7b1289a4 100644 --- a/src/theory/arith/constraint.cpp +++ b/src/theory/arith/constraint.cpp @@ -63,8 +63,7 @@ ConstraintType Constraint::constraintTypeOfComparison(const Comparison& cmp){ return Equality; case DISTINCT: return Disequality; - default: - Unhandled(k); + default: Unhandled() << k; } } @@ -322,20 +321,11 @@ void ValueCollection::add(ConstraintP c){ ConstraintP ValueCollection::getConstraintOfType(ConstraintType t) const{ switch(t){ - case LowerBound: - Assert(hasLowerBound()); - return d_lowerBound; - case Equality: - Assert(hasEquality()); - return d_equality; - case UpperBound: - Assert(hasUpperBound()); - return d_upperBound; - case Disequality: - Assert(hasDisequality()); - return d_disequality; - default: - Unreachable(); + case LowerBound: Assert(hasLowerBound()); return d_lowerBound; + case Equality: Assert(hasEquality()); return d_equality; + case UpperBound: Assert(hasUpperBound()); return d_upperBound; + case Disequality: Assert(hasDisequality()); return d_disequality; + default: Unreachable(); } } @@ -613,7 +603,7 @@ void ConstraintRule::print(std::ostream& out) const { out << "_"; } out << " * (" << *antecedent << ")" << std::endl; - + Assert((coeffs == RationalVectorCPSentinel) || coeffIterator > 0); --p; coeffIterator = (coeffs != RationalVectorCPSentinel) ? coeffIterator-1 : 0; @@ -862,7 +852,8 @@ ConstraintP ConstraintDatabase::getConstraint(ArithVar v, ConstraintType t, cons pair negInsertAttempt; negInsertAttempt = scm.insert(make_pair(negC->getValue(), ValueCollection())); Assert(negInsertAttempt.second - || ! negInsertAttempt.first->second.hasConstraintOfType(negC->getType())); + || !negInsertAttempt.first->second.hasConstraintOfType( + negC->getType())); negPos = negInsertAttempt.first; } @@ -1108,7 +1099,7 @@ void Constraint::setAssumption(bool nowInConflict){ Assert(assertedToTheTheory()); d_database->pushConstraintRule(ConstraintRule(this, AssumeAP)); - + Assert(inConflict() == nowInConflict); if(Debug.isOn("constraint::conflictCommit") && inConflict()){ Debug("constraint::conflictCommit") << "inConflict@setAssumption " << this << std::endl; @@ -1149,7 +1140,6 @@ void Constraint::impliedByUnate(ConstraintCP imp, bool nowInConflict){ Assert(imp->hasProof()); Assert(negationHasProof() == nowInConflict); - d_database->d_antecedents.push_back(NullConstraint); d_database->d_antecedents.push_back(imp); @@ -1283,7 +1273,7 @@ void Constraint::impliedByFarkas(const ConstraintCPVec& a, RationalVectorCP coef Assert(negationHasProof() == nowInConflict); Assert(allHaveProof(a)); - Assert( PROOF_ON() == (coeffs != RationalVectorCPSentinel) ); + Assert(PROOF_ON() == (coeffs != RationalVectorCPSentinel)); // !PROOF_ON() => coeffs == RationalVectorCPSentinel // PROOF_ON() => coeffs->size() == a.size() + 1 Assert(!PROOF_ON() || coeffs->size() == a.size() + 1); @@ -1404,7 +1394,8 @@ void Constraint::assertionFringe(ConstraintCPVec& v){ v[writePos] = vi; writePos++; }else{ - Assert(vi->hasTrichotomyProof() || vi->hasFarkasProof() || vi->hasIntHoleProof() ); + Assert(vi->hasTrichotomyProof() || vi->hasFarkasProof() + || vi->hasIntHoleProof()); AntecedentId p = vi->getEndAntecedent(); ConstraintCP antecedent = antecedents[p]; @@ -1561,7 +1552,7 @@ ConstraintP Constraint::getStrictlyWeakerUpperBound(bool hasLiteral, bool assert ConstraintP ConstraintDatabase::getBestImpliedBound(ArithVar v, ConstraintType t, const DeltaRational& r) const { Assert(variableDatabaseIsSetup(v)); - Assert(t == UpperBound || t == LowerBound); + Assert(t == UpperBound || t == LowerBound); SortedConstraintMap& scm = getVariableSCM(v); if(t == UpperBound){ diff --git a/src/theory/arith/delta_rational.h b/src/theory/arith/delta_rational.h index 831c631f8..7fd4e2031 100644 --- a/src/theory/arith/delta_rational.h +++ b/src/theory/arith/delta_rational.h @@ -21,8 +21,8 @@ #include +#include "base/check.h" #include "base/exception.h" -#include "base/cvc4_assert.h" #include "util/integer.h" #include "util/rational.h" diff --git a/src/theory/arith/dio_solver.cpp b/src/theory/arith/dio_solver.cpp index b30dc515b..11cf55354 100644 --- a/src/theory/arith/dio_solver.cpp +++ b/src/theory/arith/dio_solver.cpp @@ -279,7 +279,6 @@ void DioSolver::enqueueInputConstraints(){ void DioSolver::moveMinimumByAbsToQueueFront(){ Assert(!queueEmpty()); - //Select the minimum element. size_t indexInQueue = 0; Monomial minMonomial = d_trail[d_currentF[indexInQueue]].d_minimalMonomial; @@ -399,7 +398,12 @@ DioSolver::TrailIndex DioSolver::impliedGcdOfOne(){ Debug("arith::dio") << "extendedReduction combine" << endl; TrailIndex next = combineEqAtIndexes(current, s, inQueue, t); - Assert(d_trail[next].d_eq.getPolynomial().getCoefficient(vl).getValue().getNumerator() == g); + Assert(d_trail[next] + .d_eq.getPolynomial() + .getCoefficient(vl) + .getValue() + .getNumerator() + == g); current = next; currentCoeff = g; @@ -633,7 +637,8 @@ std::pair DioSolver::solveIndex(DioS d_subs.push_back(Substitution(Node::null(), var, ci)); Debug("arith::dio") << "after solveIndex " << d_trail[ci].d_eq.getNode() << " for " << av.getNode() << endl; - Assert(d_trail[ci].d_eq.getPolynomial().getCoefficient(vl) == Constant::mkConstant(-1)); + Assert(d_trail[ci].d_eq.getPolynomial().getCoefficient(vl) + == Constant::mkConstant(-1)); return make_pair(subBy, i); } @@ -690,7 +695,8 @@ std::pair DioSolver::decomposeIndex( Debug("arith::dio") << "Decompose ci(" << ci <<":" << d_trail[ci].d_eq.getNode() << ") for " << d_trail[i].d_minimalMonomial.getNode() << endl; - Assert(d_trail[ci].d_eq.getPolynomial().getCoefficient(vl) == Constant::mkConstant(-1)); + Assert(d_trail[ci].d_eq.getPolynomial().getCoefficient(vl) + == Constant::mkConstant(-1)); SumPair newFact = r + fresh_a; @@ -717,7 +723,10 @@ DioSolver::TrailIndex DioSolver::applySubstitution(DioSolver::SubIndex si, DioSo if(!a.isZero()){ Integer one(1); TrailIndex afterSub = combineEqAtIndexes(ti, one, subIndex, a.getValue().getNumerator()); - Assert(d_trail[afterSub].d_eq.getPolynomial().getCoefficient(VarList(var)).isZero()); + Assert(d_trail[afterSub] + .d_eq.getPolynomial() + .getCoefficient(VarList(var)) + .isZero()); return afterSub; }else{ return ti; diff --git a/src/theory/arith/dio_solver.h b/src/theory/arith/dio_solver.h index 0c26f9c55..fa6c08696 100644 --- a/src/theory/arith/dio_solver.h +++ b/src/theory/arith/dio_solver.h @@ -74,7 +74,8 @@ private: NodeToInputConstraintIndexMap d_varToInputConstraintMap; Node proofVariableToReason(const Variable& v) const{ - Assert(d_varToInputConstraintMap.find(v.getNode()) != d_varToInputConstraintMap.end()); + Assert(d_varToInputConstraintMap.find(v.getNode()) + != d_varToInputConstraintMap.end()); InputConstraintIndex pos = (*(d_varToInputConstraintMap.find(v.getNode()))).second; Assert(pos < d_inputConstraints.size()); return d_inputConstraints[pos].d_reason; diff --git a/src/theory/arith/error_set.h b/src/theory/arith/error_set.h index 8839739a2..9e3e7c630 100644 --- a/src/theory/arith/error_set.h +++ b/src/theory/arith/error_set.h @@ -152,8 +152,16 @@ public: inline ArithVar getVariable() const { return d_variable; } bool isRelaxed() const { return d_relaxed; } - void setRelaxed(){ Assert(!d_relaxed); d_relaxed = true; } - void setUnrelaxed(){ Assert(d_relaxed); d_relaxed = false; } + void setRelaxed() + { + Assert(!d_relaxed); + d_relaxed = true; + } + void setUnrelaxed() + { + Assert(d_relaxed); + d_relaxed = false; + } inline int sgn() const { return d_sgn; } diff --git a/src/theory/arith/fc_simplex.cpp b/src/theory/arith/fc_simplex.cpp index 827323302..29177d3f4 100644 --- a/src/theory/arith/fc_simplex.cpp +++ b/src/theory/arith/fc_simplex.cpp @@ -118,8 +118,7 @@ Result::Sat FCSimplexDecisionProcedure::findModel(bool exactResult){ }else if(d_errorSet.errorEmpty()){ //if(verbose){ Message() << "fcFindModel("<< instance <<") fixed itself" << endl; } Debug("arith::findModel") << "fcFindModel("<< instance <<") fixed itself" << endl; - if(verbose) - Assert(!d_errorSet.moreSignals()); + if (verbose) Assert(!d_errorSet.moreSignals()); Assert(d_conflictVariables.empty()); return Result::SAT; } @@ -264,7 +263,7 @@ WitnessImprovement FCSimplexDecisionProcedure::adjustFocusShrank(const ArithVarV WitnessImprovement FCSimplexDecisionProcedure::focusDownToJust(ArithVar v){ // uint32_t newErrorSize = d_errorSet.errorSize(); // uint32_t newFocusSize = d_errorSet.focusSize(); - Assert(d_focusSize == d_errorSet.focusSize()); + Assert(d_focusSize == d_errorSet.focusSize()); Assert(d_focusSize > 1); Assert(d_errorSet.inFocus(v)); @@ -558,7 +557,8 @@ void FCSimplexDecisionProcedure::updateAndSignal(const UpdateInfo& selected, Wit int prevFocusSgn = d_errorSet.popSignal(); if(d_tableau.isBasic(updated)){ - Assert(!d_variables.assignmentIsConsistent(updated) == d_errorSet.inError(updated)); + Assert(!d_variables.assignmentIsConsistent(updated) + == d_errorSet.inError(updated)); if(Debug.isOn("updateAndSignal")){debugPrintSignal(updated);} if(!d_variables.assignmentIsConsistent(updated)){ if(checkBasicForConflict(updated)){ @@ -582,7 +582,8 @@ void FCSimplexDecisionProcedure::updateAndSignal(const UpdateInfo& selected, Wit } if(Debug.isOn("error")){ d_errorSet.debugPrint(Debug("error")); } - Assert(debugSelectedErrorDropped(selected, d_errorSize, d_errorSet.errorSize())); + Assert( + debugSelectedErrorDropped(selected, d_errorSize, d_errorSet.errorSize())); adjustFocusAndError(selected, focusChanges); } @@ -729,7 +730,6 @@ Result::Sat FCSimplexDecisionProcedure::dualLike(){ Assert(d_conflictVariables.empty()); Assert(d_focusErrorVar == ARITHVAR_SENTINEL); - d_scores.purge(); d_focusErrorVar = constructInfeasiblityFunction(d_statistics.d_fcFocusConstructionTimer); @@ -752,8 +752,8 @@ Result::Sat FCSimplexDecisionProcedure::dualLike(){ d_focusSize = d_errorSet.focusSize(); - Assert( d_errorSize == d_focusSize); - Assert( d_errorSize >= 1 ); + Assert(d_errorSize == d_focusSize); + Assert(d_errorSize >= 1); d_focusErrorVar = constructInfeasiblityFunction(d_statistics.d_fcFocusConstructionTimer); @@ -795,7 +795,8 @@ Result::Sat FCSimplexDecisionProcedure::dualLike(){ if(verbose){ debugDualLike(w, Message(), instance, prevFocusSize, prevErrorSize); } - Assert(debugDualLike(w, Debug("dualLike"), instance, prevFocusSize, prevErrorSize)); + Assert(debugDualLike( + w, Debug("dualLike"), instance, prevFocusSize, prevErrorSize)); } diff --git a/src/theory/arith/linear_equality.cpp b/src/theory/arith/linear_equality.cpp index 7f729751b..8c7d22088 100644 --- a/src/theory/arith/linear_equality.cpp +++ b/src/theory/arith/linear_equality.cpp @@ -365,7 +365,6 @@ void LinearEqualityModule::debugCheckTracking(){ << "computed " << computed << " tracking " << d_btracking[ridx] << endl; Assert(computed == d_btracking[ridx]); - } } } @@ -574,12 +573,10 @@ void LinearEqualityModule::propagateRow(ConstraintCPVec& into, RowIndex ridx, bo Assert(sgn != 0); bool selectUb = rowUp ? (sgn > 0) : (sgn < 0); - Assert( nonbasic != v || - ( rowUp && a_ij.sgn() > 0 && c->isLowerBound()) || - ( rowUp && a_ij.sgn() < 0 && c->isUpperBound()) || - (!rowUp && a_ij.sgn() > 0 && c->isUpperBound()) || - (!rowUp && a_ij.sgn() < 0 && c->isLowerBound()) - ); + Assert(nonbasic != v || (rowUp && a_ij.sgn() > 0 && c->isLowerBound()) + || (rowUp && a_ij.sgn() < 0 && c->isUpperBound()) + || (!rowUp && a_ij.sgn() > 0 && c->isUpperBound()) + || (!rowUp && a_ij.sgn() < 0 && c->isLowerBound())); if(Debug.isOn("arith::propagateRow")){ if(nonbasic == v){ @@ -743,7 +740,7 @@ ConstraintCP LinearEqualityModule::minimallyWeakConflict(bool aboveUpper, ArithV fcs.addConstraint(c, coeff, adjustSgn); if(basicVar == v){ - Assert(! c->negationHasProof() ); + Assert(!c->negationHasProof()); fcs.makeLastConsequent(); } } @@ -1400,8 +1397,8 @@ void LinearEqualityModule::pop_block(BorderHeap& heap, int& brokenInBlock, int& heap.pop_heap(); }else{ // does not belong to the block - Assert((heap.direction() > 0) ? - (blockValue < top.d_diff) : (blockValue > top.d_diff)); + Assert((heap.direction() > 0) ? (blockValue < top.d_diff) + : (blockValue > top.d_diff)); break; } } diff --git a/src/theory/arith/matrix.h b/src/theory/arith/matrix.h index 02b8dc194..c845ccb05 100644 --- a/src/theory/arith/matrix.h +++ b/src/theory/arith/matrix.h @@ -478,7 +478,6 @@ protected: Assert(newEntry.getCoefficient() != 0); - ++d_entriesInUse; d_rows[row].insert(newId); @@ -650,7 +649,6 @@ public: Assert(mult != 0); - RowIterator i = getRow(to).begin(); RowIterator i_end = getRow(to).end(); while(i != i_end){ @@ -710,7 +708,6 @@ public: Assert(mult != 0); - RowIterator i = getRow(to).begin(); RowIterator i_end = getRow(to).end(); while(i != i_end){ diff --git a/src/theory/arith/nonlinear_extension.cpp b/src/theory/arith/nonlinear_extension.cpp index 4747727c8..839520c0b 100644 --- a/src/theory/arith/nonlinear_extension.cpp +++ b/src/theory/arith/nonlinear_extension.cpp @@ -975,7 +975,7 @@ bool NonlinearExtension::addCheckModelSubstitution(TNode v, TNode s) { Trace("nl-ext-model") << "...ERROR: already has value." << std::endl; // this should never happen since substitutions should be applied eagerly - Assert( false ); + Assert(false); return false; } // if we previously had an approximate bound, the exact bound should be in its @@ -1876,8 +1876,8 @@ int NonlinearExtension::checkLastCall(const std::vector& assertions, /* //mark processed if has a "one" factor (will look at reduced monomial) std::map< Node, std::map< Node, unsigned > >::iterator itme = - d_m_exp.find( a ); Assert( itme!=d_m_exp.end() ); for( std::map< Node, - unsigned >::iterator itme2 = itme->second.begin(); itme2 != + d_m_exp.find( a ); Assert( itme!=d_m_exp.end() ); for( std::map< + Node, unsigned >::iterator itme2 = itme->second.begin(); itme2 != itme->second.end(); ++itme2 ){ Node v = itme->first; Assert( d_mv[0].find( v )!=d_mv[0].end() ); Node mvv = d_mv[0][ v ]; if( mvv==d_one || mvv==d_neg_one ){ ms_proc[ a ] = true; @@ -1957,7 +1957,7 @@ int NonlinearExtension::checkLastCall(const std::vector& assertions, } else { - Assert( false ); + Assert(false); } } // initialize pi if necessary @@ -2669,7 +2669,7 @@ void NonlinearExtension::printModelValue(const char* c, int NonlinearExtension::compare_value(Node i, Node j, unsigned orderType) const { Assert(orderType >= 0 && orderType <= 3); - Assert( i.isConst() && j.isConst() ); + Assert(i.isConst() && j.isConst()); Trace("nl-ext-debug") << "compare value " << i << " " << j << ", o = " << orderType << std::endl; int ret; @@ -2725,8 +2725,8 @@ int NonlinearExtension::compareSign(Node oa, Node a, unsigned a_index, Node av = d_m_vlist[a][a_index]; unsigned aexp = d_m_exp[a][av]; // take current sign in model - Assert( d_mv[1].find(av) != d_mv[0].end() ); - Assert( d_mv[1][av].isConst() ); + Assert(d_mv[1].find(av) != d_mv[0].end()); + Assert(d_mv[1][av].isConst()); int sgn = d_mv[1][av].getConst().sgn(); Trace("nl-ext-debug") << "Process var " << av << "^" << aexp << ", model sign = " << sgn << std::endl; @@ -3032,7 +3032,7 @@ std::vector NonlinearExtension::checkMonomialMagnitude( unsigned c ) { // compare magnitude against variables for (unsigned k = 0; k < d_ms_vars.size(); k++) { Node v = d_ms_vars[k]; - Assert( d_mv[0].find( v )!=d_mv[0].end() ); + Assert(d_mv[0].find(v) != d_mv[0].end()); if( d_mv[0][v].isConst() ){ std::vector exp; NodeMultiset a_exp_proc; @@ -3185,7 +3185,7 @@ std::vector NonlinearExtension::checkTangentPlanes() { Node curr_v = p<=1 ? a_v_c : b_v_c; if( prevRefine ){ Node pt_v = d_tangent_val_bound[p][a][b]; - Assert( !pt_v.isNull() ); + Assert(!pt_v.isNull()); if( curr_v!=pt_v ){ Node do_extend = nm->mkNode((p == 1 || p == 3) ? GT : LT, curr_v, pt_v); @@ -3424,8 +3424,8 @@ std::vector NonlinearExtension::checkMonomialInferBounds( Kind type = itcr->second; for (unsigned j = 0; j < itm->second.size(); j++) { Node y = itm->second[j]; - Assert(d_m_contain_mult[x].find(y) != - d_m_contain_mult[x].end()); + Assert(d_m_contain_mult[x].find(y) + != d_m_contain_mult[x].end()); Node mult = d_m_contain_mult[x][y]; // x t => m*x t where y = m*x // get the sign of mult @@ -3583,7 +3583,7 @@ std::vector NonlinearExtension::checkFactoring( poly.push_back(NodeManager::currentNM()->mkNode(MULT, x, kf)); std::map >::iterator itfo = factor_to_mono_orig.find(x); - Assert( itfo!=factor_to_mono_orig.end() ); + Assert(itfo != factor_to_mono_orig.end()); for( std::map::iterator itm = msum.begin(); itm != msum.end(); ++itm ){ if( std::find( itfo->second.begin(), itfo->second.end(), itm->first )==itfo->second.end() ){ poly.push_back(ArithMSum::mkCoeffTerm( @@ -3781,7 +3781,7 @@ std::vector NonlinearExtension::checkTranscendentalInitialRefine() { Kind k = tfl.first; for (const Node& t : tfl.second) { - Assert( d_mv[1].find( t )!=d_mv[1].end() ); + Assert(d_mv[1].find(t) != d_mv[1].end()); //initial refinements if( d_tf_initial_refine.find( t )==d_tf_initial_refine.end() ){ d_tf_initial_refine[t] = true; @@ -3921,10 +3921,10 @@ std::vector NonlinearExtension::checkTranscendentalMonotonic() { for (unsigned i = 0; i < sorted_tf_args[k].size(); i++) { Node targ = sorted_tf_args[k][i]; - Assert( d_mv[1].find( targ )!=d_mv[1].end() ); + Assert(d_mv[1].find(targ) != d_mv[1].end()); Trace("nl-ext-tf-mono") << " " << targ << " -> " << d_mv[1][targ] << std::endl; Node t = tf_arg_to_term[k][targ]; - Assert( d_mv[1].find( t )!=d_mv[1].end() ); + Assert(d_mv[1].find(t) != d_mv[1].end()); Trace("nl-ext-tf-mono") << " f-val : " << d_mv[1][t] << std::endl; } std::vector< Node > mpoints; @@ -3947,7 +3947,7 @@ std::vector NonlinearExtension::checkTranscendentalMonotonic() { Node mpv; if( !mpoints[i].isNull() ){ mpv = computeModelValue( mpoints[i], 1 ); - Assert( mpv.isConst() ); + Assert(mpv.isConst()); } mpoints_vals.push_back( mpv ); } @@ -3959,14 +3959,14 @@ std::vector NonlinearExtension::checkTranscendentalMonotonic() { for (unsigned i = 0, size = sorted_tf_args[k].size(); i < size; i++) { Node sarg = sorted_tf_args[k][i]; - Assert( d_mv[1].find( sarg )!=d_mv[1].end() ); + Assert(d_mv[1].find(sarg) != d_mv[1].end()); Node sargval = d_mv[1][sarg]; - Assert( sargval.isConst() ); + Assert(sargval.isConst()); Node s = tf_arg_to_term[k][ sarg ]; - Assert( d_mv[1].find( s )!=d_mv[1].end() ); + Assert(d_mv[1].find(s) != d_mv[1].end()); Node sval = d_mv[1][s]; - Assert( sval.isConst() ); - + Assert(sval.isConst()); + //increment to the proper monotonicity region bool increment = true; while (increment && mdir_index < mpoints.size()) @@ -3976,7 +3976,7 @@ std::vector NonlinearExtension::checkTranscendentalMonotonic() { increment = true; }else{ Node pval = mpoints_vals[mdir_index]; - Assert( pval.isConst() ); + Assert(pval.isConst()); if( sargval.getConst() < pval.getConst() ){ increment = true; Trace("nl-ext-tf-mono") << "...increment at " << sarg << " since model value is less than " << mpoints[mdir_index] << std::endl; @@ -4017,7 +4017,7 @@ std::vector NonlinearExtension::checkTranscendentalMonotonic() { } if( !mono_lem.isNull() ){ if( !mono_bounds[0].isNull() ){ - Assert( !mono_bounds[1].isNull() ); + Assert(!mono_bounds[1].isNull()); mono_lem = NodeManager::currentNM()->mkNode( IMPLIES, NodeManager::currentNM()->mkNode( diff --git a/src/theory/arith/normal_form.cpp b/src/theory/arith/normal_form.cpp index ee298bc66..c0658b9af 100644 --- a/src/theory/arith/normal_form.cpp +++ b/src/theory/arith/normal_form.cpp @@ -69,11 +69,7 @@ bool Variable::isLeafMember(Node n){ (Theory::isLeafOf(n, theory::THEORY_ARITH)); } -VarList::VarList(Node n) - : NodeWrapper(n) -{ - Assert(isSorted(begin(), end())); -} +VarList::VarList(Node n) : NodeWrapper(n) { Assert(isSorted(begin(), end())); } bool Variable::isDivMember(Node n){ switch(n.getKind()){ @@ -275,11 +271,13 @@ Monomial Monomial::operator*(const Monomial& mono) const { return Monomial::mkMonomial(newConstant, newVL); } -// vector Monomial::sumLikeTerms(const std::vector & monos) { +// vector Monomial::sumLikeTerms(const std::vector & monos) +// { // Assert(isSorted(monos)); // vector outMonomials; // typedef vector::const_iterator iterator; -// for(iterator rangeIter = monos.begin(), end=monos.end(); rangeIter != end;) { +// for(iterator rangeIter = monos.begin(), end=monos.end(); rangeIter != end;) +// { // Rational constant = (*rangeIter).getConstant().getValue(); // VarList varList = (*rangeIter).getVarList(); // ++rangeIter; @@ -334,7 +332,7 @@ void Monomial::combineAdjacentMonomials(std::vector& monos) { writePos++; } } - Assert(rangeEnd>readPos); + Assert(rangeEnd > readPos); readPos = rangeEnd; } if(writePos > 0 ){ @@ -526,7 +524,7 @@ Integer Polynomial::numeratorGCD() const { //We'll use the standardization that gcd(0, 0) = 0 //So that the gcd of the zero polynomial is gcd{0} = 0 iterator i=begin(), e=end(); - Assert(i!=e); + Assert(i != e); Integer d = (*i).getConstant().getValue().getNumerator().abs(); if(d.isOne()){ @@ -683,13 +681,7 @@ SumPair SumPair::mkSumPair(const Polynomial& p){ } } -Comparison::Comparison(TNode n) - : NodeWrapper(n) -{ - Assert(isNormalForm()); -} - - +Comparison::Comparison(TNode n) : NodeWrapper(n) { Assert(isNormalForm()); } SumPair Comparison::toSumPair() const { Kind cmpKind = comparisonKind(); @@ -727,8 +719,7 @@ SumPair Comparison::toSumPair() const { return SumPair(left - right, Constant::mkZero()); } } - default: - Unhandled(cmpKind); + default: Unhandled() << cmpKind; } } @@ -766,8 +757,7 @@ Polynomial Comparison::normalizedVariablePart() const { } } } - default: - Unhandled(cmpKind); + default: Unhandled() << cmpKind; } } @@ -816,8 +806,7 @@ DeltaRational Comparison::normalizedDeltaRational() const { return DeltaRational(0, 0); } } - default: - Unhandled(cmpKind); + default: Unhandled() << cmpKind; } } @@ -834,8 +823,7 @@ Node Comparison::toNode(Kind k, const Polynomial& l, const Constant& r) { case kind::GEQ: case kind::GT: return NodeManager::currentNM()->mkNode(k, l.getNode(), r.getNode()); - default: - Unhandled(k); + default: Unhandled() << k; } } @@ -875,9 +863,7 @@ size_t Comparison::getComplexity() const{ case kind::GT: case kind::GEQ: return getLeft().getComplexity() + getRight().getComplexity(); - default: - Unhandled(comparisonKind()); - return -1; + default: Unhandled() << comparisonKind(); return -1; } } @@ -895,8 +881,7 @@ Polynomial Comparison::getLeft() const { case kind::GEQ: left = getNode()[0]; break; - default: - Unhandled(k); + default: Unhandled() << k; } return Polynomial::parsePolynomial(left); } @@ -915,8 +900,7 @@ Polynomial Comparison::getRight() const { case kind::GEQ: right = getNode()[1]; break; - default: - Unhandled(k); + default: Unhandled() << k; } return Polynomial::parsePolynomial(right); } @@ -1290,8 +1274,7 @@ Comparison Comparison::mkComparison(Kind k, const Polynomial& l, const Polynomia result = isInteger ? mkIntInequality(k, diff) : mkRatInequality(k, diff); break; - default: - Unhandled(k); + default: Unhandled() << k; } Assert(!result.isNull()); if(result.getKind() == kind::NOT && result[0].getKind() == kind::CONST_BOOLEAN){ diff --git a/src/theory/arith/normal_form.h b/src/theory/arith/normal_form.h index a3d173cc7..8099339ae 100644 --- a/src/theory/arith/normal_form.h +++ b/src/theory/arith/normal_form.h @@ -224,48 +224,44 @@ public: class Variable : public NodeWrapper { public: - Variable(Node n) : NodeWrapper(n) { - Assert(isMember(getNode())); - } - - // TODO: check if it's a theory leaf also - static bool isMember(Node n) { - Kind k = n.getKind(); - switch(k){ - case kind::CONST_RATIONAL: - return false; - case kind::INTS_DIVISION: - case kind::INTS_MODULUS: - case kind::DIVISION: - case kind::INTS_DIVISION_TOTAL: - case kind::INTS_MODULUS_TOTAL: - case kind::DIVISION_TOTAL: - return isDivMember(n); - case kind::EXPONENTIAL: - case kind::SINE: - case kind::COSINE: - case kind::TANGENT: - case kind::COSECANT: - case kind::SECANT: - case kind::COTANGENT: - case kind::ARCSINE: - case kind::ARCCOSINE: - case kind::ARCTANGENT: - case kind::ARCCOSECANT: - case kind::ARCSECANT: - case kind::ARCCOTANGENT: - case kind::SQRT: - case kind::PI: - return isTranscendentalMember(n); - case kind::ABS: - case kind::TO_INTEGER: - // Treat to_int as a variable; it is replaced in early preprocessing - // by a variable. - return true; - default: - return isLeafMember(n); - } - } + Variable(Node n) : NodeWrapper(n) { Assert(isMember(getNode())); } + + // TODO: check if it's a theory leaf also + static bool isMember(Node n) + { + Kind k = n.getKind(); + switch (k) + { + case kind::CONST_RATIONAL: return false; + case kind::INTS_DIVISION: + case kind::INTS_MODULUS: + case kind::DIVISION: + case kind::INTS_DIVISION_TOTAL: + case kind::INTS_MODULUS_TOTAL: + case kind::DIVISION_TOTAL: return isDivMember(n); + case kind::EXPONENTIAL: + case kind::SINE: + case kind::COSINE: + case kind::TANGENT: + case kind::COSECANT: + case kind::SECANT: + case kind::COTANGENT: + case kind::ARCSINE: + case kind::ARCCOSINE: + case kind::ARCTANGENT: + case kind::ARCCOSECANT: + case kind::ARCSECANT: + case kind::ARCCOTANGENT: + case kind::SQRT: + case kind::PI: return isTranscendentalMember(n); + case kind::ABS: + case kind::TO_INTEGER: + // Treat to_int as a variable; it is replaced in early preprocessing + // by a variable. + return true; + default: return isLeafMember(n); + } + } static bool isLeafMember(Node n); static bool isDivMember(Node n); @@ -306,7 +302,7 @@ public: if(n < m){ return -1; }else{ - Assert( n != m ); + Assert(n != m); return 1; } }else{ @@ -339,20 +335,17 @@ public: class Constant : public NodeWrapper { public: - Constant(Node n) : NodeWrapper(n) { - Assert(isMember(getNode())); - } + Constant(Node n) : NodeWrapper(n) { Assert(isMember(getNode())); } - static bool isMember(Node n) { - return n.getKind() == kind::CONST_RATIONAL; - } + static bool isMember(Node n) { return n.getKind() == kind::CONST_RATIONAL; } - bool isNormalForm() { return isMember(getNode()); } + bool isNormalForm() { return isMember(getNode()); } - static Constant mkConstant(Node n) { - Assert(n.getKind() == kind::CONST_RATIONAL); - return Constant(n); - } + static Constant mkConstant(Node n) + { + Assert(n.getKind() == kind::CONST_RATIONAL); + return Constant(n); + } static Constant mkConstant(const Rational& rat); @@ -597,8 +590,8 @@ private: Monomial(Node n, const Constant& c, const VarList& vl): NodeWrapper(n), constant(c), varList(vl) { - Assert(!c.isZero() || vl.empty() ); - Assert( c.isZero() || !vl.empty() ); + Assert(!c.isZero() || vl.empty()); + Assert(c.isZero() || !vl.empty()); Assert(!c.isOne() || !multStructured(n)); } @@ -623,15 +616,15 @@ private: Monomial(const VarList& vl): NodeWrapper(vl.getNode()), constant(Constant::mkConstant(1)), varList(vl) { - Assert( !varList.empty() ); + Assert(!varList.empty()); } Monomial(const Constant& c, const VarList& vl): NodeWrapper(makeMultNode(c,vl)), constant(c), varList(vl) { - Assert( !c.isZero() ); - Assert( !c.isOne() ); - Assert( !varList.empty() ); + Assert(!c.isZero()); + Assert(!c.isOne()); + Assert(!varList.empty()); Assert(multStructured(getNode())); } @@ -843,8 +836,8 @@ public: Polynomial(const std::vector& m): NodeWrapper(makePlusNode(m)), d_singleton(false) { - Assert( m.size() >= 2); - Assert( Monomial::isStrictlySorted(m) ); + Assert(m.size() >= 2); + Assert(Monomial::isStrictlySorted(m)); } static Polynomial mkPolynomial(const Constant& c){ @@ -901,7 +894,7 @@ public: } Polynomial getTail() const { - Assert(! singleton()); + Assert(!singleton()); iterator tailStart = begin(); ++tailStart; @@ -1097,14 +1090,9 @@ private: return NodeManager::currentNM()->mkNode(kind::PLUS, p.getNode(), c.getNode()); } - SumPair(TNode n) : - NodeWrapper(n) - { - Assert(isNormalForm()); - } - -public: + SumPair(TNode n) : NodeWrapper(n) { Assert(isNormalForm()); } + public: SumPair(const Polynomial& p): NodeWrapper(toNode(p, Constant::mkConstant(0))) { diff --git a/src/theory/arith/simplex.cpp b/src/theory/arith/simplex.cpp index 77872fb55..bf27af36a 100644 --- a/src/theory/arith/simplex.cpp +++ b/src/theory/arith/simplex.cpp @@ -57,8 +57,7 @@ SimplexDecisionProcedure::~SimplexDecisionProcedure(){ bool SimplexDecisionProcedure::standardProcessSignals(TimerStat &timer, IntStat& conflicts) { TimerStat::CodeTimer codeTimer(timer); - Assert( d_conflictVariables.empty() ); - + Assert(d_conflictVariables.empty()); while(d_errorSet.moreSignals()){ ArithVar curr = d_errorSet.topSignal(); @@ -99,7 +98,6 @@ void SimplexDecisionProcedure::reportConflict(ArithVar basic){ } ConstraintCP SimplexDecisionProcedure::generateConflictForBasic(ArithVar basic) const { - Assert(d_tableau.isBasic(basic)); Assert(checkBasicForConflict(basic)); @@ -198,7 +196,7 @@ ArithVar SimplexDecisionProcedure::constructInfeasiblityFunction(TimerStat& time TimerStat::CodeTimer codeTimer(timer); Assert(!d_errorSet.focusEmpty()); Assert(debugIsASet(set)); - + ArithVar inf = requestVariable(); Assert(inf != ARITHVAR_SENTINEL); diff --git a/src/theory/arith/simplex_update.h b/src/theory/arith/simplex_update.h index cfd00ac30..b1153d36f 100644 --- a/src/theory/arith/simplex_update.h +++ b/src/theory/arith/simplex_update.h @@ -257,7 +257,7 @@ public: /** Sets the focusDirection. */ void setFocusDirection(int fd){ - Assert(-1 <= fd && fd <= 1); + Assert(-1 <= fd && fd <= 1); d_focusDirection = fd; updateWitness(); } diff --git a/src/theory/arith/soi_simplex.cpp b/src/theory/arith/soi_simplex.cpp index e23273a09..e50d9d060 100644 --- a/src/theory/arith/soi_simplex.cpp +++ b/src/theory/arith/soi_simplex.cpp @@ -405,7 +405,8 @@ void SumOfInfeasibilitiesSPD::updateAndSignal(const UpdateInfo& selected, Witnes int prevFocusSgn = d_errorSet.popSignal(); if(d_tableau.isBasic(updated)){ - Assert(!d_variables.assignmentIsConsistent(updated) == d_errorSet.inError(updated)); + Assert(!d_variables.assignmentIsConsistent(updated) + == d_errorSet.inError(updated)); if(Debug.isOn("updateAndSignal")){debugPrintSignal(updated);} if(!d_variables.assignmentIsConsistent(updated)){ if(checkBasicForConflict(updated)){ @@ -642,7 +643,7 @@ std::vector< ArithVarVec > SumOfInfeasibilitiesSPD::greedyConflictSubsets(){ if(d_errorSize <= 2){ ArithVarVec inError; d_errorSet.pushFocusInto(inError); - + Assert(debugIsASet(inError)); subsets.push_back(inError); return subsets; @@ -712,7 +713,7 @@ std::vector< ArithVarVec > SumOfInfeasibilitiesSPD::greedyConflictSubsets(){ if(hasParticipated.isMember(v)){ continue; } hasParticipated.add(v); - + Assert(d_soiVar == ARITHVAR_SENTINEL); //d_soiVar's row = \sumofinfeasibilites underConstruction ArithVarVec underConstruction; @@ -770,7 +771,6 @@ std::vector< ArithVarVec > SumOfInfeasibilitiesSPD::greedyConflictSubsets(){ // } } - Assert(d_soiVar == ARITHVAR_SENTINEL); Debug("arith::greedyConflictSubsets") << "greedyConflictSubsets done" << endl; return subsets; @@ -781,7 +781,7 @@ bool SumOfInfeasibilitiesSPD::generateSOIConflict(const ArithVarVec& subset){ d_soiVar = constructInfeasiblityFunction(d_statistics.d_soiConflictMinimization, subset); Assert(!subset.empty()); Assert(!d_conflictBuilder->underConstruction()); - + Debug("arith::generateSOIConflict") << "SumOfInfeasibilitiesSPD::generateSOIConflict(...) start" << endl; bool success = false; @@ -791,7 +791,6 @@ bool SumOfInfeasibilitiesSPD::generateSOIConflict(const ArithVarVec& subset){ ConstraintP violated = d_errorSet.getViolated(e); Assert(violated != NullConstraint); - int sgn = d_errorSet.getSgn(e); const Rational& violatedCoeff = sgn > 0 ? d_negOne : d_posOne; Debug("arith::generateSOIConflict") << "basic error var: " @@ -815,7 +814,7 @@ bool SumOfInfeasibilitiesSPD::generateSOIConflict(const ArithVarVec& subset){ // pick a violated constraint arbitrarily. any of them may be selected for the conflict Assert(d_conflictBuilder->underConstruction()); Assert(d_conflictBuilder->consequentIsSet()); - + for(Tableau::RowIterator i = d_tableau.basicRowIterator(d_soiVar); !i.atEnd(); ++i){ const Tableau::Entry& entry = *i; ArithVar v = entry.getColVar(); @@ -864,7 +863,7 @@ WitnessImprovement SumOfInfeasibilitiesSPD::SOIConflict(){ generateSOIConflict(d_qeConflict); }else{ vector subsets = greedyConflictSubsets(); - Assert( d_soiVar == ARITHVAR_SENTINEL); + Assert(d_soiVar == ARITHVAR_SENTINEL); bool anySuccess = false; Assert(!subsets.empty()); for(vector::const_iterator i = subsets.begin(), end = subsets.end(); i != end; ++i){ @@ -879,7 +878,7 @@ WitnessImprovement SumOfInfeasibilitiesSPD::SOIConflict(){ } Assert(anySuccess); } - Assert( d_soiVar == ARITHVAR_SENTINEL); + Assert(d_soiVar == ARITHVAR_SENTINEL); d_soiVar = constructInfeasiblityFunction(d_statistics.d_soiConflictMinimization); //reportConflict(conf); do not do this. We need a custom explanations! @@ -965,7 +964,6 @@ Result::Sat SumOfInfeasibilitiesSPD::sumOfInfeasibilities(){ Assert(d_conflictVariables.empty()); Assert(d_soiVar == ARITHVAR_SENTINEL); - //d_scores.purge(); d_soiVar = constructInfeasiblityFunction(d_statistics.d_soiFocusConstructionTimer); diff --git a/src/theory/arith/tableau.cpp b/src/theory/arith/tableau.cpp index aa4c3d454..82b46bf30 100644 --- a/src/theory/arith/tableau.cpp +++ b/src/theory/arith/tableau.cpp @@ -102,7 +102,7 @@ void Tableau::addRow(ArithVar basic, { Assert(basic < getNumColumns()); Assert(debugIsASet(variables)); - Assert(coefficients.size() == variables.size() ); + Assert(coefficients.size() == variables.size()); Assert(!isBasic(basic)); RowIndex newRow = Matrix::addRow(coefficients, variables); diff --git a/src/theory/arith/theory_arith_private.cpp b/src/theory/arith/theory_arith_private.cpp index c775a2611..62be1fcc1 100644 --- a/src/theory/arith/theory_arith_private.cpp +++ b/src/theory/arith/theory_arith_private.cpp @@ -691,7 +691,6 @@ bool TheoryArithPrivate::AssertLower(ConstraintP constraint){ Assert(constraint->isLowerBound()); Assert(constraint->isTrue()); Assert(!constraint->negationHasProof()); - ArithVar x_i = constraint->getVariable(); const DeltaRational& c_i = constraint->getValue(); @@ -733,7 +732,6 @@ bool TheoryArithPrivate::AssertLower(ConstraintP constraint){ const ValueCollection& vc = constraint->getValueCollection(); if(vc.hasEquality()){ - Assert(vc.hasDisequality()); ConstraintP eq = vc.getEquality(); ConstraintP diseq = vc.getDisequality(); @@ -828,7 +826,7 @@ bool TheoryArithPrivate::AssertUpper(ConstraintP constraint){ Assert(constraint->isUpperBound()); Assert(constraint->isTrue()); Assert(!constraint->negationHasProof()); - + ArithVar x_i = constraint->getVariable(); const DeltaRational& c_i = constraint->getValue(); @@ -1001,7 +999,6 @@ bool TheoryArithPrivate::AssertEquality(ConstraintP constraint){ Assert(cmpToLB >= 0); Assert(cmpToUB < 0 || cmpToLB > 0); - if(isInteger(x_i)){ d_constantIntegerVariables.push_back(x_i); Debug("dio::push") << "dio::push " << x_i << endl; @@ -1211,7 +1208,7 @@ Node TheoryArithPrivate::ppRewriteTerms(TNode n) { case kind::INTS_MODULUS: case kind::DIVISION: // these should be removed during expand definitions - Assert( false ); + Assert(false); break; case kind::INTS_DIVISION_TOTAL: @@ -1433,8 +1430,8 @@ ArithVar TheoryArithPrivate::findShortestBasicRow(ArithVar variable){ bestRowLength = rowLength; } } - Assert(bestBasic == ARITHVAR_SENTINEL || - bestRowLength < std::numeric_limits::max()); + Assert(bestBasic == ARITHVAR_SENTINEL + || bestRowLength < std::numeric_limits::max()); return bestBasic; } @@ -1528,7 +1525,8 @@ void TheoryArithPrivate::setupDivLike(const Variable& v){ } Node vnode = v.getNode(); - Assert(isSetup(vnode)); // Otherwise there is some invariant breaking recursion + Assert( + isSetup(vnode)); // Otherwise there is some invariant breaking recursion Polynomial m = Polynomial::parsePolynomial(vnode[0]); Polynomial n = Polynomial::parsePolynomial(vnode[1]); @@ -1541,7 +1539,7 @@ void TheoryArithPrivate::setupDivLike(const Variable& v){ case INTS_DIVISION: case INTS_MODULUS: // these should be removed during expand definitions - Assert( false ); + Assert(false); break; case DIVISION_TOTAL: lem = axiomIteForTotalDivision(vnode); @@ -1743,7 +1741,7 @@ ArithVar TheoryArithPrivate::requestArithVar(TNode x, bool aux, bool internal){ throw LogicException(ss.str()); } Assert(!d_partialModel.hasArithVar(x)); - Assert(x.getType().isReal()); // real or integer + Assert(x.getType().isReal()); // real or integer ArithVar max = d_partialModel.getNumberOfVariables(); ArithVar varX = d_partialModel.allocate(x, aux); @@ -1897,7 +1895,6 @@ Node TheoryArithPrivate::callDioSolver(){ Assert(isInteger(v)); Assert(d_partialModel.boundsAreEqual(v)); - ConstraintP lb = d_partialModel.getLowerBoundConstraint(v); ConstraintP ub = d_partialModel.getUpperBoundConstraint(v); @@ -1937,7 +1934,7 @@ ConstraintP TheoryArithPrivate::constraintFromFactQueue(){ Kind simpleKind = Comparison::comparisonKind(assertion); ConstraintP constraint = d_constraintDatabase.lookup(assertion); if(constraint == NullConstraint){ - Assert(simpleKind == EQUAL || simpleKind == DISTINCT ); + Assert(simpleKind == EQUAL || simpleKind == DISTINCT); bool isDistinct = simpleKind == DISTINCT; Node eq = (simpleKind == DISTINCT) ? assertion[0] : assertion; Assert(!isSetup(eq)); @@ -1945,8 +1942,8 @@ ConstraintP TheoryArithPrivate::constraintFromFactQueue(){ if(reEq.getKind() == CONST_BOOLEAN){ if(reEq.getConst() == isDistinct){ // if is (not true), or false - Assert((reEq.getConst() && isDistinct) || - (!reEq.getConst() && !isDistinct)); + Assert((reEq.getConst() && isDistinct) + || (!reEq.getConst() && !isDistinct)); raiseBlackBoxConflict(assertion); } return NullConstraint; @@ -2209,7 +2206,8 @@ void TheoryArithPrivate::outputLemma(TNode lem) { // void TheoryArithPrivate::branchVector(const std::vector& lemmas){ // //output the lemmas -// for(vector::const_iterator i = lemmas.begin(); i != lemmas.end(); ++i){ +// for(vector::const_iterator i = lemmas.begin(); i != lemmas.end(); +// ++i){ // ArithVar v = *i; // Assert(!d_cutInContext.contains(v)); // d_cutInContext.insert(v); @@ -2343,7 +2341,7 @@ std::pair TheoryArithPrivate::replayGetConstraint(const D << " " << rhs << endl; - Assert( k == kind::LEQ || k == kind::GEQ ); + Assert(k == kind::LEQ || k == kind::GEQ); Node comparison = NodeManager::currentNM()->mkNode(k, sum, mkRationalNode(rhs)); Node rewritten = Rewriter::rewrite(comparison); @@ -2508,7 +2506,7 @@ void TheoryArithPrivate::tryBranchCut(ApproximateSimplex* approx, int nid, Branc pair p = replayGetConstraint(bci); Assert(p.second == ARITHVAR_SENTINEL); ConstraintP bc = p.first; - Assert(bc != NullConstraint); + Assert(bc != NullConstraint); if(bc->hasProof()){ return; } @@ -2538,7 +2536,7 @@ void TheoryArithPrivate::tryBranchCut(ApproximateSimplex* approx, int nid, Branc conflicts.push_back(ConstraintCPVec()); intHoleConflictToVector(d_conflicts[i], conflicts.back()); Constraint::assertionFringe(conflicts.back()); - + // ConstraintCP conflicting = d_conflicts[i]; // ConstraintCP negConflicting = conflicting->getNegation(); // Assert(conflicting->hasProof()); @@ -2891,7 +2889,6 @@ std::vector TheoryArithPrivate::replayLogRec(ApproximateSimplex } Assert(d_acTmp.empty()); - /* Garbage collect the constraints from this call */ while(d_replayConstraints.size() > rpcons_size){ ConstraintP c = d_replayConstraints.back(); @@ -3165,11 +3162,12 @@ void TheoryArithPrivate::solveInteger(Theory::Effort effortLevel){ if(mipRes == MipClosed){ d_likelyIntegerInfeasible = true; replayLog(approx); - AlwaysAssert(anyConflict() || d_qflraStatus != Result::SAT); + AlwaysAssert(anyConflict() || d_qflraStatus != Result::SAT); - if(!anyConflict()){ - solveRealRelaxation(effortLevel); - } + if (!anyConflict()) + { + solveRealRelaxation(effortLevel); + } } if(!(anyConflict() || !d_approxCuts.empty())){ turnOffApproxFor(options::replayNumericFailurePenalty()); @@ -3749,8 +3747,8 @@ void TheoryArithPrivate::check(Theory::Effort effortLevel){ d_currentPropagationList.pop_front(); ConstraintType t = curr->getType(); - Assert(t != Disequality, "Disequalities are not allowed in d_currentPropagation"); - + Assert(t != Disequality) + << "Disequalities are not allowed in d_currentPropagation"; switch(t){ case LowerBound: @@ -3776,8 +3774,7 @@ void TheoryArithPrivate::check(Theory::Effort effortLevel){ d_constraintDatabase.unatePropEquality(curr, prevLB, prevUB); break; } - default: - Unhandled(curr->getType()); + default: Unhandled() << curr->getType(); } } @@ -3796,7 +3793,7 @@ void TheoryArithPrivate::check(Theory::Effort effortLevel){ TimerStat::CodeTimer codeTimer(d_statistics.d_newPropTime); d_currentPropagationList.clear(); } - Assert( d_currentPropagationList.empty()); + Assert(d_currentPropagationList.empty()); Debug("arith::ems") << "ems: " << emmittedConflictOrSplit << "post unate" << endl; @@ -3903,7 +3900,7 @@ Node TheoryArithPrivate::branchIntegerVariable(ArithVar x) const { const Rational& i = d.getInfinitesimalPart(); Trace("integers") << "integers: assignment to [[" << d_partialModel.asNode(x) << "]] is " << r << "[" << i << "]" << endl; - Assert(! (r.getDenominator() == 1 && i.getNumerator() == 0)); + Assert(!(r.getDenominator() == 1 && i.getNumerator() == 0)); Assert(!d.isIntegral()); TNode var = d_partialModel.asNode(x); Integer floor_d = d.floor(); @@ -4134,7 +4131,9 @@ void TheoryArithPrivate::propagate(Theory::Effort e) { Debug("arith::prop") << c->getNegation()->externalExplainByAssertions() << endl; } - Assert(!c->negationHasProof(), "A constraint has been propagated on the constraint propagation queue, but the negation has been set to true. Contact Tim now!"); + Assert(!c->negationHasProof()) + << "A constraint has been propagated on the constraint propagation " + "queue, but the negation has been set to true. Contact Tim now!"; if(!c->assertedToTheTheory()){ Node literal = c->getLiteral(); @@ -4302,7 +4301,7 @@ Rational TheoryArithPrivate::deltaValueForTotalOrder() const{ bool TheoryArithPrivate::collectModelInfo(TheoryModel* m) { - AlwaysAssert(d_qflraStatus == Result::SAT); + AlwaysAssert(d_qflraStatus == Result::SAT); //AlwaysAssert(!d_nlIncomplete, "Arithmetic solver cannot currently produce models for input with nonlinear arithmetic constraints"); if(Debug.isOn("arith::collectModelInfo")){ @@ -4463,8 +4462,7 @@ void TheoryArithPrivate::presolve(){ d_constraintDatabase.outputUnateInequalityLemmas(lemmas); d_constraintDatabase.outputUnateEqualityLemmas(lemmas); break; - default: - Unhandled(options::arithUnateLemmaMode()); + default: Unhandled() << options::arithUnateLemmaMode(); } } @@ -4525,10 +4523,14 @@ bool TheoryArithPrivate::propagateCandidateBound(ArithVar basic, bool upperBound if(bestImplied != NullConstraint){ //This should be stronger Assert(!upperBound || bound <= bestImplied->getValue()); - Assert(!upperBound || d_partialModel.lessThanUpperBound(basic, bestImplied->getValue())); - - Assert( upperBound || bound >= bestImplied->getValue()); - Assert( upperBound || d_partialModel.greaterThanLowerBound(basic, bestImplied->getValue())); + Assert( + !upperBound + || d_partialModel.lessThanUpperBound(basic, bestImplied->getValue())); + + Assert(upperBound || bound >= bestImplied->getValue()); + Assert(upperBound + || d_partialModel.greaterThanLowerBound(basic, + bestImplied->getValue())); //slightly changed // ConstraintP c = d_constraintDatabase.lookup(bestImplied); @@ -5152,7 +5154,8 @@ Node TheoryArithPrivate::getArithSkolemApp(LogicRequest& logicRequest, return skolem; } -// InferBoundsResult TheoryArithPrivate::inferBound(TNode term, const InferBoundsParameters& param){ +// InferBoundsResult TheoryArithPrivate::inferBound(TNode term, const +// InferBoundsParameters& param){ // Node t = Rewriter::rewrite(term); // Assert(Polynomial::isMember(t)); // Polynomial p = Polynomial::parsePolynomial(t); @@ -5168,8 +5171,8 @@ Node TheoryArithPrivate::getArithSkolemApp(LogicRequest& logicRequest, // if(res.foundBound()){ // DeltaRational newBound = res.getValue() + c.getValue(); // if(tail.isIntegral()){ -// Integer asInt = (param.findLowerBound()) ? newBound.ceiling() : newBound.floor(); -// newBound = DeltaRational(asInt); +// Integer asInt = (param.findLowerBound()) ? newBound.ceiling() : +// newBound.floor(); newBound = DeltaRational(asInt); // } // res.setBound(newBound, res.getExplanation()); // } @@ -5202,14 +5205,16 @@ Node TheoryArithPrivate::getArithSkolemApp(LogicRequest& logicRequest, // { // InferBoundsResult lookup = inferUpperBoundLookup(t, param); // if(lookup.foundBound()){ -// if(param.getEffort() == InferBoundsParameters::LookupAndSimplexOnFailure || +// if(param.getEffort() == +// InferBoundsParameters::LookupAndSimplexOnFailure || // lookup.boundIsOptimal()){ // return lookup; // } // } // InferBoundsResult simplex = inferUpperBoundSimplex(t, param); // if(lookup.foundBound() && simplex.foundBound()){ -// return (lookup.getValue() <= simplex.getValue()) ? lookup : simplex; +// return (lookup.getValue() <= simplex.getValue()) ? lookup : +// simplex; // }else if(lookup.foundBound()){ // return lookup; // }else{ @@ -5223,7 +5228,6 @@ Node TheoryArithPrivate::getArithSkolemApp(LogicRequest& logicRequest, // } // } - std::pair TheoryArithPrivate::entailmentCheck(TNode lit, const ArithEntailmentCheckParameters& params, ArithEntailmentCheckSideEffects& out){ using namespace inferbounds; @@ -5351,7 +5355,8 @@ std::pair TheoryArithPrivate::entailmentCheck(TNode lit, const Arith << " <= " << primDir << "*" << dm << "*" << bestPrimDiff.second << " <= " << primDir << "*" << sep << endl << " by " << bestPrimDiff.first << endl; - Assert(bestPrimDiff.second * (Rational(primDir)* dm) <= (sep * Rational(primDir))); + Assert(bestPrimDiff.second * (Rational(primDir) * dm) + <= (sep * Rational(primDir))); return make_pair(true, bestPrimDiff.first); } } @@ -5842,7 +5847,8 @@ std::pair TheoryArithPrivate::entailmentCheckSimplex(int sg } } -// InferBoundsResult TheoryArithPrivate::inferUpperBoundSimplex(TNode t, const inferbounds::InferBoundAlgorithm& param){ +// InferBoundsResult TheoryArithPrivate::inferUpperBoundSimplex(TNode t, const +// inferbounds::InferBoundAlgorithm& param){ // Assert(param.findUpperBound()); // if(!(d_qflraStatus == Result::SAT && d_errorSet.noSignals())){ @@ -5907,7 +5913,8 @@ std::pair TheoryArithPrivate::entailmentCheckSimplex(int sg // // TODO improve upon bland's // ArithVar entering = ARITHVAR_SENTINEL; // const Tableau::Entry* enteringEntry = NULL; -// for(Tableau::RowIterator ri = d_tableau.ridRowIterator(ridx); !ri.atEnd(); ++ri){ +// for(Tableau::RowIterator ri = d_tableau.ridRowIterator(ridx); +// !ri.atEnd(); ++ri){ // const Tableau::Entry& entry = *ri; // ArithVar v = entry.getColVar(); // if(v != optVar){ @@ -5975,7 +5982,6 @@ std::pair TheoryArithPrivate::entailmentCheckSimplex(int sg // } // } - // if(leaving == ARITHVAR_SENTINEL){ // finalState = NoBound; // break; @@ -6003,7 +6009,8 @@ std::pair TheoryArithPrivate::entailmentCheckSimplex(int sg // case Inferred: // { // NodeBuilder<> nb(kind::AND); -// for(Tableau::RowIterator ri = d_tableau.ridRowIterator(ridx); !ri.atEnd(); ++ri){ +// for(Tableau::RowIterator ri = d_tableau.ridRowIterator(ridx); +// !ri.atEnd(); ++ri){ // const Tableau::Entry& e =*ri; // ArithVar colVar = e.getColVar(); // if(colVar != optVar){ diff --git a/src/theory/arith/type_enumerator.h b/src/theory/arith/type_enumerator.h index 5c6bf63ce..bb1612928 100644 --- a/src/theory/arith/type_enumerator.h +++ b/src/theory/arith/type_enumerator.h @@ -36,8 +36,8 @@ class RationalEnumerator : public TypeEnumeratorBase { RationalEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr) : TypeEnumeratorBase(type), d_rat(0) { - Assert(type.getKind() == kind::TYPE_CONSTANT && - type.getConst() == REAL_TYPE); + Assert(type.getKind() == kind::TYPE_CONSTANT + && type.getConst() == REAL_TYPE); } Node operator*() override { return NodeManager::currentNM()->mkConst(d_rat); } @@ -77,8 +77,8 @@ class IntegerEnumerator : public TypeEnumeratorBase { IntegerEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr) : TypeEnumeratorBase(type), d_int(0) { - Assert(type.getKind() == kind::TYPE_CONSTANT && - type.getConst() == INTEGER_TYPE); + Assert(type.getKind() == kind::TYPE_CONSTANT + && type.getConst() == INTEGER_TYPE); } Node operator*() override diff --git a/src/theory/arrays/array_info.cpp b/src/theory/arrays/array_info.cpp index 0d1095a23..3103f4ecc 100644 --- a/src/theory/arrays/array_info.cpp +++ b/src/theory/arrays/array_info.cpp @@ -134,7 +134,7 @@ void ArrayInfo::mergeLists(CTNodeList* la, const CTNodeList* lb) const{ void ArrayInfo::addIndex(const Node a, const TNode i) { Assert(a.getType().isArray()); - Assert(!i.getType().isArray()); // temporary for flat arrays + Assert(!i.getType().isArray()); // temporary for flat arrays Trace("arrays-ind")<<"Arrays::addIndex "< -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/node.h" #include "theory/arrays/static_fact_manager.h" @@ -97,7 +97,8 @@ void StaticFactManager::addEq(TNode eq) { // CNodeTNodesMap::iterator deq_ib = d_disequalities.find(b); // if(deq_ib != d_disequalities.end()) { // CTNodeListAlloc* deq = (*deq_ib).second; - // for(CTNodeListAlloc::const_iterator j = deq->begin(); j!=deq->end(); j++) { + // for(CTNodeListAlloc::const_iterator j = deq->begin(); j!=deq->end(); + // j++) { // TNode deqn = *j; // TNode s = deqn[0]; // TNode t = deqn[1]; @@ -120,12 +121,11 @@ void StaticFactManager::addEq(TNode eq) { // */ // CTNodeListAlloc* deqa = (*deq_ia).second; - // for(CTNodeListAlloc::const_iterator i = deqa->begin(); i!= deqa->end(); i++) { + // for(CTNodeListAlloc::const_iterator i = deqa->begin(); i!= deqa->end(); + // i++) { // TNode deqn = (*i); - // Assert(deqn.getKind() == kind::EQUAL || deqn.getKind() == kind::IFF); - // TNode s = deqn[0]; - // TNode t = deqn[1]; - // TNode sp = find(s); + // Assert(deqn.getKind() == kind::EQUAL || deqn.getKind() == + // kind::IFF); TNode s = deqn[0]; TNode t = deqn[1]; TNode sp = find(s); // TNode tp = find(t); // if(find(s) == find(t)) { diff --git a/src/theory/arrays/theory_arrays.cpp b/src/theory/arrays/theory_arrays.cpp index 003bb0d68..f2beec0b8 100644 --- a/src/theory/arrays/theory_arrays.cpp +++ b/src/theory/arrays/theory_arrays.cpp @@ -189,7 +189,8 @@ void TheoryArrays::setMasterEqualityEngine(eq::EqualityEngine* eq) { bool TheoryArrays::ppDisequal(TNode a, TNode b) { bool termsExist = d_ppEqualityEngine.hasTerm(a) && d_ppEqualityEngine.hasTerm(b); - Assert(!termsExist || !a.isConst() || !b.isConst() || a == b || d_ppEqualityEngine.areDisequal(a, b, false)); + Assert(!termsExist || !a.isConst() || !b.isConst() || a == b + || d_ppEqualityEngine.areDisequal(a, b, false)); return ((termsExist && d_ppEqualityEngine.areDisequal(a, b, false)) || Rewriter::rewrite(a.eqNode(b)) == d_false); } @@ -621,14 +622,17 @@ void TheoryArrays::checkWeakEquiv(bool arraysMerged) { Assert(pointer.isNull() == (weakEquivGetRep(n) == n)); Assert(!pointer.isNull() || secondary.isNull()); Assert(!index.isNull() || secondary.isNull()); - Assert(d_infoMap.getWeakEquivSecondaryReason(n).isNull() || !secondary.isNull()); + Assert(d_infoMap.getWeakEquivSecondaryReason(n).isNull() + || !secondary.isNull()); if (!pointer.isNull()) { if (index.isNull()) { Assert(d_equalityEngine.areEqual(n, pointer)); } else { - Assert((n.getKind() == kind::STORE && n[0] == pointer && n[1] == index) || - (pointer.getKind() == kind::STORE && pointer[0] == n && pointer[1] == index)); + Assert( + (n.getKind() == kind::STORE && n[0] == pointer && n[1] == index) + || (pointer.getKind() == kind::STORE && pointer[0] == n + && pointer[1] == index)); } } } @@ -694,7 +698,7 @@ void TheoryArrays::preRegisterTermInternal(TNode node) TNode s = *it; if (!d_infoMap.rIntro1Applied(s)) { d_infoMap.setRIntro1Applied(s); - Assert(s.getKind()==kind::STORE); + Assert(s.getKind() == kind::STORE); Node ni = nm->mkNode(kind::SELECT, s, s[1]); if (ni != node) { preRegisterTermInternal(ni); @@ -823,7 +827,8 @@ void TheoryArrays::preRegisterTermInternal(TNode node) } // Invariant: preregistered terms are exactly the terms in the equality engine // Disabled, see comment above for kind::EQUAL - // Assert(d_equalityEngine.hasTerm(node) || !d_equalityEngine.consistent()); + // Assert(d_equalityEngine.hasTerm(node) || + // !d_equalityEngine.consistent()); } @@ -915,7 +920,8 @@ void TheoryArrays::checkPair(TNode r1, TNode r2) if (r1[0] != r2[0]) { // If arrays are known to be disequal, or cannot become equal, we can continue - Assert(d_mayEqualEqualityEngine.hasTerm(r1[0]) && d_mayEqualEqualityEngine.hasTerm(r2[0])); + Assert(d_mayEqualEqualityEngine.hasTerm(r1[0]) + && d_mayEqualEqualityEngine.hasTerm(r2[0])); if (r1[0].getType() != r2[0].getType() || d_equalityEngine.areDisequal(r1[0], r2[0], false)) { Debug("arrays::sharing") << "TheoryArrays::computeCareGraph(): arrays can't be equal, skipping" << std::endl; @@ -976,7 +982,8 @@ void TheoryArrays::computeCareGraph() if (eqStatusArr != EQUALITY_UNKNOWN) { continue; } - Assert(d_valuation.getEqualityStatus((*it1), (*it2)) == EQUALITY_UNKNOWN); + Assert(d_valuation.getEqualityStatus((*it1), (*it2)) + == EQUALITY_UNKNOWN); addCarePair((*it1), (*it2)); ++d_numSharedArrayVarSplits; return; @@ -1133,7 +1140,7 @@ bool TheoryArrays::collectModelInfo(TheoryModel* m) size_t it = 0; for(; it < instores->size(); ++it) { TNode instore = (*instores)[it]; - Assert(instore.getKind()==kind::STORE); + Assert(instore.getKind() == kind::STORE); if (termSet.find(instore) != termSet.end() && !d_equalityEngine.areEqual(instore[1],n[1])) { Node r = nm->mkNode(kind::SELECT, instore, n[1]); @@ -1203,7 +1210,8 @@ bool TheoryArrays::collectModelInfo(TheoryModel* m) TypeNode valueType = nrep.getType().getArrayConstituentType(); rep = defaultValuesSet.nextTypeEnum(valueType); if (rep.isNull()) { - Assert(defaultValuesSet.getSet(valueType)->begin() != defaultValuesSet.getSet(valueType)->end()); + Assert(defaultValuesSet.getSet(valueType)->begin() + != defaultValuesSet.getSet(valueType)->end()); rep = *(defaultValuesSet.getSet(valueType)->begin()); } Trace("arrays-models") << "New default value = " << rep << endl; @@ -1558,7 +1566,8 @@ Node TheoryArrays::mkAnd(std::vector& conjunctions, bool invert, unsigned explained.insert(t); } else { // EXT lemma - Assert(t[1].getKind() == kind::NOT && t[1][0].getKind() == kind::EQUAL); + Assert(t[1].getKind() == kind::NOT + && t[1][0].getKind() == kind::EQUAL); Assert(t[0].getKind() == kind::EQUAL); all.insert(t[0].notNode()); explained.insert(t); @@ -1618,7 +1627,7 @@ void TheoryArrays::setNonLinear(TNode a) // Propagate non-linearity down chain of stores for( ; it < st_a->size(); ++it) { TNode store = (*st_a)[it]; - Assert(store.getKind()==kind::STORE); + Assert(store.getKind() == kind::STORE); setNonLinear(store[0]); } @@ -1847,7 +1856,7 @@ void TheoryArrays::checkStore(TNode a) { d_infoMap.getInfo(a)->print(); } Assert(a.getType().isArray()); - Assert(a.getKind()==kind::STORE); + Assert(a.getKind() == kind::STORE); TNode b = a[0]; TNode i = a[1]; @@ -1898,7 +1907,7 @@ void TheoryArrays::checkRowForIndex(TNode i, TNode a) for(; it < stores->size(); ++it) { TNode store = (*stores)[it]; - Assert(store.getKind()==kind::STORE); + Assert(store.getKind() == kind::STORE); TNode j = store[1]; if (i == j) continue; lem = std::make_tuple(store, store[0], j, i); @@ -1910,7 +1919,7 @@ void TheoryArrays::checkRowForIndex(TNode i, TNode a) it = 0; for(; it < instores->size(); ++it) { TNode instore = (*instores)[it]; - Assert(instore.getKind()==kind::STORE); + Assert(instore.getKind() == kind::STORE); TNode j = instore[1]; if (i == j) continue; lem = std::make_tuple(instore, instore[0], j, i); diff --git a/src/theory/arrays/theory_arrays_type_rules.h b/src/theory/arrays/theory_arrays_type_rules.h index 78756176d..223d742eb 100644 --- a/src/theory/arrays/theory_arrays_type_rules.h +++ b/src/theory/arrays/theory_arrays_type_rules.h @@ -218,7 +218,8 @@ struct ArraysProperties { struct ArrayPartialSelectTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::PARTIAL_SELECT_0 || n.getKind() == kind::PARTIAL_SELECT_1); + Assert(n.getKind() == kind::PARTIAL_SELECT_0 + || n.getKind() == kind::PARTIAL_SELECT_1); return nodeManager->integerType(); } };/* struct ArrayPartialSelectTypeRule */ diff --git a/src/theory/arrays/union_find.cpp b/src/theory/arrays/union_find.cpp index af2cf3c3f..0afa94a8e 100644 --- a/src/theory/arrays/union_find.cpp +++ b/src/theory/arrays/union_find.cpp @@ -18,7 +18,6 @@ #include -#include "base/cvc4_assert.h" #include "expr/node.h" #include "theory/arrays/union_find.h" diff --git a/src/theory/booleans/circuit_propagator.cpp b/src/theory/booleans/circuit_propagator.cpp index 150403b67..f9631c94d 100644 --- a/src/theory/booleans/circuit_propagator.cpp +++ b/src/theory/booleans/circuit_propagator.cpp @@ -138,7 +138,7 @@ void CircuitPropagator::propagateBackward(TNode parent, bool parentAssignment) { } break; case kind::EQUAL: - Assert( parent[0].getType().isBoolean() ); + Assert(parent[0].getType().isBoolean()); if (parentAssignment) { // IFF x y = TRUE: if x [resp y] is assigned, assign(y = x.assignment [resp x = y.assignment]) if (isAssigned(parent[0])) { @@ -289,7 +289,7 @@ void CircuitPropagator::propagateForward(TNode child, bool childAssignment) { } break; case kind::EQUAL: - Assert( parent[0].getType().isBoolean() ); + Assert(parent[0].getType().isBoolean()); if (isAssigned(parent[0]) && isAssigned(parent[1])) { // IFF x y: if x or y is assigned, assign(IFF = (x.assignment <=> y.assignment)) assignAndEnqueue(parent, getAssignment(parent[0]) == getAssignment(parent[1])); diff --git a/src/theory/booleans/type_enumerator.h b/src/theory/booleans/type_enumerator.h index 361216b10..b0bae3e47 100644 --- a/src/theory/booleans/type_enumerator.h +++ b/src/theory/booleans/type_enumerator.h @@ -34,8 +34,8 @@ class BooleanEnumerator : public TypeEnumeratorBase { BooleanEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr) : TypeEnumeratorBase(type), d_value(FALSE) { - Assert(type.getKind() == kind::TYPE_CONSTANT && - type.getConst() == BOOLEAN_TYPE); + Assert(type.getKind() == kind::TYPE_CONSTANT + && type.getConst() == BOOLEAN_TYPE); } Node operator*() override { diff --git a/src/theory/builtin/theory_builtin_rewriter.cpp b/src/theory/builtin/theory_builtin_rewriter.cpp index 63d08b0ef..d483bf994 100644 --- a/src/theory/builtin/theory_builtin_rewriter.cpp +++ b/src/theory/builtin/theory_builtin_rewriter.cpp @@ -28,7 +28,6 @@ namespace theory { namespace builtin { Node TheoryBuiltinRewriter::blastDistinct(TNode in) { - Assert(in.getKind() == kind::DISTINCT); if(in.getNumChildren() == 2) { @@ -54,7 +53,6 @@ Node TheoryBuiltinRewriter::blastDistinct(TNode in) { } Node TheoryBuiltinRewriter::blastChain(TNode in) { - Assert(in.getKind() == kind::CHAIN); Kind chainedOp = in.getOperator().getConst().getOperator(); @@ -77,7 +75,7 @@ RewriteResponse TheoryBuiltinRewriter::postRewrite(TNode node) { Trace("builtin-rewrite") << "Rewriting lambda " << node << "..." << std::endl; Node anode = getArrayRepresentationForLambda( node ); if( !anode.isNull() ){ - Assert( anode.getType().isArray() ); + Assert(anode.getType().isArray()); //must get the standard bound variable list Node varList = NodeManager::currentNM()->getBoundVarListForFunctionType( node.getType() ); Node retNode = getLambdaForArrayRepresentation( anode, varList ); @@ -86,8 +84,8 @@ RewriteResponse TheoryBuiltinRewriter::postRewrite(TNode node) { Trace("builtin-rewrite") << " input : " << node << std::endl; Trace("builtin-rewrite") << " output : " << retNode << ", constant = " << retNode.isConst() << std::endl; Trace("builtin-rewrite") << " array rep : " << anode << ", constant = " << anode.isConst() << std::endl; - Assert( anode.isConst()==retNode.isConst() ); - Assert( retNode.getType()==node.getType() ); + Assert(anode.isConst() == retNode.isConst()); + Assert(retNode.getType() == node.getType()); Assert(expr::hasFreeVar(node) == expr::hasFreeVar(retNode)); return RewriteResponse(REWRITE_DONE, retNode); } @@ -148,7 +146,7 @@ Node TheoryBuiltinRewriter::getLambdaForArrayRepresentationRec( TNode a, TNode b if( it==visited.end() ){ Node ret; if( bvlIndexmkNode( kind::ITE, cond, val, body ); } @@ -179,7 +180,7 @@ Node TheoryBuiltinRewriter::getLambdaForArrayRepresentationRec( TNode a, TNode b } Node TheoryBuiltinRewriter::getLambdaForArrayRepresentation( TNode a, TNode bvl ){ - Assert( a.getType().isArray() ); + Assert(a.getType().isArray()); std::unordered_map< TNode, Node, TNodeHashFunction > visited; Trace("builtin-rewrite-debug") << "Get lambda for : " << a << ", with variables " << bvl << std::endl; Node body = getLambdaForArrayRepresentationRec( a, bvl, 0, visited ); @@ -196,7 +197,7 @@ Node TheoryBuiltinRewriter::getLambdaForArrayRepresentation( TNode a, TNode bvl Node TheoryBuiltinRewriter::getArrayRepresentationForLambdaRec(TNode n, TypeNode retType) { - Assert( n.getKind()==kind::LAMBDA ); + Assert(n.getKind() == kind::LAMBDA); NodeManager* nm = NodeManager::currentNM(); Trace("builtin-rewrite-debug") << "Get array representation for : " << n << std::endl; @@ -343,14 +344,14 @@ Node TheoryBuiltinRewriter::getArrayRepresentationForLambdaRec(TNode n, array_type = NodeManager::currentNM()->mkArrayType( n[0][index].getType(), array_type ); } Trace("builtin-rewrite-debug2") << " make array store all " << curr.getType() << " annotated : " << array_type << std::endl; - Assert( curr.getType().isSubtypeOf( array_type.getArrayConstituentType() ) ); + Assert(curr.getType().isSubtypeOf(array_type.getArrayConstituentType())); curr = NodeManager::currentNM()->mkConst(ArrayStoreAll(((ArrayType)array_type.toType()), curr.toExpr())); Trace("builtin-rewrite-debug2") << " build array..." << std::endl; // can only build if default value is constant (since array store all must be constant) Trace("builtin-rewrite-debug2") << " got constant base " << curr << std::endl; // construct store chain for( int i=((int)conds.size()-1); i>=0; i-- ){ - Assert( conds[i].getType().isSubtypeOf( first_arg.getType() ) ); + Assert(conds[i].getType().isSubtypeOf(first_arg.getType())); curr = NodeManager::currentNM()->mkNode( kind::STORE, curr, conds[i], vals[i] ); } Trace("builtin-rewrite-debug") << "...got array " << curr << " for " << n << std::endl; @@ -363,7 +364,7 @@ Node TheoryBuiltinRewriter::getArrayRepresentationForLambdaRec(TNode n, Node TheoryBuiltinRewriter::getArrayRepresentationForLambda(TNode n) { - Assert( n.getKind()==kind::LAMBDA ); + Assert(n.getKind() == kind::LAMBDA); // must carry the overall return type to deal with cases like (lambda ((x Int)(y Int)) (ite (= x _) 0.5 0.0)), // where the inner construction for the else case about should be (arraystoreall (Array Int Real) 0.0) Node anode = getArrayRepresentationForLambdaRec(n, n[1].getType()); diff --git a/src/theory/builtin/theory_builtin_type_rules.h b/src/theory/builtin/theory_builtin_type_rules.h index db427d21e..96e2e7e6f 100644 --- a/src/theory/builtin/theory_builtin_type_rules.h +++ b/src/theory/builtin/theory_builtin_type_rules.h @@ -134,7 +134,7 @@ class LambdaTypeRule { //get array representation of this function, if possible Node na = TheoryBuiltinRewriter::getArrayRepresentationForLambda(n); if( !na.isNull() ){ - Assert( na.getType().isArray() ); + Assert(na.getType().isArray()); Trace("lambda-const") << "Array representation for " << n << " is " << na << " " << na.getType() << std::endl; // must have the standard bound variable list Node bvl = NodeManager::currentNM()->getBoundVarListForFunctionType( n.getType() ); diff --git a/src/theory/bv/abstraction.cpp b/src/theory/bv/abstraction.cpp index cb829aba6..d9de9731a 100644 --- a/src/theory/bv/abstraction.cpp +++ b/src/theory/bv/abstraction.cpp @@ -140,7 +140,7 @@ Node AbstractionModule::reverseAbstraction(Node assertion, NodeNodeMap& seen) { if (isAbstraction(assertion)) { Node interp = getInterpretation(assertion); seen[assertion] = interp; - Assert (interp.getType() == assertion.getType()); + Assert(interp.getType() == assertion.getType()); return interp; } @@ -319,7 +319,7 @@ bool AbstractionModule::hasSignature(Node node) { Node AbstractionModule::getGeneralizedSignature(Node node) { NodeNodeMap::const_iterator it = d_assertionToSignature.find(node); - Assert (it != d_assertionToSignature.end()); + Assert(it != d_assertionToSignature.end()); Node generalized_signature = getGeneralization(it->second); return generalized_signature; } @@ -417,14 +417,14 @@ TNode AbstractionModule::getGeneralization(TNode term) { return term; TNode generalization = getGeneralization(it->second); - Assert (generalization != term); + Assert(generalization != term); d_sigToGeneralization[term] = generalization; return generalization; } void AbstractionModule::storeGeneralization(TNode s, TNode t) { - Assert (s == getGeneralization(s)); - Assert (t == getGeneralization(t)); + Assert(s == getGeneralization(s)); + Assert(t == getGeneralization(t)); d_sigToGeneralization[s] = t; } @@ -559,13 +559,13 @@ void AbstractionModule::collectArguments(TNode node, TNode signature, std::vecto args.push_back(node); seen.insert(node); } else { - Assert (signature.getKind() == kind::CONST_BITVECTOR); + Assert(signature.getKind() == kind::CONST_BITVECTOR); } // return; } - Assert (node.getKind() == signature.getKind() && - node.getNumChildren() == signature.getNumChildren()); + Assert(node.getKind() == signature.getKind() + && node.getNumChildren() == signature.getNumChildren()); for (unsigned i = 0; i < node.getNumChildren(); ++i) { collectArguments(node[i], signature[i], args, seen); @@ -618,8 +618,8 @@ bool AbstractionModule::isAbstraction(TNode node) { TNode constant = node[0].getKind() == kind::CONST_BITVECTOR ? node[0] : node[1]; TNode func = node[0].getKind() == kind::APPLY_UF ? node[0] : node[1]; - Assert (constant.getKind() == kind::CONST_BITVECTOR && - func.getKind() == kind::APPLY_UF); + Assert(constant.getKind() == kind::CONST_BITVECTOR + && func.getKind() == kind::APPLY_UF); if (utils::getSize(constant) != 1) return false; if (constant != utils::mkConst(1, 1u)) @@ -633,14 +633,14 @@ bool AbstractionModule::isAbstraction(TNode node) { } Node AbstractionModule::getInterpretation(TNode node) { - Assert (isAbstraction(node)); + Assert(isAbstraction(node)); TNode constant = node[0].getKind() == kind::CONST_BITVECTOR ? node[0] : node[1]; TNode apply = node[0].getKind() == kind::APPLY_UF ? node[0] : node[1]; - Assert (constant.getKind() == kind::CONST_BITVECTOR && - apply.getKind() == kind::APPLY_UF); + Assert(constant.getKind() == kind::CONST_BITVECTOR + && apply.getKind() == kind::APPLY_UF); Node func = apply.getOperator(); - Assert (d_funcToSignature.find(func) != d_funcToSignature.end()); + Assert(d_funcToSignature.find(func) != d_funcToSignature.end()); Node sig = d_funcToSignature[func]; @@ -648,8 +648,8 @@ Node AbstractionModule::getInterpretation(TNode node) { TNodeTNodeMap seen; unsigned index = 0; Node result = substituteArguments(sig, apply, index, seen); - Assert (result.getType().isBoolean()); - Assert (index == apply.getNumChildren()); + Assert(result.getType().isBoolean()); + Assert(index == apply.getNumChildren()); // Debug("bv-abstraction") << "AbstractionModule::getInterpretation " << node << "\n"; // Debug("bv-abstraction") << " => " << result << "\n"; return result; @@ -726,10 +726,8 @@ Node AbstractionModule::simplifyConflict(TNode conflict) { continue; } - Assert (!subst.hasSubstitution(s)); - Assert (!t.isNull() && - !s.isNull() && - s!= t); + Assert(!subst.hasSubstitution(s)); + Assert(!t.isNull() && !s.isNull() && s != t); subst.addSubstitution(s, t); for (unsigned k = 0; k < conjuncts.size(); k++) { @@ -789,14 +787,14 @@ void AbstractionModule::generalizeConflict(TNode conflict, std::vector& le // collect abstract functions if (conflict.getKind() != kind::AND) { if (isAbstraction(conflict)) { - Assert (conflict[0].getKind() == kind::APPLY_UF); + Assert(conflict[0].getKind() == kind::APPLY_UF); functions.push_back(conflict[0]); } } else { for (unsigned i = 0; i < conflict.getNumChildren(); ++i) { TNode conjunct = conflict[i]; if (isAbstraction(conjunct)) { - Assert (conjunct[0].getKind() == kind::APPLY_UF); + Assert(conjunct[0].getKind() == kind::APPLY_UF); functions.push_back(conjunct[0]); } } @@ -871,7 +869,7 @@ bool AbstractionModule::LemmaInstantiatior::isConsistent(const vector& stac TNode func = d_functions[current]; ArgsTableEntry& matches = d_argsTable.getEntry(func.getOperator()); ArgsVec& args = matches.getEntry(stack[current]); - Assert (args.size() == func.getNumChildren()); + Assert(args.size() == func.getNumChildren()); for (unsigned k = 0; k < args.size(); ++k) { TNode s = func[k]; TNode t = args[k]; @@ -905,8 +903,8 @@ bool AbstractionModule::LemmaInstantiatior::isConsistent(const vector& stac continue; } - Assert (s0.getMetaKind() == kind::metakind::VARIABLE && - t0.getMetaKind() == kind::metakind::VARIABLE); + Assert(s0.getMetaKind() == kind::metakind::VARIABLE + && t0.getMetaKind() == kind::metakind::VARIABLE); if (s0 != t0) { d_subst.addSubstitution(s0, t0); @@ -952,7 +950,7 @@ void AbstractionModule::LemmaInstantiatior::generateInstantiations(std::vector stack; backtrack(stack); - Assert (d_ctx->getLevel() == 0); + Assert(d_ctx->getLevel() == 0); Debug("bv-abstraction-gen") << "numLemmas=" << d_lemmas.size() <<"\n"; lemmas.swap(d_lemmas); } @@ -976,8 +974,8 @@ void AbstractionModule::makeFreshSkolems(TNode node, SubstitutionMap& map, Subst } void AbstractionModule::makeFreshArgs(TNode func, std::vector& fresh_args) { - Assert (fresh_args.size() == 0); - Assert (func.getKind() == kind::APPLY_UF); + Assert(fresh_args.size() == 0); + Assert(func.getKind() == kind::APPLY_UF); TNodeNodeMap d_map; for (unsigned i = 0; i < func.getNumChildren(); ++i) { TNode arg = func[i]; @@ -985,7 +983,7 @@ void AbstractionModule::makeFreshArgs(TNode func, std::vector& fresh_args) fresh_args.push_back(arg); continue; } - Assert (arg.getMetaKind() == kind::metakind::VARIABLE); + Assert(arg.getMetaKind() == kind::metakind::VARIABLE); TNodeNodeMap::iterator it = d_map.find(arg); if (it != d_map.end()) { fresh_args.push_back(it->second); @@ -995,11 +993,11 @@ void AbstractionModule::makeFreshArgs(TNode func, std::vector& fresh_args) fresh_args.push_back(skolem); } } - Assert (fresh_args.size() == func.getNumChildren()); + Assert(fresh_args.size() == func.getNumChildren()); } Node AbstractionModule::tryMatching(const std::vector& ss, const std::vector& tt, TNode conflict) { - Assert (ss.size() == tt.size()); + Assert(ss.size() == tt.size()); Debug("bv-abstraction-dbg") << "AbstractionModule::tryMatching conflict = " << conflict << "\n"; if (Debug.isOn("bv-abstraction-dbg")) { @@ -1044,10 +1042,10 @@ Node AbstractionModule::tryMatching(const std::vector& ss, const std::vect continue; } - Assert (s0.getMetaKind() == kind::metakind::VARIABLE && - t0.getMetaKind() == kind::metakind::VARIABLE); + Assert(s0.getMetaKind() == kind::metakind::VARIABLE + && t0.getMetaKind() == kind::metakind::VARIABLE); - Assert (s0 != t0); + Assert(s0 != t0); subst.addSubstitution(s0, t0); } @@ -1062,20 +1060,20 @@ void AbstractionModule::storeLemma(TNode lemma) { for (unsigned i = 0; i < lemma.getNumChildren(); i++) { TNode atom = lemma[i]; atom = atom.getKind() == kind::NOT ? atom[0] : atom; - Assert (atom.getKind() != kind::NOT); - Assert (utils::isBVPredicate(atom)); + Assert(atom.getKind() != kind::NOT); + Assert(utils::isBVPredicate(atom)); d_lemmaAtoms.insert(atom); } } else { lemma = lemma.getKind() == kind::NOT? lemma[0] : lemma; - Assert (utils::isBVPredicate(lemma)); + Assert(utils::isBVPredicate(lemma)); d_lemmaAtoms.insert(lemma); } } bool AbstractionModule::isLemmaAtom(TNode node) const { - Assert (node.getType().isBoolean()); + Assert(node.getType().isBoolean()); node = node.getKind() == kind::NOT? node[0] : node; return d_inputAtoms.find(node) == d_inputAtoms.end() && @@ -1089,7 +1087,7 @@ void AbstractionModule::addInputAtom(TNode atom) { } void AbstractionModule::ArgsTableEntry::addArguments(const ArgsVec& args) { - Assert (args.size() == d_arity); + Assert(args.size() == d_arity); d_data.push_back(args); } @@ -1107,7 +1105,7 @@ bool AbstractionModule::ArgsTable::hasEntry(TNode signature) const { } AbstractionModule::ArgsTableEntry& AbstractionModule::ArgsTable::getEntry(TNode signature) { - Assert (hasEntry(signature)); + Assert(hasEntry(signature)); return d_data.find(signature)->second; } diff --git a/src/theory/bv/abstraction.h b/src/theory/bv/abstraction.h index 5472aa5a2..4895d1818 100644 --- a/src/theory/bv/abstraction.h +++ b/src/theory/bv/abstraction.h @@ -60,7 +60,11 @@ class AbstractionModule { iterator end() { return d_data.end(); } unsigned getArity() { return d_arity; } unsigned getNumEntries() { return d_data.size(); } - ArgsVec& getEntry(unsigned i ) { Assert (i < d_data.size()); return d_data[i]; } + ArgsVec& getEntry(unsigned i) + { + Assert(i < d_data.size()); + return d_data[i]; + } }; class ArgsTable { diff --git a/src/theory/bv/bitblast/aig_bitblaster.cpp b/src/theory/bv/bitblast/aig_bitblaster.cpp index 3ed926f84..c2bc9e6e8 100644 --- a/src/theory/bv/bitblast/aig_bitblaster.cpp +++ b/src/theory/bv/bitblast/aig_bitblaster.cpp @@ -18,7 +18,7 @@ #include "theory/bv/bitblast/aig_bitblaster.h" -#include "base/cvc4_check.h" +#include "base/check.h" #include "options/bv_options.h" #include "prop/sat_solver_factory.h" #include "smt/smt_statistics_registry.h" @@ -46,7 +46,7 @@ namespace bv { template <> inline std::string toString (const std::vector& bits) { - Unreachable("Don't know how to print AIG"); + Unreachable() << "Don't know how to print AIG"; } @@ -72,7 +72,7 @@ Abc_Obj_t* mkOr(Abc_Obj_t* a, Abc_Obj_t* b) { template <> inline Abc_Obj_t* mkOr(const std::vector& children) { - Assert (children.size()); + Assert(children.size()); if (children.size() == 1) return children[0]; @@ -91,7 +91,7 @@ Abc_Obj_t* mkAnd(Abc_Obj_t* a, Abc_Obj_t* b) { template <> inline Abc_Obj_t* mkAnd(const std::vector& children) { - Assert (children.size()); + Assert(children.size()); if (children.size() == 1) return children[0]; @@ -172,7 +172,7 @@ AigBitblaster::AigBitblaster() AigBitblaster::~AigBitblaster() {} Abc_Obj_t* AigBitblaster::bbFormula(TNode node) { - Assert (node.getType().isBoolean()); + Assert(node.getType().isBoolean()); Debug("bitvector-bitblast") << "AigBitblaster::bbFormula "<< node << "\n"; if (hasAig(node)) @@ -211,7 +211,7 @@ Abc_Obj_t* AigBitblaster::bbFormula(TNode node) { } case kind::IMPLIES: { - Assert (node.getNumChildren() == 2); + Assert(node.getNumChildren() == 2); Abc_Obj_t* child1 = bbFormula(node[0]); Abc_Obj_t* child2 = bbFormula(node[1]); @@ -220,7 +220,7 @@ Abc_Obj_t* AigBitblaster::bbFormula(TNode node) { } case kind::ITE: { - Assert (node.getNumChildren() == 3); + Assert(node.getNumChildren() == 3); Abc_Obj_t* a = bbFormula(node[0]); Abc_Obj_t* b = bbFormula(node[1]); Abc_Obj_t* c = bbFormula(node[2]); @@ -241,7 +241,7 @@ Abc_Obj_t* AigBitblaster::bbFormula(TNode node) { case kind::EQUAL: { if( node[0].getType().isBoolean() ){ - Assert (node.getNumChildren() == 2); + Assert(node.getNumChildren() == 2); Abc_Obj_t* child1 = bbFormula(node[0]); Abc_Obj_t* child2 = bbFormula(node[1]); @@ -283,18 +283,18 @@ void AigBitblaster::bbTerm(TNode node, Bits& bits) { getBBTerm(node, bits); return; } - Assert( node.getType().isBitVector() ); + Assert(node.getType().isBitVector()); Debug("bitvector-bitblast") << "Bitblasting term " << node <<"\n"; d_termBBStrategies[node.getKind()] (node, bits, this); - Assert (bits.size() == utils::getSize(node)); + Assert(bits.size() == utils::getSize(node)); storeBBTerm(node, bits); } void AigBitblaster::cacheAig(TNode node, Abc_Obj_t* aig) { - Assert (!hasAig(node)); + Assert(!hasAig(node)); d_aigCache.insert(std::make_pair(node, aig)); } bool AigBitblaster::hasAig(TNode node) { @@ -317,9 +317,9 @@ void AigBitblaster::makeVariable(TNode node, Bits& bits) { } Abc_Obj_t* AigBitblaster::mkInput(TNode input) { - Assert (!hasInput(input)); - Assert(input.getKind() == kind::BITVECTOR_BITOF || - (input.getType().isBoolean() && input.isVar())); + Assert(!hasInput(input)); + Assert(input.getKind() == kind::BITVECTOR_BITOF + || (input.getType().isBoolean() && input.isVar())); Abc_Obj_t* aig_input = Abc_NtkCreatePi(currentAigNtk()); // d_aigCache.insert(std::make_pair(input, aig_input)); d_nodeToAigInput.insert(std::make_pair(input, aig_input)); @@ -333,7 +333,7 @@ bool AigBitblaster::hasInput(TNode input) { bool AigBitblaster::solve(TNode node) { // setting output of network to be the query - Assert (d_aigOutputNode == NULL); + Assert(d_aigOutputNode == NULL); Abc_Obj_t* query = bbFormula(node); d_aigOutputNode = Abc_NtkCreatePo(currentAigNtk()); Abc_ObjAddFanin(d_aigOutputNode, query); @@ -345,7 +345,7 @@ bool AigBitblaster::solve(TNode node) { TimerStat::CodeTimer solveTimer(d_statistics.d_solveTime); prop::SatValue result = d_satSolver->solve(); - Assert (result != prop::SAT_VALUE_UNKNOWN); + Assert(result != prop::SAT_VALUE_UNKNOWN); return result == prop::SAT_VALUE_TRUE; } @@ -356,7 +356,7 @@ void AigBitblaster::simplifyAig() { TimerStat::CodeTimer simpTimer(d_statistics.d_simplificationTime); Abc_AigCleanup(currentAigM()); - Assert (Abc_NtkCheck(currentAigNtk())); + Assert(Abc_NtkCheck(currentAigNtk())); const char* command = options::bitvectorAigSimplifications().c_str(); Abc_Frame_t* pAbc = Abc_FrameGetGlobalFrame(); @@ -376,8 +376,8 @@ void AigBitblaster::convertToCnfAndAssert() { Aig_Man_t * pMan = NULL; Cnf_Dat_t * pCnf = NULL; - Assert( Abc_NtkIsStrash(currentAigNtk()) ); - + Assert(Abc_NtkIsStrash(currentAigNtk())); + // convert to the AIG manager pMan = Abc_NtkToDar(currentAigNtk(), 0, 0 ); Abc_Stop(); @@ -385,9 +385,9 @@ void AigBitblaster::convertToCnfAndAssert() { // // free old network // Abc_NtkDelete(currentAigNtk()); // s_abcAigNetwork = NULL; - - Assert (pMan != NULL); - Assert (Aig_ManCheck(pMan)); + + Assert(pMan != NULL); + Assert(Aig_ManCheck(pMan)); pCnf = Cnf_DeriveFast( pMan, 0 ); assertToSatSolver(pCnf); @@ -416,9 +416,9 @@ void AigBitblaster::assertToSatSolver(Cnf_Dat_t* pCnf) { prop::SatClause clause; for (pLit = pCnf->pClauses[i], pStop = pCnf->pClauses[i+1]; pLit < pStop; pLit++ ) { int int_lit = Cnf_Lit2Var(*pLit); - Assert (int_lit != 0); + Assert(int_lit != 0); unsigned index = int_lit < 0? -int_lit : int_lit; - Assert (index - 1 < sat_variables.size()); + Assert(index - 1 < sat_variables.size()); prop::SatLiteral lit(sat_variables[index-1], int_lit < 0); clause.push_back(lit); } @@ -464,7 +464,7 @@ void AigBitblaster::storeBBAtom(TNode atom, Abc_Obj_t* atom_bb) { } Abc_Obj_t* AigBitblaster::getBBAtom(TNode atom) const { - Assert (hasBBAtom(atom)); + Assert(hasBBAtom(atom)); return d_bbAtoms.find(atom)->second; } diff --git a/src/theory/bv/bitblast/bitblast_strategies_template.h b/src/theory/bv/bitblast/bitblast_strategies_template.h index 9e668e258..047396506 100644 --- a/src/theory/bv/bitblast/bitblast_strategies_template.h +++ b/src/theory/bv/bitblast/bitblast_strategies_template.h @@ -50,7 +50,7 @@ T UndefinedAtomBBStrategy(TNode node, TBitblaster* bb) { template T DefaultEqBB(TNode node, TBitblaster* bb) { Debug("bitvector-bb") << "Bitblasting node " << node << "\n"; - + Assert(node.getKind() == kind::EQUAL); std::vector lhs, rhs; bb->bbTerm(node[0], lhs); @@ -75,7 +75,7 @@ T AdderUltBB(TNode node, TBitblaster* bb) { bb->bbTerm(node[0], a); bb->bbTerm(node[1], b); Assert(a.size() == b.size()); - + // a < b <=> ~ (add(a, ~b, 1).carry_out) std::vector not_b; negateBits(b, not_b); @@ -98,7 +98,7 @@ T DefaultUltBB(TNode node, TBitblaster* bb) { bb->bbTerm(node[0], a); bb->bbTerm(node[1], b); Assert(a.size() == b.size()); - + // construct bitwise comparison T res = uLessThanBB(a, b, false); return res; @@ -139,7 +139,7 @@ T DefaultSltBB(TNode node, TBitblaster* bb){ bb->bbTerm(node[0], a); bb->bbTerm(node[1], b); Assert(a.size() == b.size()); - + T res = sLessThanBB(a, b, false); return res; } @@ -152,7 +152,7 @@ T DefaultSleBB(TNode node, TBitblaster* bb){ bb->bbTerm(node[0], a); bb->bbTerm(node[1], b); Assert(a.size() == b.size()); - + T res = sLessThanBB(a, b, true); return res; } @@ -204,13 +204,13 @@ void DefaultConstBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultConstBB bitblasting " << node << "\n"; Assert(node.getKind() == kind::CONST_BITVECTOR); Assert(bits.size() == 0); - + for (unsigned i = 0; i < utils::getSize(node); ++i) { Integer bit = node.getConst().extract(i, i).getValue(); if(bit == Integer(0)){ bits.push_back(mkFalse()); } else { - Assert (bit == Integer(1)); + Assert(bit == Integer(1)); bits.push_back(mkTrue()); } } @@ -234,8 +234,8 @@ template void DefaultConcatBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultConcatBB bitblasting " << node << "\n"; Assert(bits.size() == 0); - - Assert (node.getKind() == kind::BITVECTOR_CONCAT); + + Assert(node.getKind() == kind::BITVECTOR_CONCAT); for (int i = node.getNumChildren() -1 ; i >= 0; --i ) { TNode current = node[i]; std::vector current_bits; @@ -245,7 +245,7 @@ void DefaultConcatBB (TNode node, std::vector& bits, TBitblaster* bb) { bits.push_back(current_bits[j]); } } - Assert (bits.size() == utils::getSize(node)); + Assert(bits.size() == utils::getSize(node)); if(Debug.isOn("bitvector-bb")) { Debug("bitvector-bb") << "with bits: " << toString(bits) << "\n"; } @@ -254,9 +254,8 @@ void DefaultConcatBB (TNode node, std::vector& bits, TBitblaster* bb) { template void DefaultAndBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultAndBB bitblasting " << node << "\n"; - - Assert(node.getKind() == kind::BITVECTOR_AND && - bits.size() == 0); + + Assert(node.getKind() == kind::BITVECTOR_AND && bits.size() == 0); bb->bbTerm(node[0], bits); std::vector current; @@ -267,15 +266,14 @@ void DefaultAndBB (TNode node, std::vector& bits, TBitblaster* bb) { } current.clear(); } - Assert (bits.size() == utils::getSize(node)); + Assert(bits.size() == utils::getSize(node)); } template void DefaultOrBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultOrBB bitblasting " << node << "\n"; - Assert(node.getKind() == kind::BITVECTOR_OR && - bits.size() == 0); + Assert(node.getKind() == kind::BITVECTOR_OR && bits.size() == 0); bb->bbTerm(node[0], bits); std::vector current; @@ -286,15 +284,14 @@ void DefaultOrBB (TNode node, std::vector& bits, TBitblaster* bb) { } current.clear(); } - Assert (bits.size() == utils::getSize(node)); + Assert(bits.size() == utils::getSize(node)); } template void DefaultXorBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultXorBB bitblasting " << node << "\n"; - Assert(node.getKind() == kind::BITVECTOR_XOR && - bits.size() == 0); + Assert(node.getKind() == kind::BITVECTOR_XOR && bits.size() == 0); bb->bbTerm(node[0], bits); std::vector current; @@ -305,21 +302,20 @@ void DefaultXorBB (TNode node, std::vector& bits, TBitblaster* bb) { } current.clear(); } - Assert (bits.size() == utils::getSize(node)); + Assert(bits.size() == utils::getSize(node)); } template void DefaultXnorBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultXnorBB bitblasting " << node << "\n"; - Assert(node.getNumChildren() == 2 && - node.getKind() == kind::BITVECTOR_XNOR && - bits.size() == 0); + Assert(node.getNumChildren() == 2 && node.getKind() == kind::BITVECTOR_XNOR + && bits.size() == 0); std::vector lhs, rhs; bb->bbTerm(node[0], lhs); bb->bbTerm(node[1], rhs); - Assert(lhs.size() == rhs.size()); - + Assert(lhs.size() == rhs.size()); + for (unsigned i = 0; i < lhs.size(); ++i) { bits.push_back(mkIff(lhs[i], rhs[i])); } @@ -342,7 +338,8 @@ template void DefaultCompBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector") << "theory::bv:: DefaultCompBB bitblasting "<< node << "\n"; - Assert(utils::getSize(node) == 1 && bits.size() == 0 && node.getKind() == kind::BITVECTOR_COMP); + Assert(utils::getSize(node) == 1 && bits.size() == 0 + && node.getKind() == kind::BITVECTOR_COMP); std::vector a, b; bb->bbTerm(node[0], a); bb->bbTerm(node[1], b); @@ -359,8 +356,7 @@ void DefaultCompBB (TNode node, std::vector& bits, TBitblaster* bb) { template void DefaultMultBB (TNode node, std::vector& res, TBitblaster* bb) { Debug("bitvector") << "theory::bv:: DefaultMultBB bitblasting "<< node << "\n"; - Assert(res.size() == 0 && - node.getKind() == kind::BITVECTOR_MULT); + Assert(res.size() == 0 && node.getKind() == kind::BITVECTOR_MULT); // if (node.getNumChildren() == 2) { // std::vector a; @@ -401,8 +397,7 @@ void DefaultMultBB (TNode node, std::vector& res, TBitblaster* bb) { template void DefaultPlusBB (TNode node, std::vector& res, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultPlusBB bitblasting " << node << "\n"; - Assert(node.getKind() == kind::BITVECTOR_PLUS && - res.size() == 0); + Assert(node.getKind() == kind::BITVECTOR_PLUS && res.size() == 0); bb->bbTerm(node[0], res); @@ -415,7 +410,7 @@ void DefaultPlusBB (TNode node, std::vector& res, TBitblaster* bb) { rippleCarryAdder(res, current, newres, mkFalse()); res = newres; } - + Assert(res.size() == utils::getSize(node)); } @@ -423,13 +418,12 @@ void DefaultPlusBB (TNode node, std::vector& res, TBitblaster* bb) { template void DefaultSubBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultSubBB bitblasting " << node << "\n"; - Assert(node.getKind() == kind::BITVECTOR_SUB && - node.getNumChildren() == 2 && - bits.size() == 0); - + Assert(node.getKind() == kind::BITVECTOR_SUB && node.getNumChildren() == 2 + && bits.size() == 0); + std::vector a, b; bb->bbTerm(node[0], a); - bb->bbTerm(node[1], b); + bb->bbTerm(node[1], b); Assert(a.size() == b.size() && utils::getSize(node) == a.size()); // bvsub a b = adder(a, ~b, 1) @@ -442,7 +436,7 @@ template void DefaultNegBB (TNode node, std::vector& bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultNegBB bitblasting " << node << "\n"; Assert(node.getKind() == kind::BITVECTOR_NEG); - + std::vector a; bb->bbTerm(node[0], a); Assert(utils::getSize(node) == a.size()); @@ -458,7 +452,7 @@ void DefaultNegBB (TNode node, std::vector& bits, TBitblaster* bb) { template void uDivModRec(const std::vector& a, const std::vector& b, std::vector& q, std::vector& r, unsigned rec_width) { - Assert( q.size() == 0 && r.size() == 0); + Assert(q.size() == 0 && r.size() == 0); if(rec_width == 0 || isZero(a)) { makeZero(q, a.size()); @@ -788,7 +782,7 @@ void DefaultUltbvBB (TNode node, std::vector& res, TBitblaster* bb) { bb->bbTerm(node[0], a); bb->bbTerm(node[1], b); Assert(a.size() == b.size()); - + // construct bitwise comparison res.push_back(uLessThanBB(a, b, false)); } @@ -801,7 +795,7 @@ void DefaultSltbvBB (TNode node, std::vector& res, TBitblaster* bb) { bb->bbTerm(node[0], a); bb->bbTerm(node[1], b); Assert(a.size() == b.size()); - + // construct bitwise comparison res.push_back(sLessThanBB(a, b, false)); } @@ -814,7 +808,7 @@ void DefaultIteBB (TNode node, std::vector& res, TBitblaster* bb) { bb->bbTerm(node[0], cond); bb->bbTerm(node[1], thenpart); bb->bbTerm(node[2], elsepart); - + Assert(cond.size() == 1); Assert(thenpart.size() == elsepart.size()); @@ -826,9 +820,9 @@ void DefaultIteBB (TNode node, std::vector& res, TBitblaster* bb) { template void DefaultExtractBB (TNode node, std::vector& bits, TBitblaster* bb) { - Assert (node.getKind() == kind::BITVECTOR_EXTRACT); + Assert(node.getKind() == kind::BITVECTOR_EXTRACT); Assert(bits.size() == 0); - + std::vector base_bits; bb->bbTerm(node[0], base_bits); unsigned high = utils::getExtractHigh(node); @@ -837,7 +831,7 @@ void DefaultExtractBB (TNode node, std::vector& bits, TBitblaster* bb) { for (unsigned i = low; i <= high; ++i) { bits.push_back(base_bits[i]); } - Assert (bits.size() == high - low + 1); + Assert(bits.size() == high - low + 1); if(Debug.isOn("bitvector-bb")) { Debug("bitvector-bb") << "theory::bv::DefaultExtractBB bitblasting " << node << "\n"; @@ -868,8 +862,7 @@ template void DefaultSignExtendBB (TNode node, std::vector& res_bits, TBitblaster* bb) { Debug("bitvector-bb") << "theory::bv::DefaultSignExtendBB bitblasting " << node << "\n"; - Assert (node.getKind() == kind::BITVECTOR_SIGN_EXTEND && - res_bits.size() == 0); + Assert(node.getKind() == kind::BITVECTOR_SIGN_EXTEND && res_bits.size() == 0); std::vector bits; bb->bbTerm(node[0], bits); @@ -884,8 +877,8 @@ void DefaultSignExtendBB (TNode node, std::vector& res_bits, TBitblaster* for (unsigned i = 0 ; i < amount ; ++i ) { res_bits.push_back(sign_bit); } - - Assert (res_bits.size() == amount + bits.size()); + + Assert(res_bits.size() == amount + bits.size()); } template diff --git a/src/theory/bv/bitblast/bitblast_utils.h b/src/theory/bv/bitblast/bitblast_utils.h index f2bee22e5..03e0aa349 100644 --- a/src/theory/bv/bitblast/bitblast_utils.h +++ b/src/theory/bv/bitblast/bitblast_utils.h @@ -81,7 +81,7 @@ Node mkOr(Node a, Node b) { template <> inline Node mkOr(const std::vector& children) { - Assert (children.size()); + Assert(children.size()); if (children.size() == 1) return children[0]; return NodeManager::currentNM()->mkNode(kind::OR, children); @@ -95,7 +95,7 @@ Node mkAnd(Node a, Node b) { template <> inline Node mkAnd(const std::vector& children) { - Assert (children.size()); + Assert(children.size()); if (children.size() == 1) return children[0]; return NodeManager::currentNM()->mkNode(kind::AND, children); @@ -123,7 +123,7 @@ Node mkIte(Node cond, Node a, Node b) { template void inline extractBits(const std::vector& b, std::vector& dest, unsigned lo, unsigned hi) { - Assert ( lo < b.size() && hi < b.size() && lo <= hi); + Assert(lo < b.size() && hi < b.size() && lo <= hi); for (unsigned i = lo; i <= hi; ++i) { dest.push_back(b[i]); } @@ -168,7 +168,7 @@ void inline lshift(std::vector& bits, unsigned amount) { template void inline makeZero(std::vector& bits, unsigned width) { - Assert(bits.size() == 0); + Assert(bits.size() == 0); for(unsigned i = 0; i < width; ++i) { bits.push_back(mkFalse()); } @@ -188,7 +188,7 @@ void inline makeZero(std::vector& bits, unsigned width) { template T inline rippleCarryAdder(const std::vector&a, const std::vector& b, std::vector& res, T carry) { Assert(a.size() == b.size() && res.size() == 0); - + for (unsigned i = 0 ; i < a.size(); ++i) { T sum = mkXor(mkXor(a[i], b[i]), carry); carry = mkOr( mkAnd(a[i], b[i]), @@ -222,8 +222,8 @@ inline void shiftAddMultiplier(const std::vector&a, const std::vector&b, s template T inline uLessThanBB(const std::vector&a, const std::vector& b, bool orEqual) { - Assert (a.size() && b.size()); - + Assert(a.size() && b.size()); + T res = mkAnd(mkNot(a[0]), b[0]); if(orEqual) { @@ -240,7 +240,7 @@ T inline uLessThanBB(const std::vector&a, const std::vector& b, bool orEqu template T inline sLessThanBB(const std::vector&a, const std::vector& b, bool orEqual) { - Assert (a.size() && b.size()); + Assert(a.size() && b.size()); if (a.size() == 1) { if(orEqual) { return mkOr(mkIff(a[0], b[0]), diff --git a/src/theory/bv/bitblast/eager_bitblaster.cpp b/src/theory/bv/bitblast/eager_bitblaster.cpp index 0d3d3b483..9d43355cc 100644 --- a/src/theory/bv/bitblast/eager_bitblaster.cpp +++ b/src/theory/bv/bitblast/eager_bitblaster.cpp @@ -60,7 +60,7 @@ EagerBitblaster::EagerBitblaster(TheoryBV* theory_bv, context::Context* c) solver = prop::SatSolverFactory::createCryptoMinisat( smtStatisticsRegistry(), "EagerBitblaster"); break; - default: Unreachable("Unknown SAT solver type"); + default: Unreachable() << "Unknown SAT solver type"; } d_satSolver.reset(solver); d_cnfStream.reset( diff --git a/src/theory/bv/bitblast/lazy_bitblaster.cpp b/src/theory/bv/bitblast/lazy_bitblaster.cpp index 845fd399e..2018590f7 100644 --- a/src/theory/bv/bitblast/lazy_bitblaster.cpp +++ b/src/theory/bv/bitblast/lazy_bitblaster.cpp @@ -232,7 +232,7 @@ void TLazyBitblaster::bbTerm(TNode node, Bits& bits) { getBBTerm(node, bits); return; } - Assert( node.getType().isBitVector() ); + Assert(node.getType().isBitVector()); d_bv->spendResource(options::bitblastStep()); Debug("bitvector-bitblast") << "Bitblasting term " << node <<"\n"; @@ -240,7 +240,7 @@ void TLazyBitblaster::bbTerm(TNode node, Bits& bits) { d_termBBStrategies[node.getKind()] (node, bits,this); - Assert (bits.size() == utils::getSize(node)); + Assert(bits.size() == utils::getSize(node)); storeBBTerm(node, bits); } @@ -257,7 +257,7 @@ void TLazyBitblaster::explain(TNode atom, std::vector& explanation) { ++(d_statistics.d_numExplainedPropagations); if (options::bvEagerExplanations()) { - Assert (d_explanations->find(lit) != d_explanations->end()); + Assert(d_explanations->find(lit) != d_explanations->end()); const std::vector& literal_explanation = (*d_explanations)[lit].get(); for (unsigned i = 0; i < literal_explanation.size(); ++i) { explanation.push_back(d_cnfStream->getNode(literal_explanation[i])); @@ -292,9 +292,9 @@ bool TLazyBitblaster::assertToSat(TNode lit, bool propagate) { } else { atom = lit; } - Assert( utils::isBitblastAtom( atom ) ); + Assert(utils::isBitblastAtom(atom)); - Assert (hasBBAtom(atom)); + Assert(hasBBAtom(atom)); prop::SatLiteral markerLit = d_cnfStream->getLiteral(atom); @@ -483,7 +483,7 @@ bool TLazyBitblaster::isSharedTerm(TNode node) { } bool TLazyBitblaster::hasValue(TNode a) { - Assert (hasBBTerm(a)); + Assert(hasBBTerm(a)); Bits bits; getBBTerm(a, bits); for (int i = bits.size() -1; i >= 0; --i) { @@ -522,7 +522,7 @@ Node TLazyBitblaster::getModelFromSatSolver(TNode a, bool fullModel) { if (d_cnfStream->hasLiteral(bits[i])) { prop::SatLiteral bit = d_cnfStream->getLiteral(bits[i]); bit_value = d_satSolver->value(bit); - Assert (bit_value != prop::SAT_VALUE_UNKNOWN); + Assert(bit_value != prop::SAT_VALUE_UNKNOWN); } else { if (!fullModel) return Node(); // unconstrained bits default to false @@ -545,12 +545,12 @@ bool TLazyBitblaster::collectModelInfo(TheoryModel* m, bool fullModel) if (d_variables.find(var) == d_variables.end()) continue; - Assert (Theory::theoryOf(var) == theory::THEORY_BV || isSharedTerm(var)); + Assert(Theory::theoryOf(var) == theory::THEORY_BV || isSharedTerm(var)); // only shared terms could not have been bit-blasted - Assert (hasBBTerm(var) || isSharedTerm(var)); + Assert(hasBBTerm(var) || isSharedTerm(var)); Node const_value = getModelFromSatSolver(var, true); - Assert (const_value.isNull() || const_value.isConst()); + Assert(const_value.isNull() || const_value.isConst()); if(const_value != Node()) { Debug("bitvector-model") << "TLazyBitblaster::collectModelInfo (assert (= " << var << " " @@ -565,7 +565,7 @@ bool TLazyBitblaster::collectModelInfo(TheoryModel* m, bool fullModel) } void TLazyBitblaster::clearSolver() { - Assert (d_ctx->getLevel() == 0); + Assert(d_ctx->getLevel() == 0); d_assertedAtoms->deleteSelf(); d_assertedAtoms = new(true) context::CDList(d_ctx); d_explanations->deleteSelf(); diff --git a/src/theory/bv/bv_inequality_graph.cpp b/src/theory/bv/bv_inequality_graph.cpp index 89d5e1883..ed8756456 100644 --- a/src/theory/bv/bv_inequality_graph.cpp +++ b/src/theory/bv/bv_inequality_graph.cpp @@ -36,7 +36,7 @@ bool InequalityGraph::addInequality(TNode a, TNode b, bool strict, TNode reason) TermId id_b = registerTerm(b); ReasonId id_reason = registerReason(reason); - Assert (!(isConst(id_a) && isConst(id_b))); + Assert(!(isConst(id_a) && isConst(id_b))); BitVector a_val = getValue(id_a); BitVector b_val = getValue(id_b); @@ -73,7 +73,7 @@ bool InequalityGraph::addInequality(TNode a, TNode b, bool strict, TNode reason) // add the inequality edge addEdge(id_a, id_b, strict, id_reason); BFSQueue queue(&d_modelValues); - Assert (hasModelValue(id_a)); + Assert(hasModelValue(id_a)); queue.push(id_a); return processQueue(queue, id_a); } @@ -141,7 +141,7 @@ bool InequalityGraph::processQueue(BFSQueue& queue, TermId start) { // it means we have an overflow and hence a conflict std::vector conflict; conflict.push_back(it->reason); - Assert (hasModelValue(start)); + Assert(hasModelValue(start)); ReasonId start_reason = getModelValue(start).reason; if (start_reason != UndefinedReasonId) { conflict.push_back(start_reason); @@ -193,9 +193,9 @@ void InequalityGraph::computeExplanation(TermId from, TermId to, std::vector() : BitVector(size, 0u); @@ -248,10 +248,10 @@ TermId InequalityGraph::registerTerm(TNode term) { bool isConst = term.getKind() == kind::CONST_BITVECTOR; InequalityNode ineq = InequalityNode(id, size, isConst); - Assert (d_ineqNodes.size() == id); + Assert(d_ineqNodes.size() == id); d_ineqNodes.push_back(ineq); - - Assert (d_ineqEdges.size() == id); + + Assert(d_ineqEdges.size() == id); d_ineqEdges.push_back(Edges()); initializeModelValue(term); @@ -272,22 +272,22 @@ ReasonId InequalityGraph::registerReason(TNode reason) { } TNode InequalityGraph::getReasonNode(ReasonId id) const { - Assert (d_reasonNodes.size() > id); + Assert(d_reasonNodes.size() > id); return d_reasonNodes[id]; } TNode InequalityGraph::getTermNode(TermId id) const { - Assert (d_termNodes.size() > id); + Assert(d_termNodes.size() > id); return d_termNodes[id]; } TermId InequalityGraph::getTermId(TNode node) const { - Assert (d_termNodeToIdMap.find(node) != d_termNodeToIdMap.end()); + Assert(d_termNodeToIdMap.find(node) != d_termNodeToIdMap.end()); return d_termNodeToIdMap.find(node)->second; } void InequalityGraph::setConflict(const std::vector& conflict) { - Assert (!d_inConflict); + Assert(!d_inConflict); d_inConflict = true; d_conflict.clear(); for (unsigned i = 0; i < conflict.size(); ++i) { @@ -314,7 +314,7 @@ void InequalityGraph::setModelValue(TermId term, const ModelValue& mv) { } InequalityGraph::ModelValue InequalityGraph::getModelValue(TermId term) const { - Assert (d_modelValues.find(term) != d_modelValues.end()); + Assert(d_modelValues.find(term) != d_modelValues.end()); return (*(d_modelValues.find(term))).second; } @@ -323,7 +323,7 @@ bool InequalityGraph::hasModelValue(TermId id) const { } BitVector InequalityGraph::getValue(TermId id) const { - Assert (hasModelValue(id)); + Assert(hasModelValue(id)); return (*(d_modelValues.find(id))).second.value; } @@ -387,10 +387,12 @@ bool InequalityGraph::addDisequality(TNode a, TNode b, TNode reason) { } // void InequalityGraph::splitDisequality(TNode diseq) { -// Debug("bv-inequality-internal")<<"InequalityGraph::splitDisequality " << diseq <<"\n"; -// Assert (diseq.getKind() == kind::NOT && diseq[0].getKind() == kind::EQUAL); -// if (d_disequalitiesAlreadySplit.find(diseq) == d_disequalitiesAlreadySplit.end()) { -// d_disequalitiesToSplit.push_back(diseq); +// Debug("bv-inequality-internal")<<"InequalityGraph::splitDisequality " << +// diseq <<"\n"; Assert (diseq.getKind() == kind::NOT && +// diseq[0].getKind() == kind::EQUAL); if +// (d_disequalitiesAlreadySplit.find(diseq) == +// d_disequalitiesAlreadySplit.end()) { +// d_disequalitiesToSplit.push_back(diseq); // } // } @@ -398,7 +400,7 @@ void InequalityGraph::backtrack() { Debug("bv-inequality-internal") << "InequalityGraph::backtrack()\n"; int size = d_undoStack.size(); for (int i = size - 1; i >= (int)d_undoStackIndex.get(); --i) { - Assert (!d_undoStack.empty()); + Assert(!d_undoStack.empty()); TermId id = d_undoStack.back().first; InequalityEdge edge = d_undoStack.back().second; d_undoStack.pop_back(); @@ -409,8 +411,8 @@ void InequalityGraph::backtrack() { for (Edges::const_iterator it = edges.begin(); it!= edges.end(); ++it) { Debug("bv-inequality-internal") << getTermNode(it->next) <<" " << it->strict << "\n"; } - Assert (!edges.empty()); - Assert (edges.back() == edge); + Assert(!edges.empty()); + Assert(edges.back() == edge); edges.pop_back(); } } @@ -444,7 +446,7 @@ void InequalityGraph::checkDisequalities(std::vector& lemmas) { } bool InequalityGraph::isLessThan(TNode a, TNode b) { - Assert (isRegistered(a) && isRegistered(b)); + Assert(isRegistered(a) && isRegistered(b)); Unimplemented(); } @@ -457,8 +459,8 @@ bool InequalityGraph::hasValueInModel(TNode node) const { } BitVector InequalityGraph::getValueInModel(TNode node) const { - TermId id = getTermId(node); - Assert (hasModelValue(id)); + TermId id = getTermId(node); + Assert(hasModelValue(id)); return getValue(id); } diff --git a/src/theory/bv/bv_inequality_graph.h b/src/theory/bv/bv_inequality_graph.h index 07facf4af..9e8078a72 100644 --- a/src/theory/bv/bv_inequality_graph.h +++ b/src/theory/bv/bv_inequality_graph.h @@ -95,9 +95,9 @@ class InequalityGraph : public context::ContextNotifyObj{ : d_model(model) {} bool operator() (TermId left, TermId right) const { - Assert (d_model->find(left) != d_model->end() && - d_model->find(right) != d_model->end()); - + Assert(d_model->find(left) != d_model->end() + && d_model->find(right) != d_model->end()); + return (*(d_model->find(left))).second.value < (*(d_model->find(right))).second.value; } }; @@ -148,11 +148,22 @@ class InequalityGraph : public context::ContextNotifyObj{ ReasonId registerReason(TNode reason); TNode getReasonNode(ReasonId id) const; - - - Edges& getEdges(TermId id) { Assert (id < d_ineqEdges.size()); return d_ineqEdges[id]; } - InequalityNode& getInequalityNode(TermId id) { Assert (id < d_ineqNodes.size()); return d_ineqNodes[id]; } - const InequalityNode& getInequalityNode(TermId id) const { Assert (id < d_ineqNodes.size()); return d_ineqNodes[id]; } + + Edges& getEdges(TermId id) + { + Assert(id < d_ineqEdges.size()); + return d_ineqEdges[id]; + } + InequalityNode& getInequalityNode(TermId id) + { + Assert(id < d_ineqNodes.size()); + return d_ineqNodes[id]; + } + const InequalityNode& getInequalityNode(TermId id) const + { + Assert(id < d_ineqNodes.size()); + return d_ineqNodes[id]; + } unsigned getBitwidth(TermId id) const { return getInequalityNode(id).getBitwidth(); } bool isConst(TermId id) const { return getInequalityNode(id).isConstant(); } diff --git a/src/theory/bv/bv_quick_check.cpp b/src/theory/bv/bv_quick_check.cpp index 0183dd6e7..dbdeccfe5 100644 --- a/src/theory/bv/bv_quick_check.cpp +++ b/src/theory/bv/bv_quick_check.cpp @@ -55,7 +55,7 @@ prop::SatValue BVQuickCheck::checkSat(std::vector& assumptions, unsigned l for (unsigned i = 0; i < assumptions.size(); ++i) { TNode a = assumptions[i]; - Assert (a.getType().isBoolean()); + Assert(a.getType().isBoolean()); d_bitblaster->bbAtom(a); bool ok = d_bitblaster->assertToSat(a, false); if (!ok) { @@ -91,7 +91,7 @@ prop::SatValue BVQuickCheck::checkSat(unsigned long budget) { } bool BVQuickCheck::addAssertion(TNode assertion) { - Assert (assertion.getType().isBoolean()); + Assert(assertion.getType().isBoolean()); d_bitblaster->bbAtom(assertion); // assert to sat solver and run bcp to detect easy conflicts bool ok = d_bitblaster->assertToSat(assertion, true); @@ -162,9 +162,7 @@ QuickXPlain::~QuickXPlain() {} unsigned QuickXPlain::selectUnsatCore(unsigned low, unsigned high, std::vector& conflict) { - - Assert(!d_solver->getConflict().isNull() && - d_solver->inConflict()); + Assert(!d_solver->getConflict().isNull() && d_solver->inConflict()); Node query_confl = d_solver->getConflict(); // conflict wasn't actually minimized @@ -190,24 +188,23 @@ unsigned QuickXPlain::selectUnsatCore(unsigned low, unsigned high, if (write == low) { return low; } - Assert (write != 0); + Assert(write != 0); unsigned new_high = write - 1; for (TNodeSet::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { conflict[write++] = *it; } - Assert (write -1 == high); - Assert (new_high <= high); - + Assert(write - 1 == high); + Assert(new_high <= high); + return new_high; } void QuickXPlain::minimizeConflictInternal(unsigned low, unsigned high, std::vector& conflict, std::vector& new_conflict) { + Assert(low <= high && high < conflict.size()); - Assert (low <= high && high < conflict.size()); - if (low == high) { new_conflict.push_back(conflict[low]); return; @@ -323,7 +320,7 @@ Node QuickXPlain::minimizeConflict(TNode confl) { ++d_numCalled; ++(d_statistics.d_numConflictsMinimized); TimerStat::CodeTimer xplainTimer(d_statistics.d_xplainTime); - Assert (confl.getNumChildren() > 2); + Assert(confl.getNumChildren() > 2); std::vector conflict; for (unsigned i = 0; i < confl.getNumChildren(); ++i) { conflict.push_back(confl[i]); diff --git a/src/theory/bv/bv_subtheory_algebraic.cpp b/src/theory/bv/bv_subtheory_algebraic.cpp index 1f4aef42d..6f8804042 100644 --- a/src/theory/bv/bv_subtheory_algebraic.cpp +++ b/src/theory/bv/bv_subtheory_algebraic.cpp @@ -83,7 +83,7 @@ SubstitutionEx::SubstitutionEx(theory::SubstitutionMap* modelMap) bool SubstitutionEx::addSubstitution(TNode from, TNode to, TNode reason) { Debug("bv-substitution") << "SubstitutionEx::addSubstitution: "<< from <<" => "<< to << "\n" << " reason "<second.to; } void SubstitutionEx::storeCache(TNode from, TNode to, Node reason) { // Debug("bv-substitution") << "SubstitutionEx::storeCache(" << from <<", " << to <<", "<< reason<<")\n"; - Assert (!hasCache(from)); + Assert(!hasCache(from)); d_cache[from] = SubstitutionElement(to, reason); } @@ -284,7 +284,7 @@ bool AlgebraicSolver::check(Theory::Effort e) storeExplanation(assertion); uint64_t assertion_size = d_quickSolver->computeAtomWeight(assertion, seen_assertions); - Assert (original_bb_cost <= original_bb_cost + assertion_size); + Assert(original_bb_cost <= original_bb_cost + assertion_size); original_bb_cost+= assertion_size; } @@ -294,7 +294,7 @@ bool AlgebraicSolver::check(Theory::Effort e) Debug("bv-subtheory-algebraic") << "Assertions " << worklist.size() <<" : \n"; - Assert (d_explanations.size() == worklist.size()); + Assert(d_explanations.size() == worklist.size()); d_modelMap.reset(new SubstitutionMap(d_context)); SubstitutionEx subst(d_modelMap.get()); @@ -424,8 +424,8 @@ bool AlgebraicSolver::quickCheck(std::vector& facts) { return true; } - Assert (res == SAT_VALUE_FALSE); - Assert (d_quickSolver->inConflict()); + Assert(res == SAT_VALUE_FALSE); + Assert(d_quickSolver->inConflict()); d_isComplete.set(true); Debug("bv-subtheory-algebraic") << " Unsat.\n"; ++(d_numSolved); @@ -437,15 +437,15 @@ bool AlgebraicSolver::quickCheck(std::vector& facts) { // singleton conflict if (conflict.getKind() != kind::AND) { - Assert (d_ids.find(conflict) != d_ids.end()); + Assert(d_ids.find(conflict) != d_ids.end()); unsigned id = d_ids[conflict]; - Assert (id < d_explanations.size()); + Assert(id < d_explanations.size()); Node theory_confl = d_explanations[id]; d_bv->setConflict(theory_confl); return false; } - Assert (conflict.getKind() == kind::AND); + Assert(conflict.getKind() == kind::AND); if (options::bitvectorQuickXplain()) { d_quickSolver->popToZero(); Debug("bv-quick-xplain") << "AlgebraicSolver::quickCheck original conflict size " << conflict.getNumChildren() << "\n"; @@ -457,9 +457,9 @@ bool AlgebraicSolver::quickCheck(std::vector& facts) { for (unsigned i = 0; i < conflict.getNumChildren(); ++i) { TNode c = conflict[i]; - Assert (d_ids.find(c) != d_ids.end()); + Assert(d_ids.find(c) != d_ids.end()); unsigned c_id = d_ids[c]; - Assert (c_id < d_explanations.size()); + Assert(c_id < d_explanations.size()); TNode c_expl = d_explanations[c_id]; theory_confl.push_back(c_expl); } @@ -514,7 +514,7 @@ bool AlgebraicSolver::solve(TNode fact, TNode reason, SubstitutionEx& subst) { if (right[i] != var) right_children.push_back(right[i]); } - Assert (right_children.size()); + Assert(right_children.size()); Node new_right = utils::mkNaryNode(kind::BITVECTOR_XOR, right_children); std::vector left_children; for (unsigned i = 1; i < left.getNumChildren(); ++i) { @@ -656,17 +656,17 @@ void AlgebraicSolver::processAssertions(std::vector& worklist, worklist[i] = WorklistElement(utils::mkTrue(), worklist[i].id); changed = true; } - Assert (d_explanations.size() == worklist.size()); + Assert(d_explanations.size() == worklist.size()); } } void AlgebraicSolver::storeExplanation(unsigned id, TNode explanation) { - Assert (checkExplanation(explanation)); + Assert(checkExplanation(explanation)); d_explanations[id] = explanation; } void AlgebraicSolver::storeExplanation(TNode explanation) { - Assert (checkExplanation(explanation)); + Assert(checkExplanation(explanation)); d_explanations.push_back(explanation); } @@ -713,7 +713,7 @@ EqualityStatus AlgebraicSolver::getEqualityStatus(TNode a, TNode b) { bool AlgebraicSolver::collectModelInfo(TheoryModel* model, bool fullModel) { Debug("bitvector-model") << "AlgebraicSolver::collectModelInfo\n"; - AlwaysAssert (!d_quickSolver->inConflict()); + AlwaysAssert(!d_quickSolver->inConflict()); set termSet; d_bv->computeRelevantTerms(termSet); @@ -746,13 +746,13 @@ bool AlgebraicSolver::collectModelInfo(TheoryModel* model, bool fullModel) for (NodeSet::const_iterator it = leaf_vars.begin(); it != leaf_vars.end(); ++it) { TNode var = *it; Node value = d_quickSolver->getVarValue(var, true); - Assert (!value.isNull() || !fullModel); + Assert(!value.isNull() || !fullModel); // may be a shared term that did not appear in the current assertions // AJR: need to check whether already in map for cases where collectModelInfo is called multiple times in the same context if (!value.isNull() && !d_modelMap->hasSubstitution(var)) { Debug("bitvector-model") << " " << var << " => " << value << "\n"; - Assert (value.getKind() == kind::CONST_BITVECTOR); + Assert(value.getKind() == kind::CONST_BITVECTOR); d_modelMap->addSubstitution(var, value); } } @@ -763,7 +763,7 @@ bool AlgebraicSolver::collectModelInfo(TheoryModel* model, bool fullModel) TNode subst = Rewriter::rewrite(d_modelMap->apply(current)); Debug("bitvector-model") << "AlgebraicSolver: " << variables[i] << " => " << subst << "\n"; // Doesn't have to be constant as it may be irrelevant - Assert (subst.getKind() == kind::CONST_BITVECTOR); + Assert(subst.getKind() == kind::CONST_BITVECTOR); if (!model->assertEquality(variables[i], subst, true)) { return false; @@ -860,16 +860,16 @@ void ExtractSkolemizer::skolemize(std::vector& facts) { std::vector skolems; for (unsigned i = 0; i < cuts.size(); ++i) { current = cuts[i]; - Assert (current > 0); + Assert(current > 0); int size = current - previous; - Assert (size > 0); + Assert(size > 0); Node sk = utils::mkVar(size); skolems.push_back(sk); previous = current; } if (current < bw -1) { int size = bw - current; - Assert (size > 0); + Assert(size > 0); Node sk = utils::mkVar(size); skolems.push_back(sk); } @@ -880,7 +880,7 @@ void ExtractSkolemizer::skolemize(std::vector& facts) { } Node skolem_concat = skolems.size() == 1 ? (Node)skolems[0] : (Node) skolem_nb; - Assert (utils::getSize(skolem_concat) == utils::getSize(var)); + Assert(utils::getSize(skolem_concat) == utils::getSize(var)); storeSkolem(var, skolem_concat); for (unsigned i = 0; i < el.extracts.size(); ++i) { @@ -888,8 +888,8 @@ void ExtractSkolemizer::skolemize(std::vector& facts) { unsigned l = el.extracts[i].low; Node extract = utils::mkExtract(var, h, l); Node skolem_extract = Rewriter::rewrite(utils::mkExtract(skolem_concat, h, l)); - Assert (skolem_extract.getMetaKind() == kind::metakind::VARIABLE || - skolem_extract.getKind() == kind::BITVECTOR_CONCAT); + Assert(skolem_extract.getMetaKind() == kind::metakind::VARIABLE + || skolem_extract.getKind() == kind::BITVECTOR_CONCAT); storeSkolem(extract, skolem_extract); } } @@ -900,9 +900,9 @@ void ExtractSkolemizer::skolemize(std::vector& facts) { } Node ExtractSkolemizer::mkSkolem(Node node) { - Assert (node.getKind() == kind::BITVECTOR_EXTRACT && - node[0].getMetaKind() == kind::metakind::VARIABLE); - Assert (!d_skolemSubst.hasSubstitution(node)); + Assert(node.getKind() == kind::BITVECTOR_EXTRACT + && node[0].getMetaKind() == kind::metakind::VARIABLE); + Assert(!d_skolemSubst.hasSubstitution(node)); return utils::mkVar(utils::getSize(node)); } @@ -933,7 +933,7 @@ void ExtractSkolemizer::ExtractList::addExtract(Extract& e) { } void ExtractSkolemizer::storeExtract(TNode var, unsigned high, unsigned low) { - Assert (var.getMetaKind() == kind::metakind::VARIABLE); + Assert(var.getMetaKind() == kind::metakind::VARIABLE); if (d_varToExtract.find(var) == d_varToExtract.end()) { d_varToExtract[var] = ExtractList(utils::getSize(var)); } @@ -982,7 +982,7 @@ Node mergeExplanations(const std::vector& expls) { TNodeSet literals; for (unsigned i = 0; i < expls.size(); ++i) { TNode expl = expls[i]; - Assert (expl.getType().isBoolean()); + Assert(expl.getType().isBoolean()); if (expl.getKind() == kind::AND) { for (unsigned i = 0; i < expl.getNumChildren(); ++i) { TNode child = expl[i]; diff --git a/src/theory/bv/bv_subtheory_algebraic.h b/src/theory/bv/bv_subtheory_algebraic.h index 7f38b1563..de75ad859 100644 --- a/src/theory/bv/bv_subtheory_algebraic.h +++ b/src/theory/bv/bv_subtheory_algebraic.h @@ -228,7 +228,7 @@ public: bool check(Theory::Effort e) override; void explain(TNode literal, std::vector& assumptions) override { - Unreachable("AlgebraicSolver does not propagate.\n"); + Unreachable() << "AlgebraicSolver does not propagate.\n"; } EqualityStatus getEqualityStatus(TNode a, TNode b) override; bool collectModelInfo(TheoryModel* m, bool fullModel) override; diff --git a/src/theory/bv/bv_subtheory_core.cpp b/src/theory/bv/bv_subtheory_core.cpp index f809c38c0..bf9bfa480 100644 --- a/src/theory/bv/bv_subtheory_core.cpp +++ b/src/theory/bv/bv_subtheory_core.cpp @@ -86,7 +86,7 @@ void CoreSolver::setMasterEqualityEngine(eq::EqualityEngine* eq) { } void CoreSolver::enableSlicer() { - AlwaysAssert (!d_preregisterCalled); + AlwaysAssert(!d_preregisterCalled); d_useSlicer = true; d_statistics.d_slicerEnabled.setData(true); } @@ -97,7 +97,7 @@ void CoreSolver::preRegister(TNode node) { d_equalityEngine.addTriggerEquality(node); if (d_useSlicer) { d_slicer->processEquality(node); - AlwaysAssert(!d_checkCalled); + AlwaysAssert(!d_checkCalled); } } else { d_equalityEngine.addTerm(node); @@ -137,8 +137,8 @@ bool CoreSolver::decomposeFact(TNode fact) { Node new_a = getBaseDecomposition(a); Node new_b = getBaseDecomposition(b); - Assert (utils::getSize(new_a) == utils::getSize(new_b) && - utils::getSize(new_a) == utils::getSize(a)); + Assert(utils::getSize(new_a) == utils::getSize(new_b) + && utils::getSize(new_a) == utils::getSize(a)); NodeManager* nm = NodeManager::currentNM(); Node a_eq_new_a = nm->mkNode(kind::EQUAL, a, new_a); @@ -157,8 +157,7 @@ bool CoreSolver::decomposeFact(TNode fact) { // a_i == b_i if (new_a.getKind() == kind::BITVECTOR_CONCAT && new_b.getKind() == kind::BITVECTOR_CONCAT) { - - Assert (new_a.getNumChildren() == new_b.getNumChildren()); + Assert(new_a.getNumChildren() == new_b.getNumChildren()); for (unsigned i = 0; i < new_a.getNumChildren(); ++i) { Node eq_i = nm->mkNode(kind::EQUAL, new_a[i], new_b[i]); ok = assertFactToEqualityEngine(eq_i, fact); @@ -174,8 +173,8 @@ bool CoreSolver::check(Theory::Effort e) { d_bv->spendResource(options::theoryCheckStep()); - d_checkCalled = true; - Assert (!d_bv->inConflict()); + d_checkCalled = true; + Assert(!d_bv->inConflict()); ++(d_statistics.d_numCallstoCheck); bool ok = true; std::vector core_eqs; @@ -413,7 +412,7 @@ void CoreSolver::conflict(TNode a, TNode b) { } void CoreSolver::eqNotifyNewClass(TNode t) { - Assert( d_bv->getExtTheory()!=NULL ); + Assert(d_bv->getExtTheory() != NULL); d_bv->getExtTheory()->registerTerm( t ); } @@ -460,7 +459,7 @@ bool CoreSolver::collectModelInfo(TheoryModel* m, bool fullModel) Node CoreSolver::getModelValue(TNode var) { Debug("bitvector-model") << "CoreSolver::getModelValue (" << var <<")"; - Assert (isComplete()); + Assert(isComplete()); TNode repr = d_equalityEngine.getRepresentative(var); Node result = Node(); if (repr.getKind() == kind::CONST_BITVECTOR) { diff --git a/src/theory/bv/bv_subtheory_inequality.cpp b/src/theory/bv/bv_subtheory_inequality.cpp index b527eada4..332f96aa2 100644 --- a/src/theory/bv/bv_subtheory_inequality.cpp +++ b/src/theory/bv/bv_subtheory_inequality.cpp @@ -182,22 +182,20 @@ bool InequalitySolver::isInequalityOnly(TNode node) { } void InequalitySolver::explain(TNode literal, std::vector& assumptions) { - Assert (d_explanations.find(literal) != d_explanations.end()); + Assert(d_explanations.find(literal) != d_explanations.end()); TNode explanation = d_explanations[literal]; assumptions.push_back(explanation); Debug("bv-inequality-explain") << "InequalitySolver::explain " << literal << " with " << explanation <<"\n"; } -void InequalitySolver::propagate(Theory::Effort e) { - Assert (false); -} +void InequalitySolver::propagate(Theory::Effort e) { Assert(false); } bool InequalitySolver::collectModelInfo(TheoryModel* m, bool fullModel) { Debug("bitvector-model") << "InequalitySolver::collectModelInfo \n"; std::vector model; d_inequalityGraph.getAllValuesInModel(model); for (unsigned i = 0; i < model.size(); ++i) { - Assert (model[i].getKind() == kind::EQUAL); + Assert(model[i].getKind() == kind::EQUAL); if (!m->assertEquality(model[i][0], model[i][1], true)) { return false; @@ -207,12 +205,12 @@ bool InequalitySolver::collectModelInfo(TheoryModel* m, bool fullModel) } Node InequalitySolver::getModelValue(TNode var) { - Assert (isInequalityOnly(var)); + Assert(isInequalityOnly(var)); Debug("bitvector-model") << "InequalitySolver::getModelValue (" << var <<")"; - Assert (isComplete()); + Assert(isComplete()); Node result = Node(); if (!d_inequalityGraph.hasValueInModel(var)) { - Assert (d_bv->isSharedTerm(var)); + Assert(d_bv->isSharedTerm(var)); } else { BitVector val = d_inequalityGraph.getValueInModel(var); result = utils::mkConst(val); diff --git a/src/theory/bv/slicer.cpp b/src/theory/bv/slicer.cpp index e633792d8..0ffd58d5a 100644 --- a/src/theory/bv/slicer.cpp +++ b/src/theory/bv/slicer.cpp @@ -58,7 +58,7 @@ Base::Base(uint32_t size) : d_size(size), d_repr(size/32 + (size % 32 == 0? 0 : 1), 0) { - Assert (d_size > 0); + Assert(d_size > 0); } void Base::sliceAt(Index index) @@ -73,7 +73,7 @@ void Base::sliceAt(Index index) } void Base::sliceWith(const Base& other) { - Assert (d_size == other.d_size); + Assert(d_size == other.d_size); for (unsigned i = 0; i < d_repr.size(); ++i) { d_repr[i] = d_repr[i] | other.d_repr[i]; } @@ -86,7 +86,7 @@ bool Base::isCutPoint (Index index) const return true; Index vector_index = index / 32; - Assert (vector_index < d_size); + Assert(vector_index < d_size); Index int_index = index % 32; uint32_t bit_mask = 1u << int_index; @@ -94,9 +94,9 @@ bool Base::isCutPoint (Index index) const } void Base::diffCutPoints(const Base& other, Base& res) const { - Assert (d_size == other.d_size && res.d_size == d_size); + Assert(d_size == other.d_size && res.d_size == d_size); for (unsigned i = 0; i < d_repr.size(); ++i) { - Assert (res.d_repr[i] == 0); + Assert(res.d_repr[i] == 0); res.d_repr[i] = d_repr[i] ^ other.d_repr[i]; } } @@ -144,7 +144,7 @@ std::string ExtractTerm::debugPrint() const { */ std::pair NormalForm::getTerm(Index index, const UnionFind& uf) const { - Assert (index < base.getBitwidth()); + Assert(index < base.getBitwidth()); Index count = 0; for (unsigned i = 0; i < decomp.size(); ++i) { Index size = uf.getBitwidth(decomp[i]); @@ -207,17 +207,17 @@ TermId UnionFind::addTerm(Index bitwidth) { void UnionFind::unionTerms(const ExtractTerm& t1, const ExtractTerm& t2) { Debug("bv-slicer") << "UnionFind::unionTerms " << t1.debugPrint() << " and \n" << " " << t2.debugPrint() << endl; - Assert (t1.getBitwidth() == t2.getBitwidth()); - + Assert(t1.getBitwidth() == t2.getBitwidth()); + NormalForm nf1(t1.getBitwidth()); NormalForm nf2(t2.getBitwidth()); getNormalForm(t1, nf1); getNormalForm(t2, nf2); - Assert (nf1.decomp.size() == nf2.decomp.size()); - Assert (nf1.base == nf2.base); - + Assert(nf1.decomp.size() == nf2.decomp.size()); + Assert(nf1.base == nf2.base); + for (unsigned i = 0; i < nf1.decomp.size(); ++i) { merge (nf1.decomp[i], nf2.decomp[i]); } @@ -239,7 +239,7 @@ void UnionFind::merge(TermId t1, TermId t2) { if (t1 == t2) return; - Assert (! hasChildren(t1) && ! hasChildren(t2)); + Assert(!hasChildren(t1) && !hasChildren(t2)); setRepr(t1, t2); d_representatives.erase(t1); d_statistics.d_numRepresentatives += -1; @@ -271,7 +271,7 @@ void UnionFind::split(TermId id, Index i) { // nothing to do return; } - Assert (i < getBitwidth(id)); + Assert(i < getBitwidth(id)); if (!hasChildren(id)) { // first time we split this term TermId bottom_id = addTerm(i); @@ -303,13 +303,12 @@ void UnionFind::getNormalForm(const ExtractTerm& term, NormalForm& nf) { void UnionFind::getDecomposition(const ExtractTerm& term, Decomposition& decomp) { // making sure the term is aligned - TermId id = find(term.id); + TermId id = find(term.id); - Assert (term.high < getBitwidth(id)); + Assert(term.high < getBitwidth(id)); // because we split the node, this must be the whole extract if (!hasChildren(id)) { - Assert (term.high == getBitwidth(id) - 1 && - term.low == 0); + Assert(term.high == getBitwidth(id) - 1 && term.low == 0); decomp.push_back(id); return; } @@ -380,9 +379,9 @@ void UnionFind::handleCommonSlice(const Decomposition& decomp1, const Decomposit if (start2 - start1 < common_size) { Index overlap = start1 + common_size - start2; - Assert (overlap > 0); + Assert(overlap > 0); Index diff = common_size - overlap; - Assert (diff >= 0); + Assert(diff >= 0); Index granularity = gcd(diff, overlap); // split the common part for (unsigned i = 0; i < common_size; i+= granularity) { @@ -401,7 +400,7 @@ void UnionFind::alignSlicings(const ExtractTerm& term1, const ExtractTerm& term2 getNormalForm(term1, nf1); getNormalForm(term2, nf2); - Assert (nf1.base.getBitwidth() == nf2.base.getBitwidth()); + Assert(nf1.base.getBitwidth() == nf2.base.getBitwidth()); // first check if the two have any common slices std::vector intersection; @@ -480,8 +479,8 @@ ExtractTerm Slicer::registerTerm(TNode node) { void Slicer::processEquality(TNode eq) { Debug("bv-slicer") << "Slicer::processEquality: " << eq << endl; - - Assert (eq.getKind() == kind::EQUAL); + + Assert(eq.getKind() == kind::EQUAL); TNode a = eq[0]; TNode b = eq[1]; ExtractTerm a_ex= registerTerm(a); @@ -508,7 +507,7 @@ void Slicer::getBaseDecomposition(TNode node, std::vector& decomp) { low = utils::getExtractLow(node); top = node[0]; } - AlwaysAssert (d_nodeToId.find(top) != d_nodeToId.end()); + AlwaysAssert(d_nodeToId.find(top) != d_nodeToId.end()); TermId id = d_nodeToId[top]; NormalForm nf(high-low+1); d_unionFind.getNormalForm(ExtractTerm(id, high, low), nf); diff --git a/src/theory/bv/slicer.h b/src/theory/bv/slicer.h index 3ddbcaf36..88ac0debb 100644 --- a/src/theory/bv/slicer.h +++ b/src/theory/bv/slicer.h @@ -91,7 +91,7 @@ struct ExtractTerm { high(h), low(l) { - Assert (h >= l && id != UndefinedId); + Assert(h >= l && id != UndefinedId); } Index getBitwidth() const { return high - low + 1; } std::string debugPrint() const; @@ -138,15 +138,15 @@ class UnionFind { bool hasChildren() const { return d_ch1 != UndefinedId && d_ch0 != UndefinedId; } TermId getChild(Index i) const { - Assert (i < 2); + Assert(i < 2); return i == 0? d_ch0 : d_ch1; } void setRepr(TermId id) { - Assert (! hasChildren()); + Assert(!hasChildren()); d_repr = id; } void setChildren(TermId ch1, TermId ch0) { - Assert (d_repr == UndefinedId && !hasChildren()); + Assert(d_repr == UndefinedId && !hasChildren()); d_ch1 = ch1; d_ch0 = ch0; } @@ -162,27 +162,28 @@ class UnionFind { void handleCommonSlice(const Decomposition& d1, const Decomposition& d2, TermId common); /// getter methods for the internal nodes TermId getRepr(TermId id) const { - Assert (id < d_nodes.size()); + Assert(id < d_nodes.size()); return d_nodes[id].getRepr(); } TermId getChild(TermId id, Index i) const { - Assert (id < d_nodes.size()); + Assert(id < d_nodes.size()); return d_nodes[id].getChild(i); } Index getCutPoint(TermId id) const { return getBitwidth(getChild(id, 0)); } bool hasChildren(TermId id) const { - Assert (id < d_nodes.size()); + Assert(id < d_nodes.size()); return d_nodes[id].hasChildren(); } /// setter methods for the internal nodes void setRepr(TermId id, TermId new_repr) { - Assert (id < d_nodes.size()); + Assert(id < d_nodes.size()); d_nodes[id].setRepr(new_repr); } void setChildren(TermId id, TermId ch1, TermId ch0) { - Assert (id < d_nodes.size() && getBitwidth(id) == getBitwidth(ch1) + getBitwidth(ch0)); + Assert(id < d_nodes.size() + && getBitwidth(id) == getBitwidth(ch1) + getBitwidth(ch0)); d_nodes[id].setChildren(ch1, ch0); } @@ -218,7 +219,7 @@ public: void alignSlicings(const ExtractTerm& term1, const ExtractTerm& term2); void ensureSlicing(const ExtractTerm& term); Index getBitwidth(TermId id) const { - Assert (id < d_nodes.size()); + Assert(id < d_nodes.size()); return d_nodes[id].getBitwidth(); } std::string debugPrint(TermId id); diff --git a/src/theory/bv/theory_bv.cpp b/src/theory/bv/theory_bv.cpp index b7e52205f..23ffabcd1 100644 --- a/src/theory/bv/theory_bv.cpp +++ b/src/theory/bv/theory_bv.cpp @@ -336,7 +336,7 @@ void TheoryBV::check(Effort e) std::vector assertions; while (!done()) { TNode fact = get().assertion; - Assert (fact.getKind() == kind::BITVECTOR_EAGER_ATOM); + Assert(fact.getKind() == kind::BITVECTOR_EAGER_ATOM); assertions.push_back(fact); d_eagerSolver->assertFormula(fact[0]); } @@ -379,13 +379,13 @@ void TheoryBV::check(Effort e) bool ok = true; bool complete = false; for (unsigned i = 0; i < d_subtheories.size(); ++i) { - Assert (!inConflict()); + Assert(!inConflict()); ok = d_subtheories[i]->check(e); complete = d_subtheories[i]->isComplete(); if (!ok) { // if we are in a conflict no need to check with other theories - Assert (inConflict()); + Assert(inConflict()); sendConflict(); return; } @@ -511,7 +511,7 @@ bool TheoryBV::doExtfReductions( std::vector< Node >& terms ) { if( getExtTheory()->doReductions( 0, terms, nredr ) ){ return true; } - Assert( nredr.empty() ); + Assert(nredr.empty()); return false; } @@ -873,7 +873,7 @@ bool TheoryBV::storePropagation(TNode literal, SubTheory subtheory) void TheoryBV::explain(TNode literal, std::vector& assumptions) { - Assert (wasPropagatedBySubtheory(literal)); + Assert(wasPropagatedBySubtheory(literal)); SubTheory sub = getPropagatingSubtheory(literal); d_subtheoryMap[sub]->explain(literal, assumptions); } @@ -912,7 +912,7 @@ EqualityStatus TheoryBV::getEqualityStatus(TNode a, TNode b) { if (options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER) return EQUALITY_UNKNOWN; - Assert (options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY); + Assert(options::bitblastMode() == theory::bv::BITBLAST_MODE_LAZY); for (unsigned i = 0; i < d_subtheories.size(); ++i) { EqualityStatus status = d_subtheories[i]->getEqualityStatus(a, b); if (status != EQUALITY_UNKNOWN) { @@ -924,7 +924,7 @@ EqualityStatus TheoryBV::getEqualityStatus(TNode a, TNode b) void TheoryBV::enableCoreTheorySlicer() { - Assert (!d_calledPreregister); + Assert(!d_calledPreregister); d_isCoreTheory = true; if (d_subtheoryMap.find(SUB_CORE) != d_subtheoryMap.end()) { CoreSolver* core = (CoreSolver*)d_subtheoryMap[SUB_CORE]; @@ -979,7 +979,7 @@ bool TheoryBV::applyAbstraction(const std::vector& assertions, std::vector options::bitblastMode() == theory::bv::BITBLAST_MODE_EAGER && options::bitvectorAig()) { // disable AIG mode - AlwaysAssert (!d_eagerSolver->isInitialized()); + AlwaysAssert(!d_eagerSolver->isInitialized()); d_eagerSolver->turnOffAig(); d_eagerSolver->initialize(); } diff --git a/src/theory/bv/theory_bv_rewrite_rules.h b/src/theory/bv/theory_bv_rewrite_rules.h index eefda524e..44ac14464 100644 --- a/src/theory/bv/theory_bv_rewrite_rules.h +++ b/src/theory/bv/theory_bv_rewrite_rules.h @@ -389,6 +389,7 @@ class RewriteRule { /** Actually apply the rewrite rule */ static inline Node apply(TNode node) { Unreachable(); + SuppressWrongNoReturnWarning; } public: @@ -408,8 +409,10 @@ public: } - static inline bool applies(TNode node) { + static inline bool applies(TNode node) + { Unreachable(); + SuppressWrongNoReturnWarning; } template diff --git a/src/theory/bv/theory_bv_rewrite_rules_normalization.h b/src/theory/bv/theory_bv_rewrite_rules_normalization.h index cada3d30c..153f785ca 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_normalization.h +++ b/src/theory/bv/theory_bv_rewrite_rules_normalization.h @@ -312,7 +312,7 @@ static inline void updateCoefMap(TNode current, unsigned size, break; } case kind::BITVECTOR_SUB: - // turn into a + (-1)*b + // turn into a + (-1)*b Assert(current.getNumChildren() == 2); addToCoefMap(factorToCoefficient, current[0], BitVector(size, (unsigned)1)); addToCoefMap(factorToCoefficient, current[1], -BitVector(size, (unsigned)1)); diff --git a/src/theory/bv/theory_bv_rewrite_rules_simplification.h b/src/theory/bv/theory_bv_rewrite_rules_simplification.h index 0e42886b5..c3e1b316c 100644 --- a/src/theory/bv/theory_bv_rewrite_rules_simplification.h +++ b/src/theory/bv/theory_bv_rewrite_rules_simplification.h @@ -308,7 +308,7 @@ Node RewriteRule::apply(TNode node) { // make sure we do not lose information casting Assert(amount < Integer(1).multiplyByPow2(32)); - + uint32_t uint32_amount = amount.toUnsignedInt(); Node left = utils::mkExtract(a, size - 1 - uint32_amount, 0); @@ -350,7 +350,7 @@ Node RewriteRule::apply(TNode node) { // make sure we do not lose information casting Assert(amount < Integer(1).multiplyByPow2(32)); - + uint32_t uint32_amount = amount.toUnsignedInt(); Node right = utils::mkExtract(a, size - 1, uint32_amount); Node left = utils::mkZero(uint32_amount); @@ -481,7 +481,7 @@ Node RewriteRule::apply(TNode node) { if (node[0] == utils::mkOnes(size)) { return node[1]; } else { - Assert (node[1] == utils::mkOnes(size)); + Assert(node[1] == utils::mkOnes(size)); return node[0]; } } @@ -1640,7 +1640,7 @@ Node RewriteRule::apply(TNode node) { Node res = nb; return res; } - Assert (node[0].getKind() == kind::BITVECTOR_SIGN_EXTEND); + Assert(node[0].getKind() == kind::BITVECTOR_SIGN_EXTEND); unsigned amount2 = node[0].getOperator().getConst().signExtendAmount; return utils::mkSignExtend(node[0][0], amount1 + amount2); diff --git a/src/theory/bv/theory_bv_type_rules.h b/src/theory/bv/theory_bv_type_rules.h index e56f752af..9d5c6f396 100644 --- a/src/theory/bv/theory_bv_type_rules.h +++ b/src/theory/bv/theory_bv_type_rules.h @@ -342,7 +342,8 @@ class IntToBitVectorOpTypeRule nodeManager->mkBitVectorType(bvSize)); } - InternalError("bv-conversion typerule invoked for non-bv-conversion kind"); + InternalError() + << "bv-conversion typerule invoked for non-bv-conversion kind"; } }; /* class IntToBitVectorOpTypeRule */ @@ -372,7 +373,8 @@ class BitVectorConversionTypeRule return nodeManager->mkBitVectorType(bvSize); } - InternalError("bv-conversion typerule invoked for non-bv-conversion kind"); + InternalError() + << "bv-conversion typerule invoked for non-bv-conversion kind"; } }; /* class BitVectorConversionTypeRule */ diff --git a/src/theory/bv/theory_bv_utils.cpp b/src/theory/bv/theory_bv_utils.cpp index f1cb197ab..c0df9f35c 100644 --- a/src/theory/bv/theory_bv_utils.cpp +++ b/src/theory/bv/theory_bv_utils.cpp @@ -287,9 +287,8 @@ Node mkVar(unsigned size) Node mkSortedNode(Kind kind, TNode child1, TNode child2) { - Assert(kind == kind::BITVECTOR_AND - || kind == kind::BITVECTOR_OR - || kind == kind::BITVECTOR_XOR); + Assert(kind == kind::BITVECTOR_AND || kind == kind::BITVECTOR_OR + || kind == kind::BITVECTOR_XOR); if (child1 < child2) { diff --git a/src/theory/bv/theory_bv_utils.h b/src/theory/bv/theory_bv_utils.h index 975796719..23eaab3f8 100644 --- a/src/theory/bv/theory_bv_utils.h +++ b/src/theory/bv/theory_bv_utils.h @@ -118,15 +118,10 @@ Node mkSortedNode(Kind kind, std::vector& children); template Node mkNaryNode(Kind k, const std::vector>& nodes) { - Assert (k == kind::AND - || k == kind::OR - || k == kind::XOR - || k == kind::BITVECTOR_AND - || k == kind::BITVECTOR_OR - || k == kind::BITVECTOR_XOR - || k == kind::BITVECTOR_PLUS - || k == kind::BITVECTOR_SUB - || k == kind::BITVECTOR_MULT); + Assert(k == kind::AND || k == kind::OR || k == kind::XOR + || k == kind::BITVECTOR_AND || k == kind::BITVECTOR_OR + || k == kind::BITVECTOR_XOR || k == kind::BITVECTOR_PLUS + || k == kind::BITVECTOR_SUB || k == kind::BITVECTOR_MULT); if (nodes.size() == 1) { return nodes[0]; } return NodeManager::currentNM()->mkNode(k, nodes); diff --git a/src/theory/datatypes/datatypes_sygus.cpp b/src/theory/datatypes/datatypes_sygus.cpp index b04686492..4cc9e4640 100644 --- a/src/theory/datatypes/datatypes_sygus.cpp +++ b/src/theory/datatypes/datatypes_sygus.cpp @@ -75,7 +75,7 @@ void SygusSymBreakNew::assertTester( int tindex, TNode n, Node exp, std::vector< }else{ //this must be a proper selector IntMap::const_iterator itt = d_testers.find( n[0] ); - Assert( itt!=d_testers.end() ); + Assert(itt != d_testers.end()); int ptindex = (*itt).second; TypeNode ptn = n[0].getType(); const Datatype& pdt = ((DatatypeType)ptn.toType()).getDatatype(); @@ -109,7 +109,7 @@ void SygusSymBreakNew::assertFact( Node n, bool polarity, std::vector< Node >& l if( options::sygusFair()==SYGUS_FAIR_DT_SIZE ){ std::map>::iterator its = d_szinfo.find(m); - Assert( its!=d_szinfo.end() ); + Assert(its != d_szinfo.end()); Node mt = its->second->getOrMkMeasureValue(lemmas); //it relates the measure term to arithmetic Node blem = n.eqNode( NodeManager::currentNM()->mkNode( kind::LEQ, mt, n[1] ) ); @@ -233,13 +233,13 @@ void SygusSymBreakNew::assertTesterInternal( int tindex, TNode n, Node exp, std: << std::endl; // get the search size for this - Assert( d_term_to_anchor.find( n )!=d_term_to_anchor.end() ); + Assert(d_term_to_anchor.find(n) != d_term_to_anchor.end()); Node a = d_term_to_anchor[n]; - Assert( d_anchor_to_measure_term.find( a )!=d_anchor_to_measure_term.end() ); + Assert(d_anchor_to_measure_term.find(a) != d_anchor_to_measure_term.end()); Node m = d_anchor_to_measure_term[a]; std::map>::iterator itsz = d_szinfo.find(m); - Assert( itsz!=d_szinfo.end() ); + Assert(itsz != d_szinfo.end()); unsigned ssz = itsz->second->d_curr_search_size; if( options::sygusFair()==SYGUS_FAIR_DIRECT ){ @@ -248,7 +248,7 @@ void SygusSymBreakNew::assertTesterInternal( int tindex, TNode n, Node exp, std: // consider lower bounds for size of types unsigned lb_add = nti.getMinConsTermSize(tindex); unsigned lb_rem = n == a ? 0 : nti.getMinTermSize(); - Assert( lb_add>=lb_rem ); + Assert(lb_add >= lb_rem); d_currTermSize[a].set( d_currTermSize[a].get() + ( lb_add - lb_rem ) ); } if( (unsigned)d_currTermSize[a].get()>ssz ){ @@ -264,18 +264,19 @@ void SygusSymBreakNew::assertTesterInternal( int tindex, TNode n, Node exp, std: Node xa = d_term_to_anchor[x]; if( xa==a ){ IntMap::const_iterator ittv = d_testers.find( x ); - Assert( ittv != d_testers.end() ); + Assert(ittv != d_testers.end()); int tindex = (*ittv).second; const Datatype& dti = ((DatatypeType)x.getType().toType()).getDatatype(); if( dti[tindex].getNumArgs()>0 ){ NodeMap::const_iterator itt = d_testers_exp.find( x ); - Assert( itt != d_testers_exp.end() ); + Assert(itt != d_testers_exp.end()); conflict.push_back( (*itt).second ); } } } - Assert( conflict.size()==(unsigned)d_currTermSize[a].get() ); - Assert( itsz->second->d_search_size_exp.find( ssz )!=itsz->second->d_search_size_exp.end() ); + Assert(conflict.size() == (unsigned)d_currTermSize[a].get()); + Assert(itsz->second->d_search_size_exp.find(ssz) + != itsz->second->d_search_size_exp.end()); conflict.push_back( itsz->second->d_search_size_exp[ssz] ); Node conf = NodeManager::currentNM()->mkNode( kind::AND, conflict ); Trace("sygus-sb-fair") << "Conflict is : " << conf << std::endl; @@ -285,7 +286,7 @@ void SygusSymBreakNew::assertTesterInternal( int tindex, TNode n, Node exp, std: } // now, add all applicable symmetry breaking lemmas for this term - Assert( d_term_to_depth.find( n )!=d_term_to_depth.end() ); + Assert(d_term_to_depth.find(n) != d_term_to_depth.end()); unsigned d = d_term_to_depth[n]; Trace("sygus-sb-fair-debug") << "Tester " << exp << " is for depth " << d << " term in search size " << ssz << std::endl; //Assert( d<=ssz ); @@ -367,10 +368,10 @@ void SygusSymBreakNew::assertTesterInternal( int tindex, TNode n, Node exp, std: for( unsigned j=0; jmkNode( APPLY_SELECTOR_TOTAL, Node::fromExpr( dt[tindex].getSelectorInternal( ntn.toType(), j ) ), n ); Trace("sygus-sb-debug2") << " activate child sel : " << sel << std::endl; - Assert( d_active_terms.find( sel )==d_active_terms.end() ); + Assert(d_active_terms.find(sel) == d_active_terms.end()); IntMap::const_iterator itt = d_testers.find( sel ); if( itt != d_testers.end() ){ - Assert( d_testers_exp.find( sel ) != d_testers_exp.end() ); + Assert(d_testers_exp.find(sel) != d_testers_exp.end()); assertTesterInternal( (*itt).second, sel, d_testers_exp[sel], lemmas ); } } @@ -401,14 +402,14 @@ Node SygusSymBreakNew::getRelevancyCondition( Node n ) { excl = true; } } - Assert( !disj.empty() ); + Assert(!disj.empty()); if( excl ){ cond = disj.size() == 1 ? disj[0] : NodeManager::currentNM()->mkNode( kind::AND, disj); } }else{ int sindex = Datatype::cindexOf( selExpr ); - Assert( sindex!=-1 ); + Assert(sindex != -1); cond = utils::mkTester(n[0], sindex, dt).negate(); } Node c1 = getRelevancyCondition( n[0] ); @@ -946,9 +947,9 @@ void SygusSymBreakNew::registerSearchTerm( TypeNode tn, unsigned d, Node n, bool //register this term std::unordered_map::iterator ita = d_term_to_anchor.find(n); - Assert( ita != d_term_to_anchor.end() ); + Assert(ita != d_term_to_anchor.end()); Node a = ita->second; - Assert( !a.isNull() ); + Assert(!a.isNull()); if( std::find( d_cache[a].d_search_terms[tn][d].begin(), d_cache[a].d_search_terms[tn][d].end(), n )==d_cache[a].d_search_terms[tn][d].end() ){ Trace("sygus-sb-debug") << " register search term : " << n << " at depth " << d << ", type=" << tn << ", tl=" << topLevel << std::endl; d_cache[a].d_search_terms[tn][d].push_back( n ); @@ -1068,7 +1069,8 @@ Node SygusSymBreakNew::registerSearchValue(Node a, if( !bvr_equiv.isNull() ){ if( bvr_equiv!=bvr ){ Trace("sygus-sb-debug") << "......adding search val for " << bvr << " returned " << bvr_equiv << std::endl; - Assert( d_cache[a].d_search_val[tn].find( bvr_equiv )!=d_cache[a].d_search_val[tn].end() ); + Assert(d_cache[a].d_search_val[tn].find(bvr_equiv) + != d_cache[a].d_search_val[tn].end()); Trace("sygus-sb-debug") << "......search value was " << d_cache[a].d_search_val[tn][bvr_equiv] << std::endl; if( Trace.isOn("sygus-sb-exc") ){ Node prev = d_tds->sygusToBuiltin( d_cache[a].d_search_val[tn][bvr_equiv], tn ); @@ -1110,7 +1112,8 @@ Node SygusSymBreakNew::registerSearchValue(Node a, if( !bad_val_bvr.isNull() ){ Node bad_val = nv; Node bad_val_o = d_cache[a].d_search_val[tn][bad_val_bvr]; - Assert( d_cache[a].d_search_val_sz[tn].find( bad_val_bvr )!=d_cache[a].d_search_val_sz[tn].end() ); + Assert(d_cache[a].d_search_val_sz[tn].find(bad_val_bvr) + != d_cache[a].d_search_val_sz[tn].end()); unsigned prev_sz = d_cache[a].d_search_val_sz[tn][bad_val_bvr]; bool doFlip = (prev_sz > sz); if (doFlip) @@ -1137,8 +1140,8 @@ Node SygusSymBreakNew::registerSearchValue(Node a, Trace("sygus-sb-exc") << " (by examples)"; } Trace("sygus-sb-exc") << std::endl; - } - Assert( d_tds->getSygusTermSize( bad_val )==sz ); + } + Assert(d_tds->getSygusTermSize(bad_val) == sz); // generalize the explanation for why the analog of bad_val // is equivalent to bvr @@ -1192,7 +1195,7 @@ void SygusSymBreakNew::registerSymBreakLemma( TypeNode tn, Node lem, unsigned sz Trace("sygus-sb-debug") << " anchor : " << a << std::endl; Trace("sygus-sb-debug") << " type : " << tn << std::endl; Trace("sygus-sb-debug") << " size : " << sz << std::endl; - Assert( !a.isNull() ); + Assert(!a.isNull()); d_cache[a].d_sb_lemmas[tn][sz].push_back( lem ); TNode x = getFreeVar( tn ); unsigned csz = getSearchSizeForAnchor( a ); @@ -1219,14 +1222,14 @@ void SygusSymBreakNew::registerSymBreakLemma( TypeNode tn, Node lem, unsigned sz } } void SygusSymBreakNew::addSymBreakLemmasFor( TypeNode tn, Node t, unsigned d, std::vector< Node >& lemmas ) { - Assert( d_term_to_anchor.find( t )!=d_term_to_anchor.end() ); + Assert(d_term_to_anchor.find(t) != d_term_to_anchor.end()); Node a = d_term_to_anchor[t]; addSymBreakLemmasFor( tn, t, d, a, lemmas ); } void SygusSymBreakNew::addSymBreakLemmasFor( TypeNode tn, Node t, unsigned d, Node a, std::vector< Node >& lemmas ) { - Assert( t.getType()==tn ); - Assert( !a.isNull() ); + Assert(t.getType() == tn); + Assert(!a.isNull()); Trace("sygus-sb-debug2") << "add sym break lemmas for " << t << " " << d << " " << a << std::endl; std::map< TypeNode, std::map< unsigned, std::vector< Node > > >::iterator its = d_cache[a].d_sb_lemmas.find( tn ); @@ -1398,28 +1401,26 @@ void SygusSymBreakNew::registerMeasureTerm( Node m ) { void SygusSymBreakNew::notifySearchSize( Node m, unsigned s, Node exp, std::vector< Node >& lemmas ) { std::map>::iterator its = d_szinfo.find(m); - Assert( its!=d_szinfo.end() ); + Assert(its != d_szinfo.end()); if( its->second->d_search_size.find( s )==its->second->d_search_size.end() ){ its->second->d_search_size[s] = true; its->second->d_search_size_exp[s] = exp; - Assert( s==0 || its->second->d_search_size.find( s-1 )!=its->second->d_search_size.end() ); + Assert(s == 0 + || its->second->d_search_size.find(s - 1) + != its->second->d_search_size.end()); Trace("sygus-fair") << "SygusSymBreakNew:: now considering term measure : " << s << " for " << m << std::endl; - Assert( s>=its->second->d_curr_search_size ); + Assert(s >= its->second->d_curr_search_size); while( s>its->second->d_curr_search_size ){ incrementCurrentSearchSize( m, lemmas ); } Trace("sygus-fair") << "...finish increment for term measure : " << s << std::endl; /* //re-add all testers (some may now be relevant) TODO - for( IntMap::const_iterator it = d_testers.begin(); it != d_testers.end(); ++it ){ - Node n = (*it).first; - NodeMap::const_iterator itx = d_testers_exp.find( n ); - if( itx!=d_testers_exp.end() ){ - int tindex = (*it).second; - Node exp = (*itx).second; - assertTester( tindex, n, exp, lemmas ); - }else{ - Assert( false ); + for( IntMap::const_iterator it = d_testers.begin(); it != d_testers.end(); + ++it ){ Node n = (*it).first; NodeMap::const_iterator itx = + d_testers_exp.find( n ); if( itx!=d_testers_exp.end() ){ int tindex = + (*it).second; Node exp = (*itx).second; assertTester( tindex, n, exp, lemmas + ); }else{ Assert( false ); } } */ @@ -1430,14 +1431,14 @@ unsigned SygusSymBreakNew::getSearchSizeFor( Node n ) { Trace("sygus-sb-debug2") << "get search size for term : " << n << std::endl; std::unordered_map::iterator ita = d_term_to_anchor.find(n); - Assert( ita != d_term_to_anchor.end() ); + Assert(ita != d_term_to_anchor.end()); return getSearchSizeForAnchor( ita->second ); } unsigned SygusSymBreakNew::getSearchSizeForAnchor( Node a ) { Trace("sygus-sb-debug2") << "get search size for anchor : " << a << std::endl; std::map< Node, Node >::iterator it = d_anchor_to_measure_term.find( a ); - Assert( it!=d_anchor_to_measure_term.end() ); + Assert(it != d_anchor_to_measure_term.end()); return getSearchSizeForMeasureTerm(it->second); } @@ -1446,14 +1447,14 @@ unsigned SygusSymBreakNew::getSearchSizeForMeasureTerm(Node m) Trace("sygus-sb-debug2") << "get search size for measure : " << m << std::endl; std::map>::iterator its = d_szinfo.find(m); - Assert( its!=d_szinfo.end() ); + Assert(its != d_szinfo.end()); return its->second->d_curr_search_size; } void SygusSymBreakNew::incrementCurrentSearchSize( Node m, std::vector< Node >& lemmas ) { std::map>::iterator itsz = d_szinfo.find(m); - Assert( itsz!=d_szinfo.end() ); + Assert(itsz != d_szinfo.end()); itsz->second->d_curr_search_size++; Trace("sygus-fair") << " register search size " << itsz->second->d_curr_search_size << " for " << m << std::endl; NodeManager* nm = NodeManager::currentNM(); @@ -1461,7 +1462,7 @@ void SygusSymBreakNew::incrementCurrentSearchSize( Node m, std::vector< Node >& Node a = itc->first; Trace("sygus-fair-debug") << " look at anchor " << a << "..." << std::endl; // check whether a is bounded by m - Assert( d_anchor_to_measure_term.find( a )!=d_anchor_to_measure_term.end() ); + Assert(d_anchor_to_measure_term.find(a) != d_anchor_to_measure_term.end()); if( d_anchor_to_measure_term[a]==m ){ for( std::map< TypeNode, std::map< unsigned, std::vector< Node > > >::iterator its = itc->second.d_sb_lemmas.begin(); its != itc->second.d_sb_lemmas.end(); ++its ){ @@ -1583,7 +1584,7 @@ void SygusSymBreakNew::check( std::vector< Node >& lemmas ) { Trace("sygus-sb") << " Mv[" << prog << "] = " << progv << ", size = " << prog_szv << std::endl; if( prog_szv.getConst().getNumerator().toUnsignedInt() > getSearchSizeForAnchor( prog ) ){ - AlwaysAssert( false ); + AlwaysAssert(false); Node szlem = NodeManager::currentNM()->mkNode( kind::OR, prog.eqNode( progv ).negate(), prog_sz.eqNode( progv_sz ) ); Trace("sygus-sb-warn") << "SygusSymBreak : WARNING : adding size correction : " << szlem << std::endl; @@ -1695,7 +1696,7 @@ bool SygusSymBreakNew::checkValue(Node n, Trace("sygus-sb") << " SygusSymBreakNew::check: ...WARNING: considered " "missing split for " << n << "." << std::endl; - Assert( !split.isNull() ); + Assert(!split.isNull()); lemmas.push_back( split ); return false; } @@ -1717,11 +1718,11 @@ Node SygusSymBreakNew::getCurrentTemplate( Node n, std::map< TypeNode, int >& va if( d_active_terms.find( n )!=d_active_terms.end() ){ TypeNode tn = n.getType(); IntMap::const_iterator it = d_testers.find( n ); - Assert( it != d_testers.end() ); + Assert(it != d_testers.end()); const Datatype& dt = ((DatatypeType)tn.toType()).getDatatype(); int tindex = (*it).second; - Assert( tindex>=0 ); - Assert( tindex<(int)dt.getNumConstructors() ); + Assert(tindex >= 0); + Assert(tindex < (int)dt.getNumConstructors()); std::vector< Node > children; children.push_back( Node::fromExpr( dt[tindex].getConstructor() ) ); for( unsigned i=0; i -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/datatype.h" #include "expr/kind.h" #include "options/datatypes_options.h" @@ -138,11 +138,11 @@ void TheoryDatatypes::check(Effort e) { if (done() && e lemmas; d_sygus_sym_break->check( lemmas ); doSendLemmas( lemmas ); @@ -161,10 +161,13 @@ void TheoryDatatypes::check(Effort e) { TNode atom CVC4_UNUSED = fact.getKind() == kind::NOT ? fact[0] : fact; // extra debug check to make sure that the rewriter did its job correctly - Assert( atom.getKind() != kind::EQUAL || - ( atom[0].getKind() != kind::TUPLE_UPDATE && atom[1].getKind() != kind::TUPLE_UPDATE && - atom[0].getKind() != kind::RECORD_UPDATE && atom[1].getKind() != kind::RECORD_UPDATE), - "tuple/record escaped into datatypes decision procedure; should have been rewritten away" ); + Assert(atom.getKind() != kind::EQUAL + || (atom[0].getKind() != kind::TUPLE_UPDATE + && atom[1].getKind() != kind::TUPLE_UPDATE + && atom[0].getKind() != kind::RECORD_UPDATE + && atom[1].getKind() != kind::RECORD_UPDATE)) + << "tuple/record escaped into datatypes decision procedure; should " + "have been rewritten away"; //assert the fact assertFact( fact, fact ); @@ -173,7 +176,7 @@ void TheoryDatatypes::check(Effort e) { if( e == EFFORT_FULL && !d_conflict && !d_addedLemma && !d_valuation.needCheck() ) { //check for cycles - Assert( d_pending.empty() && d_pending_merge.empty() ); + Assert(d_pending.empty() && d_pending_merge.empty()); do { d_addedFact = false; Trace("datatypes-proc") << "Check cycles..." << std::endl; @@ -301,7 +304,7 @@ void TheoryDatatypes::check(Effort e) { Trace("datatypes-infer") << "DtInfer : 1-cons (full) : " << t << std::endl; d_infer.push_back( t ); }else{ - Assert( consIndex!=-1 || dt.isSygus() ); + Assert(consIndex != -1 || dt.isSygus()); if( options::dtBinarySplit() && consIndex!=-1 ){ Node test = utils::mkTester(n, consIndex, dt); Trace("dt-split") << "*************Split for possible constructor " << dt[consIndex] << " for " << n << endl; @@ -436,7 +439,7 @@ void TheoryDatatypes::doPendingMerges(){ //do all pending merges int i=0; while( i<(int)d_pending_merge.size() ){ - Assert( d_pending_merge[i].getKind()==EQUAL ); + Assert(d_pending_merge[i].getKind() == EQUAL); merge( d_pending_merge[i][0], d_pending_merge[i][1] ); i++; } @@ -469,7 +472,7 @@ bool TheoryDatatypes::doSendLemmas( std::vector< Node >& lemmas ){ } void TheoryDatatypes::assertFact( Node fact, Node exp ){ - Assert( d_pending_merge.empty() ); + Assert(d_pending_merge.empty()); Trace("datatypes-debug") << "TheoryDatatypes::assertFact : " << fact << std::endl; bool polarity = fact.getKind() != kind::NOT; TNode atom = polarity ? fact : fact[0]; @@ -769,7 +772,7 @@ void TheoryDatatypes::explain(TNode literal, std::vector& assumptions){ explain( atom[i], assumptions ); } } else { - Assert( atom.getKind()!=kind::AND ); + Assert(atom.getKind() != kind::AND); explainPredicate( atom, polarity, assumptions ); } } @@ -975,7 +978,7 @@ int TheoryDatatypes::getLabelIndex( EqcInfo* eqc, Node n ){ return -1; }else{ int tindex = utils::isTester(lbl); - Assert( tindex!=-1 ); + Assert(tindex != -1); return tindex; } } @@ -1078,7 +1081,7 @@ void TheoryDatatypes::addTester( }else{ //otherwise, scan list of labels NodeUIntMap::iterator lbl_i = d_labels.find(n); - Assert( lbl_i != d_labels.end() ); + Assert(lbl_i != d_labels.end()); size_t n_lbl = (*lbl_i).second; std::map< int, bool > neg_testers; for (size_t i = 0; i < n_lbl; i++) @@ -1121,7 +1124,7 @@ void TheoryDatatypes::addTester( for (unsigned i = 0, ncons = dt.getNumConstructors(); i < ncons; i++) { if( i!=ttindex && neg_testers.find( i )==neg_testers.end() ){ - Assert( n.getKind()!=APPLY_CONSTRUCTOR ); + Assert(n.getKind() != APPLY_CONSTRUCTOR); Node infer = utils::mkTester(n, i, dt).negate(); Trace("datatypes-infer") << "DtInfer : neg label : " << infer << " by " << t << std::endl; d_infer.push_back( infer ); @@ -1150,7 +1153,7 @@ void TheoryDatatypes::addTester( { Node ti = d_labels_data[n][i]; nb << ti; - Assert( ti.getKind()==NOT ); + Assert(ti.getKind() == NOT); Node t_arg2 = d_labels_args[n][i]; if( std::find( eq_terms.begin(), eq_terms.end(), t_arg2 )==eq_terms.end() ){ eq_terms.push_back( t_arg2 ); @@ -1190,7 +1193,7 @@ void TheoryDatatypes::addSelector( Node s, EqcInfo* eqc, Node n, bool assertFact Trace("dt-collapse-sel") << "Add selector : " << s << " to eqc(" << n << ")" << std::endl; //check to see if it is redundant NodeUIntMap::iterator sel_i = d_selector_apps.find(n); - Assert( sel_i != d_selector_apps.end() ); + Assert(sel_i != d_selector_apps.end()); if( sel_i != d_selector_apps.end() ){ size_t n_sel = (*sel_i).second; for (size_t j = 0; j < n_sel; j++) @@ -1221,7 +1224,7 @@ void TheoryDatatypes::addSelector( Node s, EqcInfo* eqc, Node n, bool assertFact void TheoryDatatypes::addConstructor( Node c, EqcInfo* eqc, Node n ){ Trace("datatypes-debug") << "Add constructor : " << c << " to eqc(" << n << ")" << std::endl; - Assert( eqc->d_constructor.get().isNull() ); + Assert(eqc->d_constructor.get().isNull()); //check labels NodeUIntMap::iterator lbl_i = d_labels.find(n); if( lbl_i != d_labels.end() ){ @@ -1297,7 +1300,7 @@ Node TheoryDatatypes::removeUninterpretedConstants( Node n, std::map< Node, Node } void TheoryDatatypes::collapseSelector( Node s, Node c ) { - Assert( c.getKind()==APPLY_CONSTRUCTOR ); + Assert(c.getKind() == APPLY_CONSTRUCTOR); Trace("dt-collapse-sel") << "collapse selector : " << s << " " << c << std::endl; Node r; bool wrong = false; @@ -1384,10 +1387,10 @@ void TheoryDatatypes::addCarePairs(TNodeTrie* t1, for (unsigned k = 0; k < f1.getNumChildren(); ++ k) { TNode x = f1[k]; TNode y = f2[k]; - Assert( d_equalityEngine.hasTerm(x) ); - Assert( d_equalityEngine.hasTerm(y) ); - Assert( !areDisequal( x, y ) ); - Assert( !areCareDisequal( x, y ) ); + Assert(d_equalityEngine.hasTerm(x)); + Assert(d_equalityEngine.hasTerm(y)); + Assert(!areDisequal(x, y)); + Assert(!areCareDisequal(x, y)); if( !d_equalityEngine.areEqual( x, y ) ){ Trace("dt-cg") << "Arg #" << k << " is " << x << " " << y << std::endl; if( d_equalityEngine.isTriggerTerm(x, THEORY_DATATYPES) && d_equalityEngine.isTriggerTerm(y, THEORY_DATATYPES) ){ @@ -1548,7 +1551,7 @@ bool TheoryDatatypes::collectModelInfo(TheoryModel* m) Type tt = eqc.getType().toType(); const Datatype& dt = ((DatatypeType)tt).getDatatype(); if( !d_equalityEngine.hasTerm( eqc ) ){ - Assert( false ); + Assert(false); }else{ Trace("dt-cmi") << "NOTICE : Datatypes: no constructor in equivalence class " << eqc << std::endl; Trace("dt-cmi") << " Type : " << eqc.getType() << std::endl; @@ -1629,7 +1632,7 @@ Node TheoryDatatypes::getCodatatypesValue( Node n, std::map< Node, Node >& eqc_c if( !nc.isNull() ){ vmap[n] = depth; Trace("dt-cmi-cdt-debug") << " map " << n << " -> " << depth << std::endl; - Assert( nc.getKind()==APPLY_CONSTRUCTOR ); + Assert(nc.getKind() == APPLY_CONSTRUCTOR); std::vector< Node > children; children.push_back( nc.getOperator() ); for( unsigned i=0; i0 ); + Assert(expl.size() > 0); d_conflictNode = mkAnd( expl ); Trace("dt-conflict") << "CONFLICT: Cycle conflict : " << d_conflictNode << std::endl; d_out->conflict( d_conflictNode ); @@ -1880,7 +1883,7 @@ void TheoryDatatypes::checkCycles() { cn[part_out[i][j]] = part_out[i][j]; dni.clear(); separateBisimilar( part, tpart_out, exp, cn, dni, 0, true ); - Assert( tpart_out.size()==1 && tpart_out[0].size()==2 ); + Assert(tpart_out.size() == 1 && tpart_out[0].size() == 2); part.pop_back(); //merge based on explanation Trace("dt-cdt") << " exp is : "; @@ -1912,7 +1915,7 @@ void TheoryDatatypes::separateBisimilar( std::vector< Node >& part, std::vector< Trace("dt-cdt-debug") << " " << part[i] << ", current = " << cn[part[i]] << std::endl; } } - Assert( part.size()>1 ); + Assert(part.size() > 1); std::map< Node, std::vector< Node > > new_part; std::map< Node, std::vector< Node > > new_part_c; std::map< int, std::vector< Node > > new_part_rec; @@ -2124,8 +2127,8 @@ bool TheoryDatatypes::areDisequal( TNode a, TNode b ){ } bool TheoryDatatypes::areCareDisequal( TNode x, TNode y ) { - Assert( d_equalityEngine.hasTerm( x ) ); - Assert( d_equalityEngine.hasTerm( y ) ); + Assert(d_equalityEngine.hasTerm(x)); + Assert(d_equalityEngine.hasTerm(y)); if( d_equalityEngine.isTriggerTerm(x, THEORY_DATATYPES) && d_equalityEngine.isTriggerTerm(y, THEORY_DATATYPES) ){ TNode x_shared = d_equalityEngine.getTriggerTermRepresentative(x, THEORY_DATATYPES); TNode y_shared = d_equalityEngine.getTriggerTermRepresentative(y, THEORY_DATATYPES); @@ -2289,9 +2292,9 @@ std::pair TheoryDatatypes::entailmentCheck(TNode lit, const Entailme explainEquality( n, ei->d_constructor.get(), true, exp_c ); }else{ Node lbl = getLabel( n ); - Assert( !lbl.isNull() ); + Assert(!lbl.isNull()); exp_c.push_back( lbl ); - Assert( areEqual( n, lbl[0] ) ); + Assert(areEqual(n, lbl[0])); explainEquality( n, lbl[0], true, exp_c ); } Node exp = mkAnd( exp_c ); diff --git a/src/theory/datatypes/theory_datatypes_type_rules.h b/src/theory/datatypes/theory_datatypes_type_rules.h index c8c16f368..c28673321 100644 --- a/src/theory/datatypes/theory_datatypes_type_rules.h +++ b/src/theory/datatypes/theory_datatypes_type_rules.h @@ -124,8 +124,8 @@ struct DatatypeConstructorTypeRule { struct DatatypeSelectorTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::APPLY_SELECTOR || - n.getKind() == kind::APPLY_SELECTOR_TOTAL); + Assert(n.getKind() == kind::APPLY_SELECTOR + || n.getKind() == kind::APPLY_SELECTOR_TOTAL); TypeNode selType = n.getOperator().getType(check); Type t = selType[0].toType(); Assert(t.isDatatype()); diff --git a/src/theory/datatypes/type_enumerator.cpp b/src/theory/datatypes/type_enumerator.cpp index 023ade00d..de97227e0 100644 --- a/src/theory/datatypes/type_enumerator.cpp +++ b/src/theory/datatypes/type_enumerator.cpp @@ -114,8 +114,8 @@ Node DatatypesEnumerator::getTermEnum( TypeNode tn, unsigned i ){ //we first check if the last argument (which is forced to make sum of iterated arguments equal to d_size_limit) is defined Node lc; if( ctor.getNumArgs()>0 ){ - Assert( index0 ){ - Assert( indexgetFirst() == NULL, - "Equivalence class data exists for the node being registered. " + Assert(ecN->getFirst() == NULL) + << "Equivalence class data exists for the node being registered. " "Expected getFirst() == NULL. " "This data is either already in use or was not properly maintained " - "during backtracking"); + "during backtracking"; /*Assert(ecN->getLast() == NULL, "Equivalence class data exists for the node being registered. " "Expected getLast() == NULL. " "This data is either already in use or was not properly maintained " "during backtracking.");*/ - Assert(ecN->isClassRep(), - "Equivalence class data exists for the node being registered. " + Assert(ecN->isClassRep()) + << "Equivalence class data exists for the node being registered. " "Expected isClassRep() to be true. " "This data is either already in use or was not properly maintained " - "during backtracking"); - Assert(ecN->getWatchListSize() == 0, - "Equivalence class data exists for the node being registered. " + "during backtracking"; + Assert(ecN->getWatchListSize() == 0) + << "Equivalence class data exists for the node being registered. " "Expected getWatchListSize() == 0. " "This data is either already in use or was not properly maintained " - "during backtracking"); + "during backtracking"; } else { //The attribute does not exist, so it is created and set ecN = new (true) ECData(getContext(), n); @@ -290,14 +290,13 @@ void TheoryUFTim::check(Effort level) { merge(); break; case NOT: - Assert(assertion[0].getKind() == EQUAL, - "predicates not supported in this UF implementation"); + Assert(assertion[0].getKind() == EQUAL) + << "predicates not supported in this UF implementation"; d_disequality.push_back(assertion[0]); break; case APPLY_UF: - Unhandled("predicates not supported in this UF implementation"); - default: - Unhandled(assertion.getKind()); + Unhandled() << "predicates not supported in this UF implementation"; + default: Unhandled() << assertion.getKind(); } Debug("uf") << "TheoryUFTim::check(): done = " << (done() ? "true" : "false") << std::endl; diff --git a/src/theory/ext_theory.cpp b/src/theory/ext_theory.cpp index 5a37889a2..9d2a7ac4c 100644 --- a/src/theory/ext_theory.cpp +++ b/src/theory/ext_theory.cpp @@ -18,7 +18,7 @@ #include "theory/ext_theory.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "smt/smt_statistics_registry.h" #include "theory/quantifiers_engine.h" #include "theory/substitutions.h" diff --git a/src/theory/fp/fp_converter.cpp b/src/theory/fp/fp_converter.cpp index fbdce8cd5..bcdebc12e 100644 --- a/src/theory/fp/fp_converter.cpp +++ b/src/theory/fp/fp_converter.cpp @@ -883,7 +883,7 @@ Node FpConverter::convert(TNode node) case roundTowardPositive: r.insert(current, traits::RTP()); break; case roundTowardNegative: r.insert(current, traits::RTN()); break; case roundTowardZero: r.insert(current, traits::RTZ()); break; - default: Unreachable("Unknown rounding mode"); break; + default: Unreachable() << "Unknown rounding mode"; break; } } else @@ -896,7 +896,7 @@ Node FpConverter::convert(TNode node) } else { - Unreachable("Unknown kind of type RoundingMode"); + Unreachable() << "Unknown kind of type RoundingMode"; } } // Returns a rounding-mode type so don't alter the return value @@ -930,7 +930,7 @@ Node FpConverter::convert(TNode node) case kind::VARIABLE: case kind::BOUND_VARIABLE: case kind::SKOLEM: - Unreachable("Kind should have been handled as a leaf."); + Unreachable() << "Kind should have been handled as a leaf."; break; /******** Operations ********/ @@ -959,7 +959,7 @@ Node FpConverter::convert(TNode node) (*arg1).second)); break; default: - Unreachable("Unknown unary floating-point function"); + Unreachable() << "Unknown unary floating-point function"; break; } } @@ -1002,7 +1002,8 @@ Node FpConverter::convert(TNode node) (*arg1).second)); break; default: - Unreachable("Unknown unary rounded floating-point function"); + Unreachable() + << "Unknown unary rounded floating-point function"; break; } } @@ -1077,7 +1078,8 @@ Node FpConverter::convert(TNode node) break; default: - Unreachable("Unknown binary floating-point partial function"); + Unreachable() + << "Unknown binary floating-point partial function"; break; } } @@ -1125,9 +1127,9 @@ Node FpConverter::convert(TNode node) case kind::FLOATINGPOINT_SUB: // Should have been removed by the rewriter - Unreachable( - "Floating-point subtraction should be removed by the " - "rewriter."); + Unreachable() + << "Floating-point subtraction should be removed by the " + "rewriter."; break; case kind::FLOATINGPOINT_MULT: @@ -1152,13 +1154,14 @@ Node FpConverter::convert(TNode node) (*arg1).second, (*arg2).second)); */ - Unimplemented( - "Remainder with rounding mode not yet supported by " - "SMT-LIB"); + Unimplemented() + << "Remainder with rounding mode not yet supported by " + "SMT-LIB"; break; default: - Unreachable("Unknown binary rounded floating-point function"); + Unreachable() + << "Unknown binary rounded floating-point function"; break; } } @@ -1284,8 +1287,8 @@ Node FpConverter::convert(TNode node) break; default: - Unreachable( - "Unknown converstion from bit-vector to floating-point"); + Unreachable() << "Unknown converstion from bit-vector to " + "floating-point"; break; } } @@ -1300,10 +1303,12 @@ Node FpConverter::convert(TNode node) break; case kind::FLOATINGPOINT_TO_FP_GENERIC: - Unreachable("Generic to_fp not removed"); + Unreachable() << "Generic to_fp not removed"; break; - default: Unreachable("Unknown kind of type FloatingPoint"); break; + default: + Unreachable() << "Unknown kind of type FloatingPoint"; + break; } } } @@ -1414,7 +1419,7 @@ Node FpConverter::convert(TNode node) break; default: - Unreachable("Unknown binary floating-point relation"); + Unreachable() << "Unknown binary floating-point relation"; break; } } @@ -1482,7 +1487,7 @@ Node FpConverter::convert(TNode node) break; default: - Unreachable("Unknown unary floating-point relation"); + Unreachable() << "Unknown unary floating-point relation"; break; } } @@ -1491,7 +1496,7 @@ Node FpConverter::convert(TNode node) case kind::FLOATINGPOINT_EQ: case kind::FLOATINGPOINT_GEQ: case kind::FLOATINGPOINT_GT: - Unreachable("Kind should have been removed by rewriter."); + Unreachable() << "Kind should have been removed by rewriter."; break; // Components will be registered as they are owned by @@ -1602,15 +1607,15 @@ Node FpConverter::convert(TNode node) break; case kind::FLOATINGPOINT_TO_UBV: - Unreachable( - "Partially defined fp.to_ubv should have been removed by " - "expandDefinition"); + Unreachable() + << "Partially defined fp.to_ubv should have been removed by " + "expandDefinition"; break; case kind::FLOATINGPOINT_TO_SBV: - Unreachable( - "Partially defined fp.to_sbv should have been removed by " - "expandDefinition"); + Unreachable() + << "Partially defined fp.to_sbv should have been removed by " + "expandDefinition"; break; // Again, no action is needed @@ -1653,9 +1658,9 @@ Node FpConverter::convert(TNode node) break; case kind::FLOATINGPOINT_TO_REAL: - Unreachable( - "Partially defined fp.to_real should have been removed by " - "expandDefinition"); + Unreachable() + << "Partially defined fp.to_real should have been removed by " + "expandDefinition"; break; default: CVC4_FPCONV_PASSTHROUGH; break; @@ -1669,7 +1674,7 @@ Node FpConverter::convert(TNode node) return result; #else - Unimplemented("Conversion is dependent on SymFPU"); + Unimplemented() << "Conversion is dependent on SymFPU"; #endif } @@ -1688,7 +1693,7 @@ Node FpConverter::getValue(Valuation &val, TNode var) if (i == r.end()) { - Unreachable("Asking for the value of an unregistered expression"); + Unreachable() << "Asking for the value of an unregistered expression"; } else { @@ -1702,7 +1707,7 @@ Node FpConverter::getValue(Valuation &val, TNode var) if (i == f.end()) { - Unreachable("Asking for the value of an unregistered expression"); + Unreachable() << "Asking for the value of an unregistered expression"; } else { @@ -1712,15 +1717,15 @@ Node FpConverter::getValue(Valuation &val, TNode var) } else { - Unreachable( - "Asking for the value of a type that is not managed by the " - "floating-point theory"); + Unreachable() + << "Asking for the value of a type that is not managed by the " + "floating-point theory"; } - Unreachable("Unable to find value"); + Unreachable() << "Unable to find value"; #else - Unimplemented("Conversion is dependent on SymFPU"); + Unimplemented() << "Conversion is dependent on SymFPU"; #endif } diff --git a/src/theory/fp/fp_converter.h b/src/theory/fp/fp_converter.h index 753030408..8ff5293e2 100644 --- a/src/theory/fp/fp_converter.h +++ b/src/theory/fp/fp_converter.h @@ -21,7 +21,7 @@ #ifndef CVC4__THEORY__FP__FP_CONVERTER_H #define CVC4__THEORY__FP__FP_CONVERTER_H -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/cdhashmap.h" #include "context/cdlist.h" #include "expr/node.h" diff --git a/src/theory/fp/theory_fp.cpp b/src/theory/fp/theory_fp.cpp index 2c93553fe..fa143a1d0 100644 --- a/src/theory/fp/theory_fp.cpp +++ b/src/theory/fp/theory_fp.cpp @@ -72,7 +72,7 @@ Node removeToFPGeneric(TNode node) { return nm->mkNode(op, node[0], node[1]); } - Unreachable("to_fp generic not rewritten"); + Unreachable() << "to_fp generic not rewritten"; } } // namespace removeToFPGeneric @@ -736,7 +736,7 @@ bool TheoryFp::refineAbstraction(TheoryModel *m, TNode abstract, TNode concrete) } else { - Unreachable("Unknown abstraction"); + Unreachable() << "Unknown abstraction"; } return false; @@ -863,7 +863,7 @@ void TheoryFp::registerTerm(TNode node) { } else { - Unreachable("Only isNaN, isInf and isZero have aliases"); + Unreachable() << "Only isNaN, isInf and isZero have aliases"; } handleLemma(nm->mkNode(kind::EQUAL, node, equalityAlias)); @@ -965,12 +965,12 @@ void TheoryFp::check(Effort level) { TNode predicate = negated ? fact[0] : fact; if (predicate.getKind() == kind::EQUAL) { - Assert(!(predicate[0].getType().isFloatingPoint() || - predicate[0].getType().isRoundingMode()) || - isRegistered(predicate[0])); - Assert(!(predicate[1].getType().isFloatingPoint() || - predicate[1].getType().isRoundingMode()) || - isRegistered(predicate[1])); + Assert(!(predicate[0].getType().isFloatingPoint() + || predicate[0].getType().isRoundingMode()) + || isRegistered(predicate[0])); + Assert(!(predicate[1].getType().isFloatingPoint() + || predicate[1].getType().isRoundingMode()) + || isRegistered(predicate[1])); registerTerm(predicate); // Needed for float equalities if (negated) { diff --git a/src/theory/fp/theory_fp_rewriter.cpp b/src/theory/fp/theory_fp_rewriter.cpp index 68ea01eb8..7f5ce4afb 100644 --- a/src/theory/fp/theory_fp_rewriter.cpp +++ b/src/theory/fp/theory_fp_rewriter.cpp @@ -32,7 +32,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "theory/fp/fp_converter.h" #include "theory/fp/theory_fp_rewriter.h" @@ -54,7 +54,8 @@ namespace rewrite { } RewriteResponse notFP (TNode node, bool) { - Unreachable("non floating-point kind (%d) in floating point rewrite?",node.getKind()); + Unreachable() << "non floating-point kind (" << node.getKind() + << ") in floating point rewrite?"; } RewriteResponse identity (TNode node, bool) { @@ -62,7 +63,8 @@ namespace rewrite { } RewriteResponse type (TNode node, bool) { - Unreachable("sort kind (%d) found in expression?",node.getKind()); + Unreachable() << "sort kind (" << node.getKind() + << ") found in expression?"; } RewriteResponse removeDoubleNegation (TNode node, bool) { @@ -98,12 +100,9 @@ namespace rewrite { Assert(isPreRewrite); // Should be run first Kind k = node.getKind(); - Assert(k == kind::FLOATINGPOINT_EQ || - k == kind::FLOATINGPOINT_GEQ || - k == kind::FLOATINGPOINT_LEQ || - k == kind::FLOATINGPOINT_GT || - k == kind::FLOATINGPOINT_LT); - + Assert(k == kind::FLOATINGPOINT_EQ || k == kind::FLOATINGPOINT_GEQ + || k == kind::FLOATINGPOINT_LEQ || k == kind::FLOATINGPOINT_GT + || k == kind::FLOATINGPOINT_LT); size_t children = node.getNumChildren(); if (children > 2) { @@ -153,27 +152,30 @@ namespace rewrite { return RewriteResponse(REWRITE_DONE,NodeManager::currentNM()->mkNode(kind::FLOATINGPOINT_LT,node[1],node[0])); } - RewriteResponse removed (TNode node, bool) { - Unreachable("kind (%s) should have been removed?",kindToString(node.getKind()).c_str()); + RewriteResponse removed(TNode node, bool) + { + Unreachable() << "kind (" << node.getKind() + << ") should have been removed?"; } RewriteResponse variable (TNode node, bool) { // We should only get floating point and rounding mode variables to rewrite. TypeNode tn = node.getType(true); Assert(tn.isFloatingPoint() || tn.isRoundingMode()); - + // Not that we do anything with them... return RewriteResponse(REWRITE_DONE, node); } RewriteResponse equal (TNode node, bool isPreRewrite) { Assert(node.getKind() == kind::EQUAL); - + // We should only get equalities of floating point or rounding mode types. TypeNode tn = node[0].getType(true); Assert(tn.isFloatingPoint() || tn.isRoundingMode()); - Assert(tn == node[1].getType(true)); // Should be ensured by the typing rules + Assert(tn + == node[1].getType(true)); // Should be ensured by the typing rules if (node[0] == node[1]) { return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(true)); @@ -191,8 +193,9 @@ namespace rewrite { RewriteResponse compactMinMax (TNode node, bool isPreRewrite) { #ifdef CVC4_ASSERTIONS Kind k = node.getKind(); - Assert((k == kind::FLOATINGPOINT_MIN) || (k == kind::FLOATINGPOINT_MAX) || - (k == kind::FLOATINGPOINT_MIN_TOTAL) || (k == kind::FLOATINGPOINT_MAX_TOTAL)); + Assert((k == kind::FLOATINGPOINT_MIN) || (k == kind::FLOATINGPOINT_MAX) + || (k == kind::FLOATINGPOINT_MIN_TOTAL) + || (k == kind::FLOATINGPOINT_MAX_TOTAL)); #endif if (node[0] == node[1]) { return RewriteResponse(REWRITE_AGAIN, node[0]); @@ -204,7 +207,7 @@ namespace rewrite { RewriteResponse reorderFPEquality (TNode node, bool isPreRewrite) { Assert(node.getKind() == kind::FLOATINGPOINT_EQ); - Assert(!isPreRewrite); // Likely redundant in pre-rewrite + Assert(!isPreRewrite); // Likely redundant in pre-rewrite if (node[0] > node[1]) { Node normal = NodeManager::currentNM()->mkNode(kind::FLOATINGPOINT_EQ,node[1],node[0]); @@ -217,7 +220,7 @@ namespace rewrite { RewriteResponse reorderBinaryOperation (TNode node, bool isPreRewrite) { Kind k = node.getKind(); Assert((k == kind::FLOATINGPOINT_PLUS) || (k == kind::FLOATINGPOINT_MULT)); - Assert(!isPreRewrite); // Likely redundant in pre-rewrite + Assert(!isPreRewrite); // Likely redundant in pre-rewrite if (node[1] > node[2]) { Node normal = NodeManager::currentNM()->mkNode(k,node[0],node[2],node[1]); @@ -229,7 +232,7 @@ namespace rewrite { RewriteResponse reorderFMA (TNode node, bool isPreRewrite) { Assert(node.getKind() == kind::FLOATINGPOINT_FMA); - Assert(!isPreRewrite); // Likely redundant in pre-rewrite + Assert(!isPreRewrite); // Likely redundant in pre-rewrite if (node[1] > node[2]) { Node normal = NodeManager::currentNM()->mkNode(kind::FLOATINGPOINT_FMA,node[0],node[2],node[1],node[3]); @@ -240,11 +243,11 @@ namespace rewrite { } RewriteResponse removeSignOperations (TNode node, bool isPreRewrite) { - Assert(node.getKind() == kind::FLOATINGPOINT_ISN || - node.getKind() == kind::FLOATINGPOINT_ISSN || - node.getKind() == kind::FLOATINGPOINT_ISZ || - node.getKind() == kind::FLOATINGPOINT_ISINF || - node.getKind() == kind::FLOATINGPOINT_ISNAN); + Assert(node.getKind() == kind::FLOATINGPOINT_ISN + || node.getKind() == kind::FLOATINGPOINT_ISSN + || node.getKind() == kind::FLOATINGPOINT_ISZ + || node.getKind() == kind::FLOATINGPOINT_ISINF + || node.getKind() == kind::FLOATINGPOINT_ISNAN); Assert(node.getNumChildren() == 1); Kind childKind(node[0].getKind()); @@ -325,7 +328,7 @@ namespace constantFold { RewriteResponse fpLiteral (TNode node, bool) { Assert(node.getKind() == kind::FLOATINGPOINT_FP); - + BitVector bv(node[0].getConst()); bv = bv.concat(node[1].getConst()); bv = bv.concat(node[2].getConst()); @@ -362,9 +365,9 @@ namespace constantFold { RoundingMode rm(node[0].getConst()); FloatingPoint arg1(node[1].getConst()); FloatingPoint arg2(node[2].getConst()); - + Assert(arg1.t == arg2.t); - + return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.plus(rm, arg2))); } @@ -375,9 +378,9 @@ namespace constantFold { RoundingMode rm(node[0].getConst()); FloatingPoint arg1(node[1].getConst()); FloatingPoint arg2(node[2].getConst()); - + Assert(arg1.t == arg2.t); - + return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.mult(rm, arg2))); } @@ -389,10 +392,10 @@ namespace constantFold { FloatingPoint arg1(node[1].getConst()); FloatingPoint arg2(node[2].getConst()); FloatingPoint arg3(node[3].getConst()); - + Assert(arg1.t == arg2.t); Assert(arg1.t == arg3.t); - + return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.fma(rm, arg2, arg3))); } @@ -403,9 +406,9 @@ namespace constantFold { RoundingMode rm(node[0].getConst()); FloatingPoint arg1(node[1].getConst()); FloatingPoint arg2(node[2].getConst()); - + Assert(arg1.t == arg2.t); - + return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.div(rm, arg2))); } @@ -435,9 +438,9 @@ namespace constantFold { FloatingPoint arg1(node[0].getConst()); FloatingPoint arg2(node[1].getConst()); - + Assert(arg1.t == arg2.t); - + return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.rem(arg2))); } @@ -447,7 +450,7 @@ namespace constantFold { FloatingPoint arg1(node[0].getConst()); FloatingPoint arg2(node[1].getConst()); - + Assert(arg1.t == arg2.t); FloatingPoint::PartialFloatingPoint res(arg1.min(arg2)); @@ -467,7 +470,7 @@ namespace constantFold { FloatingPoint arg1(node[0].getConst()); FloatingPoint arg2(node[1].getConst()); - + Assert(arg1.t == arg2.t); FloatingPoint::PartialFloatingPoint res(arg1.max(arg2)); @@ -544,16 +547,16 @@ namespace constantFold { RewriteResponse equal (TNode node, bool isPreRewrite) { Assert(node.getKind() == kind::EQUAL); - + // We should only get equalities of floating point or rounding mode types. TypeNode tn = node[0].getType(true); if (tn.isFloatingPoint()) { FloatingPoint arg1(node[0].getConst()); FloatingPoint arg2(node[1].getConst()); - + Assert(arg1.t == arg2.t); - + return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1 == arg2)); } else if (tn.isRoundingMode()) { @@ -563,7 +566,7 @@ namespace constantFold { return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1 == arg2)); } - Unreachable("Equality of unknown type"); + Unreachable() << "Equality of unknown type"; } @@ -573,9 +576,9 @@ namespace constantFold { FloatingPoint arg1(node[0].getConst()); FloatingPoint arg2(node[1].getConst()); - + Assert(arg1.t == arg2.t); - + return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1 <= arg2)); } @@ -586,9 +589,9 @@ namespace constantFold { FloatingPoint arg1(node[0].getConst()); FloatingPoint arg2(node[1].getConst()); - + Assert(arg1.t == arg2.t); - + return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1 < arg2)); } @@ -670,7 +673,7 @@ namespace constantFold { RewriteResponse convertFromRealLiteral (TNode node, bool) { Assert(node.getKind() == kind::FLOATINGPOINT_TO_FP_REAL); - + TNode op = node.getOperator(); const FloatingPointToFPReal ¶m = op.getConst(); @@ -686,7 +689,7 @@ namespace constantFold { RewriteResponse convertFromSBV (TNode node, bool) { Assert(node.getKind() == kind::FLOATINGPOINT_TO_FP_SIGNED_BITVECTOR); - + TNode op = node.getOperator(); const FloatingPointToFPSignedBitVector ¶m = op.getConst(); @@ -702,7 +705,7 @@ namespace constantFold { RewriteResponse convertFromUBV (TNode node, bool) { Assert(node.getKind() == kind::FLOATINGPOINT_TO_FP_UNSIGNED_BITVECTOR); - + TNode op = node.getOperator(); const FloatingPointToFPUnsignedBitVector ¶m = op.getConst(); @@ -718,7 +721,7 @@ namespace constantFold { RewriteResponse convertToUBV (TNode node, bool) { Assert(node.getKind() == kind::FLOATINGPOINT_TO_UBV); - + TNode op = node.getOperator(); const FloatingPointToUBV ¶m = op.getConst(); @@ -738,7 +741,7 @@ namespace constantFold { RewriteResponse convertToSBV (TNode node, bool) { Assert(node.getKind() == kind::FLOATINGPOINT_TO_SBV); - + TNode op = node.getOperator(); const FloatingPointToSBV ¶m = op.getConst(); @@ -758,7 +761,7 @@ namespace constantFold { RewriteResponse convertToReal (TNode node, bool) { Assert(node.getKind() == kind::FLOATINGPOINT_TO_REAL); - + FloatingPoint arg(node[0].getConst()); FloatingPoint::PartialRational res(arg.convertToRational()); @@ -887,7 +890,7 @@ namespace constantFold { result = arg0.getLiteral().sign; break; #endif - default: Unreachable("Unknown kind used in componentFlag"); break; + default: Unreachable() << "Unknown kind used in componentFlag"; break; } BitVector res(1U, (result) ? 1U : 0U); @@ -962,7 +965,7 @@ namespace constantFold { break; default: - Unreachable("Unknown rounding mode in roundingModeBitBlast"); + Unreachable() << "Unknown rounding mode in roundingModeBitBlast"; break; } #else diff --git a/src/theory/fp/type_enumerator.h b/src/theory/fp/type_enumerator.h index 4494fd40f..bb109f823 100644 --- a/src/theory/fp/type_enumerator.h +++ b/src/theory/fp/type_enumerator.h @@ -114,9 +114,7 @@ class RoundingModeEnumerator case roundNearestTiesToAway: d_enumerationComplete = true; break; - default: - Unreachable("Unknown rounding mode?"); - break; + default: Unreachable() << "Unknown rounding mode?"; break; } return *this; } diff --git a/src/theory/logic_info.cpp b/src/theory/logic_info.cpp index 34ea5f9b1..9fd28e8dc 100644 --- a/src/theory/logic_info.cpp +++ b/src/theory/logic_info.cpp @@ -22,10 +22,9 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/kind.h" - using namespace std; using namespace CVC4::theory; @@ -334,8 +333,9 @@ std::string LogicInfo::getLogicString() const { ++seen; } if(seen != d_sharingTheories) { - Unhandled("can't extract a logic string from LogicInfo; at least one " - "active theory is unknown to LogicInfo::getLogicString() !"); + Unhandled() + << "can't extract a logic string from LogicInfo; at least one " + "active theory is unknown to LogicInfo::getLogicString() !"; } if(seen == 0) { diff --git a/src/theory/output_channel.h b/src/theory/output_channel.h index 347177b93..bcbbfa274 100644 --- a/src/theory/output_channel.h +++ b/src/theory/output_channel.h @@ -21,7 +21,6 @@ #include -#include "base/cvc4_assert.h" #include "proof/proof_manager.h" #include "smt/logic_exception.h" #include "theory/interrupted.h" diff --git a/src/theory/quantifiers/alpha_equivalence.cpp b/src/theory/quantifiers/alpha_equivalence.cpp index 9d516de61..9e6e4842f 100644 --- a/src/theory/quantifiers/alpha_equivalence.cpp +++ b/src/theory/quantifiers/alpha_equivalence.cpp @@ -85,7 +85,7 @@ Node AlphaEquivalenceTypeNode::registerNode(Node q, while (index < typs.size()) { TypeNode curr = typs[index]; - Assert( typ_count.find( curr )!=typ_count.end() ); + Assert(typ_count.find(curr) != typ_count.end()); Trace("aeq-debug") << "[" << curr << " " << typ_count[curr] << "] "; aetn = &(aetn->d_children[curr][typ_count[curr]]); index = index + 1; @@ -96,7 +96,7 @@ Node AlphaEquivalenceTypeNode::registerNode(Node q, Node AlphaEquivalenceDb::addTerm(Node q) { - Assert( q.getKind()==FORALL ); + Assert(q.getKind() == FORALL); Trace("aeq") << "Alpha equivalence : register " << q << std::endl; //construct canonical quantified formula Node t = d_tc->getCanonicalTerm(q[1], true); diff --git a/src/theory/quantifiers/anti_skolem.cpp b/src/theory/quantifiers/anti_skolem.cpp index d972f2a1c..cdb15b349 100644 --- a/src/theory/quantifiers/anti_skolem.cpp +++ b/src/theory/quantifiers/anti_skolem.cpp @@ -37,7 +37,7 @@ struct sortTypeOrder { void QuantAntiSkolem::SkQuantTypeCache::add( std::vector< TypeNode >& typs, Node q, unsigned index ) { if( index==typs.size() ){ - Assert( std::find( d_quants.begin(), d_quants.end(), q )==d_quants.end() ); + Assert(std::find(d_quants.begin(), d_quants.end(), q) == d_quants.end()); d_quants.push_back( q ); }else{ d_children[typs[index]].add( typs, q, index+1 ); @@ -134,12 +134,12 @@ void QuantAntiSkolem::check(Theory::Effort e, QEffort quant_e) for( unsigned j=0; j& quants, bool pconnected ) { - Assert( !quants.empty() ); + Assert(!quants.empty()); std::sort( quants.begin(), quants.end() ); if( d_sqc->add( d_quantEngine->getUserContext(), quants ) ){ //partition into connected components @@ -190,7 +190,7 @@ bool QuantAntiSkolem::sendAntiSkolemizeLemma( std::vector< Node >& quants, bool eqcs.push_back( func_to_eqc[f] ); } } - Assert( !eqcs.empty() ); + Assert(!eqcs.empty()); //merge equivalence classes int id = eqcs[0]; eqc_to_quant[id].push_back( q ); @@ -214,7 +214,7 @@ bool QuantAntiSkolem::sendAntiSkolemizeLemma( std::vector< Node >& quants, bool if( eqc_to_quant.size()>1 ){ bool addedLemma = false; for( std::map< int, std::vector< Node > >::iterator it = eqc_to_quant.begin(); it != eqc_to_quant.end(); ++it ){ - Assert( it->second.size()second.size() < quants.size()); bool ret = sendAntiSkolemizeLemma( it->second, false ); addedLemma = addedLemma || ret; } @@ -245,7 +245,7 @@ bool QuantAntiSkolem::sendAntiSkolemizeLemma( std::vector< Node >& quants, bool std::vector< Node > subs_lhs; std::vector< Node > subs_rhs; //get outer variable substitution - Assert( d_ask_types_index[q].size()==d_ask_types[q].size() ); + Assert(d_ask_types_index[q].size() == d_ask_types[q].size()); std::vector sivars; d_quant_sip[q].getSingleInvocationVariables(sivars); for (unsigned j = 0, size = d_ask_types_index[q].size(); j < size; j++) diff --git a/src/theory/quantifiers/cegqi/ceg_instantiator.cpp b/src/theory/quantifiers/cegqi/ceg_instantiator.cpp index c52666dad..bed382e28 100644 --- a/src/theory/quantifiers/cegqi/ceg_instantiator.cpp +++ b/src/theory/quantifiers/cegqi/ceg_instantiator.cpp @@ -479,7 +479,7 @@ void CegInstantiator::activateInstantiationVariable(Node v, unsigned index) if( tn.isReal() ){ vinst = new ArithInstantiator(tn, d_parent->getVtsTermCache()); }else if( tn.isSort() ){ - Assert( options::quantEpr() ); + Assert(options::quantEpr()); vinst = new EprInstantiator(tn); }else if( tn.isDatatype() ){ vinst = new DtInstantiator(tn); @@ -622,7 +622,7 @@ bool CegInstantiator::constructInstantiation(SolvedForm& sf, unsigned i) //get the instantiator object Assert(d_instantiator.find(pv) != d_instantiator.end()); Instantiator* vinst = d_instantiator[pv]; - Assert( vinst!=NULL ); + Assert(vinst != NULL); d_active_instantiators[pv] = vinst; vinst->reset(this, sf, pv, d_effort); // if d_effort is full, we must choose at least one model value @@ -656,7 +656,7 @@ bool CegInstantiator::constructInstantiation(SolvedForm& sf, unsigned i) && d_qe->getLogicInfo().isLinear()) { Trace("cbqi-warn") << "Had to resort to model value." << std::endl; - Assert( false ); + Assert(false); } #endif Node mv = getModelValue( pv ); @@ -940,7 +940,7 @@ void CegInstantiator::pushStackVariable( Node v ) { } void CegInstantiator::popStackVariable() { - Assert( !d_stack_vars.empty() ); + Assert(!d_stack_vars.empty()); d_stack_vars.pop_back(); } @@ -961,11 +961,11 @@ bool CegInstantiator::constructInstantiationInc(Node pv, << ") "; Node mod_pv = pv_prop.getModifiedTerm( pv ); Trace("cbqi-inst-debug") << mod_pv << " -> " << n << std::endl; - Assert( n.getType().isSubtypeOf( pv.getType() ) ); + Assert(n.getType().isSubtypeOf(pv.getType())); } //must ensure variables have been computed for n computeProgVars( n ); - Assert( d_inelig.find( n )==d_inelig.end() ); + Assert(d_inelig.find(n) == d_inelig.end()); //substitute into previous substitutions, when applicable std::vector< Node > a_var; @@ -986,7 +986,7 @@ bool CegInstantiator::constructInstantiationInc(Node pv, Trace("cbqi-inst-debug2") << "Applying substitutions to previous substitution terms..." << std::endl; for( unsigned j=0; j& vars, std::vector for (unsigned i = 0, size = d_input_vars.size(); i < size; ++i) { std::map::iterator it = subs_map.find(d_input_vars[i]); - Assert( it!=subs_map.end() ); + Assert(it != subs_map.end()); Node n = it->second; Trace("cbqi-inst-debug") << " " << d_input_vars[i] << " -> " << n << std::endl; @@ -1144,7 +1147,7 @@ bool CegInstantiator::isEligibleForInstantiation(Node n) const } bool CegInstantiator::canApplyBasicSubstitution( Node n, std::vector< Node >& non_basic ){ - Assert( d_prog_var.find( n )!=d_prog_var.end() ); + Assert(d_prog_var.find(n) != d_prog_var.end()); if( !non_basic.empty() ){ for (std::unordered_set::iterator it = d_prog_var[n].begin(); @@ -1163,13 +1166,13 @@ bool CegInstantiator::canApplyBasicSubstitution( Node n, std::vector< Node >& no Node CegInstantiator::applySubstitution( TypeNode tn, Node n, std::vector< Node >& vars, std::vector< Node >& subs, std::vector< TermProperties >& prop, std::vector< Node >& non_basic, TermProperties& pv_prop, bool try_coeff ) { computeProgVars( n ); - Assert( n==Rewriter::rewrite( n ) ); + Assert(n == Rewriter::rewrite(n)); bool is_basic = canApplyBasicSubstitution( n, non_basic ); if( Trace.isOn("cegqi-si-apply-subs-debug") ){ Trace("cegqi-si-apply-subs-debug") << "is_basic = " << is_basic << " " << tn << std::endl; for( unsigned i=0; i " << subs[i] << " types : " << vars[i].getType() << " -> " << subs[i].getType() << std::endl; - Assert( subs[i].getType().isSubtypeOf( vars[i].getType() ) ); + Assert(subs[i].getType().isSubtypeOf(vars[i].getType())); } } Node nret; @@ -1182,8 +1185,8 @@ Node CegInstantiator::applySubstitution( TypeNode tn, Node n, std::vector< Node std::vector< Node > nsubs; for( unsigned i=0; imkNode( MULT, subs[i], NodeManager::currentNM()->mkConst( Rational(1)/prop[i].d_coeff.getConst() ) ); nn = NodeManager::currentNM()->mkNode( kind::TO_INTEGER, nn ); nn = Rewriter::rewrite( nn ); @@ -1238,7 +1241,7 @@ Node CegInstantiator::applySubstitution( TypeNode tn, Node n, std::vector< Node if( !it->second.isNull() ){ c_coeff = NodeManager::currentNM()->mkNode( MULT, c_coeff, it->second ); } - Assert( !c_coeff.isNull() ); + Assert(!c_coeff.isNull()); Node c; if( msum_term[it->first].isNull() ){ c = c_coeff; @@ -1285,7 +1288,7 @@ Node CegInstantiator::applySubstitutionToLiteral( Node lit, std::vector< Node >& bool pol = lit.getKind()!=NOT; //arithmetic inequalities and disequalities if( atom.getKind()==GEQ || ( atom.getKind()==EQUAL && !pol && atom[0].getType().isReal() ) ){ - Assert( atom.getKind()!=GEQ || atom[1].isConst() ); + Assert(atom.getKind() != GEQ || atom[1].isConst()); Node atom_lhs; Node atom_rhs; if( atom.getKind()==GEQ ){ @@ -1512,7 +1515,7 @@ void CegInstantiator::processAssertions() { addToAuxVarSubstitution( subs_lhs, subs_rhs, r, it->second ); }else{ Trace("cbqi-proc") << "....no substitution found for auxiliary variable " << r << "!!! type is " << r.getType() << std::endl; - Assert( false ); + Assert(false); } } diff --git a/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp b/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp index 7f9c21a65..0ec87f239 100644 --- a/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp +++ b/src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp @@ -121,7 +121,7 @@ bool InstStrategyCegqi::registerCbqiLemma(Node q) //add totality lemma std::map< TypeNode, std::vector< Node > >::iterator itc = qepr->d_consts.find( tn ); if( itc!=qepr->d_consts.end() ){ - Assert( !itc->second.empty() ); + Assert(!itc->second.empty()); Node ic = d_quantEngine->getTermUtil()->getInstantiationConstant( q, i ); std::vector< Node > disj; for( unsigned j=0; jsecond.size(); j++ ){ @@ -131,10 +131,10 @@ bool InstStrategyCegqi::registerCbqiLemma(Node q) Trace("cbqi-lemma") << "EPR totality lemma : " << tlem << std::endl; d_quantEngine->getOutputChannel().lemma( tlem ); }else{ - Assert( false ); + Assert(false); } }else{ - Assert( !options::cbqiAll() ); + Assert(!options::cbqiAll()); } } } @@ -152,7 +152,7 @@ bool InstStrategyCegqi::registerCbqiLemma(Node q) if( std::find( d_parent_quant[q].begin(), d_parent_quant[q].end(), qi )==d_parent_quant[q].end() ){ d_parent_quant[q].push_back( qi ); d_children_quant[qi].push_back( q ); - Assert( hasAddedCbqiLemma( qi ) ); + Assert(hasAddedCbqiLemma(qi)); Node qicel = getCounterexampleLiteral(qi); dep.push_back( qi ); dep.push_back( qicel ); @@ -221,7 +221,7 @@ void InstStrategyCegqi::reset_round(Theory::Effort effort) Node q = d_quantEngine->getModel()->getAssertedQuantifier( i ); //it is not active if it corresponds to a rewrite rule: we will process in rewrite engine if( doCbqi( q ) ){ - Assert( hasAddedCbqiLemma( q ) ); + Assert(hasAddedCbqiLemma(q)); if( d_quantEngine->getModel()->isQuantifierActive( q ) ){ d_active_quant[q] = true; Debug("cbqi-debug") << "Check quantified formula " << q << "..." << std::endl; @@ -242,8 +242,8 @@ void InstStrategyCegqi::reset_round(Theory::Effort effort) //process from waitlist while( d_nested_qe_waitlist_proc[q]=0 ); - Assert( index<(int)d_nested_qe_waitlist[q].size() ); + Assert(index >= 0); + Assert(index < (int)d_nested_qe_waitlist[q].size()); Node nq = d_nested_qe_waitlist[q][index]; Node nqeqn = doNestedQENode( d_nested_qe_info[nq].d_q, q, nq, d_nested_qe_info[nq].d_inst_terms, d_nested_qe_info[nq].d_doVts ); Node dqelem = nq.eqNode( nqeqn ); @@ -279,10 +279,10 @@ void InstStrategyCegqi::reset_round(Theory::Effort effort) } Trace("cbqi-debug") << "Found " << ninner.size() << " non-innermost." << std::endl; for( unsigned i=0; iinConflict() ); + Assert(!d_quantEngine->inConflict()); double clSet = 0; if( Trace.isOn("cbqi-engine") ){ clSet = double(clock())/double(CLOCKS_PER_SEC); @@ -314,7 +314,7 @@ void InstStrategyCegqi::check(Theory::Effort e, QEffort quant_e) } }else{ Trace("cbqi-warn") << "CBQI : Cannot process already eliminated quantified formula " << q << std::endl; - Assert( false ); + Assert(false); } } if( d_quantEngine->inConflict() || d_quantEngine->getNumLemmasWaiting()>lastWaiting ){ @@ -490,9 +490,10 @@ Node InstStrategyCegqi::doNestedQENode( Trace("cbqi-nqe") << " " << ceq << std::endl; Trace("cbqi-nqe") << " " << d_nested_qe[ceq] << std::endl; //should not contain quantifiers - Assert( !QuantifiersRewriter::containsQuantifiers( d_nested_qe[ceq] ) ); + Assert(!QuantifiersRewriter::containsQuantifiers(d_nested_qe[ceq])); } - Assert( d_quantEngine->getTermUtil()->d_inst_constants[q].size()==inst_terms.size() ); + Assert(d_quantEngine->getTermUtil()->d_inst_constants[q].size() + == inst_terms.size()); //replace inst constants with instantiation Node ret = d_nested_qe[ceq].substitute( d_quantEngine->getTermUtil()->d_inst_constants[q].begin(), d_quantEngine->getTermUtil()->d_inst_constants[q].end(), @@ -544,7 +545,7 @@ Node InstStrategyCegqi::doNestedQERec(Node q, d_nested_qe_info[nr].d_inst_terms.insert( d_nested_qe_info[nr].d_inst_terms.end(), inst_terms.begin(), inst_terms.end() ); d_nested_qe_info[nr].d_doVts = doVts; //TODO: ensure this holds by restricting prenex when cbqiNestedQe is true. - Assert( !options::cbqiInnermost() ); + Assert(!options::cbqiInnermost()); } } } @@ -665,7 +666,7 @@ Node InstStrategyCegqi::getCounterexampleLiteral(Node q) } bool InstStrategyCegqi::doAddInstantiation( std::vector< Node >& subs ) { - Assert( !d_curr_quant.isNull() ); + Assert(!d_curr_quant.isNull()); //if doing partial quantifier elimination, record the instantiation and set the incomplete flag instead of sending instantiation lemma if( d_quantEngine->getQuantAttributes()->isQuantElimPartial( d_curr_quant ) ){ d_cbqi_set_quant_inactive = true; diff --git a/src/theory/quantifiers/conjecture_generator.cpp b/src/theory/quantifiers/conjecture_generator.cpp index 400db4a8e..bdab6810c 100644 --- a/src/theory/quantifiers/conjecture_generator.cpp +++ b/src/theory/quantifiers/conjecture_generator.cpp @@ -42,7 +42,7 @@ struct sortConjectureScore { void OpArgIndex::addTerm( std::vector< TNode >& terms, TNode n, unsigned index ){ if( index==n.getNumChildren() ){ - Assert( n.hasOperator() ); + Assert(n.hasOperator()); if( std::find( d_ops.begin(), d_ops.end(), n.getOperator() )==d_ops.end() ){ d_ops.push_back( n.getOperator() ); d_op_terms.push_back( n ); @@ -188,12 +188,12 @@ void ConjectureGenerator::setUniversalRelevant( TNode n ) { bool ConjectureGenerator::isUniversalLessThan( TNode rt1, TNode rt2 ) { //prefer the one that is (normal, smaller) lexographically - Assert( d_pattern_is_relevant.find( rt1 )!=d_pattern_is_relevant.end() ); - Assert( d_pattern_is_relevant.find( rt2 )!=d_pattern_is_relevant.end() ); - Assert( d_pattern_is_normal.find( rt1 )!=d_pattern_is_normal.end() ); - Assert( d_pattern_is_normal.find( rt2 )!=d_pattern_is_normal.end() ); - Assert( d_pattern_fun_sum.find( rt1 )!=d_pattern_fun_sum.end() ); - Assert( d_pattern_fun_sum.find( rt2 )!=d_pattern_fun_sum.end() ); + Assert(d_pattern_is_relevant.find(rt1) != d_pattern_is_relevant.end()); + Assert(d_pattern_is_relevant.find(rt2) != d_pattern_is_relevant.end()); + Assert(d_pattern_is_normal.find(rt1) != d_pattern_is_normal.end()); + Assert(d_pattern_is_normal.find(rt2) != d_pattern_is_normal.end()); + Assert(d_pattern_fun_sum.find(rt1) != d_pattern_fun_sum.end()); + Assert(d_pattern_fun_sum.find(rt2) != d_pattern_fun_sum.end()); if( d_pattern_is_relevant[rt1] && !d_pattern_is_relevant[rt2] ){ Trace("thm-ee-debug") << "UEE : LT due to relevant." << std::endl; @@ -271,7 +271,7 @@ TNode ConjectureGenerator::getUniversalRepresentative( TNode n, bool add ) { if( d_urelevant_terms.find( eq_terms[i] )!=d_urelevant_terms.end() ){ assertEq = true; }else{ - Assert( eq_terms[i].getType()==tn ); + Assert(eq_terms[i].getType() == tn); registerPattern( eq_terms[i], tn ); if( isUniversalLessThan( eq_terms[i], t ) || ( options::conjectureUeeIntro() && d_pattern_fun_sum[t]>=d_pattern_fun_sum[eq_terms[i]] ) ){ setUniversalRelevant( eq_terms[i] ); @@ -409,8 +409,8 @@ void ConjectureGenerator::check(Theory::Effort e, QEffort quant_e) } ++eqcs_i; } - Assert( !d_bool_eqc[0].isNull() ); - Assert( !d_bool_eqc[1].isNull() ); + Assert(!d_bool_eqc[0].isNull()); + Assert(!d_bool_eqc[1].isNull()); d_urelevant_terms.clear(); Trace("sg-proc") << "...done get eq classes" << std::endl; @@ -675,7 +675,10 @@ void ConjectureGenerator::check(Theory::Effort e, QEffort quant_e) //add information about pattern Trace("sg-gen-tg-debug") << "Collect pattern information..." << std::endl; - Assert( std::find( d_rel_patterns[tnn].begin(), d_rel_patterns[tnn].end(), nn )==d_rel_patterns[tnn].end() ); + Assert(std::find(d_rel_patterns[tnn].begin(), + d_rel_patterns[tnn].end(), + nn) + == d_rel_patterns[tnn].end()); d_rel_patterns[tnn].push_back( nn ); //build information concerning the variables in this pattern unsigned sum = 0; @@ -695,7 +698,7 @@ void ConjectureGenerator::check(Theory::Effort e, QEffort quant_e) d_rel_pattern_var_sum[nn] = sum; //register the pattern registerPattern( nn, tnn ); - Assert( d_pattern_is_normal[nn] ); + Assert(d_pattern_is_normal[nn]); Trace("sg-gen-tg-debug") << "...done collect pattern information" << std::endl; //record information about types @@ -739,7 +742,7 @@ void ConjectureGenerator::check(Theory::Effort e, QEffort quant_e) Trace("sg-rel-term-debug") << " "; } Trace("sg-rel-term-debug") << it->first << ":x" << it2->first << " -> " << it2->second; - Assert( tindex+it2->firstfirst < gsubs_terms.size()); gsubs_terms[tindex+it2->first] = it2->second; } } @@ -787,7 +790,7 @@ void ConjectureGenerator::check(Theory::Effort e, QEffort quant_e) if( considerTermCanon( rhs, false ) ){ Trace("sg-rel-prop") << "Relevant RHS : " << rhs << std::endl; //register pattern - Assert( rhs.getType()==rt_types[i] ); + Assert(rhs.getType() == rt_types[i]); registerPattern( rhs, rt_types[i] ); if( rdepth mnvn; @@ -1034,11 +1037,11 @@ bool ConjectureGenerator::isGeneralization( TNode patg, TNode pat, std::map< TNo return true; } }else{ - Assert( patg.hasOperator() ); + Assert(patg.hasOperator()); if( !pat.hasOperator() || patg.getOperator()!=pat.getOperator() ){ return false; }else{ - Assert( patg.getNumChildren()==pat.getNumChildren() ); + Assert(patg.getNumChildren() == pat.getNumChildren()); for( unsigned i=0; igetEnumerateTerm(types[i], vec[i]); - Assert( !nn.isNull() ); - Assert( nn.getType()==n[i].getType() ); + Assert(!nn.isNull()); + Assert(nn.getType() == n[i].getType()); children.push_back( nn ); } children.push_back( lc ); @@ -1233,7 +1236,7 @@ void ConjectureGenerator::processCandidateConjecture( TNode lhs, TNode rhs, unsi } int ConjectureGenerator::considerCandidateConjecture( TNode lhs, TNode rhs ) { - Assert( lhs.getType()==rhs.getType() ); + Assert(lhs.getType() == rhs.getType()); Trace("sg-cconj-debug") << "Consider candidate conjecture : " << lhs << " == " << rhs << "?" << std::endl; if( lhs==rhs ){ @@ -1288,7 +1291,7 @@ int ConjectureGenerator::considerCandidateConjecture( TNode lhs, TNode rhs ) { Trace("sg-cconj") << "Consider possible candidate conjecture : " << lhs << " == " << rhs << "?" << std::endl; //find witness for counterexample, if possible if( options::conjectureFilterModel() ){ - Assert( d_rel_pattern_var_sum.find( lhs )!=d_rel_pattern_var_sum.end() ); + Assert(d_rel_pattern_var_sum.find(lhs) != d_rel_pattern_var_sum.end()); Trace("sg-cconj-debug") << "Notify substitutions over " << d_rel_pattern_var_sum[lhs] << " variables." << std::endl; std::map< TNode, TNode > subs; d_subs_confirmCount = 0; @@ -1329,7 +1332,7 @@ bool ConjectureGenerator::notifySubstitution( TNode glhs, std::map< TNode, TNode if( Trace.isOn("sg-cconj-debug") ){ Trace("sg-cconj-debug") << "Ground eqc for LHS : " << glhs << ", based on substituion: " << std::endl; for( std::map< TNode, TNode >::iterator it = subs.begin(); it != subs.end(); ++it ){ - Assert( getRepresentative( it->second )==it->second ); + Assert(getRepresentative(it->second) == it->second); Trace("sg-cconj-debug") << " " << it->first << " -> " << it->second << std::endl; } } @@ -1398,7 +1401,7 @@ bool ConjectureGenerator::notifySubstitution( TNode glhs, std::map< TNode, TNode void TermGenerator::reset( TermGenEnv * s, TypeNode tn ) { - Assert( d_children.empty() ); + Assert(d_children.empty()); d_typ = tn; d_status = 0; d_status_num = 0; @@ -1496,14 +1499,14 @@ bool TermGenerator::getNextTerm( TermGenEnv * s, unsigned depth ) { return s->considerCurrentTermCanon( d_id ) ? true : getNextTerm( s, depth ); //return true; }else{ - Assert( d_status_child_num<(int)s->d_func_args[f].size() ); + Assert(d_status_child_num < (int)s->d_func_args[f].size()); if( d_status_child_num==(int)d_children.size() ){ d_children.push_back( s->d_tg_id ); - Assert( s->d_tg_alloc.find( s->d_tg_id )==s->d_tg_alloc.end() ); + Assert(s->d_tg_alloc.find(s->d_tg_id) == s->d_tg_alloc.end()); s->d_tg_alloc[d_children[d_status_child_num]].reset( s, s->d_func_args[f][d_status_child_num] ); return getNextTerm( s, depth ); }else{ - Assert( d_status_child_num+1==(int)d_children.size() ); + Assert(d_status_child_num + 1 == (int)d_children.size()); if( s->d_tg_alloc[d_children[d_status_child_num]].getNextTerm( s, depth-1 ) ){ d_status_child_num++; return getNextTerm( s, depth ); @@ -1520,7 +1523,7 @@ bool TermGenerator::getNextTerm( TermGenEnv * s, unsigned depth ) { }else if( d_status==1 || d_status==3 ){ if( d_status==1 ){ s->removeVar( d_typ ); - Assert( d_status_num==(int)s->d_var_id[d_typ] ); + Assert(d_status_num == (int)s->d_var_id[d_typ]); //check if there is only one feasible equivalence class. if so, don't make pattern any more specific. //unsigned i = s->d_ccand_eqc[0].size()-1; //if( s->d_ccand_eqc[0][i].size()==1 && s->d_ccand_eqc[1][i].empty() ){ @@ -1533,7 +1536,7 @@ bool TermGenerator::getNextTerm( TermGenEnv * s, unsigned depth ) { d_status_num = -1; return getNextTerm( s, depth ); }else{ - Assert( d_children.empty() ); + Assert(d_children.empty()); return false; } } @@ -1598,7 +1601,7 @@ bool TermGenerator::getNextMatch( TermGenEnv * s, TNode eqc, std::map< TypeNode, return false; } } - Assert( subs[d_typ].find( d_status_num )==subs[d_typ].end() ); + Assert(subs[d_typ].find(d_status_num) == subs[d_typ].end()); subs[d_typ][d_status_num] = eqc; return true; }else{ @@ -1612,9 +1615,9 @@ bool TermGenerator::getNextMatch( TermGenEnv * s, TNode eqc, std::map< TypeNode, }else if( d_status==2 ){ if( d_match_status==0 ){ d_match_status++; - Assert( d_status_num<(int)s->getNumTgVars( d_typ ) ); + Assert(d_status_num < (int)s->getNumTgVars(d_typ)); std::map< unsigned, TNode >::iterator it = subs[d_typ].find( d_status_num ); - Assert( it!=subs[d_typ].end() ); + Assert(it != subs[d_typ].end()); return it->second==eqc; }else{ return false; @@ -1630,7 +1633,7 @@ bool TermGenerator::getNextMatch( TermGenEnv * s, TNode eqc, std::map< TypeNode, if( d_match_status_child_num==0 ){ //initial binding TNode f = s->getTgFunc( d_typ, d_status_num ); - Assert( !eqc.isNull() ); + Assert(!eqc.isNull()); TNodeTrie* tat = s->getTermDatabase()->getTermArgTrie(eqc, f); if( tat ){ d_match_children.push_back( tat->d_data.begin() ); @@ -1646,7 +1649,7 @@ bool TermGenerator::getNextMatch( TermGenEnv * s, TNode eqc, std::map< TypeNode, } } d_match_status++; - Assert( d_match_status_child_num+1==(int)d_match_children.size() ); + Assert(d_match_status_child_num + 1 == (int)d_match_children.size()); if( d_match_children[d_match_status_child_num]==d_match_children_end[d_match_status_child_num] ){ //no more arguments to bind d_match_children.pop_back(); @@ -1667,9 +1670,10 @@ bool TermGenerator::getNextMatch( TermGenEnv * s, TNode eqc, std::map< TypeNode, } } }else{ - Assert( d_match_status==1 ); - Assert( d_match_status_child_num+1==(int)d_match_children.size() ); - Assert( d_match_children[d_match_status_child_num]!=d_match_children_end[d_match_status_child_num] ); + Assert(d_match_status == 1); + Assert(d_match_status_child_num + 1 == (int)d_match_children.size()); + Assert(d_match_children[d_match_status_child_num] + != d_match_children_end[d_match_status_child_num]); d_match_status--; if( s->d_tg_alloc[d_children[d_match_status_child_num]].getNextMatch( s, d_match_children[d_match_status_child_num]->first, subs, rev_subs ) ){ d_match_status_child_num++; @@ -1681,7 +1685,7 @@ bool TermGenerator::getNextMatch( TermGenEnv * s, TNode eqc, std::map< TypeNode, } } } - Assert( false ); + Assert(false); return false; } @@ -1708,7 +1712,7 @@ unsigned TermGenerator::calculateGeneralizationDepth( TermGenEnv * s, std::map< } return sum; }else{ - Assert( d_status==2 || d_status==1 ); + Assert(d_status == 2 || d_status == 1); std::map< TypeNode, std::vector< int > >::iterator it = fvs.find( d_typ ); if( it!=fvs.end() ){ if( std::find( it->second.begin(), it->second.end(), d_status_num )!=it->second.end() ){ @@ -1731,7 +1735,7 @@ unsigned TermGenerator::getGeneralizationDepth( TermGenEnv * s ) { Node TermGenerator::getTerm( TermGenEnv * s ) { if( d_status==1 || d_status==2 ){ - Assert( !d_typ.isNull() ); + Assert(!d_typ.isNull()); return s->getFreeVar( d_typ, d_status_num ); }else if( d_status==5 ){ Node f = s->getTgFunc( d_typ, d_status_num ); @@ -1752,7 +1756,7 @@ Node TermGenerator::getTerm( TermGenEnv * s ) { return NodeManager::currentNM()->mkNode( s->d_func_kind[f], children ); } }else{ - Assert( false ); + Assert(false); } return Node::null(); } @@ -1833,7 +1837,7 @@ void TermGenEnv::collectSignatureInformation() { } void TermGenEnv::reset( unsigned depth, bool genRelevant, TypeNode tn ) { - Assert( d_tg_alloc.empty() ); + Assert(d_tg_alloc.empty()); d_tg_alloc.clear(); if( genRelevant ){ @@ -1852,7 +1856,8 @@ void TermGenEnv::reset( unsigned depth, bool genRelevant, TypeNode tn ) { bool TermGenEnv::getNextTerm() { if( d_tg_alloc[0].getNextTerm( this, d_tg_gdepth_limit ) ){ - Assert( (int)d_tg_alloc[0].getGeneralizationDepth( this )<=d_tg_gdepth_limit ); + Assert((int)d_tg_alloc[0].getGeneralizationDepth(this) + <= d_tg_gdepth_limit); if( (int)d_tg_alloc[0].getGeneralizationDepth( this )!=d_tg_gdepth_limit ){ return getNextTerm(); }else{ @@ -1919,7 +1924,7 @@ Node TermGenEnv::getFreeVar( TypeNode tn, unsigned i ) { } bool TermGenEnv::considerCurrentTerm() { - Assert( !d_tg_alloc.empty() ); + Assert(!d_tg_alloc.empty()); //if generalization depth is too large, don't consider it unsigned i = d_tg_alloc.size(); @@ -1954,10 +1959,10 @@ bool TermGenEnv::considerCurrentTerm() { Trace("sg-gen-tg-debug") << "Filter based on relevant ground EQC"; Trace("sg-gen-tg-debug") << ", #eqc to try = " << d_ccand_eqc[0][i-1].size() << "/" << d_ccand_eqc[1][i-1].size() << std::endl; - Assert( d_ccand_eqc[0].size()>=2 ); - Assert( d_ccand_eqc[0].size()==d_ccand_eqc[1].size() ); - Assert( d_ccand_eqc[0].size()==d_tg_id+1 ); - Assert( d_tg_id==d_tg_alloc.size() ); + Assert(d_ccand_eqc[0].size() >= 2); + Assert(d_ccand_eqc[0].size() == d_ccand_eqc[1].size()); + Assert(d_ccand_eqc[0].size() == d_tg_id + 1); + Assert(d_tg_id == d_tg_alloc.size()); for( unsigned r=0; r<2; r++ ){ d_ccand_eqc[r][i].clear(); } @@ -2018,13 +2023,13 @@ void TermGenEnv::changeContext( bool add ) { d_ccand_eqc[r].pop_back(); } d_tg_id--; - Assert( d_tg_alloc.find( d_tg_id )!=d_tg_alloc.end() ); + Assert(d_tg_alloc.find(d_tg_id) != d_tg_alloc.end()); d_tg_alloc.erase( d_tg_id ); } } bool TermGenEnv::considerCurrentTermCanon( unsigned tg_id ){ - Assert( tg_id& vars, if( i==vars.size() ){ d_var = eqc; }else{ - Assert( d_var.isNull() || d_var==vars[i] ); + Assert(d_var.isNull() || d_var == vars[i]); d_var = vars[i]; d_children[terms[i]].addSubstitution( eqc, vars, terms, i+1 ); } @@ -2089,10 +2094,10 @@ void SubstitutionIndex::addSubstitution( TNode eqc, std::vector< TNode >& vars, bool SubstitutionIndex::notifySubstitutions( ConjectureGenerator * s, std::map< TNode, TNode >& subs, TNode rhs, unsigned numVars, unsigned i ) { if( i==numVars ){ - Assert( d_children.empty() ); + Assert(d_children.empty()); return s->notifySubstitution( d_var, subs, rhs ); }else{ - Assert( i==0 || !d_children.empty() ); + Assert(i == 0 || !d_children.empty()); for( std::map< TNode, SubstitutionIndex >::iterator it = d_children.begin(); it != d_children.end(); ++it ){ Trace("sg-cconj-debug2") << "Try " << d_var << " -> " << it->first << " (" << i << "/" << numVars << ")" << std::endl; subs[d_var] = it->first; @@ -2130,9 +2135,9 @@ void TheoremIndex::addTheoremNode( TNode curr, std::vector< TNode >& lhs_v, std: lhs_arg.push_back( 0 ); d_children[curr.getOperator()].addTheorem( lhs_v, lhs_arg, rhs ); }else{ - Assert( curr.getKind()==kind::BOUND_VARIABLE ); + Assert(curr.getKind() == kind::BOUND_VARIABLE); TypeNode tn = curr.getType(); - Assert( d_var[tn].isNull() || d_var[tn]==curr ); + Assert(d_var[tn].isNull() || d_var[tn] == curr); d_var[tn] = curr; d_children[curr].addTheorem( lhs_v, lhs_arg, rhs ); } @@ -2180,7 +2185,7 @@ void TheoremIndex::getEquivalentTermsNode( Node curr, std::vector< TNode >& n_v, std::map< TypeNode, TNode >::iterator itt = d_var.find( tn ); if( itt!=d_var.end() ){ Trace("thm-db-debug") << "Check for substitution with " << itt->second << "..." << std::endl; - Assert( curr.getType()==itt->second.getType() ); + Assert(curr.getType() == itt->second.getType()); //add to substitution if possible bool success = false; std::map< TNode, TNode >::iterator it = smap.find( itt->second ); diff --git a/src/theory/quantifiers/ematching/candidate_generator.cpp b/src/theory/quantifiers/ematching/candidate_generator.cpp index 3be1d4a4b..3a075ec8a 100644 --- a/src/theory/quantifiers/ematching/candidate_generator.cpp +++ b/src/theory/quantifiers/ematching/candidate_generator.cpp @@ -40,7 +40,7 @@ CandidateGeneratorQE::CandidateGeneratorQE(QuantifiersEngine* qe, Node pat) d_mode(cand_term_none) { d_op = qe->getTermDatabase()->getMatchOperator( pat ); - Assert( !d_op.isNull() ); + Assert(!d_op.isNull()); } void CandidateGeneratorQE::resetInstantiationRound(){ @@ -130,8 +130,7 @@ Node CandidateGeneratorQE::getNextCandidate(){ CandidateGeneratorQELitDeq::CandidateGeneratorQELitDeq( QuantifiersEngine* qe, Node mpat ) : CandidateGenerator( qe ), d_match_pattern( mpat ){ - - Assert( d_match_pattern.getKind()==EQUAL ); + Assert(d_match_pattern.getKind() == EQUAL); d_match_pattern_type = d_match_pattern[0].getType(); } @@ -161,7 +160,7 @@ Node CandidateGeneratorQELitDeq::getNextCandidate(){ CandidateGeneratorQEAll::CandidateGeneratorQEAll( QuantifiersEngine* qe, Node mpat ) : CandidateGenerator( qe ), d_match_pattern( mpat ){ d_match_pattern_type = mpat.getType(); - Assert( mpat.getKind()==INST_CONSTANT ); + Assert(mpat.getKind() == INST_CONSTANT); d_f = quantifiers::TermUtil::getInstConstAttr( mpat ); d_index = mpat.getAttribute(InstVarNumAttribute()); d_firstTime = false; diff --git a/src/theory/quantifiers/ematching/inst_match_generator.cpp b/src/theory/quantifiers/ematching/inst_match_generator.cpp index 9e76a6a31..e639dc446 100644 --- a/src/theory/quantifiers/ematching/inst_match_generator.cpp +++ b/src/theory/quantifiers/ematching/inst_match_generator.cpp @@ -43,7 +43,7 @@ InstMatchGenerator::InstMatchGenerator( Node pat ){ d_cg = NULL; d_needsReset = true; d_active_add = true; - Assert( quantifiers::TermUtil::hasInstConstAttr(pat) ); + Assert(quantifiers::TermUtil::hasInstConstAttr(pat)); d_pattern = pat; d_match_pattern = pat; d_match_pattern_type = pat.getType(); @@ -258,7 +258,7 @@ int InstMatchGenerator::getMatch( { Trace("matching") << "Matching " << t << " against pattern " << d_match_pattern << " (" << m << ")" << ", " << d_children.size() << ", pattern is " << d_pattern << std::endl; - Assert( !d_match_pattern.isNull() ); + Assert(!d_match_pattern.isNull()); if (d_cg == nullptr) { Trace("matching-fail") << "Internal error for match generator." << std::endl; @@ -270,10 +270,12 @@ int InstMatchGenerator::getMatch( //InstMatch prev( &m ); std::vector< int > prev; //if t is null - Assert( !t.isNull() ); - Assert( !quantifiers::TermUtil::hasInstConstAttr(t) ); - Assert( d_match_pattern.getKind()==INST_CONSTANT || t.getKind()==d_match_pattern.getKind() ); - Assert( !Trigger::isAtomicTrigger( d_match_pattern ) || t.getOperator()==d_match_pattern.getOperator() ); + Assert(!t.isNull()); + Assert(!quantifiers::TermUtil::hasInstConstAttr(t)); + Assert(d_match_pattern.getKind() == INST_CONSTANT + || t.getKind() == d_match_pattern.getKind()); + Assert(!Trigger::isAtomicTrigger(d_match_pattern) + || t.getOperator() == d_match_pattern.getOperator()); //first, check if ground arguments are not equal, or a match is in conflict Trace("matching-debug2") << "Setting immediate matches..." << std::endl; for (unsigned i = 0, size = d_match_pattern.getNumChildren(); i < size; i++) @@ -338,7 +340,7 @@ int InstMatchGenerator::getMatch( if( t.getType().isBoolean() ){ t_match = NodeManager::currentNM()->mkConst( !q->areEqual( qe->getTermUtil()->d_true, t ) ); }else{ - Assert( t.getType().isReal() ); + Assert(t.getType().isReal()); t_match = NodeManager::currentNM()->mkNode(PLUS, t, qe->getTermUtil()->d_one); } }else if( pat.getKind()==GEQ ){ @@ -467,7 +469,7 @@ int InstMatchGenerator::getNextMatch(Node f, //if t not null, try to fit it into match m if( !t.isNull() ){ if( d_curr_exclude_match.find( t )==d_curr_exclude_match.end() ){ - Assert( t.getType().isComparableTo( d_match_pattern_type ) ); + Assert(t.getType().isComparableTo(d_match_pattern_type)); Trace("matching-summary") << "Try " << d_match_pattern << " : " << t << std::endl; success = getMatch(f, t, m, qe, tparent); if( d_independent_gen && success<0 ){ @@ -533,11 +535,11 @@ InstMatchGenerator* InstMatchGenerator::mkInstMatchGenerator( Node q, Node pat, } InstMatchGenerator* InstMatchGenerator::mkInstMatchGeneratorMulti( Node q, std::vector< Node >& pats, QuantifiersEngine* qe ) { - Assert( pats.size()>1 ); + Assert(pats.size() > 1); InstMatchGeneratorMultiLinear * imgm = new InstMatchGeneratorMultiLinear( q, pats, qe ); std::vector< InstMatchGenerator* > gens; imgm->initialize(q, qe, gens); - Assert( gens.size()==pats.size() ); + Assert(gens.size() == pats.size()); std::vector< Node > patsn; std::map< Node, InstMatchGenerator * > pat_map_init; for( unsigned i=0; isetIndependent(); @@ -722,7 +724,7 @@ int InstMatchGeneratorMultiLinear::resetChildren( QuantifiersEngine* qe ){ } bool InstMatchGeneratorMultiLinear::reset( Node eqc, QuantifiersEngine* qe ) { - Assert( eqc.isNull() ); + Assert(eqc.isNull()); if( options::multiTriggerLinear() ){ return true; }else{ @@ -744,7 +746,7 @@ int InstMatchGeneratorMultiLinear::getNextMatch(Node q, } } Trace("multi-trigger-linear-debug") << "InstMatchGeneratorMultiLinear::getNextMatch : continue match " << std::endl; - Assert( d_next!=NULL ); + Assert(d_next != NULL); int ret_val = continueNextMatch(q, m, qe, tparent); if( ret_val>0 ){ Trace("multi-trigger-linear") << "Successful multi-trigger instantiation." << std::endl; @@ -924,7 +926,7 @@ void InstMatchGeneratorMulti::processNewInstantiations(QuantifiersEngine* qe, int endChildIndex, bool modEq) { - Assert( !qe->inConflict() ); + Assert(!qe->inConflict()); if( childIndex==endChildIndex ){ // m is an instantiation if (sendInstantiation(tparent, m)) @@ -1036,9 +1038,9 @@ InstMatchGeneratorSimple::InstMatchGeneratorSimple(Node q, if( d_match_pattern.getKind()==EQUAL ){ d_eqc = d_match_pattern[1]; d_match_pattern = d_match_pattern[0]; - Assert( !quantifiers::TermUtil::hasInstConstAttr( d_eqc ) ); + Assert(!quantifiers::TermUtil::hasInstConstAttr(d_eqc)); } - Assert( Trigger::isSimpleTrigger( d_match_pattern ) ); + Assert(Trigger::isSimpleTrigger(d_match_pattern)); for( unsigned i=0; id_data.empty() ); + Assert(!tat->d_data.empty()); TNode t = tat->getData(); Debug("simple-trigger") << "Actual term is " << t << std::endl; //convert to actual used terms @@ -1135,7 +1137,8 @@ void InstMatchGeneratorSimple::addInstantiations(InstMatch& m, Node t = tt.first; Node prev = m.get( v ); //using representatives, just check if equal - Assert( t.getType().isComparableTo( d_match_pattern_arg_types[argIndex] ) ); + Assert( + t.getType().isComparableTo(d_match_pattern_arg_types[argIndex])); if( prev.isNull() || prev==t ){ m.setValue( v, t); addInstantiations(m, qe, addedLemmas, argIndex + 1, &(tt.second)); diff --git a/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp b/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp index 876e4e369..3420f282d 100644 --- a/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp +++ b/src/theory/quantifiers/ematching/inst_strategy_e_matching.cpp @@ -125,7 +125,7 @@ int InstStrategyUserPatterns::process( Node f, Theory::Effort effort, int e ){ } void InstStrategyUserPatterns::addUserPattern( Node q, Node pat ){ - Assert( pat.getKind()==INST_PATTERN ); + Assert(pat.getKind() == INST_PATTERN); //add to generators bool usable = true; std::vector< Node > nodes; @@ -308,7 +308,7 @@ void InstStrategyAutoGenTriggers::generateTriggers( Node f ){ if( Trace.isOn("auto-gen-trigger-debug") ){ Trace("auto-gen-trigger-debug") << "Collected pat terms for " << bd << ", no-patterns : " << d_user_no_gen[f].size() << std::endl; for( unsigned i=0; i rmPatTermsF; int last_weight = -1; for( unsigned i=0; igetNumLemmasWaiting(); doInstantiationRound( e ); if( d_quantEngine->inConflict() ){ - Assert( d_quantEngine->getNumLemmasWaiting()>lastWaiting ); + Assert(d_quantEngine->getNumLemmasWaiting() > lastWaiting); Trace("inst-engine") << "Conflict, added lemmas = " << (d_quantEngine->getNumLemmasWaiting()-lastWaiting) << std::endl; }else if( d_quantEngine->hasAddedLemma() ){ Trace("inst-engine") << "Added lemmas = " << (d_quantEngine->getNumLemmasWaiting()-lastWaiting) << std::endl; diff --git a/src/theory/quantifiers/ematching/trigger.cpp b/src/theory/quantifiers/ematching/trigger.cpp index 201aad3a0..f539bccf5 100644 --- a/src/theory/quantifiers/ematching/trigger.cpp +++ b/src/theory/quantifiers/ematching/trigger.cpp @@ -144,7 +144,7 @@ bool Trigger::mkTriggerTerms( Node q, std::vector< Node >& nodes, unsigned n_var bool foundVar = false; for( unsigned j=0; jmkNode( MINUS, x, n[i] ); }else if( n.getKind()==MULT ){ - Assert( n[i].isConst() ); + Assert(n[i].isConst()); if( x.getType().isInteger() ){ Node coeff = NodeManager::currentNM()->mkConst( n[i].getConst().abs() ); if( !n[i].getConst().abs().isOne() ){ diff --git a/src/theory/quantifiers/equality_infer.cpp b/src/theory/quantifiers/equality_infer.cpp index ef80af5f5..66745c94a 100644 --- a/src/theory/quantifiers/equality_infer.cpp +++ b/src/theory/quantifiers/equality_infer.cpp @@ -97,7 +97,7 @@ Node EqualityInference::getMaster( Node t, EqcInfo * eqc, bool& updated, Node ne return t; } }else{ - Assert( d_eqci.find( eqc->d_master.get() )!=d_eqci.end() ); + Assert(d_eqci.find(eqc->d_master.get()) != d_eqci.end()); EqcInfo * eqc_m = d_eqci[eqc->d_master.get()]; Node m = getMaster( eqc->d_master.get(), eqc_m, updated, new_m ); eqc->d_master = m; @@ -141,7 +141,7 @@ void EqualityInference::eqNotifyNewClass(TNode t) { }else{ eqci = itec->second; } - Assert( !eqci->d_valid.get() ); + Assert(!eqci->d_valid.get()); if( !eqci->d_solved.get() ){ //somewhat strange: t may not be in rewritten form Node r = Rewriter::rewrite( t ); @@ -160,16 +160,16 @@ void EqualityInference::eqNotifyNewClass(TNode t) { BoolMap::const_iterator itv = d_elim_vars.find( n ); if( itv!=d_elim_vars.end() ){ changed = true; - Assert( d_eqci.find( n )!=d_eqci.end() ); - Assert( n!=t ); - Assert( d_eqci[n]->d_solved.get() ); + Assert(d_eqci.find(n) != d_eqci.end()); + Assert(n != t); + Assert(d_eqci[n]->d_solved.get()); Trace("eq-infer-debug2") << "......its solved form is " << d_eqci[n]->d_rep.get() << std::endl; if( d_trackExplain ){ //track the explanation: justified by explanation for each substitution addToExplanationEqc( exp, n ); } n = d_eqci[n]->d_rep; - Assert( !n.isNull() ); + Assert(!n.isNull()); } if( it->second.isNull() ){ children.push_back( n ); @@ -177,7 +177,7 @@ void EqualityInference::eqNotifyNewClass(TNode t) { children.push_back( NodeManager::currentNM()->mkNode( MULT, it->second, n ) ); } }else{ - Assert( !it->second.isNull() ); + Assert(!it->second.isNull()); children.push_back( it->second ); } } @@ -275,8 +275,8 @@ void EqualityInference::setEqcRep( Node t, Node r, std::vector< Node >& exp_to_a } void EqualityInference::eqNotifyMerge(TNode t1, TNode t2) { - Assert( !t1.isNull() ); - Assert( !t2.isNull() ); + Assert(!t1.isNull()); + Assert(!t2.isNull()); std::map< Node, EqcInfo * >::iterator itv1 = d_eqci.find( t1 ); if( itv1!=d_eqci.end() ){ std::map< Node, EqcInfo * >::iterator itv2 = d_eqci.find( t2 ); @@ -324,7 +324,7 @@ void EqualityInference::eqNotifyMerge(TNode t1, TNode t2) { { Node v_value = veq[1]; Trace("eq-infer") << "...solved " << v_solve << " == " << v_value << std::endl; - Assert( d_elim_vars.find( v_solve )==d_elim_vars.end() ); + Assert(d_elim_vars.find(v_solve) == d_elim_vars.end()); d_elim_vars[v_solve] = true; //store value in eqc info EqcInfo * eqci_solved; diff --git a/src/theory/quantifiers/equality_query.cpp b/src/theory/quantifiers/equality_query.cpp index bb0306c06..f7fd13d4d 100644 --- a/src/theory/quantifiers/equality_query.cpp +++ b/src/theory/quantifiers/equality_query.cpp @@ -105,7 +105,7 @@ Node EqualityQueryQuantifiersEngine::getInternalRepresentative(Node a, if( r.getType().isSort() ){ Trace("internal-rep-warn") << "No representative for UF constant." << std::endl; //should never happen : UF constants should never escape model - Assert( false ); + Assert(false); } } } @@ -165,7 +165,7 @@ Node EqualityQueryQuantifiersEngine::getInternalRepresentative(Node a, d_rep_score[ r_best ] = d_reset_count; } Trace("internal-rep-select") << "...Choose " << r_best << " with score " << r_best_score << std::endl; - Assert( r_best.getType().isSubtypeOf( v_tn ) ); + Assert(r_best.getType().isSubtypeOf(v_tn)); v_int_rep[r] = r_best; if( r_best!=a ){ Trace("internal-rep-debug") << "rep( " << a << " ) = " << r << ", " << std::endl; @@ -193,7 +193,7 @@ void EqualityQueryQuantifiersEngine::getEquivalenceClass( Node a, std::vector< N eqc.push_back( a ); } //a should be in its equivalence class - Assert( std::find( eqc.begin(), eqc.end(), a )!=eqc.end() ); + Assert(std::find(eqc.begin(), eqc.end(), a) != eqc.end()); } TNode EqualityQueryQuantifiersEngine::getCongruentTerm( Node f, std::vector< TNode >& args ) { @@ -243,7 +243,7 @@ int EqualityQueryQuantifiersEngine::getRepScore(Node n, //score prefers earliest use of this term as a representative return d_rep_score.find( n )==d_rep_score.end() ? -1 : d_rep_score[n]; }else{ - Assert( options::quantRepMode()==quantifiers::QUANT_REP_MODE_DEPTH ); + Assert(options::quantRepMode() == quantifiers::QUANT_REP_MODE_DEPTH); return quantifiers::TermUtil::getTermDepth( n ); } } diff --git a/src/theory/quantifiers/first_order_model.cpp b/src/theory/quantifiers/first_order_model.cpp index 4b8b65697..bfef42b65 100644 --- a/src/theory/quantifiers/first_order_model.cpp +++ b/src/theory/quantifiers/first_order_model.cpp @@ -46,7 +46,7 @@ void FirstOrderModel::assertQuantifier( Node n ){ if( n.getKind()==FORALL ){ d_forall_asserts.push_back( n ); }else if( n.getKind()==NOT ){ - Assert( n[0].getKind()==FORALL ); + Assert(n[0].getKind() == FORALL); } } @@ -58,7 +58,7 @@ Node FirstOrderModel::getAssertedQuantifier( unsigned i, bool ordered ) { if( !ordered ){ return d_forall_asserts[i]; }else{ - Assert( d_forall_rlv_assert.size()==d_forall_asserts.size() ); + Assert(d_forall_rlv_assert.size() == d_forall_asserts.size()); return d_forall_rlv_assert[i]; } } @@ -186,7 +186,7 @@ void FirstOrderModel::reset_round() { } } Trace("fm-relevant-debug") << "Sizes : " << d_forall_rlv_assert.size() << " " << d_forall_asserts.size() << std::endl; - Assert( d_forall_rlv_assert.size()==d_forall_asserts.size() ); + Assert(d_forall_rlv_assert.size() == d_forall_asserts.size()); }else{ for( unsigned i=0; id_cond.size()-1); i>=0; i--) { Node v = d_models[op]->d_value[i]; Trace("fmc-model-func") << "Value is : " << v << std::endl; - Assert( v.isConst() ); + Assert(v.isConst()); /* if( !hasTerm( v ) ){ //can happen when the model basis term does not exist in ground assignment @@ -431,7 +431,7 @@ Node FirstOrderModelFmc::getFunctionValue(Node op, const char* argPrefix ) { children.push_back( NodeManager::currentNM()->mkNode( EQUAL, vars[j], c ) ); } } - Assert( !children.empty() ); + Assert(!children.empty()); Node cc = children.size()==1 ? children[0] : NodeManager::currentNM()->mkNode( AND, children ); Trace("fmc-model-func") << "condition : " << cc << ", value : " << v << std::endl; diff --git a/src/theory/quantifiers/fmf/bounded_integers.cpp b/src/theory/quantifiers/fmf/bounded_integers.cpp index 87f0b1ffe..c6800b092 100644 --- a/src/theory/quantifiers/fmf/bounded_integers.cpp +++ b/src/theory/quantifiers/fmf/bounded_integers.cpp @@ -167,7 +167,7 @@ void BoundedIntegers::process( Node q, Node n, bool pol, conj = TermUtil::simpleNegate( conj ); } Trace("bound-int-debug") << "Process possible finite disequality conjunction : " << conj << std::endl; - Assert( conj.getKind()==AND ); + Assert(conj.getKind() == AND); Node v; std::vector< Node > v_cases; bool success = true; @@ -199,7 +199,7 @@ void BoundedIntegers::process( Node q, Node n, bool pol, bound_lit_type_map[v] = BOUND_FIXED_SET; bound_lit_map[3][v] = n; bound_lit_pol_map[3][v] = pol; - Assert( v_cases.size()==1 ); + Assert(v_cases.size() == 1); bound_fixed_set[v].clear(); bound_fixed_set[v].push_back( v_cases[0] ); } @@ -266,7 +266,7 @@ void BoundedIntegers::process( Node q, Node n, bool pol, } } }else{ - Assert( n.getKind()!=LEQ && n.getKind()!=LT && n.getKind()!=GT ); + Assert(n.getKind() != LEQ && n.getKind() != LT && n.getKind() != GT); } } @@ -335,7 +335,8 @@ void BoundedIntegers::checkOwnership(Node f) setBoundVar = true; for( unsigned b=0; b<2; b++ ){ //set the bounds - Assert( bound_int_range_term[b].find( v )!=bound_int_range_term[b].end() ); + Assert(bound_int_range_term[b].find(v) + != bound_int_range_term[b].end()); d_bounds[b][f][v] = bound_int_range_term[b][v]; } Node r = nm->mkNode(MINUS, d_bounds[1][f][v], d_bounds[0][f][v]); @@ -396,7 +397,7 @@ void BoundedIntegers::checkOwnership(Node f) } else { - Assert( it->second!=BOUND_INT_RANGE ); + Assert(it->second != BOUND_INT_RANGE); } } } @@ -424,7 +425,7 @@ void BoundedIntegers::checkOwnership(Node f) for( unsigned i=0; i::iterator itr = d_range[f].find( v ); if( itr != d_range[f].end() ){ Node r = itr->second; - Assert( !r.isNull() ); + Assert(!r.isNull()); bool isProxy = false; if (expr::hasBoundVar(r)) { @@ -695,16 +696,16 @@ Node BoundedIntegers::getSetRangeValue( Node q, Node v, RepSetIterator * rsi ) { bool BoundedIntegers::getRsiSubsitution( Node q, Node v, std::vector< Node >& vars, std::vector< Node >& subs, RepSetIterator * rsi ) { Trace("bound-int-rsi") << "Get bound value in model of variable " << v << std::endl; - Assert( d_set_nums[q].find( v )!=d_set_nums[q].end() ); + Assert(d_set_nums[q].find(v) != d_set_nums[q].end()); int vindex = d_set_nums[q][v]; - Assert( d_set_nums[q][v]==vindex ); + Assert(d_set_nums[q][v] == vindex); Trace("bound-int-rsi-debug") << " index order is " << vindex << std::endl; //must take substitution for all variables that are iterating at higher level for( int i=0; igetVariableOrder( i ); - Assert( q[0][v]==d_set[q][i] ); + Assert(q[0][v] == d_set[q][i]); Node t = rsi->getCurrentTerm(v, true); Trace("bound-int-rsi") << "term : " << t << std::endl; vars.push_back( d_set[q][i] ); @@ -772,7 +773,7 @@ bool BoundedIntegers::getBoundElements( RepSetIterator * rsi, bool initial, Node Node tl = l; Node tu = u; getBounds( q, v, rsi, tl, tu ); - Assert( !tl.isNull() && !tu.isNull() ); + Assert(!tl.isNull() && !tu.isNull()); if( ra==d_quantEngine->getTermUtil()->d_true ){ long rr = range.getConst().getNumerator().getLong()+1; Trace("bound-int-rsi") << "Actual bound range is " << rr << std::endl; @@ -797,11 +798,11 @@ bool BoundedIntegers::getBoundElements( RepSetIterator * rsi, bool initial, Node if( srv.getKind()!=EMPTYSET ){ //collect the elements while( srv.getKind()==UNION ){ - Assert( srv[1].getKind()==kind::SINGLETON ); + Assert(srv[1].getKind() == kind::SINGLETON); elements.push_back( srv[1][0] ); srv = srv[0]; } - Assert( srv.getKind()==kind::SINGLETON ); + Assert(srv.getKind() == kind::SINGLETON); elements.push_back( srv[0] ); //check if we need to do matching, for literals like ( tuple( v ) in S ) Node t = d_setm_range_lit[q][v][0]; diff --git a/src/theory/quantifiers/fmf/full_model_check.cpp b/src/theory/quantifiers/fmf/full_model_check.cpp index 2306a0565..f6edd3195 100644 --- a/src/theory/quantifiers/fmf/full_model_check.cpp +++ b/src/theory/quantifiers/fmf/full_model_check.cpp @@ -443,7 +443,7 @@ bool FullModelChecker::processBuildModel(TheoryModel* m){ } if( !isStar && !ri.isConst() ){ Trace("fmc-warn") << "Warning : model for " << op << " has non-constant argument in model " << ri << " (from " << c[i] << ")" << std::endl; - Assert( false ); + Assert(false); } entry_children.push_back(ri); } @@ -453,7 +453,7 @@ bool FullModelChecker::processBuildModel(TheoryModel* m){ << "Representative of " << v << " is " << nv << std::endl; if( !nv.isConst() ){ Trace("fmc-warn") << "Warning : model for " << op << " has non-constant value in model " << nv << std::endl; - Assert( false ); + Assert(false); } Node en = (useSimpleModels() && hasNonStar) ? n : NodeManager::currentNM()->mkNode( APPLY_UF, entry_children ); if( std::find(conds.begin(), conds.end(), n )==conds.end() ){ @@ -501,13 +501,14 @@ bool FullModelChecker::processBuildModel(TheoryModel* m){ inst.push_back( r ); } Node ev = fm->d_models[op]->evaluate( fm, inst ); - Trace("fmc-model-debug") << ".....Checking eval( " << fm->d_uf_terms[op][i] << " ) = " << ev << std::endl; - AlwaysAssert( fm->areEqual( ev, fm->d_uf_terms[op][i] ) ); + Trace("fmc-model-debug") << ".....Checking eval( " << + fm->d_uf_terms[op][i] << " ) = " << ev << std::endl; AlwaysAssert( + fm->areEqual( ev, fm->d_uf_terms[op][i] ) ); } */ } - Assert( d_addedLemmas==0 ); - + Assert(d_addedLemmas == 0); + //make function values for( std::map::iterator it = fm->d_models.begin(); it != fm->d_models.end(); ++it ){ Node f_def = getFunctionValue( fm, it->first, "$x" ); @@ -582,7 +583,7 @@ void FullModelChecker::debugPrint(const char * tr, Node n, bool dispStar) { int FullModelChecker::doExhaustiveInstantiation( FirstOrderModel * fm, Node f, int effort ) { Trace("fmc") << "Full model check " << f << ", effort = " << effort << "..." << std::endl; - Assert( !d_qe->inConflict() ); + Assert(!d_qe->inConflict()); if( optUseModel() ){ FirstOrderModelFmc * fmfmc = fm->asFirstOrderModelFmc(); if (effort==0) { @@ -606,7 +607,7 @@ int FullModelChecker::doExhaustiveInstantiation( FirstOrderModel * fm, Node f, i //model check the quantifier doCheck(fmfmc, f, d_quant_models[f], f[1]); Trace("fmc") << "Definition for quantifier " << f << " is : " << std::endl; - Assert( !d_quant_models[f].d_cond.empty() ); + Assert(!d_quant_models[f].d_cond.empty()); d_quant_models[f].debugPrint("fmc", Node::null(), this); Trace("fmc") << std::endl; @@ -1159,7 +1160,7 @@ void FullModelChecker::doInterpretedCompose( FirstOrderModelFmc * fm, Node f, De int FullModelChecker::isCompat( FirstOrderModelFmc * fm, std::vector< Node > & cond, Node c ) { Trace("fmc-debug3") << "isCompat " << c << std::endl; - Assert(cond.size()==c.getNumChildren()+1); + Assert(cond.size() == c.getNumChildren() + 1); for (unsigned i=1; iisStar(cond[i]) && !fm->isStar(c[i - 1])) { @@ -1171,7 +1172,7 @@ int FullModelChecker::isCompat( FirstOrderModelFmc * fm, std::vector< Node > & c bool FullModelChecker::doMeet( FirstOrderModelFmc * fm, std::vector< Node > & cond, Node c ) { Trace("fmc-debug3") << "doMeet " << c << std::endl; - Assert(cond.size()==c.getNumChildren()+1); + Assert(cond.size() == c.getNumChildren() + 1); for (unsigned i=1; iisStar(cond[i])) @@ -1203,7 +1204,7 @@ void FullModelChecker::mkCondDefaultVec( FirstOrderModelFmc * fm, Node f, std::v cond.push_back(d_quant_cond[f]); for (unsigned i=0; igetStar(f[0][i].getType()); - Assert( ts.getType()==f[0][i].getType() ); + Assert(ts.getType() == f[0][i].getType()); cond.push_back(ts); } } diff --git a/src/theory/quantifiers/fmf/model_engine.cpp b/src/theory/quantifiers/fmf/model_engine.cpp index 3ab52a63b..cdaaa239a 100644 --- a/src/theory/quantifiers/fmf/model_engine.cpp +++ b/src/theory/quantifiers/fmf/model_engine.cpp @@ -77,7 +77,7 @@ void ModelEngine::check(Theory::Effort e, QEffort quant_e) doCheck = quant_e == QEFFORT_MODEL; } if( doCheck ){ - Assert( !d_quantEngine->inConflict() ); + Assert(!d_quantEngine->inConflict()); int addedLemmas = 0; FirstOrderModel* fm = d_quantEngine->getModel(); @@ -240,7 +240,7 @@ int ModelEngine::checkModel(){ if( d_addedLemmas>0 ){ break; }else{ - Assert( !d_quantEngine->inConflict() ); + Assert(!d_quantEngine->inConflict()); } } diff --git a/src/theory/quantifiers/fun_def_process.cpp b/src/theory/quantifiers/fun_def_process.cpp index 185a349c0..aa3efca19 100644 --- a/src/theory/quantifiers/fun_def_process.cpp +++ b/src/theory/quantifiers/fun_def_process.cpp @@ -36,7 +36,7 @@ void FunDefFmf::simplify( std::vector< Node >& assertions ) { for( unsigned i=0; i& assertions ) { Node FunDefFmf::simplifyFormula( Node n, bool pol, bool hasPol, std::vector< Node >& constraints, Node hd, bool is_fun_def, std::map< int, std::map< Node, Node > >& visited, std::map< int, std::map< Node, Node > >& visited_cons ) { - Assert( constraints.empty() ); + Assert(constraints.empty()); int index = ( is_fun_def ? 1 : 0 ) + 2*( hasPol ? ( pol ? 1 : -1 ) : 0 ); std::map< Node, Node >::iterator itv = visited[index].find( n ); if( itv!=visited[index].end() ){ @@ -240,7 +240,7 @@ Node FunDefFmf::simplifyFormula( Node n, bool pol, bool hasPol, std::vector< Nod cons = constraints[0]; } visited_cons[index][n] = cons; - Assert( constraints.size()==1 && constraints[0]==cons ); + Assert(constraints.size() == 1 && constraints[0] == cons); } visited[index][n] = ret; return ret; diff --git a/src/theory/quantifiers/inst_match.cpp b/src/theory/quantifiers/inst_match.cpp index 069d5b888..bd947d70b 100644 --- a/src/theory/quantifiers/inst_match.cpp +++ b/src/theory/quantifiers/inst_match.cpp @@ -107,7 +107,7 @@ void InstMatch::setValue( int i, TNode n ) { } bool InstMatch::set(EqualityQuery* q, int i, TNode n) { - Assert( i>=0 ); + Assert(i >= 0); if( !d_vals[i].isNull() ){ if (q->areEqual(d_vals[i], n)) { diff --git a/src/theory/quantifiers/inst_propagator.cpp b/src/theory/quantifiers/inst_propagator.cpp index a3c114d90..6566319fa 100644 --- a/src/theory/quantifiers/inst_propagator.cpp +++ b/src/theory/quantifiers/inst_propagator.cpp @@ -121,8 +121,8 @@ Node EqualityQueryInstProp::getRepresentativeExp( Node a, std::vector< Node >& e if( !ar.isNull() ){ if( engine_has_a || getEngine()->hasTerm( ar ) ){ Trace("qip-eq") << "getRepresentativeExp " << a << " returns " << ar << std::endl; - Assert( getEngine()->hasTerm( ar ) ); - Assert( getEngine()->getRepresentative( ar )==ar ); + Assert(getEngine()->hasTerm(ar)); + Assert(getEngine()->getRepresentative(ar) == ar); return ar; } }else{ @@ -187,15 +187,15 @@ TNode EqualityQueryInstProp::getCongruentTermExp( Node f, std::vector< TNode >& } Node EqualityQueryInstProp::getUfRepresentative( Node a, std::vector< Node >& exp ) { - Assert( exp.empty() ); + Assert(exp.empty()); std::map< Node, Node >::iterator it = d_uf.find( a ); if( it!=d_uf.end() ){ if( it->second==a ){ - Assert( d_uf_exp[ a ].empty() ); + Assert(d_uf_exp[a].empty()); return it->second; }else{ Node m = getUfRepresentative( it->second, exp ); - Assert( !m.isNull() ); + Assert(!m.isNull()); if( m!=it->second ){ //update union find d_uf[ a ] = m; @@ -224,7 +224,7 @@ int EqualityQueryInstProp::setEqual( Node& a, Node& b, bool pol, std::vector< No std::vector< Node > exp_a; Node ar = getUfRepresentative( a, exp_a ); if( ar.isNull() ){ - Assert( exp_a.empty() ); + Assert(exp_a.empty()); ar = a; } if( ar==b ){ @@ -241,7 +241,7 @@ int EqualityQueryInstProp::setEqual( Node& a, Node& b, bool pol, std::vector< No std::vector< Node > exp_b; Node br = getUfRepresentative( b, exp_b ); if( br.isNull() ){ - Assert( exp_b.empty() ); + Assert(exp_b.empty()); br = b; if( !getEngine()->hasTerm( br ) ){ if( ar!=a || getEngine()->hasTerm( ar ) ){ @@ -278,8 +278,8 @@ int EqualityQueryInstProp::setEqual( Node& a, Node& b, bool pol, std::vector< No br = temp_r; } - Assert( !getEngine()->hasTerm( ar ) || getEngine()->hasTerm( br ) ); - Assert( ar!=br ); + Assert(!getEngine()->hasTerm(ar) || getEngine()->hasTerm(br)); + Assert(ar != br); std::vector< Node > exp_d; if( areDisequalExp( ar, br, exp_d ) ){ @@ -294,8 +294,8 @@ int EqualityQueryInstProp::setEqual( Node& a, Node& b, bool pol, std::vector< No }else{ if( pol ){ //update the union find - Assert( d_uf_exp[ar].empty() ); - Assert( d_uf_exp[br].empty() ); + Assert(d_uf_exp[ar].empty()); + Assert(d_uf_exp[br].empty()); //registerUfTerm( ar ); d_uf[ar] = br; @@ -326,8 +326,8 @@ int EqualityQueryInstProp::setEqual( Node& a, Node& b, bool pol, std::vector< No return status; }else{ Trace("qip-eq") << "EqualityQueryInstProp::setEqual : disequal " << ar << " <> " << br << std::endl; - Assert( d_diseq_list[ar].find( br )==d_diseq_list[ar].end() ); - Assert( d_diseq_list[br].find( ar )==d_diseq_list[br].end() ); + Assert(d_diseq_list[ar].find(br) == d_diseq_list[ar].end()); + Assert(d_diseq_list[br].find(ar) == d_diseq_list[br].end()); merge_exp( d_diseq_list[ar][br], reason ); merge_exp( d_diseq_list[br][ar], reason ); @@ -372,7 +372,7 @@ bool EqualityQueryInstProp::isPropagateLiteral( Node n ) { Node atom = n.getKind()==NOT ? n[0] : n; return !atom[0].getType().isBoolean(); }else{ - Assert( ak!=NOT ); + Assert(ak != NOT); return ak!=AND && ak!=OR && ak!=ITE; } } @@ -410,7 +410,7 @@ Node EqualityQueryInstProp::evaluateTermExp( Node n, std::vector< Node >& exp, s Node ret; //check if it should be propagated in this context if( hasPol && isPropagateLiteral( n ) ){ - Assert( n.getType().isBoolean() ); + Assert(n.getType().isBoolean()); //must be Boolean ret = evaluateTermExp( n, exp, visited, false, pol, watch_list_out, props ); if( isPropagateLiteral( ret ) ){ @@ -432,7 +432,7 @@ Node EqualityQueryInstProp::evaluateTermExp( Node n, std::vector< Node >& exp, s bool childChanged = false; int abort_i = -1; //get the child entailed polarity - Assert( n.getKind()!=IMPLIES ); + Assert(n.getKind() != IMPLIES); bool newHasPol, newPol; QuantPhaseReq::getEntailPolarity( n, 0, hasPol, pol, newHasPol, newPol ); std::vector< Node > watch; @@ -511,19 +511,19 @@ Node EqualityQueryInstProp::evaluateTermExp( Node n, std::vector< Node >& exp, s Trace("qip-eval") << "arg " << i << " : " << args[i] << std::endl; t_args.push_back( args[i] ); } - Assert( args.size()==n.getNumChildren() ); + Assert(args.size() == n.getNumChildren()); //args contains terms known by the equality engine TNode nn = getCongruentTerm( f, t_args ); Trace("qip-eval") << " got congruent term " << nn << " for " << n << std::endl; if( !nn.isNull() ){ //successfully constructed representative in EE - Assert( exp_n.empty() ); + Assert(exp_n.empty()); ret = getRepresentativeExp( nn, exp_n ); Trace("qip-eval") << "return rep, exp size = " << exp_n.size() << std::endl; merge_exp( exp, exp_n ); ret_set = true; - Assert( !ret.isNull() ); - Assert( ret!=n ); + Assert(!ret.isNull()); + Assert(ret != n); // we have that n == ret, check if the union find should be updated TODO? }else{ watch.push_back( ret ); @@ -542,7 +542,7 @@ Node EqualityQueryInstProp::evaluateTermExp( Node n, std::vector< Node >& exp, s ret_set = true; } }else{ - Assert( args.size()==n.getNumChildren() ); + Assert(args.size() == n.getNumChildren()); } if( !ret_set ){ if( n.getMetaKind() == kind::metakind::PARAMETERIZED ){ @@ -576,7 +576,7 @@ Node EqualityQueryInstProp::evaluateTermExp( Node n, std::vector< Node >& exp, s void EqualityQueryInstProp::merge_exp( std::vector< Node >& v, std::vector< Node >& v_to_merge, int up_to_size ) { //TODO : optimize if( v.empty() ){ - Assert( up_to_size==-1 || up_to_size==(int)v_to_merge.size() ); + Assert(up_to_size == -1 || up_to_size == (int)v_to_merge.size()); v.insert( v.end(), v_to_merge.begin(), v_to_merge.end() ); }else{ //std::vector< Node >::iterator v_end = v.end(); @@ -595,7 +595,7 @@ void InstPropagator::InstInfo::init( Node q, Node lem, std::vector< Node >& term //information about the instance d_q = q; d_lem = lem; - Assert( d_terms.empty() ); + Assert(d_terms.empty()); d_terms.insert( d_terms.end(), terms.begin(), terms.end() ); //the current lemma d_curr = body; @@ -641,7 +641,7 @@ bool InstPropagator::notifyInstantiation(QuantifiersModule::QEffort quant_e, unsigned id = allocateInstantiation( q, lem, terms, body ); //initialize the information if( cacheConclusion( id, body ) ){ - Assert( d_update_list.empty() ); + Assert(d_update_list.empty()); d_update_list.push_back( id ); bool firstTime = true; //update infos in the update list until empty @@ -660,7 +660,7 @@ bool InstPropagator::notifyInstantiation(QuantifiersModule::QEffort quant_e, Trace("qip-prop") << "...finished notify instantiation." << std::endl; return !d_conflict; }else{ - Assert( false ); + Assert(false); return false; } } @@ -676,7 +676,7 @@ void InstPropagator::filterInstantiations() { it->second.d_q, it->second.d_lem, it->second.d_terms)) { Trace("qip-warn") << "WARNING : did not remove instantiation id " << it->first << std::endl; - Assert( false ); + Assert(false); }else{ Trace("qip-prop-debug") << it->first << " "; } @@ -700,8 +700,8 @@ unsigned InstPropagator::allocateInstantiation( Node q, Node lem, std::vector< N } bool InstPropagator::update( unsigned id, InstInfo& ii, bool firstTime ) { - Assert( !d_conflict ); - Assert( ii.d_active ); + Assert(!d_conflict); + Assert(ii.d_active); Trace("qip-prop-debug") << "Update info [" << id << "]..." << std::endl; //update the evaluation of the current lemma std::map< Node, std::vector< Node > > watch_list_out; @@ -733,14 +733,14 @@ bool InstPropagator::update( unsigned id, InstInfo& ii, bool firstTime ) { } //determine the status of eval if( eval==d_qy.d_false ){ - Assert( props.empty() ); + Assert(props.empty()); //we have inferred a conflict conflict( ii.d_curr_exp ); return false; }else{ for( unsigned i=0; i& e if( status==EqualityQueryInstProp::STATUS_MERGED_KNOWN ){ Trace("qip-rlv-propagate") << "Relevant propagation : " << a << " == " << b << std::endl; - Assert( d_qy.getEngine()->hasTerm( a ) ); - Assert( d_qy.getEngine()->hasTerm( b ) ); + Assert(d_qy.getEngine()->hasTerm(a)); + Assert(d_qy.getEngine()->hasTerm(b)); Trace("qip-prop-debug") << "...equality between known terms." << std::endl; addRelevantInstances( exp, "qip-propagate" ); //d_has_relevant_inst = true; @@ -837,7 +837,7 @@ void InstPropagator::conflict( std::vector< Node >& exp ) { } bool InstPropagator::cacheConclusion( unsigned id, Node body, int prop_index ) { - Assert( prop_index==0 || prop_index==1 ); + Assert(prop_index == 0 || prop_index == 1); //check if the conclusion is non-redundant if( d_conc_to_id[prop_index].find( body )==d_conc_to_id[prop_index].end() ){ d_conc_to_id[prop_index][body] = id; @@ -849,7 +849,7 @@ bool InstPropagator::cacheConclusion( unsigned id, Node body, int prop_index ) { void InstPropagator::addRelevantInstances( std::vector< Node >& exp, const char * c ) { for( unsigned i=0; i& exp, const char void InstPropagator::debugPrintExplanation( std::vector< Node >& exp, const char * c ) { for( unsigned i=0; i& lemmas ) { reset(); for( unsigned i=0; i bvs; @@ -189,7 +189,7 @@ void LtePartialInst::getInstantiations( std::vector< Node >& lemmas ) { } getPartialInstantiations( conj, q, bvl, d_vars[q], terms, types, NULL, 0, 0, 0 ); - Assert( !conj.empty() ); + Assert(!conj.empty()); lemmas.push_back( NodeManager::currentNM()->mkNode( OR, q.negate(), conj.size()==1 ? conj[0] : NodeManager::currentNM()->mkNode( AND, conj ) ) ); d_wasInvoked = true; } @@ -226,16 +226,16 @@ void LtePartialInst::getPartialInstantiations(std::vector& conj, conj.push_back( nq ); } }else{ - Assert( pindexgetTermDatabase()->getTermArgTrie( pat.getOperator() ); } diff --git a/src/theory/quantifiers/quant_conflict_find.cpp b/src/theory/quantifiers/quant_conflict_find.cpp index 4b055f71c..de46eee74 100644 --- a/src/theory/quantifiers/quant_conflict_find.cpp +++ b/src/theory/quantifiers/quant_conflict_find.cpp @@ -148,7 +148,7 @@ void QuantInfo::getPropagateVars( QuantConflictFind * p, std::vector< TNode >& v bool rec = true; bool newPol = pol; if( d_var_num.find( n )!=d_var_num.end() ){ - Assert( std::find( vars.begin(), vars.end(), n )==vars.end() ); + Assert(std::find(vars.begin(), vars.end(), n) == vars.end()); vars.push_back( n ); TNode f = p->getTermDatabase()->getMatchOperator( n ); if( !f.isNull() ){ @@ -157,7 +157,7 @@ void QuantInfo::getPropagateVars( QuantConflictFind * p, std::vector< TNode >& v } } }else if( MatchGen::isHandledBoolConnective( n ) ){ - Assert( n.getKind()!=IMPLIES ); + Assert(n.getKind() != IMPLIES); QuantPhaseReq::getEntailPolarity( n, 0, true, pol, rec, newPol ); } Trace("qcf-opt-debug") << "getPropagateVars " << n << ", pol = " << pol << ", rec = " << rec << std::endl; @@ -298,7 +298,7 @@ TNode QuantInfo::getCurrentValue( TNode n ) { if( d_match[v].isNull() ){ return n; }else{ - Assert( getVarNum( d_match[v] )!=v ); + Assert(getVarNum(d_match[v]) != v); return getCurrentValue( d_match[v] ); } } @@ -312,7 +312,7 @@ TNode QuantInfo::getCurrentExpValue( TNode n ) { if( d_match[v].isNull() ){ return n; }else{ - Assert( getVarNum( d_match[v] )!=v ); + Assert(getVarNum(d_match[v]) != v); if( d_match_term[v].isNull() ){ return getCurrentValue( d_match[v] ); }else{ @@ -356,9 +356,9 @@ int QuantInfo::addConstraint( QuantConflictFind * p, int v, TNode n, int vn, boo //for handling equalities between variables, and disequalities involving variables Debug("qcf-match-debug") << "- " << (doRemove ? "un" : "" ) << "constrain : " << v << " -> " << n << " (cv=" << getCurrentValue( n ) << ")"; Debug("qcf-match-debug") << ", (vn=" << vn << "), polarity = " << polarity << std::endl; - Assert( doRemove || n==getCurrentValue( n ) ); - Assert( doRemove || v==getCurrentRepVar( v ) ); - Assert( doRemove || vn==getCurrentRepVar( getVarNum( n ) ) ); + Assert(doRemove || n == getCurrentValue(n)); + Assert(doRemove || v == getCurrentRepVar(v)); + Assert(doRemove || vn == getCurrentRepVar(getVarNum(n))); if( polarity ){ if( vn!=v ){ if( doRemove ){ @@ -398,7 +398,7 @@ int QuantInfo::addConstraint( QuantConflictFind * p, int v, TNode n, int vn, boo bool alreadySet = false; if( !d_match[vn].isNull() ){ alreadySet = true; - Assert( !isVar( d_match[vn] ) ); + Assert(!isVar(d_match[vn])); } //copy or check disequalities @@ -461,7 +461,7 @@ int QuantInfo::addConstraint( QuantConflictFind * p, int v, TNode n, int vn, boo return -1; }else{ if( doRemove ){ - Assert( d_curr_var_deq[v].find( n )!=d_curr_var_deq[v].end() ); + Assert(d_curr_var_deq[v].find(n) != d_curr_var_deq[v].end()); d_curr_var_deq[v].erase( n ); return 1; }else{ @@ -831,7 +831,7 @@ bool QuantInfo::completeMatch( QuantConflictFind * p, std::vector< int >& assign Trace("qcf-check-unassign") << "Failed match with mg at " << d_una_index << std::endl; } }else{ - Assert( doFail || d_una_index==(int)d_una_eqc_count.size()-1 ); + Assert(doFail || d_una_index == (int)d_una_eqc_count.size() - 1); if( d_una_eqc_count[d_una_index]<(int)p->d_eqcs[d_unassigned_tn[d_una_index]].size() ){ int currIndex = d_una_eqc_count[d_una_index]; d_una_eqc_count[d_una_index]++; @@ -975,7 +975,7 @@ MatchGen::MatchGen( QuantInfo * qi, Node n, bool isVar ) std::vector< Node > qni_apps; d_qni_size = 0; if( isVar ){ - Assert( qi->d_var_num.find( n )!=qi->d_var_num.end() ); + Assert(qi->d_var_num.find(n) != qi->d_var_num.end()); if( n.getKind()==ITE ){ d_type = typ_invalid; }else{ @@ -1026,10 +1026,10 @@ MatchGen::MatchGen( QuantInfo * qi, Node n, bool isVar ) d_type = typ_invalid; //literals if( isHandledUfTerm( d_n ) ){ - Assert( qi->isVar( d_n ) ); + Assert(qi->isVar(d_n)); d_type = typ_pred; }else if( d_n.getKind()==BOUND_VARIABLE ){ - Assert( d_n.getType().isBoolean() ); + Assert(d_n.getType().isBoolean()); d_type = typ_bool_var; }else if( d_n.getKind()==EQUAL || options::qcfTConstraint() ){ for (unsigned i = 0; i < d_n.getNumChildren(); i++) @@ -1140,7 +1140,7 @@ void MatchGen::determineVariableOrder( QuantInfo * qi, std::vector< int >& bvars Trace("qcf-qregister-vo") << vu_count[min_score_index] << " " << vb_count[min_score_index] << " " << has_nested[min_score_index] << std::endl; Trace("qcf-qregister-debug") << "...assign child " << min_score_index << std::endl; Trace("qcf-qregister-debug") << "...score : " << min_score << std::endl; - Assert( min_score_index!=-1 ); + Assert(min_score_index != -1); //add to children order d_children_order.push_back( min_score_index ); assigned[min_score_index] = true; @@ -1291,7 +1291,7 @@ void MatchGen::reset( QuantConflictFind * p, bool tgt, QuantInfo * qi ) { d_qn.push_back( NULL ); } }else if( d_type==typ_var ){ - Assert( isHandledUfTerm( d_n ) ); + Assert(isHandledUfTerm(d_n)); TNode f = getMatchOperator( p, d_n ); Debug("qcf-match-debug") << " reset: Var will match operators of " << f << std::endl; TNodeTrie* qni = p->getTermDatabase()->getTermArgTrie(Node::null(), f); @@ -1520,7 +1520,7 @@ bool MatchGen::getNextMatch( QuantConflictFind * p, QuantInfo * qi ) { //clean up the matches you set for( std::map< int, int >::iterator it = d_qni_bound.begin(); it != d_qni_bound.end(); ++it ){ Debug("qcf-match") << " Clean up bound var " << it->second << std::endl; - Assert( it->secondgetNumVars() ); + Assert(it->second < qi->getNumVars()); qi->unsetMatch( p, it->second ); qi->d_match_term[ it->second ] = TNode::null(); } @@ -1650,8 +1650,8 @@ bool MatchGen::doMatching( QuantConflictFind * p, QuantInfo * qi ) { d_qn.clear(); return true; }else{ - Assert( d_type==typ_var ); - Assert( d_qni_size>0 ); + Assert(d_type == typ_var); + Assert(d_qni_size > 0); bool invalidMatch; do { invalidMatch = false; @@ -1694,10 +1694,10 @@ bool MatchGen::doMatching( QuantConflictFind * p, QuantInfo * qi ) { } }else{ Debug("qcf-match-debug") << " Match " << index << " is ground term" << std::endl; - Assert( d_qni_gterm.find( index )!=d_qni_gterm.end() ); - Assert( d_qni_gterm_rep.find( index )!=d_qni_gterm_rep.end() ); + Assert(d_qni_gterm.find(index) != d_qni_gterm.end()); + Assert(d_qni_gterm_rep.find(index) != d_qni_gterm_rep.end()); val = d_qni_gterm_rep[index]; - Assert( !val.isNull() ); + Assert(!val.isNull()); } if( !val.isNull() ){ //constrained by val @@ -1715,7 +1715,7 @@ bool MatchGen::doMatching( QuantConflictFind * p, QuantInfo * qi ) { } } }else{ - Assert( d_qn.size()==d_qni.size() ); + Assert(d_qn.size() == d_qni.size()); int index = d_qni.size()-1; //increment if binding this variable bool success = false; @@ -1751,7 +1751,7 @@ bool MatchGen::doMatching( QuantConflictFind * p, QuantInfo * qi ) { if( d_qni.size()==d_qni_size ){ //Assert( !d_qni[d_qni.size()-1]->second.d_data.empty() ); //Debug("qcf-match-debug") << " We matched " << d_qni[d_qni.size()-1]->second.d_children.begin()->first << std::endl; - Assert( !d_qni[d_qni.size()-1]->second.d_data.empty() ); + Assert(!d_qni[d_qni.size() - 1]->second.d_data.empty()); TNode t = d_qni[d_qni.size()-1]->second.d_data.begin()->first; Debug("qcf-match-debug") << " " << d_n << " matched " << t << std::endl; qi->d_match_term[d_qni_var_num[0]] = t; @@ -1760,8 +1760,8 @@ bool MatchGen::doMatching( QuantConflictFind * p, QuantInfo * qi ) { Debug("qcf-match-debug") << " position " << it->first << " bounded " << it->second << " / " << qi->d_q[0].getNumChildren() << std::endl; //if( it->second<(int)qi->d_q[0].getNumChildren() ){ //if it is an actual variable, we are interested in knowing the actual term if( it->first>0 ){ - Assert( !qi->d_match[ it->second ].isNull() ); - Assert( p->areEqual( t[it->first-1], qi->d_match[ it->second ] ) ); + Assert(!qi->d_match[it->second].isNull()); + Assert(p->areEqual(t[it->first - 1], qi->d_match[it->second])); qi->d_match_term[it->second] = t[it->first-1]; } //} diff --git a/src/theory/quantifiers/quantifiers_attributes.cpp b/src/theory/quantifiers/quantifiers_attributes.cpp index f5ebb33b1..0e6eb1581 100644 --- a/src/theory/quantifiers/quantifiers_attributes.cpp +++ b/src/theory/quantifiers/quantifiers_attributes.cpp @@ -64,24 +64,24 @@ void QuantAttributes::setUserAttribute( const std::string& attr, Node n, std::ve QuantNameAttribute qna; n.setAttribute(qna, true); } else if (attr == "sygus-synth-grammar") { - Assert( node_values.size()==1 ); + Assert(node_values.size() == 1); Trace("quant-attr-debug") << "Set sygus synth grammar " << n << " to " << node_values[0] << std::endl; SygusSynthGrammarAttribute ssg; n.setAttribute(ssg, node_values[0]); }else if( attr=="sygus-synth-fun-var-list" ){ - Assert( node_values.size()==1 ); + Assert(node_values.size() == 1); Trace("quant-attr-debug") << "Set sygus synth fun var list to " << n << " to " << node_values[0] << std::endl; SygusSynthFunVarListAttribute ssfvla; n.setAttribute( ssfvla, node_values[0] ); }else if( attr=="quant-inst-max-level" ){ - Assert( node_values.size()==1 ); + Assert(node_values.size() == 1); uint64_t lvl = node_values[0].getConst().getNumerator().getLong(); Trace("quant-attr-debug") << "Set instantiation level " << n << " to " << lvl << std::endl; QuantInstLevelAttribute qila; n.setAttribute( qila, lvl ); }else if( attr=="rr-priority" ){ - Assert( node_values.size()==1 ); + Assert(node_values.size() == 1); uint64_t lvl = node_values[0].getConst().getNumerator().getLong(); Trace("quant-attr-debug") << "Set rewrite rule priority " << n << " to " << lvl << std::endl; RrPriorityAttribute rrpa; @@ -296,7 +296,7 @@ void QuantAttributes::computeQuantAttributes( Node q, QAttributes& qa ){ } if( avar.getKind()==REWRITE_RULE ){ Trace("quant-attr") << "Attribute : rewrite rule : " << q << std::endl; - Assert( i==0 ); + Assert(i == 0); qa.d_rr = avar; } } diff --git a/src/theory/quantifiers/quantifiers_rewriter.cpp b/src/theory/quantifiers/quantifiers_rewriter.cpp index 33da46675..0039ec845 100644 --- a/src/theory/quantifiers/quantifiers_rewriter.cpp +++ b/src/theory/quantifiers/quantifiers_rewriter.cpp @@ -92,7 +92,7 @@ void QuantifiersRewriter::computeArgVec(const std::vector& args, std::vector& activeArgs, Node n) { - Assert( activeArgs.empty() ); + Assert(activeArgs.empty()); std::map< Node, bool > activeMap; std::map< Node, bool > visited; computeArgs( args, activeMap, n, visited ); @@ -110,7 +110,7 @@ void QuantifiersRewriter::computeArgVec2(const std::vector& args, Node n, Node ipl) { - Assert( activeArgs.empty() ); + Assert(activeArgs.empty()); std::map< Node, bool > activeMap; std::map< Node, bool > visited; computeArgs( args, activeMap, n, visited ); @@ -286,7 +286,7 @@ Node QuantifiersRewriter::computeElimSymbols( Node body ) { } if( !success ){ // tautology - Assert( k==OR || k==AND ); + Assert(k == OR || k == AND); return NodeManager::currentNM()->mkConst( k==OR ); } childrenChanged = childrenChanged || c!=body[i]; @@ -405,7 +405,7 @@ int getEntailedCond( Node n, std::map< Node, bool >& currCond ){ }else if( j==start ){ res1 = res; }else{ - Assert( res!=0 ); + Assert(res != 0); if( n.getKind()==ITE ){ return res1==res ? res : 0; }else if( n.getKind()==EQUAL ){ @@ -456,7 +456,7 @@ void setEntailedCond( Node n, bool pol, std::map< Node, bool >& currCond, std::v if( n.getKind()==APPLY_TESTER ){ const Datatype& dt = Datatype::datatypeOf(n.getOperator().toExpr()); unsigned index = Datatype::indexOf(n.getOperator().toExpr()); - Assert( dt.getNumConstructors()>1 ); + Assert(dt.getNumConstructors() > 1); if( pol ){ for( unsigned i=0; i& n std::map< Node, Node > icache; if( qa.isFunDef() ){ Node h = QuantAttributes::getFunDefHead( q ); - Assert( !h.isNull() ); + Assert(!h.isNull()); // if it is a function definition, rewrite the body independently Node fbody = QuantAttributes::getFunDefBody( q ); Trace("quantifiers-rewrite-debug") << "Decompose " << h << " / " << fbody << " as function definition for " << q << "." << std::endl; @@ -572,8 +572,8 @@ Node QuantifiersRewriter::computeProcessTerms2( Node body, bool hasPol, bool pol nCurrCond = nCurrCond + 1; } setEntailedCond( children[0], i==1, currCond, new_cond, conflict ); - //should not conflict (entailment check failed) - Assert( !conflict ); + // should not conflict (entailment check failed) + Assert(!conflict); } if( body.getKind()==OR || body.getKind()==AND ){ bool use_pol = body.getKind()==AND; @@ -763,7 +763,7 @@ Node QuantifiersRewriter::computeCondSplit(Node body, std::map< Node, std::map< int, Node > > ncons; std::vector< Node > conj; computeDtTesterIteSplit( body, pcons, ncons, conj ); - Assert( !conj.empty() ); + Assert(!conj.empty()); if( conj.size()>1 ){ Trace("quantifiers-rewrite-ite") << "*** Split ITE (datatype tester) " << body << " into : " << std::endl; for( unsigned i=0; i& args, s NodeManager::currentNM()->mkNode( kind::OR, body[0], body[1].notNode() ) ); return computePrenex( nn, args, nargs, pol, prenexAgg ); }else if( body.getType().isBoolean() ){ - Assert( body.getKind()!=EXISTS ); + Assert(body.getKind() != EXISTS); bool childrenChanged = false; std::vector< Node > newChildren; for( unsigned i=0; i& args, Node body, QAttributes& qa ) { - Assert( body.getKind()==OR ); + Assert(body.getKind() == OR); size_t var_found_count = 0; size_t eqc_count = 0; size_t eqc_active = 0; @@ -1732,7 +1732,7 @@ Node QuantifiersRewriter::computeSplit( std::vector< Node >& args, Node body, QA Node fa = NodeManager::currentNM()->mkNode( FORALL, bvl, body ); lits.push_back(fa); } - Assert( !lits.empty() ); + Assert(!lits.empty()); Node nf = lits.size()==1 ? lits[0] : NodeManager::currentNM()->mkNode(OR,lits); Trace("clause-split-debug") << "Made node : " << nf << std::endl; return nf; @@ -1828,7 +1828,7 @@ Node QuantifiersRewriter::computeMiniscoping( std::vector< Node >& args, Node bo } } }else if( body.getKind()==NOT ){ - Assert( isLiteral( body[0] ) ); + Assert(isLiteral(body[0])); } //remove variables that don't occur std::vector< Node > activeArgs; @@ -1902,8 +1902,8 @@ Node QuantifiersRewriter::computeAggressiveMiniscoping( std::vector< Node >& arg qvl2.push_back( args[i] ); } } - Assert( !qvl1.empty() ); - Assert( !qvl2.empty() || !qvsh.empty() ); + Assert(!qvl1.empty()); + Assert(!qvl2.empty() || !qvsh.empty()); //check for literals that only contain shared variables std::vector qlitsh; std::vector qlit2; @@ -2023,7 +2023,7 @@ Node QuantifiersRewriter::computeOperation( Node f, int computeOption, QAttribut }else{ std::vector< Node > nargs; n = computePrenex( n, args, nargs, true, false ); - Assert( nargs.empty() ); + Assert(nargs.empty()); } }else if( computeOption==COMPUTE_VAR_ELIMINATION ){ n = computeVarElimination( n, args, qa ); @@ -2091,9 +2091,7 @@ Node QuantifiersRewriter::rewriteRewriteRule( Node r ) { break; } break; - default: - Unreachable("RewriteRules can be of only three kinds"); - break; + default: Unreachable() << "RewriteRules can be of only three kinds"; break; } // Add the other guards TNode g = r[1]; diff --git a/src/theory/quantifiers/query_generator.cpp b/src/theory/quantifiers/query_generator.cpp index 742b3000b..99e7b5a8c 100644 --- a/src/theory/quantifiers/query_generator.cpp +++ b/src/theory/quantifiers/query_generator.cpp @@ -177,7 +177,7 @@ void QueryGenerator::checkQuery(Node qy, unsigned spIndex) ss << " " << d_vars[i] << " -> " << pt[i] << std::endl; } ss << "but CVC4 answered unsat!" << std::endl; - AlwaysAssert(false, ss.str().c_str()); + AlwaysAssert(false) << ss.str(); } if (options::sygusQueryGenDumpFiles() == SYGUS_QUERY_DUMP_UNSOLVED) { diff --git a/src/theory/quantifiers/relevant_domain.cpp b/src/theory/quantifiers/relevant_domain.cpp index 071bd7933..fbd1f05a6 100644 --- a/src/theory/quantifiers/relevant_domain.cpp +++ b/src/theory/quantifiers/relevant_domain.cpp @@ -27,8 +27,8 @@ using namespace CVC4::theory; using namespace CVC4::theory::quantifiers; void RelevantDomain::RDomain::merge( RDomain * r ) { - Assert( !d_parent ); - Assert( !r->d_parent ); + Assert(!d_parent); + Assert(!r->d_parent); d_parent = r; for( unsigned i=0; iaddTerm( d_terms[i] ); @@ -79,7 +79,7 @@ RelevantDomain::~RelevantDomain() { for( std::map< Node, std::map< int, RDomain * > >::iterator itr = d_rel_doms.begin(); itr != d_rel_doms.end(); ++itr ){ for( std::map< int, RDomain * >::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2 ){ RDomain * current = (*itr2).second; - Assert( current != NULL ); + Assert(current != NULL); delete current; } } @@ -183,7 +183,8 @@ void RelevantDomain::computeRelevantDomain( Node q, Node n, bool hasPol, bool po //compute the information for what this literal does computeRelevantDomainLit( q, hasPol, pol, n ); if( d_rel_dom_lit[hasPol][pol][n].d_merge ){ - Assert( d_rel_dom_lit[hasPol][pol][n].d_rd[0]!=NULL && d_rel_dom_lit[hasPol][pol][n].d_rd[1]!=NULL ); + Assert(d_rel_dom_lit[hasPol][pol][n].d_rd[0] != NULL + && d_rel_dom_lit[hasPol][pol][n].d_rd[1] != NULL); RDomain * rd1 = d_rel_dom_lit[hasPol][pol][n].d_rd[0]->getParent(); RDomain * rd2 = d_rel_dom_lit[hasPol][pol][n].d_rd[1]->getParent(); if( rd1!=rd2 ){ diff --git a/src/theory/quantifiers/rewrite_engine.cpp b/src/theory/quantifiers/rewrite_engine.cpp index 07ff9ee46..9903456c9 100644 --- a/src/theory/quantifiers/rewrite_engine.cpp +++ b/src/theory/quantifiers/rewrite_engine.cpp @@ -68,7 +68,7 @@ void RewriteEngine::check(Theory::Effort e, QEffort quant_e) { if (quant_e == QEFFORT_STANDARD) { - Assert( !d_quantEngine->inConflict() ); + Assert(!d_quantEngine->inConflict()); Trace("rewrite-engine") << "---Rewrite Engine Round, effort = " << e << "---" << std::endl; //if( e==Theory::EFFORT_LAST_CALL ){ // if( !d_quantEngine->getModel()->isModelSet() ){ diff --git a/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp b/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp index 47a1f6142..c34b7d4e3 100644 --- a/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp +++ b/src/theory/quantifiers/sygus/ce_guided_single_inv.cpp @@ -53,7 +53,7 @@ CegSingleInv::~CegSingleInv() void CegSingleInv::initialize(Node q) { // can only register one quantified formula with this - Assert( d_quant.isNull() ); + Assert(d_quant.isNull()); d_quant = q; d_simp_quant = q; Trace("cegqi-si") << "CegSingleInv::initialize : " << q << std::endl; @@ -466,7 +466,7 @@ Node CegSingleInv::getSolution(unsigned sol_index, int& reconstructed, bool rconsSygus) { - Assert( d_sol!=NULL ); + Assert(d_sol != NULL); const Datatype& dt = ((DatatypeType)(stn).toType()).getDatatype(); Node varList = Node::fromExpr( dt.getSygusVarList() ); Node prog = d_quant[0][sol_index]; @@ -486,7 +486,7 @@ Node CegSingleInv::getSolution(unsigned sol_index, Trace("csi-sol") << "Get solution for " << prog << ", with skolems : "; sol_index = d_prog_to_sol_index[prog]; d_sol->d_varList.clear(); - Assert( d_single_inv_arg_sk.size()==varList.getNumChildren() ); + Assert(d_single_inv_arg_sk.size() == varList.getNumChildren()); for( unsigned i=0; imkNode(ITE, cond, d_inst[uindex][sol_index], s); } - Assert( vars.size()==d_sol->d_varList.size() ); + Assert(vars.size() == d_sol->d_varList.size()); s = s.substitute( vars.begin(), vars.end(), d_sol->d_varList.begin(), d_sol->d_varList.end() ); } d_orig_solution = s; diff --git a/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.cpp b/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.cpp index d349e8ad4..811210628 100644 --- a/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.cpp +++ b/src/theory/quantifiers/sygus/ce_guided_single_inv_sol.cpp @@ -119,7 +119,7 @@ Node CegSingleInvSol::reconstructSolution(Node sol, if( status==0 ){ Node ret = getReconstructedSolution( d_root_id ); Trace("csi-rcons") << "Sygus solution is : " << ret << std::endl; - Assert( !ret.isNull() ); + Assert(!ret.isNull()); reconstructed = 1; return ret; } @@ -224,11 +224,11 @@ int CegSingleInvSol::collectReconstructNodes(Node t, TypeNode stn, int& status) int id = allocate( t, stn ); d_rcons_to_status[stn][t] = -1; TypeNode tn = t.getType(); - Assert( stn.isDatatype() ); + Assert(stn.isDatatype()); const Datatype& dt = stn.getDatatype(); TermDbSygus* tds = d_qe->getTermDatabaseSygus(); SygusTypeInfo& sti = tds->getTypeInfo(stn); - Assert( dt.isSygus() ); + Assert(dt.isSygus()); Trace("csi-rcons-debug") << "Check reconstruct " << t << ", sygus type " << dt.getName() << ", kind " << t.getKind() << ", id : " << id << std::endl; int carg = -1; int karg = -1; @@ -291,7 +291,7 @@ int CegSingleInvSol::collectReconstructNodes(Node t, TypeNode stn, int& status) //try identity functions for (unsigned ii : d_id_funcs[stn]) { - Assert( dt[ii].getNumArgs()==1 ); + Assert(dt[ii].getNumArgs() == 1); //try to directly reconstruct from single argument std::vector< Node > tchildren; tchildren.push_back( min_t ); @@ -402,7 +402,7 @@ int CegSingleInvSol::collectReconstructNodes(Node t, TypeNode stn, int& status) //if one succeeds if( status==0 ){ Node rsol = getReconstructedSolution( equiv_ids[i] ); - Assert( !rsol.isNull() ); + Assert(!rsol.isNull()); //set all members of the equivalence class that this is the reconstructed solution setReconstructed( id, rsol ); break; @@ -433,7 +433,7 @@ bool CegSingleInvSol::collectReconstructNodes(int pid, std::vector& ids, int& status) { - Assert( dtc.getNumArgs()==ts.size() ); + Assert(dtc.getNumArgs() == ts.size()); for( unsigned i=0; igetTermDatabaseSygus()->getArgType( dtc, i ); int cstatus; diff --git a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp index 0dc49fa96..8f935de27 100644 --- a/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp +++ b/src/theory/quantifiers/sygus/sygus_grammar_cons.cpp @@ -177,7 +177,7 @@ Node CegGrammarConstructor::process(Node q, std::map::const_iterator itta = templates_arg.find(sf); Assert(itta != templates_arg.end()); TNode templ_arg = itta->second; - Assert( !templ_arg.isNull() ); + Assert(!templ_arg.isNull()); // if there is a template for this argument, make a sygus type on top of it if( options::sygusTemplEmbedGrammar() ){ Trace("cegqi-debug") << "Template for " << sf << " is : " << templ @@ -737,7 +737,7 @@ void CegGrammarConstructor::mkSygusDefaultGrammar( weights[i].push_back(-1); // length TypeNode intType = nm->integerType(); - Assert(std::find(types.begin(),types.end(),intType)!=types.end()); + Assert(std::find(types.begin(), types.end(), intType) != types.end()); unsigned i_intType = std::distance( types.begin(), std::find(types.begin(), @@ -1086,12 +1086,12 @@ TypeNode CegGrammarConstructor::mkSygusDefaultType( datatypes, unres); Trace("sygus-grammar-def") << "...made " << datatypes.size() << " datatypes, now make mutual datatype types..." << std::endl; - Assert( !datatypes.empty() ); + Assert(!datatypes.empty()); std::vector types = NodeManager::currentNM()->toExprManager()->mkMutualDatatypeTypes( datatypes, unres, ExprManager::DATATYPE_FLAG_PLACEHOLDER); Trace("sygus-grammar-def") << "...finished" << std::endl; - Assert( types.size()==datatypes.size() ); + Assert(types.size() == datatypes.size()); return TypeNode::fromType( types[0] ); } @@ -1114,7 +1114,7 @@ TypeNode CegGrammarConstructor::mkSygusTemplateTypeRec( Node templ, Node templ_a // TODO : can short circuit to this case when !TermUtil::containsTerm( templ, templ_arg ) op = templ; }else{ - Assert( templ.hasOperator() ); + Assert(templ.hasOperator()); op = templ.getOperator(); // make constructor taking arguments types from children for( unsigned i=0; i types = NodeManager::currentNM()->toExprManager()->mkMutualDatatypeTypes( datatypes, unres, ExprManager::DATATYPE_FLAG_PLACEHOLDER); - Assert( types.size()==1 ); + Assert(types.size() == 1); return TypeNode::fromType( types[0] ); } } diff --git a/src/theory/quantifiers/sygus/sygus_pbe.cpp b/src/theory/quantifiers/sygus/sygus_pbe.cpp index 64bf0972c..474fdb5d8 100644 --- a/src/theory/quantifiers/sygus/sygus_pbe.cpp +++ b/src/theory/quantifiers/sygus/sygus_pbe.cpp @@ -440,7 +440,7 @@ bool SygusPbe::constructCandidates(const std::vector& enums, std::vector& candidate_values, std::vector& lems) { - Assert( enums.size()==enum_values.size() ); + Assert(enums.size() == enum_values.size()); if( !enums.empty() ){ unsigned min_term_size = 0; Trace("sygus-pbe-enum") << "Register new enumerated values : " << std::endl; diff --git a/src/theory/quantifiers/sygus/sygus_unif_io.cpp b/src/theory/quantifiers/sygus/sygus_unif_io.cpp index ff58dbe38..72091c0cf 100644 --- a/src/theory/quantifiers/sygus/sygus_unif_io.cpp +++ b/src/theory/quantifiers/sygus/sygus_unif_io.cpp @@ -1453,12 +1453,11 @@ Node SygusUnifIo::constructSol( if (!rec_c.isNull()) { Assert(ecache_child.d_enum_val_to_index.find(rec_c) - != ecache_child.d_enum_val_to_index.end()); + != ecache_child.d_enum_val_to_index.end()); split_cond_res_index = ecache_child.d_enum_val_to_index[rec_c]; set_split_cond_res_index = true; split_cond_enum = ce; - Assert(split_cond_res_index - < ecache_child.d_enum_vals_res.size()); + Assert(split_cond_res_index < ecache_child.d_enum_vals_res.size()); } } else diff --git a/src/theory/quantifiers/sygus/term_database_sygus.cpp b/src/theory/quantifiers/sygus/term_database_sygus.cpp index ff9fede0b..7fb54f14e 100644 --- a/src/theory/quantifiers/sygus/term_database_sygus.cpp +++ b/src/theory/quantifiers/sygus/term_database_sygus.cpp @@ -14,7 +14,7 @@ #include "theory/quantifiers/sygus/term_database_sygus.h" -#include "base/cvc4_check.h" +#include "base/check.h" #include "options/base_options.h" #include "options/datatypes_options.h" #include "options/quantifiers_options.h" @@ -80,7 +80,7 @@ TNode TermDbSygus::getFreeVar( TypeNode tn, int i, bool useSygusType ) { }else{ ss << "fv_" << tn << "_" << i; } - Assert( !vtn.isNull() ); + Assert(!vtn.isNull()); Node v = NodeManager::currentNM()->mkSkolem( ss.str(), vtn, "for sygus normal form testing" ); d_fv_stype[v] = tn; d_fv_num[v] = i; @@ -155,7 +155,7 @@ Node TermDbSygus::getProxyVariable(TypeNode tn, Node c) } TypeNode TermDbSygus::getSygusTypeForVar( Node v ) { - Assert( d_fv_stype.find( v )!=d_fv_stype.end() ); + Assert(d_fv_stype.find(v) != d_fv_stype.end()); return d_fv_stype[v]; } @@ -165,8 +165,8 @@ Node TermDbSygus::mkGeneric(const Datatype& dt, std::map& pre) { Assert(c < dt.getNumConstructors()); - Assert( dt.isSygus() ); - Assert( !dt[c].getSygusOp().isNull() ); + Assert(dt.isSygus()); + Assert(!dt[c].getSygusOp().isNull()); std::vector< Node > children; Trace("sygus-db-debug") << "mkGeneric " << dt.getName() << " " << c << "..." << std::endl; @@ -182,7 +182,7 @@ Node TermDbSygus::mkGeneric(const Datatype& dt, } Trace("sygus-db-debug") << " child " << i << " : " << a << " : " << a.getType() << std::endl; - Assert( !a.isNull() ); + Assert(!a.isNull()); children.push_back( a ); } return datatypes::utils::mkSygusTerm(dt, c, children); @@ -495,7 +495,7 @@ void TermDbSygus::registerEnumerator(Node e, } else { - Unreachable("Unknown enumerator mode in registerEnumerator"); + Unreachable() << "Unknown enumerator mode in registerEnumerator"; } } Trace("sygus-db") << "isActiveGen for " << e << ", role = " << erole @@ -1039,7 +1039,7 @@ Node TermDbSygus::getEagerUnfold( Node n, std::map< Node, Node >& visited ) { std::vector< Node > vars; std::vector< Node > subs; Node var_list = Node::fromExpr( dt.getSygusVarList() ); - Assert( var_list.getNumChildren()+1==n.getNumChildren() ); + Assert(var_list.getNumChildren() + 1 == n.getNumChildren()); for( unsigned j=0; j& visited ) { Assert(subs[j - 1].getType().isComparableTo( var_list[j - 1].getType())); } - Assert( vars.size()==subs.size() ); + Assert(vars.size() == subs.size()); bTerm = bTerm.substitute( vars.begin(), vars.end(), subs.begin(), subs.end() ); Trace("cegqi-eager") << "Built-in term after subs : " << bTerm << std::endl; Trace("cegqi-eager-debug") << "Types : " << bTerm.getType() << " " << n.getType() << std::endl; diff --git a/src/theory/quantifiers/sygus/type_info.cpp b/src/theory/quantifiers/sygus/type_info.cpp index 818a53711..8f280c587 100644 --- a/src/theory/quantifiers/sygus/type_info.cpp +++ b/src/theory/quantifiers/sygus/type_info.cpp @@ -14,7 +14,7 @@ #include "theory/quantifiers/sygus/type_info.h" -#include "base/cvc4_check.h" +#include "base/check.h" #include "theory/datatypes/theory_datatypes_utils.h" #include "theory/quantifiers/sygus/term_database_sygus.h" @@ -123,7 +123,7 @@ void SygusTypeInfo::initialize(TermDbSygus* tds, TypeNode tn) TypeNode ct = TypeNode::fromType(dt[i].getArgType(j)); TypeNode cbt = tds->sygusToBuiltinType(ct); TypeNode lat = TypeNode::fromType(sop[0][j].getType()); - CVC4_CHECK(cbt.isSubtypeOf(lat)) + AlwaysAssert(cbt.isSubtypeOf(lat)) << "In sygus datatype " << dt.getName() << ", argument to a lambda constructor is not " << lat << std::endl; } @@ -152,7 +152,7 @@ void SygusTypeInfo::initialize(TermDbSygus* tds, TypeNode tn) // e.g. bitvector-and is a constructor of an integer grammar. Node g = tds->mkGeneric(dt, i); TypeNode gtn = g.getType(); - CVC4_CHECK(gtn.isSubtypeOf(btn)) + AlwaysAssert(gtn.isSubtypeOf(btn)) << "Sygus datatype " << dt.getName() << " encodes terms that are not of type " << btn << std::endl; Trace("sygus-db") << "...done register Operator #" << i << std::endl; diff --git a/src/theory/quantifiers/sygus_sampler.cpp b/src/theory/quantifiers/sygus_sampler.cpp index 10d7ef6ab..834ca1975 100644 --- a/src/theory/quantifiers/sygus_sampler.cpp +++ b/src/theory/quantifiers/sygus_sampler.cpp @@ -813,8 +813,8 @@ void SygusSampler::checkEquivalent(Node bv, Node bvr) if (options::sygusRewVerifyAbort()) { - AlwaysAssert(false, - "--sygus-rr-verify detected unsoundness in the rewriter!"); + AlwaysAssert(false) + << "--sygus-rr-verify detected unsoundness in the rewriter!"; } } } diff --git a/src/theory/quantifiers/term_database.cpp b/src/theory/quantifiers/term_database.cpp index 9da9c95b6..79279eb41 100644 --- a/src/theory/quantifiers/term_database.cpp +++ b/src/theory/quantifiers/term_database.cpp @@ -46,7 +46,8 @@ TermDb::~TermDb(){ } void TermDb::registerQuantifier( Node q ) { - Assert( q[0].getNumChildren()==d_quantEngine->getTermUtil()->getNumInstantiationConstants( q ) ); + Assert(q[0].getNumChildren() + == d_quantEngine->getTermUtil()->getNumInstantiationConstants(q)); for( unsigned i=0; igetTermUtil()->getInstantiationConstant( q, i ); setTermInactive( ic ); @@ -257,7 +258,7 @@ void TermDb::computeArgReps( TNode n ) { } void TermDb::computeUfEqcTerms( TNode f ) { - Assert( f==getOperatorRepresentative( f ) ); + Assert(f == getOperatorRepresentative(f)); if (d_func_map_eqc_trie.find(f) != d_func_map_eqc_trie.end()) { return; @@ -291,7 +292,7 @@ void TermDb::computeUfTerms( TNode f ) { // already computed return; } - Assert( f==getOperatorRepresentative( f ) ); + Assert(f == getOperatorRepresentative(f)); d_op_nonred_count[f] = 0; // get the matchable operators in the equivalence class of f std::vector ops; @@ -501,8 +502,9 @@ bool TermDb::inRelevantDomain( TNode f, unsigned i, TNode r ) { f = getOperatorRepresentative( f ); } computeUfTerms( f ); - Assert( !d_quantEngine->getActiveEqualityEngine()->hasTerm( r ) || - d_quantEngine->getActiveEqualityEngine()->getRepresentative( r )==r ); + Assert(!d_quantEngine->getActiveEqualityEngine()->hasTerm(r) + || d_quantEngine->getActiveEqualityEngine()->getRepresentative(r) + == r); std::map< Node, std::map< unsigned, std::vector< Node > > >::iterator it = d_func_map_rel_dom.find( f ); if( it != d_func_map_rel_dom.end() ){ std::map< unsigned, std::vector< Node > >::iterator it2 = it->second.find( i ); @@ -712,7 +714,7 @@ Node TermDb::evaluateTerm2(TNode n, TNode TermDb::getEntailedTerm2( TNode n, std::map< TNode, TNode >& subs, bool subsRep, bool hasSubs, EqualityQuery * qy ) { - Assert( !qy->extendsEngine() ); + Assert(!qy->extendsEngine()); Trace("term-db-entail") << "get entailed term : " << n << std::endl; if( qy->getEngine()->hasTerm( n ) ){ Trace("term-db-entail") << "...exists in ee, return rep " << std::endl; @@ -723,8 +725,8 @@ TNode TermDb::getEntailedTerm2( TNode n, std::map< TNode, TNode >& subs, bool su if( it!=subs.end() ){ Trace("term-db-entail") << "...substitution is : " << it->second << std::endl; if( subsRep ){ - Assert( qy->getEngine()->hasTerm( it->second ) ); - Assert( qy->getEngine()->getRepresentative( it->second )==it->second ); + Assert(qy->getEngine()->hasTerm(it->second)); + Assert(qy->getEngine()->getRepresentative(it->second) == it->second); return it->second; }else{ return getEntailedTerm2( it->second, subs, subsRep, hasSubs, qy ); @@ -805,9 +807,9 @@ TNode TermDb::getEntailedTerm( TNode n, EqualityQuery * qy ) { } bool TermDb::isEntailed2( TNode n, std::map< TNode, TNode >& subs, bool subsRep, bool hasSubs, bool pol, EqualityQuery * qy ) { - Assert( !qy->extendsEngine() ); + Assert(!qy->extendsEngine()); Trace("term-db-entail") << "Check entailed : " << n << ", pol = " << pol << std::endl; - Assert( n.getType().isBoolean() ); + Assert(n.getType().isBoolean()); if( n.getKind()==EQUAL && !n[0].getType().isBoolean() ){ TNode n1 = getEntailedTerm2( n[0], subs, subsRep, hasSubs, qy ); if( !n1.isNull() ){ @@ -816,8 +818,8 @@ bool TermDb::isEntailed2( TNode n, std::map< TNode, TNode >& subs, bool subsRep, if( n1==n2 ){ return pol; }else{ - Assert( qy->getEngine()->hasTerm( n1 ) ); - Assert( qy->getEngine()->hasTerm( n2 ) ); + Assert(qy->getEngine()->hasTerm(n1)); + Assert(qy->getEngine()->hasTerm(n2)); if( pol ){ return qy->getEngine()->areEqual( n1, n2 ); }else{ @@ -854,7 +856,7 @@ bool TermDb::isEntailed2( TNode n, std::map< TNode, TNode >& subs, bool subsRep, }else if( n.getKind()==APPLY_UF ){ TNode n1 = getEntailedTerm2( n, subs, subsRep, hasSubs, qy ); if( !n1.isNull() ){ - Assert( qy->hasTerm( n1 ) ); + Assert(qy->hasTerm(n1)); if( n1==d_true ){ return pol; }else if( n1==d_false ){ @@ -871,7 +873,7 @@ bool TermDb::isEntailed2( TNode n, std::map< TNode, TNode >& subs, bool subsRep, bool TermDb::isEntailed( TNode n, bool pol, EqualityQuery * qy ) { if( qy==NULL ){ - Assert( d_consistent_ee ); + Assert(d_consistent_ee); qy = d_quantEngine->getEqualityQuery(); } std::map< TNode, TNode > subs; @@ -880,7 +882,7 @@ bool TermDb::isEntailed( TNode n, bool pol, EqualityQuery * qy ) { bool TermDb::isEntailed( TNode n, std::map< TNode, TNode >& subs, bool subsRep, bool pol, EqualityQuery * qy ) { if( qy==NULL ){ - Assert( d_consistent_ee ); + Assert(d_consistent_ee); qy = d_quantEngine->getEqualityQuery(); } return isEntailed2( n, subs, subsRep, true, pol, qy ); @@ -908,7 +910,7 @@ bool TermDb::hasTermCurrent( Node n, bool useMode ) { }else if( options::termDbMode()==TERM_DB_RELEVANT ){ return d_has_map.find( n )!=d_has_map.end(); }else{ - Assert( false ); + Assert(false); return false; } } diff --git a/src/theory/quantifiers/term_util.cpp b/src/theory/quantifiers/term_util.cpp index c9c738eb3..7f94130f3 100644 --- a/src/theory/quantifiers/term_util.cpp +++ b/src/theory/quantifiers/term_util.cpp @@ -217,7 +217,7 @@ Node TermUtil::substituteBoundVariables(Node n, std::vector& terms) { registerQuantifier(q); - Assert( d_vars[q].size()==terms.size() ); + Assert(d_vars[q].size() == terms.size()); return n.substitute( d_vars[q].begin(), d_vars[q].end(), terms.begin(), terms.end() ); } @@ -306,7 +306,7 @@ void TermUtil::computeInstConstContainsForQuant(Node q, Node TermUtil::ensureType( Node n, TypeNode tn ) { TypeNode ntn = n.getType(); - Assert( ntn.isComparableTo( tn ) ); + Assert(ntn.isComparableTo(tn)); if( ntn.isSubtypeOf( tn ) ){ return n; }else{ diff --git a/src/theory/quantifiers/theory_quantifiers.cpp b/src/theory/quantifiers/theory_quantifiers.cpp index f24a4bb2b..1682b4d0c 100644 --- a/src/theory/quantifiers/theory_quantifiers.cpp +++ b/src/theory/quantifiers/theory_quantifiers.cpp @@ -16,8 +16,7 @@ #include "theory/quantifiers/theory_quantifiers.h" - -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/kind.h" #include "options/quantifiers_options.h" #include "theory/quantifiers/ematching/instantiation_engine.h" @@ -147,15 +146,11 @@ void TheoryQuantifiers::check(Effort e) { //do nothing break; case kind::INST_CLOSURE: - default: - Unhandled(assertion[0].getKind()); - break; + default: Unhandled() << assertion[0].getKind(); break; } } break; - default: - Unhandled(assertion.getKind()); - break; + default: Unhandled() << assertion.getKind(); break; } } // call the quantifiers engine to check diff --git a/src/theory/quantifiers/theory_quantifiers_type_rules.h b/src/theory/quantifiers/theory_quantifiers_type_rules.h index ad1c4c69b..62d75cf18 100644 --- a/src/theory/quantifiers/theory_quantifiers_type_rules.h +++ b/src/theory/quantifiers/theory_quantifiers_type_rules.h @@ -29,7 +29,7 @@ struct QuantifierForallTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { Debug("typecheck-q") << "type check for fa " << n << std::endl; - Assert(n.getKind() == kind::FORALL && n.getNumChildren()>0 ); + Assert(n.getKind() == kind::FORALL && n.getNumChildren() > 0); if( check ){ if( n[ 0 ].getType(check)!=nodeManager->boundVarListType() ){ throw TypeCheckingExceptionPrivate(n, "first argument of universal quantifier is not bound var list"); @@ -49,7 +49,7 @@ struct QuantifierExistsTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { Debug("typecheck-q") << "type check for ex " << n << std::endl; - Assert(n.getKind() == kind::EXISTS && n.getNumChildren()>0 ); + Assert(n.getKind() == kind::EXISTS && n.getNumChildren() > 0); if( check ){ if( n[ 0 ].getType(check)!=nodeManager->boundVarListType() ){ throw TypeCheckingExceptionPrivate(n, "first argument of existential quantifier is not bound var list"); @@ -68,7 +68,7 @@ struct QuantifierExistsTypeRule { struct QuantifierBoundVarListTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::BOUND_VAR_LIST ); + Assert(n.getKind() == kind::BOUND_VAR_LIST); if( check ){ for( int i=0; i<(int)n.getNumChildren(); i++ ){ if( n[i].getKind()!=kind::BOUND_VARIABLE ){ @@ -83,7 +83,7 @@ struct QuantifierBoundVarListTypeRule { struct QuantifierInstPatternTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::INST_PATTERN ); + Assert(n.getKind() == kind::INST_PATTERN); if( check ){ TypeNode tn = n[0].getType(check); // this check catches the common mistake writing :pattern (f x) instead of :pattern ((f x)) @@ -98,7 +98,7 @@ struct QuantifierInstPatternTypeRule { struct QuantifierInstNoPatternTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::INST_NO_PATTERN ); + Assert(n.getKind() == kind::INST_NO_PATTERN); return nodeManager->instPatternType(); } };/* struct QuantifierInstNoPatternTypeRule */ @@ -106,7 +106,7 @@ struct QuantifierInstNoPatternTypeRule { struct QuantifierInstAttributeTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::INST_ATTRIBUTE ); + Assert(n.getKind() == kind::INST_ATTRIBUTE); return nodeManager->instPatternType(); } };/* struct QuantifierInstAttributeTypeRule */ @@ -114,7 +114,7 @@ struct QuantifierInstAttributeTypeRule { struct QuantifierInstPatternListTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::INST_PATTERN_LIST ); + Assert(n.getKind() == kind::INST_PATTERN_LIST); if( check ){ for( int i=0; i<(int)n.getNumChildren(); i++ ){ if( n[i].getKind()!=kind::INST_PATTERN && n[i].getKind()!=kind::INST_NO_PATTERN && n[i].getKind()!=kind::INST_ATTRIBUTE ){ @@ -129,7 +129,7 @@ struct QuantifierInstPatternListTypeRule { struct QuantifierInstClosureTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::INST_CLOSURE ); + Assert(n.getKind() == kind::INST_CLOSURE); if( check ){ TypeNode tn = n[0].getType(check); if( tn.isBoolean() ){ @@ -157,7 +157,7 @@ public: bool check) { Debug("typecheck-r") << "type check for rr " << n << std::endl; - Assert(n.getKind() == kind::REWRITE_RULE && n.getNumChildren()==3 ); + Assert(n.getKind() == kind::REWRITE_RULE && n.getNumChildren() == 3); if( check ){ if( n[ 0 ].getType(check)!=nodeManager->boundVarListType() ){ throw TypeCheckingExceptionPrivate(n[0], @@ -182,7 +182,7 @@ public: inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::RR_REWRITE ); + Assert(n.getKind() == kind::RR_REWRITE); if( check ){ if( n[0].getType(check)!=n[1].getType(check) ){ throw TypeCheckingExceptionPrivate(n, @@ -204,8 +204,8 @@ public: inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::RR_REDUCTION || - n.getKind() == kind::RR_DEDUCTION ); + Assert(n.getKind() == kind::RR_REDUCTION + || n.getKind() == kind::RR_DEDUCTION); if( check ){ if( n[ 0 ].getType(check)!=nodeManager->booleanType() ){ throw TypeCheckingExceptionPrivate(n, "head of reduction rule is not boolean"); diff --git a/src/theory/quantifiers_engine.cpp b/src/theory/quantifiers_engine.cpp index e399af71d..686843189 100644 --- a/src/theory/quantifiers_engine.cpp +++ b/src/theory/quantifiers_engine.cpp @@ -250,7 +250,7 @@ QuantifiersEngine::QuantifiersEngine(context::Context* c, Trace("quant-engine-debug") << "Initialize model, mbqi : " << options::mbqiMode() << std::endl; if( options::quantEpr() ){ - Assert( !options::incrementalSolving() ); + Assert(!options::incrementalSolving()); d_qepr.reset(new quantifiers::QuantEPR); } //---- end utilities @@ -660,7 +660,7 @@ void QuantifiersEngine::check( Theory::Effort e ){ return; }else{ //should only fail reset if added a lemma - Assert( false ); + Assert(false); } } } @@ -742,7 +742,7 @@ void QuantifiersEngine::check( Theory::Effort e ){ if( d_hasAddedLemma ){ break; }else{ - Assert( !d_conflict ); + Assert(!d_conflict); if (quant_e == QuantifiersModule::QEFFORT_CONFLICT) { if( e==Theory::EFFORT_FULL ){ @@ -812,7 +812,7 @@ void QuantifiersEngine::check( Theory::Effort e ){ setIncomplete = true; break; }else{ - Assert( qmd!=NULL ); + Assert(qmd != NULL); Trace("quant-engine-debug2") << "Complete for " << q << " due to " << qmd->identify().c_str() << std::endl; } } @@ -899,7 +899,7 @@ void QuantifiersEngine::registerQuantifierInternal(Node f) Trace("quant") << " : " << f << std::endl; unsigned prev_lemma_waiting = d_lemmas_waiting.size(); ++(d_statistics.d_num_quant); - Assert( f.getKind()==FORALL ); + Assert(f.getKind() == FORALL); // register with utilities for (unsigned i = 0; i < d_util.size(); i++) { diff --git a/src/theory/rep_set.cpp b/src/theory/rep_set.cpp index 0530e7889..ea462e55c 100644 --- a/src/theory/rep_set.cpp +++ b/src/theory/rep_set.cpp @@ -96,7 +96,7 @@ void RepSet::add( TypeNode tn, Node n ){ } } Trace("rsi-debug") << "Add rep #" << d_type_reps[tn].size() << " for " << tn << " : " << n << std::endl; - Assert( n.getType().isSubtypeOf( tn ) ); + Assert(n.getType().isSubtypeOf(tn)); d_tmap[ n ] = (int)d_type_reps[tn].size(); d_type_reps[tn].push_back( n ); } @@ -204,7 +204,7 @@ unsigned RepSetIterator::domainSize(unsigned i) bool RepSetIterator::setQuantifier(Node q) { Trace("rsi") << "Make rsi for quantified formula " << q << std::endl; - Assert( d_types.empty() ); + Assert(d_types.empty()); //store indicies for (size_t i = 0; i < q[0].getNumChildren(); i++) { @@ -217,7 +217,7 @@ bool RepSetIterator::setQuantifier(Node q) bool RepSetIterator::setFunctionDomain(Node op) { Trace("rsi") << "Make rsi for function " << op << std::endl; - Assert( d_types.empty() ); + Assert(d_types.empty()); TypeNode tn = op.getType(); for( size_t i=0; ibegin(), type_reps->end()); } }else{ - Assert( d_incomplete ); + Assert(d_incomplete); return false; } } @@ -344,7 +344,7 @@ int RepSetIterator::resetIndex(unsigned i, bool initial) int RepSetIterator::incrementAtIndex(int i) { - Assert( !isFinished() ); + Assert(!isFinished()); #ifdef DISABLE_EVAL_SKIP_MULTIPLE i = (int)d_index.size()-1; #endif diff --git a/src/theory/rewriter.cpp b/src/theory/rewriter.cpp index 045ac3f39..866883681 100644 --- a/src/theory/rewriter.cpp +++ b/src/theory/rewriter.cpp @@ -222,15 +222,18 @@ Node Rewriter::rewriteTo(theory::TheoryId theoryId, Node node) { } else if (response.status == REWRITE_DONE) { #ifdef CVC4_ASSERTIONS RewriteResponse r2 = Rewriter::callPostRewrite(newTheoryId, response.node); - Assert(r2.node == response.node); + Assert(r2.node == response.node); #endif rewriteStackTop.node = response.node; break; } // Check for trivial rewrite loops of size 1 or 2 Assert(response.node != rewriteStackTop.node); - Assert(Rewriter::callPostRewrite((TheoryId) rewriteStackTop.theoryId, response.node).node != rewriteStackTop.node); - rewriteStackTop.node = response.node; + Assert(Rewriter::callPostRewrite((TheoryId)rewriteStackTop.theoryId, + response.node) + .node + != rewriteStackTop.node); + rewriteStackTop.node = response.node; } // We're done with the post rewrite, so we add to the cache Rewriter::setPostRewriteCache((TheoryId) rewriteStackTop.originalTheoryId, rewriteStackTop.original, rewriteStackTop.node); @@ -243,7 +246,8 @@ Node Rewriter::rewriteTo(theory::TheoryId theoryId, Node node) { // If this is the last node, just return if (rewriteStack.size() == 1) { - Assert(!isEquality || rewriteStackTop.node.getKind() == kind::EQUAL || rewriteStackTop.node.isConst()); + Assert(!isEquality || rewriteStackTop.node.getKind() == kind::EQUAL + || rewriteStackTop.node.isConst()); return rewriteStackTop.node; } diff --git a/src/theory/sep/theory_sep.cpp b/src/theory/sep/theory_sep.cpp index b787cd94f..1392f8fab 100644 --- a/src/theory/sep/theory_sep.cpp +++ b/src/theory/sep/theory_sep.cpp @@ -222,8 +222,8 @@ void TheorySep::postProcessModel( TheoryModel* m ){ Node m_heap; for( std::map< TypeNode, Node >::iterator it = d_base_label.begin(); it != d_base_label.end(); ++it ){ //should only be constructing for one heap type - Assert( m_heap.isNull() ); - Assert( d_loc_to_data_type.find( it->first )!=d_loc_to_data_type.end() ); + Assert(m_heap.isNull()); + Assert(d_loc_to_data_type.find(it->first) != d_loc_to_data_type.end()); Trace("sep-model") << "Model for heap, type = " << it->first << " with data type " << d_loc_to_data_type[it->first] << " : " << std::endl; TypeNode data_type = d_loc_to_data_type[it->first]; computeLabelModel( it->second ); @@ -231,10 +231,11 @@ void TheorySep::postProcessModel( TheoryModel* m ){ Trace("sep-model") << " [empty]" << std::endl; }else{ for( unsigned j=0; jsecond].d_heap_locs_model.size(); j++ ){ - Assert( d_label_model[it->second].d_heap_locs_model[j].getKind()==kind::SINGLETON ); + Assert(d_label_model[it->second].d_heap_locs_model[j].getKind() + == kind::SINGLETON); std::vector< Node > pto_children; Node l = d_label_model[it->second].d_heap_locs_model[j][0]; - Assert( l.isConst() ); + Assert(l.isConst()); pto_children.push_back( l ); Trace("sep-model") << " " << l << " -> "; if( d_pto_model[l].isNull() ){ @@ -260,7 +261,7 @@ void TheorySep::postProcessModel( TheoryModel* m ){ }else{ Trace("sep-model") << d_pto_model[l]; Node vpto = d_valuation.getModel()->getRepresentative( d_pto_model[l] ); - Assert( vpto.isConst() ); + Assert(vpto.isConst()); pto_children.push_back( vpto ); } Trace("sep-model") << std::endl; @@ -378,7 +379,7 @@ void TheorySep::check(Effort e) { std::vector< Node > labels; getLabelChildren( s_atom, s_lbl, children, labels ); Node empSet = NodeManager::currentNM()->mkConst(EmptySet(s_lbl.getType().toType())); - Assert( children.size()>1 ); + Assert(children.size() > 1); if( s_atom.getKind()==kind::SEP_STAR ){ //reduction for heap : union, pairwise disjoint Node ulem = NodeManager::currentNM()->mkNode( kind::UNION, labels[0], labels[1] ); @@ -446,7 +447,7 @@ void TheorySep::check(Effort e) { }else{ //labeled emp should be rewritten - Assert( false ); + Assert(false); } d_red_conc[s_lbl][s_atom] = conc; } @@ -464,7 +465,7 @@ void TheorySep::check(Effort e) { Node lit = ds->getLiteral(0); d_neg_guard[s_lbl][s_atom] = lit; Trace("sep-lemma-debug") << "Neg guard : " << s_lbl << " " << s_atom << " " << lit << std::endl; - AlwaysAssert( !lit.isNull() ); + AlwaysAssert(!lit.isNull()); d_neg_guards.push_back( lit ); d_guard_to_assertion[lit] = s_atom; //Node lem = NodeManager::currentNM()->mkNode( kind::EQUAL, lit, conc ); @@ -493,7 +494,7 @@ void TheorySep::check(Effort e) { Trace("sep-assert") << "Done asserting " << atom << " to EE." << std::endl; }else if( s_atom.getKind()==kind::SEP_PTO ){ Node pto_lbl = NodeManager::currentNM()->mkNode( kind::SINGLETON, s_atom[0] ); - Assert( s_lbl==pto_lbl ); + Assert(s_lbl == pto_lbl); Trace("sep-assert") << "Asserting " << s_atom << std::endl; d_equalityEngine.assertPredicate(s_atom, polarity, fact); //associate the equivalence class of the lhs with this pto @@ -551,7 +552,7 @@ void TheorySep::check(Effort e) { Node fact = (*i); bool polarity = fact.getKind() != kind::NOT; TNode atom = polarity ? fact : fact[0]; - Assert( atom.getKind()==kind::SEP_LABEL ); + Assert(atom.getKind() == kind::SEP_LABEL); TNode s_atom = atom[0]; TNode s_lbl = atom[1]; lbl_to_assertions[s_lbl].push_back( fact ); @@ -647,9 +648,9 @@ void TheorySep::check(Effort e) { TNode s_atom = atom[0]; bool use_polarity = s_atom.getKind()==kind::SEP_WAND ? !polarity : polarity; if( !use_polarity ){ - Assert( assert_active.find( fact )!=assert_active.end() ); + Assert(assert_active.find(fact) != assert_active.end()); if( assert_active[fact] ){ - Assert( atom.getKind()==kind::SEP_LABEL ); + Assert(atom.getKind() == kind::SEP_LABEL); TNode s_lbl = atom[1]; std::map >& lms = d_label_map[s_atom]; if (lms.find(s_lbl) != lms.end()) @@ -672,9 +673,9 @@ void TheorySep::check(Effort e) { bool use_polarity = s_atom.getKind()==kind::SEP_WAND ? !polarity : polarity; Trace("sep-process-debug") << " check atom : " << s_atom << " use polarity " << use_polarity << std::endl; if( !use_polarity ){ - Assert( assert_active.find( fact )!=assert_active.end() ); + Assert(assert_active.find(fact) != assert_active.end()); if( assert_active[fact] ){ - Assert( atom.getKind()==kind::SEP_LABEL ); + Assert(atom.getKind() == kind::SEP_LABEL); TNode s_lbl = atom[1]; Trace("sep-process") << "--> Active negated atom : " << s_atom << ", lbl = " << s_lbl << std::endl; //add refinement lemma @@ -701,7 +702,7 @@ void TheorySep::check(Effort e) { } // Now, assert model-instantiated implication based on the negation - Assert( d_label_model.find( s_lbl )!=d_label_model.end() ); + Assert(d_label_model.find(s_lbl) != d_label_model.end()); std::vector< Node > conc; bool inst_success = true; //new refinement @@ -746,7 +747,8 @@ void TheorySep::check(Effort e) { else { Trace("sep-process-debug") << " no children." << std::endl; - Assert( s_atom.getKind()==kind::SEP_PTO || s_atom.getKind()==kind::SEP_EMP ); + Assert(s_atom.getKind() == kind::SEP_PTO + || s_atom.getKind() == kind::SEP_EMP); } }else{ Trace("sep-process-debug") << "--> inactive negated assertion " << s_atom << std::endl; @@ -764,7 +766,8 @@ void TheorySep::check(Effort e) { computeLabelModel( it->second ); Trace("sep-process-debug") << "Check heap data for " << it->first << " -> " << data_type << std::endl; for( unsigned j=0; jsecond].d_heap_locs_model.size(); j++ ){ - Assert( d_label_model[it->second].d_heap_locs_model[j].getKind()==kind::SINGLETON ); + Assert(d_label_model[it->second].d_heap_locs_model[j].getKind() + == kind::SINGLETON); Node l = d_label_model[it->second].d_heap_locs_model[j][0]; Trace("sep-process-debug") << " location : " << l << std::endl; if( d_pto_model[l].isNull() ){ @@ -856,12 +859,12 @@ TheorySep::HeapAssertInfo * TheorySep::getOrMakeEqcInfo( Node n, bool doMake ) { //for now, assume all constraints are for the same heap type (ensured by logic exceptions thrown in computeReferenceType2) TypeNode TheorySep::getReferenceType( Node n ) { - Assert( !d_type_ref.isNull() ); + Assert(!d_type_ref.isNull()); return d_type_ref; } TypeNode TheorySep::getDataType( Node n ) { - Assert( !d_type_data.isNull() ); + Assert(!d_type_data.isNull()); return d_type_data; } @@ -976,7 +979,7 @@ int TheorySep::processAssertion( Node n, std::map< int, std::map< Node, int > >& if( n.getKind()==kind::SEP_WAND ){ //TODO }else{ - Assert( n.getKind()==kind::SEP_STAR && hasPol && pol ); + Assert(n.getKind() == kind::SEP_STAR && hasPol && pol); references_strict[index][n] = true; } } @@ -988,7 +991,7 @@ int TheorySep::processAssertion( Node n, std::map< int, std::map< Node, int > >& if( !underSpatial && ( !references[index][n].empty() || card>0 ) ){ TypeNode tn = getReferenceType( n ); - Assert( !tn.isNull() ); + Assert(!tn.isNull()); // add references to overall type unsigned bt = d_bound_kind[tn]; bool add = true; @@ -1034,7 +1037,7 @@ void TheorySep::registerRefDataTypes( TypeNode tn1, TypeNode tn2, Node atom ){ std::stringstream ss; ss << "ERROR: specifying heap constraints for two different types : " << tn1 << " -> " << tn2 << " and " << te1 << " -> " << d_loc_to_data_type[te1] << std::endl; throw LogicException(ss.str()); - Assert( false ); + Assert(false); } if( tn2.isNull() ){ Trace("sep-type") << "Sep: assume location type " << tn1 << " (from " << atom << ")" << std::endl; @@ -1058,7 +1061,7 @@ void TheorySep::registerRefDataTypes( TypeNode tn1, TypeNode tn2, Node atom ){ std::stringstream ss; ss << "ERROR: location type " << tn1 << " is already associated with data type " << itt->second << ", offending atom is " << atom << " with data type " << tn2 << std::endl; throw LogicException(ss.str()); - Assert( false ); + Assert(false); } } } @@ -1221,7 +1224,7 @@ Node TheorySep::getNilRef( TypeNode tn ) { } void TheorySep::setNilRef( TypeNode tn, Node n ) { - Assert( n.getType()==tn ); + Assert(n.getType() == tn); d_nil_ref[tn] = n; } @@ -1233,7 +1236,7 @@ Node TheorySep::mkUnion( TypeNode tn, std::vector< Node >& locs ) { }else{ for( unsigned i=0; imkNode( kind::SINGLETON, s ); if( u.isNull() ){ u = s; @@ -1263,7 +1266,7 @@ Node TheorySep::getLabel( Node atom, int child, Node lbl ) { } Node TheorySep::applyLabel( Node n, Node lbl, std::map< Node, Node >& visited ) { - Assert( n.getKind()!=kind::SEP_LABEL ); + Assert(n.getKind() != kind::SEP_LABEL); if( n.getKind()==kind::SEP_STAR || n.getKind()==kind::SEP_WAND || n.getKind()==kind::SEP_PTO || n.getKind()==kind::SEP_EMP ){ return NodeManager::currentNM()->mkNode( kind::SEP_LABEL, n, lbl ); }else if( !n.getType().isBoolean() || n.getNumChildren()==0 ){ @@ -1306,28 +1309,28 @@ Node TheorySep::instantiateLabel( Node n, Node o_lbl, Node lbl, Node lbl_v, std: Trace("sep-inst") << n << "[" << lbl << "] :: " << lbl_v << std::endl; } } - Assert( n.getKind()!=kind::SEP_LABEL ); + Assert(n.getKind() != kind::SEP_LABEL); if( n.getKind()==kind::SEP_STAR || n.getKind()==kind::SEP_WAND ){ if( lbl==o_lbl ){ std::vector< Node > children; children.resize( n.getNumChildren() ); - Assert( d_label_map[n].find( lbl )!=d_label_map[n].end() ); + Assert(d_label_map[n].find(lbl) != d_label_map[n].end()); std::map< int, Node > mvals; for( std::map< int, Node >::iterator itl = d_label_map[n][lbl].begin(); itl != d_label_map[n][lbl].end(); ++itl ){ Node sub_lbl = itl->second; int sub_index = itl->first; - Assert( sub_index>=0 && sub_index<(int)children.size() ); + Assert(sub_index >= 0 && sub_index < (int)children.size()); Trace("sep-inst-debug") << "Sublabel " << sub_index << " is " << sub_lbl << std::endl; Node lbl_mval; if( n.getKind()==kind::SEP_WAND && sub_index==1 ){ - Assert( d_label_map[n][lbl].find( 0 )!=d_label_map[n][lbl].end() ); + Assert(d_label_map[n][lbl].find(0) != d_label_map[n][lbl].end()); Node sub_lbl_0 = d_label_map[n][lbl][0]; computeLabelModel( sub_lbl_0 ); - Assert( d_label_model.find( sub_lbl_0 )!=d_label_model.end() ); + Assert(d_label_model.find(sub_lbl_0) != d_label_model.end()); lbl_mval = NodeManager::currentNM()->mkNode( kind::UNION, lbl, d_label_model[sub_lbl_0].getValue( rtn ) ); }else{ computeLabelModel( sub_lbl ); - Assert( d_label_model.find( sub_lbl )!=d_label_model.end() ); + Assert(d_label_model.find(sub_lbl) != d_label_model.end()); lbl_mval = d_label_model[sub_lbl].getValue( rtn ); } Trace("sep-inst-debug") << "Sublabel value is " << lbl_mval << std::endl; @@ -1360,8 +1363,8 @@ Node TheorySep::instantiateLabel( Node n, Node o_lbl, Node lbl, Node lbl_v, std: } } bchildren.push_back( vsu.eqNode( lbl ) ); - - Assert( bchildren.size()>1 ); + + Assert(bchildren.size() > 1); conj.push_back( NodeManager::currentNM()->mkNode( kind::AND, bchildren ) ); if( options::sepChildRefine() ){ @@ -1403,7 +1406,7 @@ Node TheorySep::instantiateLabel( Node n, Node o_lbl, Node lbl, Node lbl_v, std: } }else if( n.getKind()==kind::SEP_PTO ){ //check if this pto reference is in the base label, if not, then it does not need to be added as an assumption - Assert( d_label_model.find( o_lbl )!=d_label_model.end() ); + Assert(d_label_model.find(o_lbl) != d_label_model.end()); Node vr = d_valuation.getModel()->getRepresentative( n[0] ); Node svr = NodeManager::currentNM()->mkNode( kind::SINGLETON, vr ); bool inBaseHeap = std::find( d_label_model[o_lbl].d_heap_locs_model.begin(), d_label_model[o_lbl].d_heap_locs_model.end(), svr )!=d_label_model[o_lbl].d_heap_locs_model.end(); @@ -1481,17 +1484,17 @@ void TheorySep::setInactiveAssertionRec( Node fact, std::map< Node, std::vector< void TheorySep::getLabelChildren( Node s_atom, Node lbl, std::vector< Node >& children, std::vector< Node >& labels ) { for( unsigned i=0; i visited; Node lc = applyLabel( s_atom[i], lblc, visited ); - Assert( !lc.isNull() ); + Assert(!lc.isNull()); if( i==1 && s_atom.getKind()==kind::SEP_WAND ){ lc = lc.negate(); } children.push_back( lc ); labels.push_back( lblc ); } - Assert( children.size()>1 ); + Assert(children.size() > 1); } void TheorySep::computeLabelModel( Node lbl ) { @@ -1504,7 +1507,7 @@ void TheorySep::computeLabelModel( Node lbl ) { Trace("sep-process") << "Model value (from valuation) for " << lbl << " : " << v_val << std::endl; if( v_val.getKind()!=kind::EMPTYSET ){ while( v_val.getKind()==kind::UNION ){ - Assert( v_val[1].getKind()==kind::SINGLETON ); + Assert(v_val[1].getKind() == kind::SINGLETON); d_label_model[lbl].d_heap_locs_model.push_back( v_val[1] ); v_val = v_val[0]; } @@ -1512,12 +1515,12 @@ void TheorySep::computeLabelModel( Node lbl ) { d_label_model[lbl].d_heap_locs_model.push_back( v_val ); }else{ throw Exception("Could not establish value of heap in model."); - Assert( false ); + Assert(false); } } for( unsigned j=0; j::iterator itm = d_tmodel.find( u ); @@ -1528,8 +1531,8 @@ void TheorySep::computeLabelModel( Node lbl ) { //TypeNode tn = u.getType().getRefConstituentType(); TypeNode tn = u.getType(); Trace("sep-process") << "WARNING: could not find symbolic term in model for " << u << ", cref type " << tn << std::endl; - Assert( d_type_references_all.find( tn )!=d_type_references_all.end() ); - Assert( !d_type_references_all[tn].empty() ); + Assert(d_type_references_all.find(tn) != d_type_references_all.end()); + Assert(!d_type_references_all[tn].empty()); tt = d_type_references_all[tn][0]; }else{ tt = itm->second; @@ -1604,7 +1607,7 @@ void TheorySep::validatePto( HeapAssertInfo * ei, Node ei_n ) { if (fact.getKind() == kind::NOT) { TNode atom = fact[0]; - Assert( atom.getKind()==kind::SEP_LABEL ); + Assert(atom.getKind() == kind::SEP_LABEL); TNode s_atom = atom[0]; if( s_atom.getKind()==kind::SEP_PTO ){ if( areEqual( atom[1], ei_n ) ){ @@ -1627,9 +1630,10 @@ void TheorySep::addPto( HeapAssertInfo * ei, Node ei_n, Node p, bool polarity ) }else{ Node pb = ei->d_pto.get(); Trace("sep-pto") << "Process positive/negated pto " << " " << pb << " " << p << std::endl; - Assert( pb.getKind()==kind::SEP_LABEL && pb[0].getKind()==kind::SEP_PTO ); - Assert( p.getKind()==kind::SEP_LABEL && p[0].getKind()==kind::SEP_PTO ); - Assert( areEqual( pb[1], p[1] ) ); + Assert(pb.getKind() == kind::SEP_LABEL + && pb[0].getKind() == kind::SEP_PTO); + Assert(p.getKind() == kind::SEP_LABEL && p[0].getKind() == kind::SEP_PTO); + Assert(areEqual(pb[1], p[1])); std::vector< Node > exp; if( pb[1]!=p[1] ){ //if( pb[1].getKind()==kind::SINGLETON && p[1].getKind()==kind::SINGLETON ){ @@ -1664,12 +1668,12 @@ void TheorySep::addPto( HeapAssertInfo * ei, Node ei_n, Node p, bool polarity ) void TheorySep::mergePto( Node p1, Node p2 ) { Trace("sep-lemma-debug") << "Merge pto " << p1 << " " << p2 << std::endl; - Assert( p1.getKind()==kind::SEP_LABEL && p1[0].getKind()==kind::SEP_PTO ); - Assert( p2.getKind()==kind::SEP_LABEL && p2[0].getKind()==kind::SEP_PTO ); + Assert(p1.getKind() == kind::SEP_LABEL && p1[0].getKind() == kind::SEP_PTO); + Assert(p2.getKind() == kind::SEP_LABEL && p2[0].getKind() == kind::SEP_PTO); if( !areEqual( p1[0][1], p2[0][1] ) ){ std::vector< Node > exp; if( p1[1]!=p2[1] ){ - Assert( areEqual( p1[1], p2[1] ) ); + Assert(areEqual(p1[1], p2[1])); exp.push_back( p1[1].eqNode( p2[1] ) ); } exp.push_back( p1 ); @@ -1771,7 +1775,7 @@ void TheorySep::debugPrintHeap( HeapInfo& heap, const char * c ) { } Node TheorySep::HeapInfo::getValue( TypeNode tn ) { - Assert( d_heap_locs.size()==d_heap_locs_model.size() ); + Assert(d_heap_locs.size() == d_heap_locs_model.size()); if( d_heap_locs.empty() ){ return NodeManager::currentNM()->mkConst(EmptySet(tn.toType())); }else if( d_heap_locs.size()==1 ){ diff --git a/src/theory/sep/theory_sep_rewriter.cpp b/src/theory/sep/theory_sep_rewriter.cpp index 92e7db7aa..09429cb13 100644 --- a/src/theory/sep/theory_sep_rewriter.cpp +++ b/src/theory/sep/theory_sep_rewriter.cpp @@ -25,7 +25,7 @@ namespace theory { namespace sep { void TheorySepRewriter::getStarChildren( Node n, std::vector< Node >& s_children, std::vector< Node >& ns_children ){ - Assert( n.getKind()==kind::SEP_STAR ); + Assert(n.getKind() == kind::SEP_STAR); Node tr = NodeManager::currentNM()->mkConst( true ); for( unsigned i=0; isecond); Trace("sets-model") << "Cardinality of " << eqc << " is " << v << std::endl; - Assert(v.getConst() <= LONG_MAX, - "Exceeded LONG_MAX in sets model"); + Assert(v.getConst() <= LONG_MAX) + << "Exceeded LONG_MAX in sets model"; unsigned vu = v.getConst().getNumerator().toUnsignedInt(); Assert(els.size() <= vu); NodeManager* nm = NodeManager::currentNM(); diff --git a/src/theory/sets/rels_utils.h b/src/theory/sets/rels_utils.h index 1bbbb359b..6354b59e9 100644 --- a/src/theory/sets/rels_utils.h +++ b/src/theory/sets/rels_utils.h @@ -72,7 +72,7 @@ public: } static Node reverseTuple( Node tuple ) { - Assert( tuple.getType().isTuple() ); + Assert(tuple.getType().isTuple()); std::vector elements; std::vector tuple_types = tuple.getType().getTupleTypes(); std::reverse( tuple_types.begin(), tuple_types.end() ); diff --git a/src/theory/sets/theory_sets_private.cpp b/src/theory/sets/theory_sets_private.cpp index 3b52da338..94fef85f5 100644 --- a/src/theory/sets/theory_sets_private.cpp +++ b/src/theory/sets/theory_sets_private.cpp @@ -127,12 +127,14 @@ void TheorySetsPrivate::eqNotifyPostMerge(TNode t1, TNode t2){ n_members = (*mem_i1).second; } for( int i=0; i<(*mem_i2).second; i++ ){ - Assert( i<(int)d_members_data[t2].size() && d_members_data[t2][i].getKind()==kind::MEMBER ); + Assert(i < (int)d_members_data[t2].size() + && d_members_data[t2][i].getKind() == kind::MEMBER); Node m2 = d_members_data[t2][i]; //check if redundant bool add = true; for( int j=0; jmkNode( kind::AND, m2[1].eqNode( s1 ), m2 ); if( s1.getKind()==kind::SINGLETON ){ @@ -213,7 +215,8 @@ bool TheorySetsPrivate::areCareDisequal(Node a, Node b) } bool TheorySetsPrivate::isMember( Node x, Node s ) { - Assert( d_equalityEngine.hasTerm( s ) && d_equalityEngine.getRepresentative( s )==s ); + Assert(d_equalityEngine.hasTerm(s) + && d_equalityEngine.getRepresentative(s) == s); NodeIntMap::iterator mem_i = d_members.find( s ); if( mem_i != d_members.end() ) { for( int i=0; i<(*mem_i).second; i++ ){ @@ -331,10 +334,10 @@ void TheorySetsPrivate::fullEffortCheck(){ } TypeNode tnn = n.getType(); if( isSet ){ - Assert( tnn.isSet() ); + Assert(tnn.isSet()); TypeNode tnnel = tnn.getSetElementType(); tnc = TypeNode::mostCommonTypeNode( tnc, tnnel ); - Assert( !tnc.isNull() ); + Assert(!tnc.isNull()); //update the common type term if( tnc==tnnel ){ tnct = n; @@ -367,7 +370,7 @@ void TheorySetsPrivate::fullEffortCheck(){ ++eqc_i; } if( isSet ){ - Assert( tnct.getType().getSetElementType()==tnc ); + Assert(tnct.getType().getSetElementType() == tnc); d_most_common_type[eqc] = tnc; d_most_common_type_term[eqc] = tnct; } @@ -513,7 +516,7 @@ void TheorySetsPrivate::checkDownwardsClosure() { Node mem = it2.second; Node eq_set = nv; - Assert( d_equalityEngine.areEqual( mem[1], eq_set ) ); + Assert(d_equalityEngine.areEqual(mem[1], eq_set)); if( mem[1]!=eq_set ){ Trace("sets-debug") << "Downwards closure based on " << mem << ", eq_set = " << eq_set << std::endl; if( !options::setsProxyLemmas() ){ @@ -621,7 +624,7 @@ void TheorySetsPrivate::checkUpwardsClosure() } } }else{ - Assert( k==kind::SETMINUS ); + Assert(k == kind::SETMINUS); std::map::const_iterator itm = r2mem.find(xr); if (itm == r2mem.end()) { @@ -847,8 +850,8 @@ void TheorySetsPrivate::addCarePairs(TNodeTrie* t1, for (unsigned k = 0; k < f1.getNumChildren(); ++ k) { TNode x = f1[k]; TNode y = f2[k]; - Assert( d_equalityEngine.hasTerm(x) ); - Assert( d_equalityEngine.hasTerm(y) ); + Assert(d_equalityEngine.hasTerm(x)); + Assert(d_equalityEngine.hasTerm(y)); Assert(!d_state.areDisequal(x, y)); Assert(!areCareDisequal(x, y)); if( !d_equalityEngine.areEqual( x, y ) ){ @@ -860,7 +863,7 @@ void TheorySetsPrivate::addCarePairs(TNodeTrie* t1, }else if( isCareArg( f1, k ) && isCareArg( f2, k ) ){ //splitting on sets (necessary for handling set of sets properly) if( x.getType().isSet() ){ - Assert( y.getType().isSet() ); + Assert(y.getType().isSet()); if (!d_state.areDisequal(x, y)) { Trace("sets-cg-lemma") << "Should split on : " << x << "==" << y << std::endl; diff --git a/src/theory/sets/theory_sets_rels.cpp b/src/theory/sets/theory_sets_rels.cpp index 65cff2418..5c24cb088 100644 --- a/src/theory/sets/theory_sets_rels.cpp +++ b/src/theory/sets/theory_sets_rels.cpp @@ -522,7 +522,7 @@ void TheorySetsRels::check(Theory::Effort level) std::map< Node, std::map< Node, Node > >::iterator tc_exp_it = d_tcr_tcGraph_exps.find( tc_rel ); TC_GRAPH_IT tc_graph_it = (tc_it->second).find( mem_rep_fst ); - Assert( tc_exp_it != d_tcr_tcGraph_exps.end() ); + Assert(tc_exp_it != d_tcr_tcGraph_exps.end()); std::map< Node, Node >::iterator exp_map_it = (tc_exp_it->second).find( mem_rep_tup ); if( exp_map_it == (tc_exp_it->second).end() ) { @@ -679,7 +679,7 @@ void TheorySetsRels::check(Theory::Effort level) std::vector< Node > reasons; std::unordered_set seen; Node tuple = RelsUtils::constructPair( tc_rel, getRepresentative( tc_graph_it->first ), getRepresentative( *snd_elements_it) ); - Assert( rel_tc_graph_exps.find( tuple ) != rel_tc_graph_exps.end() ); + Assert(rel_tc_graph_exps.find(tuple) != rel_tc_graph_exps.end()); Node exp = rel_tc_graph_exps.find( tuple )->second; reasons.push_back( exp ); @@ -918,7 +918,8 @@ void TheorySetsRels::check(Theory::Effort level) Trace("rels-debug") << "[Theory::Rels] ****** Finalizing transitive closure inferences!" << std::endl; TC_IT tc_graph_it = d_tcr_tcGraph.begin(); while( tc_graph_it != d_tcr_tcGraph.end() ) { - Assert ( d_tcr_tcGraph_exps.find(tc_graph_it->first) != d_tcr_tcGraph_exps.end() ); + Assert(d_tcr_tcGraph_exps.find(tc_graph_it->first) + != d_tcr_tcGraph_exps.end()); doTCInference( tc_graph_it->second, d_tcr_tcGraph_exps.find(tc_graph_it->first)->second, tc_graph_it->first ); ++tc_graph_it; } @@ -992,7 +993,7 @@ void TheorySetsRels::check(Theory::Effort level) std::vector members = d_rReps_memberReps_cache[rel0_rep]; std::vector exps = d_rReps_memberReps_exp_cache[rel0_rep]; - Assert( members.size() == exps.size() ); + Assert(members.size() == exps.size()); for(unsigned int i = 0; i < members.size(); i++) { Node reason = exps[i]; diff --git a/src/theory/sets/theory_sets_rewriter.cpp b/src/theory/sets/theory_sets_rewriter.cpp index 5d654e7d5..aa6f4de3f 100644 --- a/src/theory/sets/theory_sets_rewriter.cpp +++ b/src/theory/sets/theory_sets_rewriter.cpp @@ -35,8 +35,9 @@ bool checkConstantMembership(TNode elementTerm, TNode setTerm) return elementTerm == setTerm[0]; } - Assert(setTerm.getKind() == kind::UNION && setTerm[1].getKind() == kind::SINGLETON, - "kind was %d, term: %s", setTerm.getKind(), setTerm.toString().c_str()); + Assert(setTerm.getKind() == kind::UNION + && setTerm[1].getKind() == kind::SINGLETON) + << "kind was " << setTerm.getKind() << ", term: " << setTerm; return elementTerm == setTerm[1][0] || @@ -81,7 +82,8 @@ RewriteResponse TheorySetsRewriter::postRewrite(TNode node) { }//kind::MEMBER case kind::SUBSET: { - Assert(false, "TheorySets::postRrewrite(): Subset is handled in preRewrite."); + Assert(false) + << "TheorySets::postRrewrite(): Subset is handled in preRewrite."; // but in off-chance we do end up here, let us do our best diff --git a/src/theory/sets/theory_sets_type_rules.h b/src/theory/sets/theory_sets_type_rules.h index 7e6038423..27aa58452 100644 --- a/src/theory/sets/theory_sets_type_rules.h +++ b/src/theory/sets/theory_sets_type_rules.h @@ -48,9 +48,8 @@ public: struct SetsBinaryOperatorTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::UNION || - n.getKind() == kind::INTERSECTION || - n.getKind() == kind::SETMINUS); + Assert(n.getKind() == kind::UNION || n.getKind() == kind::INTERSECTION + || n.getKind() == kind::SETMINUS); TypeNode setType = n[0].getType(check); if( check ) { if(!setType.isSet()) { @@ -73,9 +72,8 @@ struct SetsBinaryOperatorTypeRule { } inline static bool computeIsConst(NodeManager* nodeManager, TNode n) { - Assert(n.getKind() == kind::UNION || - n.getKind() == kind::INTERSECTION || - n.getKind() == kind::SETMINUS); + Assert(n.getKind() == kind::UNION || n.getKind() == kind::INTERSECTION + || n.getKind() == kind::SETMINUS); if(n.getKind() == kind::UNION) { return NormalForm::checkNormalConstant(n); } else { @@ -223,7 +221,7 @@ struct InsertTypeRule { { Assert(n.getKind() == kind::INSERT); size_t numChildren = n.getNumChildren(); - Assert( numChildren >= 2 ); + Assert(numChildren >= 2); TypeNode setType = n[numChildren-1].getType(check); if( check ) { if(!setType.isSet()) { @@ -249,8 +247,7 @@ struct InsertTypeRule { struct RelBinaryOperatorTypeRule { inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert(n.getKind() == kind::PRODUCT || - n.getKind() == kind::JOIN); + Assert(n.getKind() == kind::PRODUCT || n.getKind() == kind::JOIN); TypeNode firstRelType = n[0].getType(check); TypeNode secondRelType = n[1].getType(check); @@ -286,8 +283,7 @@ struct RelBinaryOperatorTypeRule { } inline static bool computeIsConst(NodeManager* nodeManager, TNode n) { - Assert(n.getKind() == kind::JOIN || - n.getKind() == kind::PRODUCT); + Assert(n.getKind() == kind::JOIN || n.getKind() == kind::PRODUCT); return false; } };/* struct RelBinaryOperatorTypeRule */ @@ -331,8 +327,8 @@ struct RelTransClosureTypeRule { } inline static bool computeIsConst(NodeManager* nodeManager, TNode n) { - Assert(n.getKind() == kind::TCLOSURE); - return false; + Assert(n.getKind() == kind::TCLOSURE); + return false; } };/* struct RelTransClosureTypeRule */ diff --git a/src/theory/sort_inference.cpp b/src/theory/sort_inference.cpp index 6c141cf2a..d1ecef831 100644 --- a/src/theory/sort_inference.cpp +++ b/src/theory/sort_inference.cpp @@ -654,13 +654,13 @@ Node SortInference::simplifyNode( } if( processChild ){ if( n.getKind()==kind::APPLY_UF ){ - Assert( d_op_arg_types.find( op )!=d_op_arg_types.end() ); + Assert(d_op_arg_types.find(op) != d_op_arg_types.end()); tnnc = getOrCreateTypeForId( d_op_arg_types[op][i], n[i].getType() ); - Assert( !tnnc.isNull() ); + Assert(!tnnc.isNull()); }else if( n.getKind()==kind::EQUAL && i==0 ){ - Assert( d_equality_types.find( n )!=d_equality_types.end() ); + Assert(d_equality_types.find(n) != d_equality_types.end()); tnnc = getOrCreateTypeForId( d_equality_types[n], n[0].getType() ); - Assert( !tnnc.isNull() ); + Assert(!tnnc.isNull()); } Node nc = simplifyNode(n[i], var_bound, @@ -688,7 +688,7 @@ Node SortInference::simplifyNode( if( !tn1.isSubtypeOf( tn2 ) && !tn2.isSubtypeOf( tn1 ) ){ Trace("sort-inference-warn") << "Sort inference created bad equality: " << children[0] << " = " << children[1] << std::endl; Trace("sort-inference-warn") << " Types : " << children[0].getType() << " " << children[1].getType() << std::endl; - Assert( false ); + Assert(false); } ret = NodeManager::currentNM()->mkNode( kind::EQUAL, children ); }else if( n.getKind()==kind::APPLY_UF ){ @@ -727,7 +727,7 @@ Node SortInference::simplifyNode( if (!tn.isSubtypeOf(tna)) { Trace("sort-inference-warn") << "Sort inference created bad child: " << n << " " << n[i] << " " << tn << " " << tna << std::endl; - Assert( false ); + Assert(false); } } ret = NodeManager::currentNM()->mkNode( kind::APPLY_UF, children ); @@ -844,7 +844,7 @@ void SortInference::getSortConstraints( Node n, UnionFind& uf ) { } bool SortInference::isMonotonic( TypeNode tn ) { - Assert( tn.isSort() ); + Assert(tn.isSort()); return d_non_monotonic_sorts_orig.find( tn )==d_non_monotonic_sorts_orig.end(); } diff --git a/src/theory/strings/regexp_operation.cpp b/src/theory/strings/regexp_operation.cpp index b20e2f3ad..aaf1c864f 100644 --- a/src/theory/strings/regexp_operation.cpp +++ b/src/theory/strings/regexp_operation.cpp @@ -281,7 +281,7 @@ int RegExpOpr::delta( Node r, Node &exp ) { // 0-unknown, 1-yes, 2-no int RegExpOpr::derivativeS( Node r, CVC4::String c, Node &retNode ) { - Assert( c.size() < 2 ); + Assert(c.size() < 2); Trace("regexp-derive") << "RegExp-derive starts with /" << mkString( r ) << "/, c=" << c << std::endl; int ret = 1; @@ -522,7 +522,7 @@ int RegExpOpr::derivativeS( Node r, CVC4::String c, Node &retNode ) { } Node RegExpOpr::derivativeSingle( Node r, CVC4::String c ) { - Assert( c.size() < 2 ); + Assert(c.size() < 2); Trace("regexp-derive") << "RegExp-derive starts with /" << mkString( r ) << "/, c=" << c << std::endl; Node retNode = d_emptyRegexp; PairNodeStr dv = std::make_pair( r, c ); @@ -1249,8 +1249,8 @@ bool RegExpOpr::isPairNodesInSet(std::set< PairNodes > &s, Node n1, Node n2) { bool RegExpOpr::containC2(unsigned cnt, Node n) { if(n.getKind() == kind::REGEXP_RV) { - Assert(n[0].getConst() <= Rational(String::maxSize()), - "Exceeded UINT32_MAX in RegExpOpr::containC2"); + Assert(n[0].getConst() <= Rational(String::maxSize())) + << "Exceeded UINT32_MAX in RegExpOpr::containC2"; unsigned y = n[0].getConst().getNumerator().toUnsignedInt(); return cnt == y; } else if(n.getKind() == kind::REGEXP_CONCAT) { @@ -1291,8 +1291,8 @@ void RegExpOpr::convert2(unsigned cnt, Node n, Node &r1, Node &r2) { r1 = d_emptySingleton; r2 = d_emptySingleton; } else if(n.getKind() == kind::REGEXP_RV) { - Assert(n[0].getConst() <= Rational(String::maxSize()), - "Exceeded UINT32_MAX in RegExpOpr::convert2"); + Assert(n[0].getConst() <= Rational(String::maxSize())) + << "Exceeded UINT32_MAX in RegExpOpr::convert2"; unsigned y = n[0].getConst().getNumerator().toUnsignedInt(); r1 = d_emptySingleton; if(cnt == y) { @@ -1503,7 +1503,7 @@ Node RegExpOpr::intersectInternal( Node r1, Node r2, std::map< PairNodes, Node > } Node RegExpOpr::removeIntersection(Node r) { - Assert( checkConstRegExp(r) ); + Assert(checkConstRegExp(r)); std::map < Node, Node >::const_iterator itr = d_rm_inter_cache.find(r); if(itr != d_rm_inter_cache.end()) { return itr->second; diff --git a/src/theory/strings/regexp_solver.cpp b/src/theory/strings/regexp_solver.cpp index 11471c09f..b13b64f98 100644 --- a/src/theory/strings/regexp_solver.cpp +++ b/src/theory/strings/regexp_solver.cpp @@ -574,9 +574,9 @@ bool RegExpSolver::deriveRegExp(Node x, { if (x.isConst()) { - Assert(false, - "Impossible: RegExpSolver::deriveRegExp: const string in const " - "regular expression."); + Assert(false) + << "Impossible: RegExpSolver::deriveRegExp: const string in const " + "regular expression."; return false; } else diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp index b0681b1ff..750710769 100644 --- a/src/theory/strings/theory_strings.cpp +++ b/src/theory/strings/theory_strings.cpp @@ -73,7 +73,7 @@ Node TheoryStrings::TermIndex::add(TNode n, } return d_data; }else{ - Assert( index() <= Rational(String::maxSize()), - "Exceeded UINT32_MAX in string model"); + Assert(len_value.getConst() <= Rational(String::maxSize())) + << "Exceeded UINT32_MAX in string model"; unsigned lvalue = len_value.getConst().getNumerator().toUnsignedInt(); std::map::iterator itvu = values_used.find(lvalue); @@ -668,8 +668,8 @@ bool TheoryStrings::collectModelInfo(TheoryModel* m) Trace("strings-model") << std::endl; //use type enumerator - Assert(lts_values[i].getConst() <= Rational(String::maxSize()), - "Exceeded UINT32_MAX in string model"); + Assert(lts_values[i].getConst() <= Rational(String::maxSize())) + << "Exceeded UINT32_MAX in string model"; StringEnumeratorLength sel(lts_values[i].getConst().getNumerator().toUnsignedInt()); for (const Node& eqc : pure_eq) { @@ -677,7 +677,7 @@ bool TheoryStrings::collectModelInfo(TheoryModel* m) std::map::iterator itp = pure_eq_assign.find(eqc); if (itp == pure_eq_assign.end()) { - Assert( !sel.isFinished() ); + Assert(!sel.isFinished()); c = *sel; while (m->hasTerm(c)) { @@ -765,11 +765,11 @@ bool TheoryStrings::collectModelInfo(TheoryModel* m) for (const Node& n : nf.d_nf) { Node r = d_state.getRepresentative(n); - Assert( r.isConst() || processed.find( r )!=processed.end() ); + Assert(r.isConst() || processed.find(r) != processed.end()); nc.push_back(r.isConst() ? r : processed[r]); } Node cc = utils::mkNConcat(nc); - Assert( cc.getKind()==kind::CONST_STRING ); + Assert(cc.getKind() == kind::CONST_STRING); Trace("strings-model") << "*** Determined constant " << cc << " for " << nodes[i] << std::endl; processed[nodes[i]] = cc; if (!m->assertEquality(nodes[i], cc, true)) @@ -1164,10 +1164,10 @@ void TheoryStrings::addCarePairs(TNodeTrie* t1, for (unsigned k = 0; k < f1.getNumChildren(); ++ k) { TNode x = f1[k]; TNode y = f2[k]; - Assert( d_equalityEngine.hasTerm(x) ); - Assert( d_equalityEngine.hasTerm(y) ); - Assert( !d_equalityEngine.areDisequal( x, y, false ) ); - Assert( !areCareDisequal( x, y ) ); + Assert(d_equalityEngine.hasTerm(x)); + Assert(d_equalityEngine.hasTerm(y)); + Assert(!d_equalityEngine.areDisequal(x, y, false)); + Assert(!areCareDisequal(x, y)); if( !d_equalityEngine.areEqual( x, y ) ){ if( d_equalityEngine.isTriggerTerm(x, THEORY_STRINGS) && d_equalityEngine.isTriggerTerm(y, THEORY_STRINGS) ){ TNode x_shared = d_equalityEngine.getTriggerTermRepresentative(x, THEORY_STRINGS); @@ -1259,7 +1259,7 @@ void TheoryStrings::computeCareGraph(){ void TheoryStrings::assertPendingFact(Node atom, bool polarity, Node exp) { Trace("strings-pending") << "Assert pending fact : " << atom << " " << polarity << " from " << exp << std::endl; - Assert(atom.getKind() != kind::OR, "Infer error: a split."); + Assert(atom.getKind() != kind::OR) << "Infer error: a split."; if( atom.getKind()==kind::EQUAL ){ Trace("strings-pending-debug") << " Register term" << std::endl; for( unsigned j=0; j<2; j++ ) { @@ -1369,7 +1369,7 @@ void TheoryStrings::checkInit() { } //explain equal components if( count[0]& curr, std::vecto } Trace("strings-error") << "Looping term should be congruent : " << n << " " << eqc << " " << ncy << std::endl; //should find a non-empty component, otherwise would have been singular congruent (I_Norm_S) - Assert( false ); + Assert(false); }else{ return ncy; } @@ -2661,7 +2661,7 @@ void TheoryStrings::normalizeEquivalenceClass( Node eqc ) { } //construct the normal form - Assert( !normal_forms.empty() ); + Assert(!normal_forms.empty()); unsigned nf_index = 0; std::map::iterator it = term_to_nf_index.find(eqc); // we prefer taking the normal form whose base is the equivalence @@ -2901,9 +2901,9 @@ void TheoryStrings::getNormalForms(Node eqc, Trace("strings-solve") << "Normal form for " << n << " cannot be contained in constant " << c << std::endl; //conflict, explanation is n = base ^ base = c ^ relevant porition of ( n = N[n] ) std::vector< Node > exp; - Assert( d_eqc_to_const_base.find( eqc )!=d_eqc_to_const_base.end() ); + Assert(d_eqc_to_const_base.find(eqc) != d_eqc_to_const_base.end()); d_im.addToExplanation(n, d_eqc_to_const_base[eqc], exp); - Assert( d_eqc_to_const_exp.find( eqc )!=d_eqc_to_const_exp.end() ); + Assert(d_eqc_to_const_exp.find(eqc) != d_eqc_to_const_exp.end()); if( !d_eqc_to_const_exp[eqc].isNull() ){ exp.push_back( d_eqc_to_const_exp[eqc] ); } @@ -3219,8 +3219,10 @@ void TheoryStrings::processSimpleNEq(NormalForm& nfi, NormalForm& nfnc = nfiv[index].isConst() ? nfj : nfi; std::vector& nfncv = nfnc.d_nf; Node other_str = nfncv[index]; - Assert( other_str.getKind()!=kind::CONST_STRING, "Other string is not constant." ); - Assert( other_str.getKind()!=kind::STRING_CONCAT, "Other string is not CONCAT." ); + Assert(other_str.getKind() != kind::CONST_STRING) + << "Other string is not constant."; + Assert(other_str.getKind() != kind::STRING_CONCAT) + << "Other string is not CONCAT."; if( !d_equalityEngine.areDisequal( other_str, d_emptyString, true ) ){ Node eq = other_str.eqNode( d_emptyString ); eq = Rewriter::rewrite(eq); @@ -3263,7 +3265,7 @@ void TheoryStrings::processSimpleNEq(NormalForm& nfi, Node const_str = TheoryStringsRewriter::collectConstantStringAt( nfcv, index_c_k, false); - Assert( !const_str.isNull() ); + Assert(!const_str.isNull()); CVC4::String stra = const_str.getConst(); CVC4::String strb = next_const_str.getConst(); //since non-empty, we start with charecter #1 @@ -3428,7 +3430,7 @@ void TheoryStrings::processSimpleNEq(NormalForm& nfi, } if( info_valid ){ pinfer.push_back( info ); - Assert( !success ); + Assert(!success); } } } @@ -3703,13 +3705,14 @@ void TheoryStrings::processDeq( Node ni, Node nj ) { if( ret!=0 ) { return; }else{ - Assert( index lexp; Node li = d_state.getLength(i, lexp); Node lj = d_state.getLength(j, lexp); @@ -3835,7 +3838,7 @@ void TheoryStrings::processDeq( Node ni, Node nj ) { index++; } } - Assert( false ); + Assert(false); } } @@ -3965,8 +3968,8 @@ void TheoryStrings::addNormalFormPair( Node n1, Node n2 ){ d_nf_pairs_data[n1][index] = n2; }else{ d_nf_pairs_data[n1].push_back( n2 ); - } - Assert( isNormalFormPair( n1, n2 ) ); + } + Assert(isNormalFormPair(n1, n2)); } else { Trace("strings-nf-debug") << "Already a normal form pair " << n1 << " " << n2 << std::endl; } @@ -3981,9 +3984,9 @@ bool TheoryStrings::isNormalFormPair2( Node n1, Node n2 ) { //Trace("strings-debug") << "is normal form pair. " << n1 << " " << n2 << std::endl; NodeIntMap::const_iterator it = d_nf_pairs.find( n1 ); if( it!=d_nf_pairs.end() ){ - Assert( d_nf_pairs_data.find( n1 )!=d_nf_pairs_data.end() ); + Assert(d_nf_pairs_data.find(n1) != d_nf_pairs_data.end()); for( int i=0; i<(*it).second; i++ ){ - Assert( i<(int)d_nf_pairs_data[n1].size() ); + Assert(i < (int)d_nf_pairs_data[n1].size()); if( d_nf_pairs_data[n1][i]==n2 ){ return true; } @@ -4489,7 +4492,7 @@ void TheoryStrings::separateByLength(std::vector< Node >& n, std::map< unsigned, std::vector< Node > > eqc_to_strings; for( unsigned i=0; id_lengthTerm : Node::null(); if( !lt.isNull() ){ @@ -4593,7 +4596,7 @@ Node TheoryStrings::ppRewrite(TNode atom) { } return ret; }else{ - Assert( new_nodes.empty() ); + Assert(new_nodes.empty()); } } return atom; @@ -4658,7 +4661,7 @@ bool TheoryStrings::hasStrategyEffort(Effort e) const void TheoryStrings::addStrategyStep(InferStep s, int effort, bool addBreak) { // must run check init first - Assert((s == CHECK_INIT)==d_infer_steps.empty()); + Assert((s == CHECK_INIT) == d_infer_steps.empty()); // must use check cycles when using flat forms Assert(s != CHECK_FLAT_FORMS || std::find(d_infer_steps.begin(), d_infer_steps.end(), CHECK_CYCLES) diff --git a/src/theory/strings/theory_strings_rewriter.cpp b/src/theory/strings/theory_strings_rewriter.cpp index adf74f0cc..1e5b2a65a 100644 --- a/src/theory/strings/theory_strings_rewriter.cpp +++ b/src/theory/strings/theory_strings_rewriter.cpp @@ -52,8 +52,8 @@ Node TheoryStringsRewriter::simpleRegexpConsume( std::vector< Node >& mchildren, do_next = false; Node xc = mchildren[mchildren.size()-1]; Node rc = children[children.size()-1]; - Assert( rc.getKind()!=kind::REGEXP_CONCAT ); - Assert( xc.getKind()!=kind::STRING_CONCAT ); + Assert(rc.getKind() != kind::REGEXP_CONCAT); + Assert(xc.getKind() != kind::STRING_CONCAT); if( rc.getKind() == kind::STRING_TO_REGEXP ){ if( xc==rc[0] ){ children.pop_back(); @@ -132,7 +132,7 @@ Node TheoryStringsRewriter::simpleRegexpConsume( std::vector< Node >& mchildren, }else{ if( children_s.empty() ){ //if we were able to fully consume, store the result - Assert( mchildren_s.size()<=1 ); + Assert(mchildren_s.size() <= 1); if( mchildren_s.empty() ){ mchildren_s.push_back( emp_s ); } @@ -149,7 +149,7 @@ Node TheoryStringsRewriter::simpleRegexpConsume( std::vector< Node >& mchildren, if( result_valid ){ if( result.isNull() ){ //all disjuncts cannot be satisfied, return false - Assert( rc.getKind()==kind::REGEXP_UNION ); + Assert(rc.getKind() == kind::REGEXP_UNION); return NodeManager::currentNM()->mkConst( false ); }else{ //all branches led to the same result @@ -820,7 +820,7 @@ Node TheoryStringsRewriter::rewriteConcat(Node node) Node TheoryStringsRewriter::rewriteConcatRegExp(TNode node) { - Assert( node.getKind() == kind::REGEXP_CONCAT ); + Assert(node.getKind() == kind::REGEXP_CONCAT); NodeManager* nm = NodeManager::currentNM(); Trace("strings-rewrite-debug") << "Strings::rewriteConcatRegExp flatten " << node << std::endl; @@ -1105,11 +1105,11 @@ Node TheoryStringsRewriter::rewriteLoopRegExp(TNode node) TNode n1 = node[1]; NodeManager* nm = NodeManager::currentNM(); CVC4::Rational rMaxInt(String::maxSize()); - AlwaysAssert(n1.isConst(), "re.loop contains non-constant integer (1)."); - AlwaysAssert(n1.getConst().sgn() >= 0, - "Negative integer in string REGEXP_LOOP (1)"); - Assert(n1.getConst() <= rMaxInt, - "Exceeded UINT32_MAX in string REGEXP_LOOP (1)"); + AlwaysAssert(n1.isConst()) << "re.loop contains non-constant integer (1)."; + AlwaysAssert(n1.getConst().sgn() >= 0) + << "Negative integer in string REGEXP_LOOP (1)"; + Assert(n1.getConst() <= rMaxInt) + << "Exceeded UINT32_MAX in string REGEXP_LOOP (1)"; uint32_t l = n1.getConst().getNumerator().toUnsignedInt(); std::vector vec_nodes; for (unsigned i = 0; i < l; i++) @@ -1123,11 +1123,11 @@ Node TheoryStringsRewriter::rewriteLoopRegExp(TNode node) vec_nodes.size() == 0 ? nm->mkNode(STRING_TO_REGEXP, nm->mkConst(String(""))) : vec_nodes.size() == 1 ? r : nm->mkNode(REGEXP_CONCAT, vec_nodes); - AlwaysAssert(n2.isConst(), "re.loop contains non-constant integer (2)."); - AlwaysAssert(n2.getConst().sgn() >= 0, - "Negative integer in string REGEXP_LOOP (2)"); - Assert(n2.getConst() <= rMaxInt, - "Exceeded UINT32_MAX in string REGEXP_LOOP (2)"); + AlwaysAssert(n2.isConst()) << "re.loop contains non-constant integer (2)."; + AlwaysAssert(n2.getConst().sgn() >= 0) + << "Negative integer in string REGEXP_LOOP (2)"; + Assert(n2.getConst() <= rMaxInt) + << "Exceeded UINT32_MAX in string REGEXP_LOOP (2)"; uint32_t u = n2.getConst().getNumerator().toUnsignedInt(); if (u <= l) { @@ -1184,7 +1184,7 @@ bool TheoryStringsRewriter::isConstRegExp( TNode t ) { } bool TheoryStringsRewriter::testConstStringInRegExp( CVC4::String &s, unsigned int index_start, TNode r ) { - Assert( index_start <= s.size() ); + Assert(index_start <= s.size()); Trace("regexp-debug") << "Checking " << s << " in " << r << ", starting at " << index_start << std::endl; Assert(!r.isVar()); Kind k = r.getKind(); @@ -1194,7 +1194,7 @@ bool TheoryStringsRewriter::testConstStringInRegExp( CVC4::String &s, unsigned i if(r[0].getKind() == kind::CONST_STRING) { return ( s2 == r[0].getConst() ); } else { - Assert( false, "RegExp contains variables" ); + Assert(false) << "RegExp contains variables"; return false; } } @@ -1295,7 +1295,8 @@ bool TheoryStringsRewriter::testConstStringInRegExp( CVC4::String &s, unsigned i } else if(l==0 && r[1]==r[2]) { return false; } else { - Assert(r.getNumChildren() == 3, "String rewriter error: LOOP has 2 children"); + Assert(r.getNumChildren() == 3) + << "String rewriter error: LOOP has 2 children"; if(l==0) { //R{0,u} uint32_t u = r[2].getConst().getNumerator().toUnsignedInt(); @@ -1316,7 +1317,8 @@ bool TheoryStringsRewriter::testConstStringInRegExp( CVC4::String &s, unsigned i return false; } else { //R{l,l} - Assert(r[1]==r[2], "String rewriter error: LOOP nums are not equal"); + Assert(r[1] == r[2]) + << "String rewriter error: LOOP nums are not equal"; if(l>s.size() - index_start) { if(testConstStringInRegExp(s, s.size(), r[0])) { l = s.size() - index_start; @@ -3352,7 +3354,7 @@ Node TheoryStringsRewriter::rewriteStringCode(Node n) } Node TheoryStringsRewriter::splitConstant( Node a, Node b, int& index, bool isRev ) { - Assert( a.isConst() && b.isConst() ); + Assert(a.isConst() && b.isConst()); index = a.getConst().size() <= b.getConst().size() ? 1 : 0; unsigned len_short = index==1 ? a.getConst().size() : b.getConst().size(); bool cmp = isRev ? a.getConst().rstrncmp(b.getConst(), len_short): a.getConst().strncmp(b.getConst(), len_short); @@ -3371,10 +3373,10 @@ Node TheoryStringsRewriter::splitConstant( Node a, Node b, int& index, bool isRe } bool TheoryStringsRewriter::canConstantContainConcat( Node c, Node n, int& firstc, int& lastc ) { - Assert( c.isConst() ); + Assert(c.isConst()); CVC4::String t = c.getConst(); const std::vector& tvec = t.getVec(); - Assert( n.getKind()==kind::STRING_CONCAT ); + Assert(n.getKind() == kind::STRING_CONCAT); //must find constant components in order size_t pos = 0; firstc = -1; @@ -3410,7 +3412,7 @@ bool TheoryStringsRewriter::canConstantContainConcat( Node c, Node n, int& first } bool TheoryStringsRewriter::canConstantContainList( Node c, std::vector< Node >& l, int& firstc, int& lastc ) { - Assert( c.isConst() ); + Assert(c.isConst()); CVC4::String t = c.getConst(); //must find constant components in order size_t pos = 0; @@ -3457,7 +3459,7 @@ Node TheoryStringsRewriter::collectConstantStringAt( std::vector< Node >& vec, u std::reverse( c.begin(), c.end() ); } Node cc = Rewriter::rewrite(utils::mkConcat(STRING_CONCAT, c)); - Assert( cc.isConst() ); + Assert(cc.isConst()); return cc; }else{ return Node::null(); @@ -5135,8 +5137,8 @@ Node TheoryStringsRewriter::decomposeSubstrChain(Node s, std::vector& ss, std::vector& ls) { - Assert( ss.empty() ); - Assert( ls.empty() ); + Assert(ss.empty()); + Assert(ls.empty()); while (s.getKind() == STRING_SUBSTR) { ss.push_back(s[1]); diff --git a/src/theory/strings/type_enumerator.h b/src/theory/strings/type_enumerator.h index 5ca0b624d..4218d4ce5 100644 --- a/src/theory/strings/type_enumerator.h +++ b/src/theory/strings/type_enumerator.h @@ -44,8 +44,8 @@ class StringEnumerator : public TypeEnumeratorBase { StringEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr) : TypeEnumeratorBase(type) { - Assert(type.getKind() == kind::TYPE_CONSTANT && - type.getConst() == STRING_TYPE); + Assert(type.getKind() == kind::TYPE_CONSTANT + && type.getConst() == STRING_TYPE); d_cardinality = TheoryStringsRewriter::getAlphabetCardinality(); mkCurr(); } diff --git a/src/theory/substitutions.cpp b/src/theory/substitutions.cpp index 9007386c4..333f09d2d 100644 --- a/src/theory/substitutions.cpp +++ b/src/theory/substitutions.cpp @@ -180,7 +180,7 @@ void SubstitutionMap::addSubstitution(TNode x, TNode t, bool invalidateCache) // this causes a later assert-fail (the rhs != current one, above) anyway // putting it here is easier to diagnose - Assert(x != t, "cannot substitute a term for itself"); + Assert(x != t) << "cannot substitute a term for itself"; d_substitutions[x] = t; diff --git a/src/theory/theory.cpp b/src/theory/theory.cpp index a4b9d1ddf..719239806 100644 --- a/src/theory/theory.cpp +++ b/src/theory/theory.cpp @@ -21,7 +21,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/node_algorithm.h" #include "smt/smt_statistics_registry.h" #include "theory/ext_theory.h" diff --git a/src/theory/theory.h b/src/theory/theory.h index f6f1de69c..b133b878e 100644 --- a/src/theory/theory.h +++ b/src/theory/theory.h @@ -517,8 +517,9 @@ public: * (which was previously propagated by this theory). */ virtual Node explain(TNode n) { - Unimplemented("Theory %s propagated a node but doesn't implement the " - "Theory::explain() interface!", identify().c_str()); + Unimplemented() << "Theory " << identify() + << " propagated a node but doesn't implement the " + "Theory::explain() interface!"; } /** @@ -615,8 +616,8 @@ public: * via the syntax (! n :attr) */ virtual void setUserAttribute(const std::string& attr, Node n, std::vector node_values, std::string str_value) { - Unimplemented("Theory %s doesn't support Theory::setUserAttribute interface", - identify().c_str()); + Unimplemented() << "Theory " << identify() + << " doesn't support Theory::setUserAttribute interface"; } /** A set of theories */ @@ -645,7 +646,7 @@ public: /** Returns the index size of a set of theories */ static inline size_t setIndex(TheoryId id, Set set) { - Assert (setContains(id, set)); + Assert(setContains(id, set)); size_t count = 0; while (setPop(set) != id) { ++ count; @@ -858,7 +859,7 @@ std::ostream& operator<<(std::ostream& os, theory::Theory::Effort level); inline theory::Assertion Theory::get() { - Assert( !done(), "Theory::get() called with assertion queue empty!" ); + Assert(!done()) << "Theory::get() called with assertion queue empty!"; // Get the assertion Assertion fact = d_facts[d_factsHead]; diff --git a/src/theory/theory_engine.cpp b/src/theory/theory_engine.cpp index 2782badcb..0adb592f2 100644 --- a/src/theory/theory_engine.cpp +++ b/src/theory/theory_engine.cpp @@ -998,11 +998,13 @@ void TheoryEngine::postsolve() { #ifdef CVC4_FOR_EACH_THEORY_STATEMENT #undef CVC4_FOR_EACH_THEORY_STATEMENT #endif -#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \ - if (theory::TheoryTraits::hasPostsolve) { \ - theoryOf(THEORY)->postsolve(); \ - Assert(! d_inConflict || wasInConflict, "conflict raised during postsolve()"); \ - } +#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \ + if (theory::TheoryTraits::hasPostsolve) \ + { \ + theoryOf(THEORY)->postsolve(); \ + Assert(!d_inConflict || wasInConflict) \ + << "conflict raised during postsolve()"; \ + } // Postsolve for each theory using the statement above CVC4_FOR_EACH_THEORY; @@ -1317,7 +1319,8 @@ void TheoryEngine::assertToTheory(TNode assertion, TNode originalAssertion, theo // If sending to the shared terms database, it's also simple if (toTheoryId == THEORY_BUILTIN) { - Assert(atom.getKind() == kind::EQUAL, "atom should be an EQUALity, not `%s'", atom.toString().c_str()); + Assert(atom.getKind() == kind::EQUAL) + << "atom should be an EQUALity, not `" << atom << "'"; if (markPropagation(assertion, originalAssertion, toTheoryId, fromTheoryId)) { d_sharedTerms.assertEquality(atom, polarity, assertion); } @@ -1561,7 +1564,7 @@ void TheoryEngine::getInstantiatedQuantifiedFormulas( std::vector< Node >& qs ) if( d_quantEngine ){ d_quantEngine->getInstantiatedQuantifiedFormulas( qs ); }else{ - Assert( false ); + Assert(false); } } @@ -1569,7 +1572,7 @@ void TheoryEngine::getInstantiations( Node q, std::vector< Node >& insts ) { if( d_quantEngine ){ d_quantEngine->getInstantiations( q, insts ); }else{ - Assert( false ); + Assert(false); } } @@ -1577,7 +1580,7 @@ void TheoryEngine::getInstantiationTermVectors( Node q, std::vector< std::vector if( d_quantEngine ){ d_quantEngine->getInstantiationTermVectors( q, tvecs ); }else{ - Assert( false ); + Assert(false); } } @@ -1585,7 +1588,7 @@ void TheoryEngine::getInstantiations( std::map< Node, std::vector< Node > >& ins if( d_quantEngine ){ d_quantEngine->getInstantiations( insts ); }else{ - Assert( false ); + Assert(false); } } @@ -1593,7 +1596,7 @@ void TheoryEngine::getInstantiationTermVectors( std::map< Node, std::vector< std if( d_quantEngine ){ d_quantEngine->getInstantiationTermVectors( insts ); }else{ - Assert( false ); + Assert(false); } } @@ -1601,7 +1604,7 @@ Node TheoryEngine::getInstantiatedConjunction( Node q ) { if( d_quantEngine ){ return d_quantEngine->getInstantiatedConjunction( q ); }else{ - Assert( false ); + Assert(false); return Node::null(); } } @@ -1792,8 +1795,9 @@ void TheoryEngine::ensureLemmaAtoms(const std::vector& atoms, theory::The } continue; }else if( eqNormalized.getKind() != kind::EQUAL){ - Assert( eqNormalized.getKind()==kind::BOOLEAN_TERM_VARIABLE || - ( eqNormalized.getKind()==kind::NOT && eqNormalized[0].getKind()==kind::BOOLEAN_TERM_VARIABLE ) ); + Assert(eqNormalized.getKind() == kind::BOOLEAN_TERM_VARIABLE + || (eqNormalized.getKind() == kind::NOT + && eqNormalized[0].getKind() == kind::BOOLEAN_TERM_VARIABLE)); // this happens for Boolean term equalities V = true that are rewritten to V, we should skip // TODO : revisit this continue; @@ -2125,7 +2129,8 @@ void TheoryEngine::getExplanation(std::vector& explanationVector } Debug("theory::explain") << "TheoryEngine::explain(): got explanation " << explanation << " got from " << toExplain.theory << endl; - Assert( explanation != toExplain.node, "wasn't sent to you, so why are you explaining it trivially"); + Assert(explanation != toExplain.node) + << "wasn't sent to you, so why are you explaining it trivially"; // Mark the explanation NodeTheoryPair newExplain(explanation, toExplain.theory, toExplain.timestamp); explanationVector.push_back(newExplain); @@ -2217,14 +2222,17 @@ void TheoryEngine::checkTheoryAssertionsWithModel(bool hardFailure) { ++it) { Node assertion = (*it).assertion; Node val = getModel()->getValue(assertion); - if(val != d_true) { - stringstream ss; - ss << theoryId << " has an asserted fact that the model doesn't satisfy." << endl - << "The fact: " << assertion << endl - << "Model value: " << val << endl; - if(hardFailure) { - InternalError(ss.str()); - } + if (val != d_true) + { + if (hardFailure) + { + InternalError() + << theoryId + << " has an asserted fact that the model doesn't satisfy." + << endl + << "The fact: " << assertion << endl + << "Model value: " << val << endl; + } } } } diff --git a/src/theory/theory_engine.h b/src/theory/theory_engine.h index e88d3323a..bf3e394f1 100644 --- a/src/theory/theory_engine.h +++ b/src/theory/theory_engine.h @@ -26,7 +26,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/cdhashset.h" #include "expr/node.h" #include "options/options.h" diff --git a/src/theory/theory_model.cpp b/src/theory/theory_model.cpp index 0d82d3f02..da66a2ef2 100644 --- a/src/theory/theory_model.cpp +++ b/src/theory/theory_model.cpp @@ -369,12 +369,11 @@ void TheoryModel::addSubstitution( TNode x, TNode t, bool invalidateCache ){ Node oldX = d_substitutions.getSubstitution(x); // check that either the old substitution is the same, or it now maps to the new substitution if(oldX != t && d_substitutions.apply(oldX) != d_substitutions.apply(t)) { - stringstream ss; - ss << "Two incompatible substitutions added to TheoryModel:\n" - << "the term: " << x << "\n" - << "old mapping: " << d_substitutions.apply(oldX) << "\n" - << "new mapping: " << d_substitutions.apply(t); - InternalError(ss.str()); + InternalError() + << "Two incompatible substitutions added to TheoryModel:\n" + << "the term: " << x << "\n" + << "old mapping: " << d_substitutions.apply(oldX) << "\n" + << "new mapping: " << d_substitutions.apply(t); } #endif /* CVC4_ASSERTIONS */ } @@ -600,7 +599,7 @@ bool TheoryModel::areFunctionValuesEnabled() const } void TheoryModel::assignFunctionDefinition( Node f, Node f_def ) { - Assert( d_uf_models.find( f )==d_uf_models.end() ); + Assert(d_uf_models.find(f) == d_uf_models.end()); Trace("model-builder") << " Assigning function (" << f << ") to (" << f_def << ")" << endl; if( options::ufHo() ){ @@ -608,7 +607,7 @@ void TheoryModel::assignFunctionDefinition( Node f, Node f_def ) { f_def = Rewriter::rewrite( f_def ); Trace("model-builder-debug") << "Model value (post-rewrite) : " << f_def << std::endl; - Assert( f_def.isConst() ); + Assert(f_def.isConst()); } // d_uf_models only stores models for variables @@ -646,7 +645,7 @@ std::vector< Node > TheoryModel::getFunctionsToAssign() { // collect functions for( std::map< Node, std::vector< Node > >::iterator it = d_uf_terms.begin(); it != d_uf_terms.end(); ++it ){ Node n = it->first; - Assert( !n.isNull() ); + Assert(!n.isNull()); if( !hasAssignedFunctionDefinition( n ) ){ Trace("model-builder-fun-debug") << "Look at function : " << n << std::endl; if( options::ufHo() ){ diff --git a/src/theory/theory_model_builder.cpp b/src/theory/theory_model_builder.cpp index 7a2a9ae16..b1171f152 100644 --- a/src/theory/theory_model_builder.cpp +++ b/src/theory/theory_model_builder.cpp @@ -881,8 +881,8 @@ void TheoryEngineModelBuilder::debugCheckModel(TheoryModel* tm) << "getValue(n): " << tm->getValue(n) << endl << "rep: " << rep << endl; - Assert(tm->getValue(*eqc_i) == rep, - "run with -d check-model::rep-checking for details"); + Assert(tm->getValue(*eqc_i) == rep) + << "run with -d check-model::rep-checking for details"; } } } @@ -950,8 +950,7 @@ Node TheoryEngineModelBuilder::normalize(TheoryModel* m, TNode r, bool evalOnly) { retNode = Rewriter::rewrite(retNode); Assert(retNode.getKind() == kind::APPLY_UF - || !retNode.getType().isFirstClass() - || retNode.isConst()); + || !retNode.getType().isFirstClass() || retNode.isConst()); } } d_normalizedCache[r] = retNode; diff --git a/src/theory/theory_test_utils.h b/src/theory/theory_test_utils.h index ecda12dee..dbb42f2bc 100644 --- a/src/theory/theory_test_utils.h +++ b/src/theory/theory_test_utils.h @@ -24,7 +24,6 @@ #include #include -#include "base/cvc4_assert.h" #include "expr/node.h" #include "theory/interrupted.h" #include "theory/output_channel.h" diff --git a/src/theory/theory_traits_template.h b/src/theory/theory_traits_template.h index 564864f19..9bd67dba6 100644 --- a/src/theory/theory_traits_template.h +++ b/src/theory/theory_traits_template.h @@ -42,8 +42,7 @@ struct TheoryConstructor { ${theory_constructors} - default: - Unhandled(id); +default: Unhandled() << id; } } };/* struct CVC4::theory::TheoryConstructor */ diff --git a/src/theory/type_enumerator.h b/src/theory/type_enumerator.h index a92cfd2af..81c0c38c8 100644 --- a/src/theory/type_enumerator.h +++ b/src/theory/type_enumerator.h @@ -19,8 +19,8 @@ #ifndef CVC4__THEORY__TYPE_ENUMERATOR_H #define CVC4__THEORY__TYPE_ENUMERATOR_H +#include "base/check.h" #include "base/exception.h" -#include "base/cvc4_assert.h" #include "expr/node.h" #include "expr/type_node.h" @@ -129,7 +129,7 @@ class TypeEnumerator { if(d_te->isFinished()) { try { **d_te; - Assert(false, "expected an NoMoreValuesException to be thrown"); + Assert(false) << "expected an NoMoreValuesException to be thrown"; } catch(NoMoreValuesException&) { // ignore the exception, we're just asserting that it would be thrown // @@ -142,7 +142,7 @@ class TypeEnumerator { try { **d_te; } catch(NoMoreValuesException&) { - Assert(false, "didn't expect a NoMoreValuesException to be thrown"); + Assert(false) << "didn't expect a NoMoreValuesException to be thrown"; } } #endif /* CVC4_ASSERTIONS && !(APPLE || clang) */ @@ -157,7 +157,7 @@ class TypeEnumerator { try { Node n = **d_te; Assert(n.isConst()); - Assert(! isFinished()); + Assert(!isFinished()); return n; } catch(NoMoreValuesException&) { Assert(isFinished()); diff --git a/src/theory/type_enumerator_template.cpp b/src/theory/type_enumerator_template.cpp index 8ccf27302..26d83334d 100644 --- a/src/theory/type_enumerator_template.cpp +++ b/src/theory/type_enumerator_template.cpp @@ -16,7 +16,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/kind.h" #include "theory/type_enumerator.h" @@ -32,26 +32,18 @@ namespace theory { TypeEnumeratorInterface* TypeEnumerator::mkTypeEnumerator( TypeNode type, TypeEnumeratorProperties* tep) { - switch(type.getKind()) { - case kind::TYPE_CONSTANT: - switch(type.getConst()) { -${mk_type_enumerator_type_constant_cases} - default: + switch (type.getKind()) + { + case kind::TYPE_CONSTANT: + switch (type.getConst()) { - stringstream ss; - ss << "No type enumerator for type `" << type << "'"; - Unhandled(ss.str()); + ${mk_type_enumerator_type_constant_cases} + default: Unhandled() << "No type enumerator for type `" << type << "'"; } - } - Unreachable(); -${mk_type_enumerator_cases} -#line 49 "${template}" - default: - { - stringstream ss; - ss << "No type enumerator for type `" << type << "'"; - Unhandled(ss.str()); - } + Unreachable(); + ${mk_type_enumerator_cases} +#line 44 "${template}" + default: Unhandled() << "No type enumerator for type `" << type << "'"; } Unreachable(); } diff --git a/src/theory/uf/cardinality_extension.cpp b/src/theory/uf/cardinality_extension.cpp index 87696ef5f..bb1e434f2 100644 --- a/src/theory/uf/cardinality_extension.cpp +++ b/src/theory/uf/cardinality_extension.cpp @@ -65,8 +65,8 @@ void Region::addRep( Node n ) { } void Region::takeNode( Region* r, Node n ){ - Assert( !hasRep( n ) ); - Assert( r->hasRep( n ) ); + Assert(!hasRep(n)); + Assert(r->hasRep(n)); //add representative setRep( n, true ); //take disequalities from r @@ -130,7 +130,7 @@ void Region::combine( Region* r ){ /** setEqual */ void Region::setEqual( Node a, Node b ){ - Assert( hasRep( a ) && hasRep( b ) ); + Assert(hasRep(a) && hasRep(b)); //move disequalities of b over to a for( int t=0; t<2; t++ ){ DiseqList* del = d_nodes[b]->get(t); @@ -181,7 +181,7 @@ void Region::setDisequal( Node n1, Node n2, int type, bool valid ){ } void Region::setRep( Node n, bool valid ) { - Assert( hasRep( n )!=valid ); + Assert(hasRep(n) != valid); if( valid && d_nodes.find( n )==d_nodes.end() ){ d_nodes[n] = new RegionNodeInfo( d_cf->d_thss->getSatContext() ); } @@ -189,7 +189,7 @@ void Region::setRep( Node n, bool valid ) { d_reps_size = d_reps_size + ( valid ? 1 : -1 ); //removing a member of the test clique from this region if( d_testClique.find( n ) != d_testClique.end() && d_testClique[n] ){ - Assert( !valid ); + Assert(!valid); d_testClique[n] = false; d_testCliqueSize = d_testCliqueSize - 1; //remove all splits involving n @@ -326,7 +326,7 @@ bool Region::check( Theory::Effort level, int cardinality, } } } - Assert( maxNode!=Node::null() ); + Assert(maxNode != Node::null()); newClique.push_back( maxNode ); } //check splits internal to new members @@ -540,7 +540,7 @@ void SortModel::newEqClass( Node n ){ if( d_regions_indexdebugPrint("uf-ss-debug",true); d_regions[ d_regions_index ]->setValid(true); - Assert(d_regions[d_regions_index]->getNumReps()==0); + Assert(d_regions[d_regions_index]->getNumReps() == 0); }else{ d_regions.push_back( new Region( this, d_thss->getSatContext() ) ); } @@ -564,8 +564,8 @@ void SortModel::merge( Node a, Node b ){ Debug("uf-ss") << "CardinalityExtension: Merging " << a << " = " << b << "..." << std::endl; if( a!=b ){ - Assert( d_regions_map.find( a )!=d_regions_map.end() ); - Assert( d_regions_map.find( b )!=d_regions_map.end() ); + Assert(d_regions_map.find(a) != d_regions_map.end()); + Assert(d_regions_map.find(b) != d_regions_map.end()); int ai = d_regions_map[a]; int bi = d_regions_map[b]; Debug("uf-ss") << " regions: " << ai << " " << bi << std::endl; @@ -636,8 +636,8 @@ void SortModel::assertDisequal( Node a, Node b, Node reason ){ } d_disequalities_index = d_disequalities_index + 1; //now, add disequalities to regions - Assert( d_regions_map.find( a )!=d_regions_map.end() ); - Assert( d_regions_map.find( b )!=d_regions_map.end() ); + Assert(d_regions_map.find(a) != d_regions_map.end()); + Assert(d_regions_map.find(b) != d_regions_map.end()); Debug("uf-ss") << " regions: " << ai << " " << bi << std::endl; if( ai==bi ){ //internal disequality @@ -671,7 +671,7 @@ bool SortModel::areDisequal( Node a, Node b ) { /** check */ void SortModel::check( Theory::Effort level, OutputChannel* out ){ - Assert( options::ufssMode()==UF_SS_FULL ); + Assert(options::ufssMode() == UF_SS_FULL); if( level>=Theory::EFFORT_STANDARD && d_hasCard && !d_conflict ){ Debug("uf-ss") << "CardinalityExtension: Check " << level << " " << d_type << std::endl; @@ -809,7 +809,7 @@ void SortModel::getDisequalitiesToRegions(int ri, DiseqList* del = it->second->get(0); for( DiseqList::iterator it2 = del->begin(); it2 != del->end(); ++it2 ){ if( (*it2).second ){ - Assert( isValid( d_regions_map[ (*it2).first ] ) ); + Assert(isValid(d_regions_map[(*it2).first])); //Notice() << "Found disequality with " << (*it2).first << ", region = " << d_regions_map[ (*it2).first ] << std::endl; regions_diseq[ d_regions_map[ (*it2).first ] ]++; } @@ -836,7 +836,7 @@ void SortModel::assertCardinality( OutputChannel* out, int c, bool val ){ << "Assert cardinality " << d_type << " " << c << " " << val << " level = " << d_thss->getTheory()->getValuation().getAssertionLevel() << std::endl; - Assert( c>0 ); + Assert(c > 0); Node cl = getCardinalityLiteral( c ); if( val ){ bool doCheckRegions = !d_hasCard; @@ -883,7 +883,7 @@ void SortModel::assertCardinality( OutputChannel* out, int c, bool val ){ void SortModel::checkRegion( int ri, bool checkCombine ){ if( isValid(ri) && d_hasCard ){ - Assert( d_cardinality>0 ); + Assert(d_cardinality > 0); if( checkCombine && d_regions[ri]->getMustCombine( d_cardinality ) ){ ////alternatively, check if we can reduce the number of external disequalities by moving single nodes //for( std::map< Node, bool >::iterator it = d_regions[i]->d_reps.begin(); it != d_regions[i]->d_reps.end(); ++it ){ @@ -931,9 +931,9 @@ int SortModel::forceCombineRegion( int ri, bool useDensity ){ Debug("uf-ss-check-region") << it->first << " : " << it->second << std::endl; } for( std::map< int, int >::iterator it = regions_diseq.begin(); it != regions_diseq.end(); ++it ){ - Assert( it->first!=ri ); - Assert( isValid( it->first ) ); - Assert( d_regions[ it->first ]->getNumReps()>0 ); + Assert(it->first != ri); + Assert(isValid(it->first)); + Assert(d_regions[it->first]->getNumReps() > 0); double tempScore = double(it->second)/double(d_regions[it->first]->getNumReps() ); if( tempScore>maxScore ){ maxRegion = it->first; @@ -959,7 +959,7 @@ int SortModel::combineRegions( int ai, int bi ){ } #endif Debug("uf-ss-region") << "uf-ss: Combine Region #" << bi << " with Region #" << ai << std::endl; - Assert( isValid( ai ) && isValid( bi ) ); + Assert(isValid(ai) && isValid(bi)); Region* region_bi = d_regions[bi]; for(Region::iterator it = region_bi->begin(); it != region_bi->end(); ++it){ Region::RegionNodeInfo* rni = it->second; @@ -975,8 +975,8 @@ int SortModel::combineRegions( int ai, int bi ){ void SortModel::moveNode( Node n, int ri ){ Debug("uf-ss-region") << "uf-ss: Move node " << n << " to Region #" << ri << std::endl; - Assert( isValid( d_regions_map[ n ] ) ); - Assert( isValid( ri ) ); + Assert(isValid(d_regions_map[n])); + Assert(isValid(ri)); //move node to region ri d_regions[ri]->takeNode( d_regions[ d_regions_map[n] ], n ); d_regions_map[n] = ri; @@ -993,11 +993,11 @@ int SortModel::addSplit( Region* r, OutputChannel* out ){ break; } } - Assert( s!=Node::null() ); + Assert(s != Node::null()); } if (!s.isNull() ){ //add lemma to output channel - Assert( s.getKind()==EQUAL ); + Assert(s.getKind() == EQUAL); Node ss = Rewriter::rewrite( s ); if( ss.getKind()!=EQUAL ){ Node b_t = NodeManager::currentNM()->mkConst( true ); @@ -1042,8 +1042,8 @@ int SortModel::addSplit( Region* r, OutputChannel* out ){ void SortModel::addCliqueLemma( std::vector< Node >& clique, OutputChannel* out ){ - Assert( d_hasCard ); - Assert( d_cardinality>0 ); + Assert(d_hasCard); + Assert(d_cardinality > 0); while( clique.size()>size_t(d_cardinality+1) ){ clique.pop_back(); } @@ -1454,8 +1454,8 @@ void CardinalityExtension::assertNode(Node n, bool isDecision) if( options::ufssMode()==UF_SS_FULL ){ if( lit.getKind()==CARDINALITY_CONSTRAINT ){ TypeNode tn = lit[0].getType(); - Assert( tn.isSort() ); - Assert( d_rep_model[tn] ); + Assert(tn.isSort()); + Assert(d_rep_model[tn]); int nCard = lit[1].getConst().getNumerator().getSignedInt(); Node ct = d_rep_model[tn]->getCardinalityTerm(); Trace("uf-ss-debug") << "...check cardinality terms : " << lit[0] << " " << ct << std::endl; @@ -1627,7 +1627,7 @@ void CardinalityExtension::check(Theory::Effort level) } }else{ // unhandled uf ss mode - Assert( false ); + Assert(false); } Trace("uf-ss-solver") << "Done CardinalityExtension: check " << level << std::endl; @@ -1776,7 +1776,7 @@ void CardinalityExtension::initializeCombinedCardinality() /** check */ void CardinalityExtension::checkCombinedCardinality() { - Assert( options::ufssMode()==UF_SS_FULL ); + Assert(options::ufssMode() == UF_SS_FULL); if( options::ufssFairness() ){ Trace("uf-ss-com-card-debug") << "Check combined cardinality, get maximum negative cardinalities..." << std::endl; int totalCombinedCard = 0; diff --git a/src/theory/uf/cardinality_extension.h b/src/theory/uf/cardinality_extension.h index 3e3d90be5..37d442968 100644 --- a/src/theory/uf/cardinality_extension.h +++ b/src/theory/uf/cardinality_extension.h @@ -76,7 +76,7 @@ class CardinalityExtension ~DiseqList(){} void setDisequal( Node n, bool valid ){ - Assert( (!isSet(n)) || getDisequalityValue(n) != valid ); + Assert((!isSet(n)) || getDisequalityValue(n) != valid); d_disequalities[ n ] = valid; d_size = d_size + ( valid ? 1 : -1 ); } diff --git a/src/theory/uf/equality_engine.cpp b/src/theory/uf/equality_engine.cpp index 32d32b479..8e0c96ae3 100644 --- a/src/theory/uf/equality_engine.cpp +++ b/src/theory/uf/equality_engine.cpp @@ -375,7 +375,7 @@ bool EqualityEngine::hasTerm(TNode t) const { } EqualityNodeId EqualityEngine::getNodeId(TNode node) const { - Assert(hasTerm(node), node.toString().c_str()); + Assert(hasTerm(node)) << node; return (*d_nodeIds.find(node)).second; } @@ -417,7 +417,7 @@ void EqualityEngine::assertEqualityInternal(TNode t1, TNode t2, TNode reason, un void EqualityEngine::assertPredicate(TNode t, bool polarity, TNode reason, unsigned pid) { Debug("equality") << d_name << "::eq::addPredicate(" << t << "," << (polarity ? "true" : "false") << ")" << std::endl; - Assert(t.getKind() != kind::EQUAL, "Use assertEquality instead"); + Assert(t.getKind() != kind::EQUAL) << "Use assertEquality instead"; assertEqualityInternal(t, polarity ? d_true : d_false, reason, pid); propagate(); } @@ -556,8 +556,9 @@ bool EqualityEngine::merge(EqualityNode& class1, EqualityNode& class2, std::vect // Check for constant merges bool class1isConstant = d_isConstant[class1Id]; bool class2isConstant = d_isConstant[class2Id]; - Assert(class1isConstant || !class2isConstant, "Should always merge into constants"); - Assert(!class1isConstant || !class2isConstant, "Don't merge constants"); + Assert(class1isConstant || !class2isConstant) + << "Should always merge into constants"; + Assert(!class1isConstant || !class2isConstant) << "Don't merge constants"; // Trigger set of class 1 TriggerTermSetRef class1triggerRef = d_nodeIndividualTrigger[class1Id]; @@ -884,7 +885,8 @@ void EqualityEngine::backtrack() { if (d_deducedDisequalities.size() > d_deducedDisequalitiesSize) { for(int i = d_deducedDisequalities.size() - 1, i_end = (int)d_deducedDisequalitiesSize; i >= i_end; -- i) { EqualityPair pair = d_deducedDisequalities[i]; - Assert(d_disequalityReasonsMap.find(pair) != d_disequalityReasonsMap.end()); + Assert(d_disequalityReasonsMap.find(pair) + != d_disequalityReasonsMap.end()); // Remove from the map d_disequalityReasonsMap.erase(pair); std::swap(pair.first, pair.second); @@ -934,7 +936,8 @@ void EqualityEngine::explainEquality(TNode t1, TNode t2, bool polarity, << ", proof = " << (eqp ? "ON" : "OFF") << std::endl; // The terms must be there already - Assert(hasTerm(t1) && hasTerm(t2));; + Assert(hasTerm(t1) && hasTerm(t2)); + ; // Get the ids EqualityNodeId t1Id = getNodeId(t1); @@ -952,7 +955,8 @@ void EqualityEngine::explainEquality(TNode t1, TNode t2, bool polarity, // Get the reason for this disequality EqualityPair pair(t1Id, t2Id); - Assert(d_disequalityReasonsMap.find(pair) != d_disequalityReasonsMap.end(), "Don't ask for stuff I didn't notify you about"); + Assert(d_disequalityReasonsMap.find(pair) != d_disequalityReasonsMap.end()) + << "Don't ask for stuff I didn't notify you about"; DisequalityReasonRef reasonRef = d_disequalityReasonsMap.find(pair)->second; for (unsigned i = reasonRef.mergesStart; i < reasonRef.mergesEnd; ++ i) { @@ -1219,7 +1223,8 @@ void EqualityEngine::getExplanation( eqpc->d_node = NodeManager::currentNM()->mkNode(kind::PARTIAL_SELECT_1, d_nodes[f1.b]); // The first child is a PARTIAL_SELECT_0. // Give it a child so that we know what kind of (read) it is, when we dump to LFSC. - Assert(eqpc->d_children[0]->d_node.getKind() == kind::PARTIAL_SELECT_0); + Assert(eqpc->d_children[0]->d_node.getKind() + == kind::PARTIAL_SELECT_0); Assert(eqpc->d_children[0]->d_children.size() == 0); eqpc->d_children[0]->d_node = NodeManager::currentNM()->mkNode(kind::PARTIAL_SELECT_0, @@ -1241,7 +1246,7 @@ void EqualityEngine::getExplanation( Debug("equality") << d_name << "::eq::getExplanation(): due to reflexivity, going deeper" << std::endl; EqualityNodeId eqId = currentNode == d_trueId ? edgeNode : currentNode; const FunctionApplication& eq = d_applications[eqId].original; - Assert(eq.isEquality(), "Must be an equality"); + Assert(eq.isEquality()) << "Must be an equality"; // Explain why a = b constant Debug("equality") << push; @@ -1416,8 +1421,10 @@ void EqualityEngine::addTriggerEquality(TNode eq) { } void EqualityEngine::addTriggerPredicate(TNode predicate) { - Assert(predicate.getKind() != kind::NOT && predicate.getKind() != kind::EQUAL); - Assert(d_congruenceKinds.tst(predicate.getKind()), "No point in adding non-congruence predicates"); + Assert(predicate.getKind() != kind::NOT + && predicate.getKind() != kind::EQUAL); + Assert(d_congruenceKinds.tst(predicate.getKind())) + << "No point in adding non-congruence predicates"; if (d_done) { return; @@ -1811,7 +1818,8 @@ size_t EqualityEngine::getSize(TNode t) { void EqualityEngine::addPathReconstructionTrigger(unsigned trigger, const PathReconstructionNotify* notify) { // Currently we can only inform one callback per trigger - Assert(d_pathReconstructionTriggers.find(trigger) == d_pathReconstructionTriggers.end()); + Assert(d_pathReconstructionTriggers.find(trigger) + == d_pathReconstructionTriggers.end()); d_pathReconstructionTriggers[trigger] = notify; } @@ -1993,7 +2001,7 @@ bool EqualityEngine::hasPropagatedDisequality(EqualityNodeId lhsId, EqualityNode bool propagated = d_propagatedDisequalities.find(eq) != d_propagatedDisequalities.end(); #ifdef CVC4_ASSERTIONS bool stored = d_disequalityReasonsMap.find(eq) != d_disequalityReasonsMap.end(); - Assert(propagated == stored, "These two should be in sync"); + Assert(propagated == stored) << "These two should be in sync"; #endif Debug("equality::disequality") << d_name << "::eq::hasPropagatedDisequality(" << d_nodes[lhsId] << ", " << d_nodes[rhsId] << ") => " << (propagated ? "true" : "false") << std::endl; return propagated; @@ -2005,11 +2013,13 @@ bool EqualityEngine::hasPropagatedDisequality(TheoryId tag, EqualityNodeId lhsId PropagatedDisequalitiesMap::const_iterator it = d_propagatedDisequalities.find(eq); if (it == d_propagatedDisequalities.end()) { - Assert(d_disequalityReasonsMap.find(eq) == d_disequalityReasonsMap.end(), "Why do we have a proof if not propagated"); + Assert(d_disequalityReasonsMap.find(eq) == d_disequalityReasonsMap.end()) + << "Why do we have a proof if not propagated"; Debug("equality::disequality") << d_name << "::eq::hasPropagatedDisequality(" << tag << ", " << d_nodes[lhsId] << ", " << d_nodes[rhsId] << ") => false" << std::endl; return false; } - Assert(d_disequalityReasonsMap.find(eq) != d_disequalityReasonsMap.end(), "We propagated but there is no proof"); + Assert(d_disequalityReasonsMap.find(eq) != d_disequalityReasonsMap.end()) + << "We propagated but there is no proof"; bool result = Theory::setContains(tag, (*it).second); Debug("equality::disequality") << d_name << "::eq::hasPropagatedDisequality(" << tag << ", " << d_nodes[lhsId] << ", " << d_nodes[rhsId] << ") => " << (result ? "true" : "false") << std::endl; return result; @@ -2017,9 +2027,9 @@ bool EqualityEngine::hasPropagatedDisequality(TheoryId tag, EqualityNodeId lhsId void EqualityEngine::storePropagatedDisequality(TheoryId tag, EqualityNodeId lhsId, EqualityNodeId rhsId) { - - Assert(!hasPropagatedDisequality(tag, lhsId, rhsId), "Check before you store it"); - Assert(lhsId != rhsId, "Wow, wtf!"); + Assert(!hasPropagatedDisequality(tag, lhsId, rhsId)) + << "Check before you store it"; + Assert(lhsId != rhsId) << "Wow, wtf!"; Debug("equality::disequality") << d_name << "::eq::storePropagatedDisequality(" << tag << ", " << d_nodes[lhsId] << ", " << d_nodes[rhsId] << ")" << std::endl; @@ -2040,12 +2050,15 @@ void EqualityEngine::storePropagatedDisequality(TheoryId tag, EqualityNodeId lhs // Store the proof if provided if (d_deducedDisequalityReasons.size() > d_deducedDisequalityReasonsSize) { Debug("equality::disequality") << d_name << "::eq::storePropagatedDisequality(" << tag << ", " << d_nodes[lhsId] << ", " << d_nodes[rhsId] << "): storing proof" << std::endl; - Assert(d_disequalityReasonsMap.find(pair1) == d_disequalityReasonsMap.end(), "There can't be a proof if you're adding a new one"); + Assert(d_disequalityReasonsMap.find(pair1) == d_disequalityReasonsMap.end()) + << "There can't be a proof if you're adding a new one"; DisequalityReasonRef ref(d_deducedDisequalityReasonsSize, d_deducedDisequalityReasons.size()); #ifdef CVC4_ASSERTIONS // Check that the reasons are valid for (unsigned i = ref.mergesStart; i < ref.mergesEnd; ++ i) { - Assert(getEqualityNode(d_deducedDisequalityReasons[i].first).getFind() == getEqualityNode(d_deducedDisequalityReasons[i].second).getFind()); + Assert( + getEqualityNode(d_deducedDisequalityReasons[i].first).getFind() + == getEqualityNode(d_deducedDisequalityReasons[i].second).getFind()); } #endif if (Debug.isOn("equality::disequality")) { @@ -2065,7 +2078,8 @@ void EqualityEngine::storePropagatedDisequality(TheoryId tag, EqualityNodeId lhs d_disequalityReasonsMap[pair1] = ref; d_disequalityReasonsMap[pair2] = ref; } else { - Assert(d_disequalityReasonsMap.find(pair1) != d_disequalityReasonsMap.end(), "You must provide a proof initially"); + Assert(d_disequalityReasonsMap.find(pair1) != d_disequalityReasonsMap.end()) + << "You must provide a proof initially"; } } @@ -2073,7 +2087,11 @@ void EqualityEngine::getDisequalities(bool allowConstants, EqualityNodeId classI // Must be empty on input Assert(out.size() == 0); // The class we are looking for, shouldn't have any of the tags we are looking for already set - Assert(d_nodeIndividualTrigger[classId] == null_set_id || Theory::setIntersection(getTriggerTermSet(d_nodeIndividualTrigger[classId]).tags, inputTags) == 0); + Assert(d_nodeIndividualTrigger[classId] == null_set_id + || Theory::setIntersection( + getTriggerTermSet(d_nodeIndividualTrigger[classId]).tags, + inputTags) + == 0); if (inputTags == 0) { return; @@ -2259,7 +2277,7 @@ EqClassIterator::EqClassIterator(Node eqc, const eq::EqualityEngine* ee) Assert(d_ee->consistent()); d_current = d_start = d_ee->getNodeId(eqc); Assert(d_start == d_ee->getEqualityNode(d_start).getFind()); - Assert (!d_ee->d_isInternal[d_start]); + Assert(!d_ee->d_isInternal[d_start]); } Node EqClassIterator::operator*() const { diff --git a/src/theory/uf/equality_engine_types.h b/src/theory/uf/equality_engine_types.h index 3813bb697..402b21a02 100644 --- a/src/theory/uf/equality_engine_types.h +++ b/src/theory/uf/equality_engine_types.h @@ -261,7 +261,7 @@ public: */ template void removeTopFromUseList(memory_class& memory) { - Assert ((int) d_useList == (int)memory.size() - 1); + Assert((int)d_useList == (int)memory.size() - 1); d_useList = memory.back().getNext(); memory.pop_back(); } diff --git a/src/theory/uf/symmetry_breaker.cpp b/src/theory/uf/symmetry_breaker.cpp index 9c1d4c2f1..56d0c59cc 100644 --- a/src/theory/uf/symmetry_breaker.cpp +++ b/src/theory/uf/symmetry_breaker.cpp @@ -86,8 +86,7 @@ bool SymmetryBreaker::Template::matchRecursive(TNode t, TNode n) { Debug("ufsymm:match") << "UFSYMM we have constants, failing match" << endl; return false; } - Assert(t.isVar() && - n.isVar()); + Assert(t.isVar() && n.isVar()); t = find(t); n = find(n); Debug("ufsymm:match") << "UFSYMM variable match " << t << " , " << n << endl; @@ -720,7 +719,8 @@ void SymmetryBreaker::selectTerms(const Permutation& p) { Debug("ufsymm:eq") << "UFSYMM -- yep" << endl; } } - Assert(j != teq.end(), "failed to find a difference between p and teq ?!"); + Assert(j != teq.end()) + << "failed to find a difference between p and teq ?!"; } } } else { diff --git a/src/theory/uf/theory_uf.cpp b/src/theory/uf/theory_uf.cpp index 76e6e08bc..95e3f702b 100644 --- a/src/theory/uf/theory_uf.cpp +++ b/src/theory/uf/theory_uf.cpp @@ -188,7 +188,7 @@ void TheoryUF::check(Effort level) { }/* TheoryUF::check() */ Node TheoryUF::getOperatorForApplyTerm( TNode node ) { - Assert( node.getKind()==kind::APPLY_UF || node.getKind()==kind::HO_APPLY ); + Assert(node.getKind() == kind::APPLY_UF || node.getKind() == kind::HO_APPLY); if( node.getKind()==kind::APPLY_UF ){ return node.getOperator(); }else{ @@ -197,7 +197,7 @@ Node TheoryUF::getOperatorForApplyTerm( TNode node ) { } unsigned TheoryUF::getArgumentStartIndexForApplyTerm( TNode node ) { - Assert( node.getKind()==kind::APPLY_UF || node.getKind()==kind::HO_APPLY ); + Assert(node.getKind() == kind::APPLY_UF || node.getKind() == kind::HO_APPLY); return node.getKind()==kind::APPLY_UF ? 0 : 1; } @@ -230,7 +230,7 @@ void TheoryUF::preRegisterTerm(TNode node) { // we always use APPLY_UF if not higher-order, HO_APPLY if higher-order //Assert( node.getKind()!=kind::APPLY_UF || !options::ufHo() ); - Assert( node.getKind()!=kind::HO_APPLY || options::ufHo() ); + Assert(node.getKind() != kind::HO_APPLY || options::ufHo()); switch (node.getKind()) { case kind::EQUAL: @@ -507,8 +507,8 @@ void TheoryUF::addSharedTerm(TNode t) { } bool TheoryUF::areCareDisequal(TNode x, TNode y){ - Assert( d_equalityEngine.hasTerm(x) ); - Assert( d_equalityEngine.hasTerm(y) ); + Assert(d_equalityEngine.hasTerm(x)); + Assert(d_equalityEngine.hasTerm(y)); if( d_equalityEngine.isTriggerTerm(x, THEORY_UF) && d_equalityEngine.isTriggerTerm(y, THEORY_UF) ){ TNode x_shared = d_equalityEngine.getTriggerTermRepresentative(x, THEORY_UF); TNode y_shared = d_equalityEngine.getTriggerTermRepresentative(y, THEORY_UF); @@ -536,10 +536,10 @@ void TheoryUF::addCarePairs(TNodeTrie* t1, for (unsigned k = arg_start_index; k < f1.getNumChildren(); ++ k) { TNode x = f1[k]; TNode y = f2[k]; - Assert( d_equalityEngine.hasTerm(x) ); - Assert( d_equalityEngine.hasTerm(y) ); - Assert( !d_equalityEngine.areDisequal( x, y, false ) ); - Assert( !areCareDisequal( x, y ) ); + Assert(d_equalityEngine.hasTerm(x)); + Assert(d_equalityEngine.hasTerm(y)); + Assert(!d_equalityEngine.areDisequal(x, y, false)); + Assert(!areCareDisequal(x, y)); if( !d_equalityEngine.areEqual( x, y ) ){ if( d_equalityEngine.isTriggerTerm(x, THEORY_UF) && d_equalityEngine.isTriggerTerm(y, THEORY_UF) ){ TNode x_shared = d_equalityEngine.getTriggerTermRepresentative(x, THEORY_UF); diff --git a/src/theory/uf/theory_uf_model.cpp b/src/theory/uf/theory_uf_model.cpp index f279aebaf..ffe3730c4 100644 --- a/src/theory/uf/theory_uf_model.cpp +++ b/src/theory/uf/theory_uf_model.cpp @@ -91,7 +91,9 @@ Node UfModelTreeNode::getFunctionValue(std::vector& args, int index, Node stk.push(val); val = val[2]; } while(val.getKind() == ITE); - AlwaysAssert(val == defaultValue, "default values don't match when constructing function definition!"); + AlwaysAssert(val == defaultValue) + << "default values don't match when constructing function " + "definition!"; while(!stk.empty()) { val = stk.top(); stk.pop(); diff --git a/src/theory/uf/theory_uf_rewriter.h b/src/theory/uf/theory_uf_rewriter.h index bad4189d6..7f4c1c164 100644 --- a/src/theory/uf/theory_uf_rewriter.h +++ b/src/theory/uf/theory_uf_rewriter.h @@ -160,7 +160,7 @@ public: public: //conversion between HO_APPLY AND APPLY_UF // converts an APPLY_UF to a curried HO_APPLY e.g. (f a b) becomes (@ (@ f a) b) static Node getHoApplyForApplyUf(TNode n) { - Assert( n.getKind()==kind::APPLY_UF ); + Assert(n.getKind() == kind::APPLY_UF); Node curr = n.getOperator(); for( unsigned i=0; imkNode( kind::HO_APPLY, curr, n[i] ); @@ -169,7 +169,7 @@ public: //conversion between HO_APPLY AND APPLY_UF } // converts a curried HO_APPLY into an APPLY_UF e.g. (@ (@ f a) b) becomes (f a b) static Node getApplyUfForHoApply(TNode n) { - Assert( n.getType().getNumChildren()==2 ); + Assert(n.getType().getNumChildren() == 2); std::vector< TNode > children; TNode curr = decomposeHoApply( n, children, true ); // if operator is standard diff --git a/src/theory/uf/theory_uf_type_rules.h b/src/theory/uf/theory_uf_type_rules.h index cb373b535..f782cd618 100644 --- a/src/theory/uf/theory_uf_type_rules.h +++ b/src/theory/uf/theory_uf_type_rules.h @@ -145,13 +145,13 @@ class HoApplyTypeRule { // the typing rule for HO_APPLY terms inline static TypeNode computeType(NodeManager* nodeManager, TNode n, bool check) { - Assert( n.getKind()==kind::HO_APPLY ); + Assert(n.getKind() == kind::HO_APPLY); TypeNode fType = n[0].getType(check); if (!fType.isFunction()) { throw TypeCheckingExceptionPrivate( n, "first argument does not have function type"); } - Assert( fType.getNumChildren()>=2 ); + Assert(fType.getNumChildren() >= 2); if (check) { TypeNode aType = n[1].getType(check); if( !aType.isSubtypeOf( fType[0] ) ){ diff --git a/src/util/abstract_value.cpp b/src/util/abstract_value.cpp index 7c3ce6aaf..49247ee38 100644 --- a/src/util/abstract_value.cpp +++ b/src/util/abstract_value.cpp @@ -20,7 +20,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" using namespace std; diff --git a/src/util/bin_heap.h b/src/util/bin_heap.h index d6a7c95d7..7ada9a655 100644 --- a/src/util/bin_heap.h +++ b/src/util/bin_heap.h @@ -26,7 +26,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/exception.h" namespace CVC4 { diff --git a/src/util/cardinality.cpp b/src/util/cardinality.cpp index ce1763ba1..6615f8378 100644 --- a/src/util/cardinality.cpp +++ b/src/util/cardinality.cpp @@ -16,7 +16,7 @@ #include "util/cardinality.h" -#include "base/cvc4_assert.h" +#include "base/check.h" namespace CVC4 { @@ -174,9 +174,10 @@ Cardinality& Cardinality::operator^=(const Cardinality& c) { // inf ^ finite == inf return *this; } else { - Assert(compare(2) != LESS && !c.isFinite(), - "fall-through case not as expected:\n%s\n%s", - this->toString().c_str(), c.toString().c_str()); + Assert(compare(2) != LESS && !c.isFinite()) + << "fall-through case not as expected:\n" + << this << "\n" + << c; // (>= 2) ^ beth_k == beth_(k+1) // unless the base is already > the exponent if (compare(c) == GREATER) { diff --git a/src/util/dense_map.h b/src/util/dense_map.h index cc1a094eb..08da8faaa 100644 --- a/src/util/dense_map.h +++ b/src/util/dense_map.h @@ -29,7 +29,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "util/index.h" @@ -101,7 +101,7 @@ public: if( x >= allocated()){ return false; }else{ - Assert(x < allocated()); + Assert(x < allocated()); return d_posVector[x] != +POSITION_SENTINEL; } } diff --git a/src/util/divisible.cpp b/src/util/divisible.cpp index f336a318c..c89886fa8 100644 --- a/src/util/divisible.cpp +++ b/src/util/divisible.cpp @@ -17,7 +17,7 @@ #include "util/divisible.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/exception.h" using namespace std; diff --git a/src/util/floatingpoint.cpp b/src/util/floatingpoint.cpp index f7e73ca4b..1b1bfddc2 100644 --- a/src/util/floatingpoint.cpp +++ b/src/util/floatingpoint.cpp @@ -15,7 +15,7 @@ **/ #include "util/floatingpoint.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "util/integer.h" #include @@ -459,7 +459,7 @@ void traits::invariant(const prop &p) #ifndef CVC4_USE_SYMFPU void FloatingPointLiteral::unfinished(void) const { - Unimplemented("Floating-point literals not yet implemented."); + Unimplemented() << "Floating-point literals not yet implemented."; } #endif @@ -500,7 +500,7 @@ static FloatingPointLiteral constructorHelperBitVector( #else return FloatingPointLiteral(2, 2, 0.0); #endif - Unreachable("Constructor helper broken"); + Unreachable() << "Constructor helper broken"; } FloatingPoint::FloatingPoint (const FloatingPointSize &ct, const RoundingMode &rm, const BitVector &bv, bool signedBV) : @@ -592,7 +592,7 @@ static FloatingPointLiteral constructorHelperBitVector( // Compute the sticky bit Rational remainder(r - workingSig); - Assert(Rational(0,1) <= remainder); + Assert(Rational(0, 1) <= remainder); if (!remainder.isZero()) { sig = sig | one; @@ -616,10 +616,10 @@ static FloatingPointLiteral constructorHelperBitVector( symfpu::convertFloatToFloat(exactFormat, ct, rm, exactFloat)); return rounded; #else - Unreachable("no concrete implementation of FloatingPointLiteral"); + Unreachable() << "no concrete implementation of FloatingPointLiteral"; #endif } - Unreachable("Constructor helper broken"); + Unreachable() << "Constructor helper broken"; } FloatingPoint::FloatingPoint (const FloatingPointSize &ct, const RoundingMode &rm, const Rational &r) : @@ -923,7 +923,7 @@ static FloatingPointLiteral constructorHelperBitVector( // Only have pow(uint32_t) so we should check this. Assert(this->t.significand() <= 32); - + if (!(exp.strictlyNegative())) { Integer r(signedSignificand.multiplyByPow2(exp.toUnsignedInt())); return PartialRational(Rational(r), true); @@ -935,7 +935,7 @@ static FloatingPointLiteral constructorHelperBitVector( } } - Unreachable("Convert float literal to real broken."); + Unreachable() << "Convert float literal to real broken."; } BitVector FloatingPoint::pack (void) const { diff --git a/src/util/integer_cln_imp.cpp b/src/util/integer_cln_imp.cpp index 6439708b9..5cca2fcba 100644 --- a/src/util/integer_cln_imp.cpp +++ b/src/util/integer_cln_imp.cpp @@ -26,7 +26,7 @@ # error "This source should only ever be built if CVC4_CLN_IMP is on !" #endif /* CVC4_CLN_IMP */ -#include "base/cvc4_assert.h" +#include "base/check.h" using namespace std; diff --git a/src/util/integer_gmp_imp.cpp b/src/util/integer_gmp_imp.cpp index ed206bb45..2bc11f0a7 100644 --- a/src/util/integer_gmp_imp.cpp +++ b/src/util/integer_gmp_imp.cpp @@ -22,7 +22,7 @@ #include "cvc4autoconfig.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "util/rational.h" #ifndef CVC4_GMP_IMP diff --git a/src/util/random.cpp b/src/util/random.cpp index 72a8fbc24..325fac325 100644 --- a/src/util/random.cpp +++ b/src/util/random.cpp @@ -19,7 +19,7 @@ #include "util/random.h" #include -#include "base/cvc4_assert.h" +#include "base/check.h" namespace CVC4 { diff --git a/src/util/rational_cln_imp.cpp b/src/util/rational_cln_imp.cpp index ca67dd6cb..d19f99d31 100644 --- a/src/util/rational_cln_imp.cpp +++ b/src/util/rational_cln_imp.cpp @@ -24,7 +24,7 @@ # error "This source should only ever be built if CVC4_CLN_IMP is on !" #endif /* CVC4_CLN_IMP */ -#include "base/cvc4_assert.h" +#include "base/check.h" using namespace std; diff --git a/src/util/rational_gmp_imp.cpp b/src/util/rational_gmp_imp.cpp index 229b51db7..0127381b6 100644 --- a/src/util/rational_gmp_imp.cpp +++ b/src/util/rational_gmp_imp.cpp @@ -25,7 +25,7 @@ # error "This source should only ever be built if CVC4_GMP_IMP is on !" #endif /* CVC4_GMP_IMP */ -#include "base/cvc4_assert.h" +#include "base/check.h" namespace CVC4 { diff --git a/src/util/regexp.cpp b/src/util/regexp.cpp index a76e9084b..d91280926 100644 --- a/src/util/regexp.cpp +++ b/src/util/regexp.cpp @@ -23,7 +23,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/exception.h" using namespace std; diff --git a/src/util/resource_manager.cpp b/src/util/resource_manager.cpp index 6d7e08736..8f00a23ea 100644 --- a/src/util/resource_manager.cpp +++ b/src/util/resource_manager.cpp @@ -16,7 +16,7 @@ **/ #include "util/resource_manager.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/output.h" #include "options/smt_options.h" @@ -49,7 +49,7 @@ void Timer::set(uint64_t millis, bool wallTime) { /** Return the milliseconds elapsed since last set(). */ uint64_t Timer::elapsedWall() const { - Assert (d_wall_time); + Assert(d_wall_time); timeval tv; gettimeofday(&tv, NULL); Trace("limit") << "Timer::elapsedWallTime(): it's now " << tv.tv_sec << "," << tv.tv_usec << std::endl; @@ -60,7 +60,7 @@ uint64_t Timer::elapsedWall() const { } uint64_t Timer::elapsedCPU() const { - Assert (!d_wall_time); + Assert(!d_wall_time); clock_t elapsed = ((double)clock())/(CLOCKS_PER_SEC *0.001)- d_cpu_start_time; Trace("limit") << "Timer::elapsedCPUTime(): elapsed time is " << elapsed << " ms" < #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "options/set_language.h" using namespace std; @@ -172,8 +172,7 @@ Result Result::asSatisfiabilityResult() const { case VALIDITY_UNKNOWN: return Result(SAT_UNKNOWN, d_unknownExplanation, d_inputName); - default: - Unhandled(d_validity); + default: Unhandled() << d_validity; } } @@ -197,8 +196,7 @@ Result Result::asValidityResult() const { case SAT_UNKNOWN: return Result(VALIDITY_UNKNOWN, d_unknownExplanation, d_inputName); - default: - Unhandled(d_sat); + default: Unhandled() << d_sat; } } @@ -223,8 +221,7 @@ ostream& operator<<(ostream& out, enum Result::Sat s) { case Result::SAT_UNKNOWN: out << "SAT_UNKNOWN"; break; - default: - Unhandled(s); + default: Unhandled() << s; } return out; } @@ -240,8 +237,7 @@ ostream& operator<<(ostream& out, enum Result::Validity v) { case Result::VALIDITY_UNKNOWN: out << "VALIDITY_UNKNOWN"; break; - default: - Unhandled(v); + default: Unhandled() << v; } return out; } @@ -278,8 +274,7 @@ ostream& operator<<(ostream& out, enum Result::UnknownExplanation e) { case Result::UNKNOWN_REASON: out << "UNKNOWN_REASON"; break; - default: - Unhandled(e); + default: Unhandled() << e; } return out; } diff --git a/src/util/sampler.cpp b/src/util/sampler.cpp index 948b4dfd3..eeb38f988 100644 --- a/src/util/sampler.cpp +++ b/src/util/sampler.cpp @@ -17,7 +17,7 @@ #include "util/sampler.h" -#include "base/cvc4_assert.h" +#include "base/check.h" #include "util/bitvector.h" namespace CVC4 { diff --git a/src/util/sexpr.cpp b/src/util/sexpr.cpp index 88aeb3e2f..b2dcbbc8e 100644 --- a/src/util/sexpr.cpp +++ b/src/util/sexpr.cpp @@ -28,7 +28,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "options/set_language.h" #include "util/ostream_util.h" #include "util/smt2_quote_string.h" diff --git a/src/util/statistics_registry.cpp b/src/util/statistics_registry.cpp index 2ccbc2971..7f93a690e 100644 --- a/src/util/statistics_registry.cpp +++ b/src/util/statistics_registry.cpp @@ -20,8 +20,7 @@ #include #include -#include "base/cvc4_assert.h" -#include "base/cvc4_check.h" +#include "base/check.h" #include "lib/clock_gettime.h" #include "util/ostream_util.h" @@ -77,7 +76,7 @@ inline timespec& operator-=(timespec& a, const timespec& b) { nsec -= nsec_per_sec; ++a.tv_sec; } - CVC4_DCHECK(nsec >= 0 && nsec < nsec_per_sec); + Assert(nsec >= 0 && nsec < nsec_per_sec); a.tv_nsec = nsec; return a; } @@ -168,8 +167,8 @@ void StatisticsRegistry::registerStat(Stat* s) void StatisticsRegistry::unregisterStat(Stat* s) { #ifdef CVC4_STATISTICS_ON - CVC4_CHECK(s != nullptr); - CVC4_CHECK(d_stats.erase(s) > 0) + AlwaysAssert(s != nullptr); + AlwaysAssert(d_stats.erase(s) > 0) << "Statistic `" << s->getName() << "' was not registered with this registry."; #endif /* CVC4_STATISTICS_ON */ @@ -203,7 +202,7 @@ void TimerStat::start() { void TimerStat::stop() { if(CVC4_USE_STATISTICS) { - CVC4_CHECK(d_running) << "timer not running"; + AlwaysAssert(d_running) << "timer not running"; ::timespec end; clock_gettime(CLOCK_MONOTONIC, &end); d_data += end - d_start; diff --git a/src/util/utility.cpp b/src/util/utility.cpp index 97d5ef36b..acabd8739 100644 --- a/src/util/utility.cpp +++ b/src/util/utility.cpp @@ -21,7 +21,7 @@ #include #include -#include "base/cvc4_check.h" +#include "base/check.h" namespace CVC4 { diff --git a/test/unit/context/cdmap_black.h b/test/unit/context/cdmap_black.h index 6c5ecdf08..96c575218 100644 --- a/test/unit/context/cdmap_black.h +++ b/test/unit/context/cdmap_black.h @@ -18,12 +18,12 @@ #include -#include "base/cvc4_assert.h" -#include "context/context.h" +#include "base/check.h" #include "context/cdhashmap.h" #include "context/cdlist.h" +#include "context/context.h" +#include "test_utils.h" -using CVC4::AssertionException; using CVC4::context::Context; using CVC4::context::CDHashMap; @@ -163,10 +163,8 @@ class CDMapBlack : public CxxTest::TestSuite { TS_ASSERT( ElementsAre(map, {{1, 2}, {3, 4}, {5, 6}, {9, 8}, {23, 317}})); - TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 317), - AssertionException&); - TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 472), - AssertionException&); + TS_UTILS_EXPECT_ABORT(map.insertAtContextLevelZero(23, 317)); + TS_UTILS_EXPECT_ABORT(map.insertAtContextLevelZero(23, 472)); map.insert(23, 472); TS_ASSERT( @@ -177,8 +175,7 @@ class CDMapBlack : public CxxTest::TestSuite { TS_ASSERT( ElementsAre(map, {{1, 2}, {3, 4}, {5, 6}, {9, 8}, {23, 472}})); - TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 0), - AssertionException&); + TS_UTILS_EXPECT_ABORT(map.insertAtContextLevelZero(23, 0)); map.insert(23, 1024); TS_ASSERT( @@ -194,8 +191,7 @@ class CDMapBlack : public CxxTest::TestSuite { TS_ASSERT( ElementsAre(map, {{3, 4}, {5, 6}, {9, 8}, {23, 317}})); - TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 0), - AssertionException&); + TS_UTILS_EXPECT_ABORT(map.insertAtContextLevelZero(23, 0)); map.insert(23, 477); TS_ASSERT( @@ -203,7 +199,7 @@ class CDMapBlack : public CxxTest::TestSuite { d_context->pop(); } - TS_ASSERT_THROWS(map.insertAtContextLevelZero(23, 0), AssertionException&); + TS_UTILS_EXPECT_ABORT(map.insertAtContextLevelZero(23, 0)); TS_ASSERT( ElementsAre(map, {{3, 4}, {23, 317}})); diff --git a/test/unit/context/cdmap_white.h b/test/unit/context/cdmap_white.h index 1a1f683bc..d22ecc7f1 100644 --- a/test/unit/context/cdmap_white.h +++ b/test/unit/context/cdmap_white.h @@ -16,8 +16,9 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/cdhashmap.h" +#include "test_utils.h" using namespace std; using namespace CVC4; @@ -38,12 +39,12 @@ class CDMapWhite : public CxxTest::TestSuite { TS_ASSERT_THROWS_NOTHING(map.makeCurrent()); - TS_ASSERT_THROWS(map.update(), UnreachableCodeException&); + TS_UTILS_EXPECT_ABORT(map.update()); - TS_ASSERT_THROWS(map.save(d_context->getCMM()), UnreachableCodeException&); - TS_ASSERT_THROWS(map.restore(&map), UnreachableCodeException&); + TS_UTILS_EXPECT_ABORT(map.save(d_context->getCMM())); + TS_UTILS_EXPECT_ABORT(map.restore(&map)); d_context->push(); - TS_ASSERT_THROWS(map.makeCurrent(), UnreachableCodeException&); + TS_UTILS_EXPECT_ABORT(map.makeCurrent()); } }; diff --git a/test/unit/context/cdo_black.h b/test/unit/context/cdo_black.h index 4f927abfc..4e1efb7b1 100644 --- a/test/unit/context/cdo_black.h +++ b/test/unit/context/cdo_black.h @@ -19,7 +19,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/cdlist.h" #include "context/cdo.h" #include "context/context.h" diff --git a/test/unit/context/context_black.h b/test/unit/context/context_black.h index 3659d3494..258c3fd9b 100644 --- a/test/unit/context/context_black.h +++ b/test/unit/context/context_black.h @@ -19,11 +19,11 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/exception.h" #include "context/cdlist.h" #include "context/cdo.h" #include "context/context.h" - +#include "test_utils.h" using namespace std; using namespace CVC4; @@ -106,8 +106,8 @@ private: d_context->push(); d_context->pop(); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(d_context->pop(), AssertionException&); - TS_ASSERT_THROWS(d_context->pop(), AssertionException&); + TS_UTILS_EXPECT_ABORT(d_context->pop()); + TS_UTILS_EXPECT_ABORT(d_context->pop()); #endif /* CVC4_ASSERTIONS */ } diff --git a/test/unit/context/context_mm_black.h b/test/unit/context/context_mm_black.h index 15f9b09de..cd5ff8242 100644 --- a/test/unit/context/context_mm_black.h +++ b/test/unit/context/context_mm_black.h @@ -22,8 +22,7 @@ #include #include "context/context_mm.h" - -#include "base/cvc4_assert.h" +#include "test_utils.h" using namespace std; using namespace CVC4::context; @@ -90,7 +89,7 @@ private: } // Try popping out of scope - TS_ASSERT_THROWS(d_cmm->pop(), CVC4::AssertionException&); + TS_UTILS_EXPECT_ABORT(d_cmm->pop()); #endif /* __CVC4__CONTEXT__CONTEXT_MM_H */ } diff --git a/test/unit/context/context_white.h b/test/unit/context/context_white.h index 515ffb848..87ff73cce 100644 --- a/test/unit/context/context_white.h +++ b/test/unit/context/context_white.h @@ -16,9 +16,9 @@ #include -#include "base/cvc4_assert.h" -#include "context/context.h" +#include "base/check.h" #include "context/cdo.h" +#include "context/context.h" using namespace std; using namespace CVC4; diff --git a/test/unit/expr/attribute_white.h b/test/unit/expr/attribute_white.h index d109efdfd..745264b83 100644 --- a/test/unit/expr/attribute_white.h +++ b/test/unit/expr/attribute_white.h @@ -18,7 +18,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/attribute.h" #include "expr/node.h" #include "expr/node_builder.h" diff --git a/test/unit/expr/node_black.h b/test/unit/expr/node_black.h index 287704f39..e4a0dbb36 100644 --- a/test/unit/expr/node_black.h +++ b/test/unit/expr/node_black.h @@ -27,6 +27,7 @@ #include "expr/node_builder.h" #include "expr/node_manager.h" #include "expr/node_value.h" +#include "test_utils.h" using namespace CVC4; using namespace CVC4::kind; @@ -179,8 +180,8 @@ class NodeBlack : public CxxTest::TestSuite { #ifdef CVC4_ASSERTIONS // Basic bounds check on a node w/out children - TS_ASSERT_THROWS(Node::null()[-1], AssertionException&); - TS_ASSERT_THROWS(Node::null()[0], AssertionException&); + TS_UTILS_EXPECT_ABORT(Node::null()[-1]); + TS_UTILS_EXPECT_ABORT(Node::null()[0]); #endif /* CVC4_ASSERTIONS */ // Basic access check @@ -198,8 +199,8 @@ class NodeBlack : public CxxTest::TestSuite { #ifdef CVC4_ASSERTIONS // Bounds check on a node with children - TS_ASSERT_THROWS(ite == ite[-1], AssertionException&); - TS_ASSERT_THROWS(ite == ite[4], AssertionException&); + TS_UTILS_EXPECT_ABORT(ite == ite[-1]); + TS_UTILS_EXPECT_ABORT(ite == ite[4]); #endif /* CVC4_ASSERTIONS */ } @@ -459,10 +460,10 @@ class NodeBlack : public CxxTest::TestSuite { } #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(testNaryExpForSize(AND, 0), AssertionException&); - TS_ASSERT_THROWS(testNaryExpForSize(AND, 1), AssertionException&); - TS_ASSERT_THROWS(testNaryExpForSize(NOT, 0), AssertionException&); - TS_ASSERT_THROWS(testNaryExpForSize(NOT, 2), AssertionException&); + TS_UTILS_EXPECT_ABORT(testNaryExpForSize(AND, 0)); + TS_UTILS_EXPECT_ABORT(testNaryExpForSize(AND, 1)); + TS_UTILS_EXPECT_ABORT(testNaryExpForSize(NOT, 0)); + TS_UTILS_EXPECT_ABORT(testNaryExpForSize(NOT, 2)); #endif /* CVC4_ASSERTIONS */ } diff --git a/test/unit/expr/node_builder_black.h b/test/unit/expr/node_builder_black.h index 2ece96cb8..473557e07 100644 --- a/test/unit/expr/node_builder_black.h +++ b/test/unit/expr/node_builder_black.h @@ -20,11 +20,12 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/kind.h" #include "expr/node.h" #include "expr/node_builder.h" #include "expr/node_manager.h" +#include "test_utils.h" #include "util/rational.h" using namespace CVC4; @@ -90,9 +91,9 @@ private: NodeBuilder<> def; TS_ASSERT_EQUALS(def.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(def.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(def.begin(), AssertionException&); - TS_ASSERT_THROWS(def.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(def.getNumChildren()); + TS_UTILS_EXPECT_ABORT(def.begin()); + TS_UTILS_EXPECT_ABORT(def.end()); #endif /* CVC4_ASSERTIONS */ NodeBuilder<> spec(specKind); @@ -104,9 +105,9 @@ private: NodeBuilder<> from_nm(d_nm); TS_ASSERT_EQUALS(from_nm.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(from_nm.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(from_nm.begin(), AssertionException&); - TS_ASSERT_THROWS(from_nm.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(from_nm.getNumChildren()); + TS_UTILS_EXPECT_ABORT(from_nm.begin()); + TS_UTILS_EXPECT_ABORT(from_nm.end()); #endif /* CVC4_ASSERTIONS */ NodeBuilder<> from_nm_kind(d_nm, specKind); @@ -120,9 +121,9 @@ private: NodeBuilder ws; TS_ASSERT_EQUALS(ws.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(ws.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(ws.begin(), AssertionException&); - TS_ASSERT_THROWS(ws.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(ws.getNumChildren()); + TS_UTILS_EXPECT_ABORT(ws.begin()); + TS_UTILS_EXPECT_ABORT(ws.end()); #endif /* CVC4_ASSERTIONS */ NodeBuilder ws_kind(specKind); @@ -134,9 +135,9 @@ private: NodeBuilder ws_from_nm(d_nm); TS_ASSERT_EQUALS(ws_from_nm.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(ws_from_nm.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(ws_from_nm.begin(), AssertionException&); - TS_ASSERT_THROWS(ws_from_nm.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(ws_from_nm.getNumChildren()); + TS_UTILS_EXPECT_ABORT(ws_from_nm.begin()); + TS_UTILS_EXPECT_ABORT(ws_from_nm.end()); #endif /* CVC4_ASSERTIONS */ NodeBuilder ws_from_nm_kind(d_nm, specKind); @@ -158,33 +159,33 @@ private: NodeBuilder<> copy(def); TS_ASSERT_EQUALS(copy.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(copy.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(copy.begin(), AssertionException&); - TS_ASSERT_THROWS(copy.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(copy.getNumChildren()); + TS_UTILS_EXPECT_ABORT(copy.begin()); + TS_UTILS_EXPECT_ABORT(copy.end()); #endif /* CVC4_ASSERTIONS */ NodeBuilder cp_ws(ws); TS_ASSERT_EQUALS(cp_ws.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(cp_ws.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(cp_ws.begin(), AssertionException&); - TS_ASSERT_THROWS(cp_ws.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(cp_ws.getNumChildren()); + TS_UTILS_EXPECT_ABORT(cp_ws.begin()); + TS_UTILS_EXPECT_ABORT(cp_ws.end()); #endif /* CVC4_ASSERTIONS */ NodeBuilder cp_from_larger(ws); TS_ASSERT_EQUALS(cp_from_larger.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(cp_from_larger.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(cp_from_larger.begin(), AssertionException&); - TS_ASSERT_THROWS(cp_from_larger.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(cp_from_larger.getNumChildren()); + TS_UTILS_EXPECT_ABORT(cp_from_larger.begin()); + TS_UTILS_EXPECT_ABORT(cp_from_larger.end()); #endif /* CVC4_ASSERTIONS */ NodeBuilder cp_from_smaller(ws); TS_ASSERT_EQUALS(cp_from_smaller.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(cp_from_smaller.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(cp_from_smaller.begin(), AssertionException&); - TS_ASSERT_THROWS(cp_from_smaller.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(cp_from_smaller.getNumChildren()); + TS_UTILS_EXPECT_ABORT(cp_from_smaller.begin()); + TS_UTILS_EXPECT_ABORT(cp_from_smaller.end()); #endif /* CVC4_ASSERTIONS */ } @@ -282,7 +283,7 @@ private: Node n = noKind; #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(noKind.getKind(), AssertionException&); + TS_UTILS_EXPECT_ABORT(noKind.getKind()); #endif /* CVC4_ASSERTIONS */ NodeBuilder<> spec(PLUS); @@ -297,7 +298,7 @@ private: NodeBuilder<> nb; #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb.getNumChildren(), AssertionException&); + TS_UTILS_EXPECT_ABORT(nb.getNumChildren()); #endif /* CVC4_ASSERTIONS */ nb << PLUS << x << x; @@ -309,7 +310,7 @@ private: Node n = nb;// avoid warning on clear() nb.clear(); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb.getNumChildren(), AssertionException&); + TS_UTILS_EXPECT_ABORT(nb.getNumChildren()); #endif /* CVC4_ASSERTIONS */ nb.clear(PLUS); TS_ASSERT_EQUALS(nb.getNumChildren(), 0u); @@ -321,16 +322,16 @@ private: TS_ASSERT_EQUALS(nb.getNumChildren(), 6u); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb << PLUS, AssertionException&); + TS_UTILS_EXPECT_ABORT(nb << PLUS); n = nb; - TS_ASSERT_THROWS(nb.getNumChildren(), AssertionException&); + TS_UTILS_EXPECT_ABORT(nb.getNumChildren()); #endif /* CVC4_ASSERTIONS */ } void testOperatorSquare() { /* Node operator[](int i) const { - Assert(i >= 0 && i < d_ev->getNumChildren()); + TS_ASSERT(i >= 0 && i < d_ev->getNumChildren()); return Node(d_ev->d_children[i]); } */ @@ -341,8 +342,8 @@ private: Node i_K = d_nm->mkNode(NOT, i_0); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(arr[-1], AssertionException&); - TS_ASSERT_THROWS(arr[0], AssertionException&); + TS_UTILS_EXPECT_ABORT(arr[-1]); + TS_UTILS_EXPECT_ABORT(arr[0]); #endif /* CVC4_ASSERTIONS */ arr << i_0; @@ -375,7 +376,7 @@ private: #ifdef CVC4_ASSERTIONS Node n = arr; - TS_ASSERT_THROWS(arr[0], AssertionException&); + TS_UTILS_EXPECT_ABORT(arr[0]); #endif /* CVC4_ASSERTIONS */ } @@ -385,9 +386,9 @@ private: TS_ASSERT_EQUALS(nb.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(nb.begin(), AssertionException&); - TS_ASSERT_THROWS(nb.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(nb.getNumChildren()); + TS_UTILS_EXPECT_ABORT(nb.begin()); + TS_UTILS_EXPECT_ABORT(nb.end()); #endif /* CVC4_ASSERTIONS */ nb << specKind; @@ -402,9 +403,9 @@ private: TS_ASSERT_EQUALS(nb.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(nb.begin(), AssertionException&); - TS_ASSERT_THROWS(nb.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(nb.getNumChildren()); + TS_UTILS_EXPECT_ABORT(nb.begin()); + TS_UTILS_EXPECT_ABORT(nb.end()); #endif /* CVC4_ASSERTIONS */ nb << specKind; @@ -427,9 +428,9 @@ private: TS_ASSERT_EQUALS(nb.getKind(), UNDEFINED_KIND); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb.getNumChildren(), AssertionException&); - TS_ASSERT_THROWS(nb.begin(), AssertionException&); - TS_ASSERT_THROWS(nb.end(), AssertionException&); + TS_UTILS_EXPECT_ABORT(nb.getNumChildren()); + TS_UTILS_EXPECT_ABORT(nb.begin()); + TS_UTILS_EXPECT_ABORT(nb.end()); #endif /* CVC4_ASSERTIONS */ } @@ -438,7 +439,7 @@ private: #ifdef CVC4_ASSERTIONS NodeBuilder<> spec(specKind); - TS_ASSERT_THROWS(spec << PLUS, AssertionException&); + TS_UTILS_EXPECT_ABORT(spec << PLUS); #endif /* CVC4_ASSERTIONS */ NodeBuilder<> noSpec; @@ -457,12 +458,12 @@ private: nb.clear(PLUS); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(n = nb, AssertionException&); + TS_UTILS_EXPECT_ABORT(n = nb); nb.clear(PLUS); #endif /* CVC4_ASSERTIONS */ #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb << PLUS, AssertionException&); + TS_UTILS_EXPECT_ABORT(nb << PLUS); #endif /* CVC4_ASSERTIONS */ NodeBuilder<> testRef; @@ -470,7 +471,7 @@ private: #ifdef CVC4_ASSERTIONS NodeBuilder<> testTwo; - TS_ASSERT_THROWS(testTwo << specKind << PLUS, AssertionException&); + TS_UTILS_EXPECT_ABORT(testTwo << specKind << PLUS); #endif /* CVC4_ASSERTIONS */ NodeBuilder<> testMixOrder1; @@ -494,7 +495,7 @@ private: #ifdef CVC4_ASSERTIONS Node n = nb; - TS_ASSERT_THROWS(nb << n, AssertionException&); + TS_UTILS_EXPECT_ABORT(nb << n); #endif /* CVC4_ASSERTIONS */ NodeBuilder<> overflow(specKind); @@ -527,7 +528,7 @@ private: Node q = d_nm->mkNode(AND, x, z, d_nm->mkNode(NOT, y)); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(d_nm->mkNode(XOR, y, x, x), AssertionException&); + TS_UTILS_EXPECT_ABORT(d_nm->mkNode(XOR, y, x, x)); #endif /* CVC4_ASSERTIONS */ NodeBuilder<> b(specKind); @@ -588,7 +589,7 @@ private: TS_ASSERT_EQUALS(nexplicit.getNumChildren(), K); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(Node blah = implicit, AssertionException&); + TS_UTILS_EXPECT_ABORT(Node blah = implicit); #endif /* CVC4_ASSERTIONS */ } diff --git a/test/unit/expr/node_manager_black.h b/test/unit/expr/node_manager_black.h index e568fc9df..4b9c42bd0 100644 --- a/test/unit/expr/node_manager_black.h +++ b/test/unit/expr/node_manager_black.h @@ -22,6 +22,7 @@ #include "base/output.h" #include "expr/node_manager.h" #include "expr/node_manager_attributes.h" +#include "test_utils.h" #include "util/integer.h" #include "util/rational.h" @@ -300,7 +301,7 @@ class NodeManagerBlack : public CxxTest::TestSuite { void testMkNodeTooFew() { #ifdef CVC4_ASSERTIONS Node x = d_nodeManager->mkSkolem( "x", d_nodeManager->booleanType() ); - TS_ASSERT_THROWS(d_nodeManager->mkNode(AND, x), AssertionException&); + TS_UTILS_EXPECT_ABORT(d_nodeManager->mkNode(AND, x)); #endif } @@ -319,7 +320,7 @@ class NodeManagerBlack : public CxxTest::TestSuite { vars.push_back(skolem_j); vars.push_back(orNode); } - TS_ASSERT_THROWS(d_nodeManager->mkNode(AND, vars), AssertionException&); + TS_UTILS_EXPECT_ABORT(d_nodeManager->mkNode(AND, vars)); #endif } }; diff --git a/test/unit/expr/node_manager_white.h b/test/unit/expr/node_manager_white.h index c2888a708..6f7729f74 100644 --- a/test/unit/expr/node_manager_white.h +++ b/test/unit/expr/node_manager_white.h @@ -19,6 +19,7 @@ #include #include "expr/node_manager.h" +#include "test_utils.h" #include "util/integer.h" #include "util/rational.h" @@ -57,7 +58,7 @@ class NodeManagerWhite : public CxxTest::TestSuite { TS_ASSERT_THROWS_NOTHING(nb.realloc(25)); TS_ASSERT_THROWS_NOTHING(nb.realloc(256)); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb.realloc(100), AssertionException&); + TS_UTILS_EXPECT_ABORT(nb.realloc(100)); #endif /* CVC4_ASSERTIONS */ TS_ASSERT_THROWS_NOTHING(nb.realloc(257)); TS_ASSERT_THROWS_NOTHING(nb.realloc(4000)); @@ -67,7 +68,7 @@ class NodeManagerWhite : public CxxTest::TestSuite { TS_ASSERT_THROWS_NOTHING(nb.realloc(65536)); TS_ASSERT_THROWS_NOTHING(nb.realloc(67108863)); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(nb.realloc(67108863), AssertionException&); + TS_UTILS_EXPECT_ABORT(nb.realloc(67108863)); #endif /* CVC4_ASSERTIONS */ } diff --git a/test/unit/expr/node_white.h b/test/unit/expr/node_white.h index e9a3112cf..c95c46e02 100644 --- a/test/unit/expr/node_white.h +++ b/test/unit/expr/node_white.h @@ -18,7 +18,7 @@ #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "expr/node.h" #include "expr/node_builder.h" #include "expr/node_manager.h" diff --git a/test/unit/expr/symbol_table_black.h b/test/unit/expr/symbol_table_black.h index ef65e8773..1ac1fa315 100644 --- a/test/unit/expr/symbol_table_black.h +++ b/test/unit/expr/symbol_table_black.h @@ -19,7 +19,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "base/exception.h" #include "context/context.h" #include "expr/expr.h" diff --git a/test/unit/memory.h b/test/unit/memory.h index 49b0885b1..9c92ba918 100644 --- a/test/unit/memory.h +++ b/test/unit/memory.h @@ -36,8 +36,8 @@ #include #include +#include "base/check.h" #include "base/configuration_private.h" -#include "base/cvc4_assert.h" // Conditionally define CVC4_MEMORY_LIMITING_DISABLED. #ifdef __APPLE__ diff --git a/test/unit/preprocessing/pass_bv_gauss_white.h b/test/unit/preprocessing/pass_bv_gauss_white.h index 7f7af40b9..4037c7191 100644 --- a/test/unit/preprocessing/pass_bv_gauss_white.h +++ b/test/unit/preprocessing/pass_bv_gauss_white.h @@ -20,6 +20,7 @@ #include "preprocessing/passes/bv_gauss.h" #include "smt/smt_engine.h" #include "smt/smt_engine_scope.h" +#include "test_utils.h" #include "theory/bv/theory_bv_utils.h" #include "theory/rewriter.h" #include "util/bitvector.h" @@ -116,14 +117,6 @@ static void testGaussElimX(Integer prime, } } -template -static void testGaussElimT(Integer prime, - std::vector rhs, - std::vector> lhs) -{ - TS_ASSERT_THROWS(BVGauss::gaussElim(prime, rhs, lhs), T); -} - class TheoryBVGaussWhite : public CxxTest::TestSuite { ExprManager *d_em; @@ -319,7 +312,7 @@ class TheoryBVGaussWhite : public CxxTest::TestSuite {Integer(2), Integer(3), Integer(5)}, {Integer(4), Integer(0), Integer(5)}}; std::cout << "matrix 0, modulo 0" << std::endl; // throws - testGaussElimT(Integer(0), rhs, lhs); + TS_UTILS_EXPECT_ABORT(BVGauss::gaussElim(Integer(0), rhs, lhs)); std::cout << "matrix 0, modulo 1" << std::endl; testGaussElimX(Integer(1), rhs, lhs, BVGauss::Result::UNIQUE); std::cout << "matrix 0, modulo 2" << std::endl; diff --git a/test/unit/prop/cnf_stream_white.h b/test/unit/prop/cnf_stream_white.h index 7aaf1f4de..70357ea1b 100644 --- a/test/unit/prop/cnf_stream_white.h +++ b/test/unit/prop/cnf_stream_white.h @@ -18,7 +18,7 @@ /* #include */ /* #include */ -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/context.h" #include "expr/expr_manager.h" #include "expr/node_manager.h" diff --git a/test/unit/test_utils.h b/test/unit/test_utils.h index 67bc34456..474f2e78b 100644 --- a/test/unit/test_utils.h +++ b/test/unit/test_utils.h @@ -18,7 +18,7 @@ /** * Use TS_UTILS_EXPECT_ABORT if you expect the expression to abort() when a - * CVC4_CHECK or CVC4_DCHECK is triggered. + * AlwaysAssert or Assert is triggered. */ #define TS_UTILS_EXPECT_ABORT(expr) \ do \ diff --git a/test/unit/theory/theory_engine_white.h b/test/unit/theory/theory_engine_white.h index d357b200e..88f8ed6dd 100644 --- a/test/unit/theory/theory_engine_white.h +++ b/test/unit/theory/theory_engine_white.h @@ -25,7 +25,7 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" #include "context/context.h" #include "expr/kind.h" #include "expr/node.h" diff --git a/test/unit/theory/theory_quantifiers_bv_inverter_white.h b/test/unit/theory/theory_quantifiers_bv_inverter_white.h index 5be92b19e..03fcaab69 100644 --- a/test/unit/theory/theory_quantifiers_bv_inverter_white.h +++ b/test/unit/theory/theory_quantifiers_bv_inverter_white.h @@ -47,9 +47,9 @@ class TheoryQuantifiersBvInverter : public CxxTest::TestSuite Node x, Node (*getsc)(bool, Kind, Node, Node)) { - Assert(k == BITVECTOR_ULT || k == BITVECTOR_SLT || k == EQUAL - || k == BITVECTOR_UGT || k == BITVECTOR_SGT); - Assert(k != EQUAL || pol == false); + TS_ASSERT(k == BITVECTOR_ULT || k == BITVECTOR_SLT || k == EQUAL + || k == BITVECTOR_UGT || k == BITVECTOR_SGT); + TS_ASSERT(k != EQUAL || pol == false); Node sc = getsc(pol, k, d_sk, d_t); Kind ksc = sc.getKind(); @@ -78,7 +78,7 @@ class TheoryQuantifiersBvInverter : public CxxTest::TestSuite } else { - Assert(k == EQUAL); + TS_ASSERT(k == EQUAL); k = DISTINCT; } } @@ -95,10 +95,10 @@ class TheoryQuantifiersBvInverter : public CxxTest::TestSuite unsigned idx, Node (*getsc)(bool, Kind, Kind, unsigned, Node, Node, Node)) { - Assert(k == BITVECTOR_MULT || k == BITVECTOR_UREM_TOTAL - || k == BITVECTOR_UDIV_TOTAL || k == BITVECTOR_AND - || k == BITVECTOR_OR || k == BITVECTOR_LSHR || k == BITVECTOR_ASHR - || k == BITVECTOR_SHL); + TS_ASSERT(k == BITVECTOR_MULT || k == BITVECTOR_UREM_TOTAL + || k == BITVECTOR_UDIV_TOTAL || k == BITVECTOR_AND + || k == BITVECTOR_OR || k == BITVECTOR_LSHR || k == BITVECTOR_ASHR + || k == BITVECTOR_SHL); Node sc = getsc(pol, litk, k, idx, d_sk, d_s, d_t); TS_ASSERT(!sc.isNull()); @@ -148,7 +148,7 @@ class TheoryQuantifiersBvInverter : public CxxTest::TestSuite } else { - Assert(idx == 2); + TS_ASSERT(idx == 2); s1 = d_nm->mkVar("s1", d_nm->mkBitVectorType(4)); s2 = d_nm->mkVar("s2", d_nm->mkBitVectorType(4)); x = d_nm->mkBoundVar(s2.getType()); diff --git a/test/unit/util/array_store_all_black.h b/test/unit/util/array_store_all_black.h index 0b8313222..c0d1474e9 100644 --- a/test/unit/util/array_store_all_black.h +++ b/test/unit/util/array_store_all_black.h @@ -21,24 +21,22 @@ #include "expr/expr_manager.h" #include "expr/expr_manager_scope.h" #include "expr/type.h" +#include "test_utils.h" using namespace CVC4; using namespace std; class ArrayStoreAllBlack : public CxxTest::TestSuite { ExprManager* d_em; - ExprManagerScope* d_scope; public: void setUp() override { d_em = new ExprManager(); - d_scope = new ExprManagerScope(*d_em); } void tearDown() override { - delete d_scope; delete d_em; } @@ -55,15 +53,15 @@ class ArrayStoreAllBlack : public CxxTest::TestSuite { d_em->mkConst(Rational(0))); } - void testTypeErrors() { - // these two throw an AssertionException in assertions-enabled builds, and - // an IllegalArgumentException in production builds - TS_ASSERT_THROWS_ANYTHING(ArrayStoreAll( - d_em->integerType(), - d_em->mkConst(UninterpretedConstant(d_em->mkSort("U"), 0)))); - TS_ASSERT_THROWS_ANYTHING( - ArrayStoreAll(d_em->integerType(), d_em->mkConst(Rational(9, 2)))); - + void testTypeErrors() + { + TS_ASSERT_THROWS(ArrayStoreAll(d_em->integerType(), + d_em->mkConst(UninterpretedConstant( + d_em->mkSort("U"), 0))), + IllegalArgumentException&); + TS_ASSERT_THROWS( + ArrayStoreAll(d_em->integerType(), d_em->mkConst(Rational(9, 2))), + IllegalArgumentException&); TS_ASSERT_THROWS( ArrayStoreAll(d_em->mkArrayType(d_em->integerType(), d_em->mkSort("U")), d_em->mkConst(Rational(9, 2))), diff --git a/test/unit/util/assert_white.h b/test/unit/util/assert_white.h index 47acbcc6d..03afcdbf7 100644 --- a/test/unit/util/assert_white.h +++ b/test/unit/util/assert_white.h @@ -19,96 +19,49 @@ #include #include -#include "base/cvc4_assert.h" +#include "base/check.h" +#include "test_utils.h" using namespace CVC4; using namespace std; class AssertWhite : public CxxTest::TestSuite { public: - - void testAssert() { + void testAssert() + { #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS(Assert(false), AssertionException&); - TS_ASSERT_THROWS(AssertArgument(false, "x"), AssertArgumentException&); + TS_UTILS_EXPECT_ABORT(Assert(false)); + TS_ASSERT_THROWS(AssertArgument(false, "x"), AssertArgumentException&); #else /* CVC4_ASSERTIONS */ - TS_ASSERT_THROWS_NOTHING( Assert(false) ); - TS_ASSERT_THROWS_NOTHING( AssertArgument(false, "x") ); + TS_ASSERT_THROWS_NOTHING(Assert(false)); + TS_ASSERT_THROWS_NOTHING(AssertArgument(false, "x")); #endif /* CVC4_ASSERTIONS */ - TS_ASSERT_THROWS_NOTHING( Assert(true) ); - TS_ASSERT_THROWS(AlwaysAssert(false), AssertionException&); - TS_ASSERT_THROWS(Unreachable(), UnreachableCodeException&); - TS_ASSERT_THROWS(Unhandled(), UnhandledCaseException&); - TS_ASSERT_THROWS(Unimplemented(), UnimplementedOperationException&); - TS_ASSERT_THROWS(IllegalArgument("x"), IllegalArgumentException&); - TS_ASSERT_THROWS(CheckArgument(false, "x"), IllegalArgumentException&); - TS_ASSERT_THROWS(AlwaysAssertArgument(false, "x"), - AssertArgumentException&); - TS_ASSERT_THROWS_NOTHING( AssertArgument(true, "x") ); - TS_ASSERT_THROWS_NOTHING( AssertArgument(true, "x") ); - } - - void testReallyLongAssert() { - string msg(1034, 'x'); - try { - AlwaysAssert(false, msg.c_str()); - TS_FAIL("Should have thrown an exception !"); - } catch(AssertionException& e) { - // we don't want to match on the entire string, because it may - // have an absolute path to the unit test binary, line number - // info, etc. - std::string s = e.toString(); - const char* theString = s.c_str(); - const char* firstPart = - "Assertion failure\nvoid AssertWhite::testReallyLongAssert()\n"; - string lastPartStr = "\n\n false\n" + msg; - const char* lastPart = lastPartStr.c_str(); - TS_ASSERT(strncmp(theString, firstPart, strlen(firstPart)) == 0); - TS_ASSERT(strncmp(theString + strlen(theString) - strlen(lastPart), - lastPart, strlen(lastPart)) == 0); - } catch(...) { - TS_FAIL("Threw the wrong kind of exception !"); - } - - // Now test an assert with a format that drives it over the 512 - // byte initial buffer. This was a bug in r1441, see bug: - // https://github.com/CVC4/CVC4/issues/465 - string fmt = string(200, 'x') + " %s " + string(200, 'x'); - string arg(200, 'y'); - try { - AlwaysAssert(false, fmt.c_str(), arg.c_str()); - TS_FAIL("Should have thrown an exception !"); - } catch(AssertionException& e) { - // we don't want to match on the entire string, because it may - // have an absolute path to the unit test binary, line number - // info, etc. - std::string s = e.toString(); - const char* theString = s.c_str(); - const char* firstPart = - "Assertion failure\nvoid AssertWhite::testReallyLongAssert()\n"; - string lastPartStr = "\n\n false\n" + string(200, 'x') + " " + - string(200, 'y') + " " + string(200, 'x'); - const char* lastPart = lastPartStr.c_str(); - TS_ASSERT(strncmp(theString, firstPart, strlen(firstPart)) == 0); - TS_ASSERT(strncmp(theString + strlen(theString) - strlen(lastPart), - lastPart, strlen(lastPart)) == 0); - } catch(...) { - TS_FAIL("Threw the wrong kind of exception !"); - } - } + TS_ASSERT_THROWS_NOTHING(Assert(true)); + TS_UTILS_EXPECT_ABORT(AlwaysAssert(false)); + TS_UTILS_EXPECT_ABORT(Unreachable()); + TS_UTILS_EXPECT_ABORT(Unhandled()); + TS_UTILS_EXPECT_ABORT(Unimplemented()); + TS_ASSERT_THROWS(IllegalArgument("x"), IllegalArgumentException&); + TS_ASSERT_THROWS(CheckArgument(false, "x"), IllegalArgumentException&); + TS_ASSERT_THROWS(AlwaysAssertArgument(false, "x"), AssertArgumentException&); + TS_ASSERT_THROWS_NOTHING(AssertArgument(true, "x")); + TS_ASSERT_THROWS_NOTHING(AssertArgument(true, "x")); + } void testUnreachable() { - TS_ASSERT_THROWS(Unreachable(), UnreachableCodeException&); - TS_ASSERT_THROWS(Unreachable("hello"), UnreachableCodeException&); - TS_ASSERT_THROWS(Unreachable("hello %s", "world"), - UnreachableCodeException&); + TS_UTILS_EXPECT_ABORT(Unreachable()); + TS_UTILS_EXPECT_ABORT(Unreachable() << "hello"); + TS_UTILS_EXPECT_ABORT(Unreachable() << "hello " + << "world"); int x = 5; - TS_ASSERT_THROWS(Unhandled(), UnhandledCaseException&); - TS_ASSERT_THROWS(Unhandled(x), UnhandledCaseException&); - TS_ASSERT_THROWS(Unhandled("foo"), UnhandledCaseException&); - TS_ASSERT_THROWS(Unhandled("foo %s baz", "bar"), UnhandledCaseException&); + TS_UTILS_EXPECT_ABORT(Unhandled()); + TS_UTILS_EXPECT_ABORT(Unhandled() << x); + TS_UTILS_EXPECT_ABORT(Unhandled() << "foo"); + TS_UTILS_EXPECT_ABORT(Unhandled() << "foo " + << "bar" + << " baz"); } }; diff --git a/test/unit/util/binary_heap_black.h b/test/unit/util/binary_heap_black.h index 192237b49..3cb18c974 100644 --- a/test/unit/util/binary_heap_black.h +++ b/test/unit/util/binary_heap_black.h @@ -19,6 +19,7 @@ #include #include +#include "test_utils.h" #include "util/bin_heap.h" using namespace CVC4; @@ -43,8 +44,8 @@ class BinaryHeapBlack : public CxxTest::TestSuite { TS_ASSERT_EQUALS(heap.size(), 0u); TS_ASSERT(heap.empty()); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS_ANYTHING(heap.top()); - TS_ASSERT_THROWS_ANYTHING(heap.pop()); + TS_UTILS_EXPECT_ABORT(heap.top()); + TS_UTILS_EXPECT_ABORT(heap.pop()); #endif /* CVC4_ASSERTIONS */ TS_ASSERT_EQUALS(heap.begin(), heap.end()); @@ -60,8 +61,8 @@ class BinaryHeapBlack : public CxxTest::TestSuite { TS_ASSERT(heap.empty()); TS_ASSERT_EQUALS(heap.size(), 0u); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS_ANYTHING(heap.top()); - TS_ASSERT_THROWS_ANYTHING(heap.pop()); + TS_UTILS_EXPECT_ABORT(heap.top()); + TS_UTILS_EXPECT_ABORT(heap.pop()); #endif /* CVC4_ASSERTIONS */ // Next test a heap of 4 elements @@ -118,8 +119,8 @@ class BinaryHeapBlack : public CxxTest::TestSuite { TS_ASSERT(heap.empty()); TS_ASSERT_EQUALS(heap.size(), 0u); #ifdef CVC4_ASSERTIONS - TS_ASSERT_THROWS_ANYTHING(heap.top()); - TS_ASSERT_THROWS_ANYTHING(heap.pop()); + TS_UTILS_EXPECT_ABORT(heap.top()); + TS_UTILS_EXPECT_ABORT(heap.pop()); #endif /* CVC4_ASSERTIONS */ // Now with a few updates diff --git a/test/unit/util/check_white.h b/test/unit/util/check_white.h index 052a35110..1a169f320 100644 --- a/test/unit/util/check_white.h +++ b/test/unit/util/check_white.h @@ -19,7 +19,7 @@ #include #include -#include "base/cvc4_check.h" +#include "base/check.h" #include "test_utils.h" using namespace std; @@ -40,25 +40,25 @@ class CheckWhite : public CxxTest::TestSuite "return type."; } - void testCheck() { CVC4_CHECK(kOne >= 0) << kOne << " must be positive"; } + void testCheck() { AlwaysAssert(kOne >= 0) << kOne << " must be positive"; } void testDCheck() { - CVC4_DCHECK(kOne == 1) << "always passes"; + Assert(kOne == 1) << "always passes"; #ifndef CVC4_ASSERTIONS - CVC4_DCHECK(false) << "Will not be compiled in when CVC4_ASSERTIONS off."; + Assert(false) << "Will not be compiled in when CVC4_ASSERTIONS off."; #endif /* CVC4_ASSERTIONS */ } void testPointerTypeCanBeTheCondition() { const int* one_pointer = &kOne; - CVC4_CHECK(one_pointer); + AlwaysAssert(one_pointer); } void testExpectAbort() { - TS_UTILS_EXPECT_ABORT(CVC4_CHECK(false)); - TS_UTILS_EXPECT_ABORT(CVC4_DCHECK(false)); + TS_UTILS_EXPECT_ABORT(AlwaysAssert(false)); + TS_UTILS_EXPECT_ABORT(Assert(false)); } }; diff --git a/test/unit/util/stats_black.h b/test/unit/util/stats_black.h index 5cb6c2099..9c40d8a47 100644 --- a/test/unit/util/stats_black.h +++ b/test/unit/util/stats_black.h @@ -46,8 +46,8 @@ public: // StatisticsRegistry //static void flushStatistics(std::ostream& out); - //static inline void registerStat(Stat* s) throw (AssertionException); - //static inline void unregisterStat(Stat* s) throw (AssertionException); + // static inline void registerStat(Stat* s); + // static inline void unregisterStat(Stat* s); string empty, bar = "bar", baz = "baz"; ReferenceStat refStr("stat #1", empty);