#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"
#-----------------------------------------------------------------------------#
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
--- /dev/null
+/********************* */
+/*! \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 <cstdlib>
+#include <iostream>
+
+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
--- /dev/null
+/********************* */
+/*! \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 <cstdarg>
+#include <ostream>
+
+#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 */
+++ /dev/null
-/********************* */
-/*! \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 <new>
-#include <cstdarg>
-#include <cstdio>
-
-#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 */
+++ /dev/null
-/********************* */
-/*! \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 <cstdarg>
-#include <cstdio>
-#include <cstdlib>
-#include <sstream>
-#include <string>
-
-#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 <class T>
- 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 */
+++ /dev/null
-/********************* */
-/*! \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 <cstdlib>
-#include <iostream>
-
-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
+++ /dev/null
-/********************* */
-/*! \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 <ostream>
-
-// 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 */
#include <cstring>
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
using namespace std;
#include <list>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
namespace CVC4 {
#ifndef CVC4__BASE__MAP_UTIL_H
#define CVC4__BASE__MAP_UTIL_H
-#include "base/cvc4_check.h"
+#include "base/check.h"
namespace CVC4 {
const MapMappedTypeT<M>& FindOrDie(const M& map, const MapKeyTypeT<M>& 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;
}
void List<T>::concat (List<T>* 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;
#include <unordered_map>
#include <vector>
-#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 {
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(); }
#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 {
}
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) :
#include <unordered_map>
#include <utility>
-#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 {
#include <string>
#include <sstream>
-#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 {
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
* 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];
}
* 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];
}
#ifndef CVC4__CONTEXT__CDO_H
#define CVC4__CONTEXT__CDO_H
-#include "base/cvc4_assert.h"
#include "context/context.h"
* 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];
}
* 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];
}
/** 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;
}
#include <iostream>
#include <vector>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "context/context.h"
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;
<< *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.
// 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;
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();
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) {
{
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";
#include <typeinfo>
#include <vector>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/output.h"
#include "context/context_mm.h"
}
~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 */
* 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!";
}
/**
#include <valgrind/memcheck.h>
#endif /* CVC4_VALGRIND */
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/output.h"
#include "context/context_mm.h"
// 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()) {
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 "
/** 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;
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();
}
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);
}
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();
case kind::CONST_BOOLEAN:
Assert(node.getConst<bool>() == false || desiredVal == SAT_VALUE_TRUE);
- Assert(node.getConst<bool>() == true || desiredVal == SAT_VALUE_FALSE);
+ Assert(node.getConst<bool>() == true || desiredVal == SAT_VALUE_FALSE);
break;
case kind::AND:
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) {
}
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;
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);
}
}
}
- Assert(d_curThreshold != 0, "handleAndOrEasy: No controlling input found");
+ Assert(d_curThreshold != 0) << "handleAndOrEasy: No controlling input found";
return DONT_KNOW;
}
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;
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;
}
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'
#include <iostream>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/expr.h"
#include "expr/type.h"
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);
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:
*/
static inline uint64_t registerAttribute() {
const uint64_t id = attr::LastAttributeId<bool, context_dep>::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, ...> */
#include <string>
#include <sstream>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/attribute.h"
#include "expr/expr_manager.h"
#include "expr/expr_manager_scope.h"
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";
}
}
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;
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;
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();
}
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];
}
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);
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);
// 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;
}
}
// 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) {
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,
}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;
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]++;
}
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();
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 );
/** Make a function type with input types from argTypes. */
FunctionType ExprManager::mkFunctionType(const std::vector<Type>& argTypes, Type range) {
NodeManagerScope nms(d_nodeManager);
- Assert( argTypes.size() >= 1 );
+ Assert(argTypes.size() >= 1);
std::vector<TypeNode> argTypeNodes;
for (unsigned i = 0, i_end = argTypes.size(); i < i_end; ++ i) {
argTypeNodes.push_back(*argTypes[i].d_typeNode);
FunctionType ExprManager::mkFunctionType(const std::vector<Type>& sorts) {
NodeManagerScope nms(d_nodeManager);
- Assert( sorts.size() >= 2 );
+ Assert(sorts.size() >= 2);
std::vector<TypeNode> sortNodes;
for (unsigned i = 0, i_end = sorts.size(); i < i_end; ++ i) {
sortNodes.push_back(*sorts[i].d_typeNode);
FunctionType ExprManager::mkPredicateType(const std::vector<Type>& sorts) {
NodeManagerScope nms(d_nodeManager);
- Assert( sorts.size() >= 1 );
+ Assert(sorts.size() >= 1);
std::vector<TypeNode> sortNodes;
for (unsigned i = 0, i_end = sorts.size(); i < i_end; ++ i) {
sortNodes.push_back(*sorts[i].d_typeNode);
if( (*i).isSort() ) {
name = SortType(*i).getName();
} else {
- Assert( (*i).isSortConstructor() );
+ Assert((*i).isSortConstructor());
name = SortConstructorType(*i).getName();
}
std::map<std::string, DatatypeType>::const_iterator resolver =
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 );
}
++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";
}
}
}
}
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;
}
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));
/* 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);
}/* 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)));
#include <utility>
#include <vector>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/expr_manager_scope.h"
#include "expr/node.h"
#include "expr/node_algorithm.h"
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) {
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;
}
}
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;
}
}
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;
}
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()));
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);
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);
}
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);
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);
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,
switch(n.getKind()) {
${exportConstant_cases}
- default: Unhandled(n.getKind());
+default: Unhandled() << n.getKind();
}
}/* exportConstant() */
#include <stdint.h>
#include <iterator>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/kind.h"
namespace CVC4 {
#include <vector>
#include <map>
-#include "base/cvc4_assert.h"
#include "expr/node.h"
#include "expr/type_node.h"
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);
}
}
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);
}
}
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);
}
}
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);
}
}
#include <iosfwd>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/kind.h"
namespace CVC4 {
fi
else
type_constant_groundterms="${type_constant_groundterms}#line $lineno \"$kf\"
- case $id: Unhandled(tc);
+ case $id: Unhandled() << tc;
"
fi
}
"
else
type_groundterms="${type_groundterms}#line $lineno \"$kf\"
- case $id: Unhandled(typeNode);
+ case $id: Unhandled() << typeNode;
"
fi
if [ -n "$header" ]; then
#include <utility>
#include <vector>
+#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"
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";
}
}
template <class AttrKind>
inline typename AttrKind::value_type NodeTemplate<ref_count>::
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();
template <class AttrKind>
inline bool NodeTemplate<ref_count>::
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();
template <class AttrKind>
inline bool NodeTemplate<ref_count>::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();
template <class AttrKind>
inline void NodeTemplate<ref_count>::
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();
template <bool ref_count>
NodeTemplate<ref_count>::NodeTemplate(const expr::NodeValue* ev) :
d_nv(const_cast<expr::NodeValue*> (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";
}
}
template <bool ref_count>
NodeTemplate<ref_count>::NodeTemplate(const NodeTemplate<!ref_count>& 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 <bool ref_count>
NodeTemplate<ref_count>::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 <bool ref_count>
NodeTemplate<ref_count>::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();
}
template <bool ref_count>
NodeTemplate<ref_count>::~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();
}
}
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 <bool ref_count>
NodeTemplate<ref_count>& NodeTemplate<ref_count>::
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;
template <bool ref_count>
NodeTemplate<ref_count>& NodeTemplate<ref_count>::
operator=(const NodeTemplate<!ref_count>& 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;
*/
template <bool ref_count>
NodeTemplate<true> NodeTemplate<ref_count>::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();
case kind::metakind::NULLARY_OPERATOR:
IllegalArgument(*this, "getOperator() called on Node with NULLARY_OPERATOR-kinded kind");
- default:
- Unhandled(mk);
+ default: Unhandled() << mk;
}
}
template <bool ref_count>
TypeNode NodeTemplate<ref_count>::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();
}
// 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;
std::vector<TNode> 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();
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
* 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;
}
* 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;
}
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;
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;
/** 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<true> >();
}
/** 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<true> >();
}
/** 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();
}
* 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());
}
* 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));
}
/** Set the Kind of this Node-under-construction. */
inline NodeBuilder<nchild_thresh>& 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,
* append the given Node as a child. Otherwise, simply append.
*/
NodeBuilder<nchild_thresh>& 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),
* append the given Node as a child. Otherwise, simply append.
*/
NodeBuilder<nchild_thresh>& 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),
/** Append a sequence of children to this TypeNode-under-construction. */
inline NodeBuilder<nchild_thresh>&
append(const std::vector<TypeNode>& 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());
}
template <bool ref_count>
inline NodeBuilder<nchild_thresh>&
append(const std::vector<NodeTemplate<ref_count> >& 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 <class Iterator>
NodeBuilder<nchild_thresh>& 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);
}
/** Append a child to this Node-under-construction. */
NodeBuilder<nchild_thresh>& 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);
}
/** Append a child to this Node-under-construction. */
NodeBuilder<nchild_thresh>& 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();
template <unsigned nchild_thresh>
void NodeBuilder<nchild_thresh>::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();
template <unsigned nchild_thresh>
void NodeBuilder<nchild_thresh>::realloc(size_t toSize) {
- AlwaysAssert(toSize > d_nvMaxChildren,
- "attempt to realloc() a NodeBuilder to a smaller/equal size!");
- Assert(toSize < (static_cast<size_t>(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<size_t>(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
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;
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;
template <unsigned nchild_thresh>
void NodeBuilder<nchild_thresh>::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();
template <unsigned nchild_thresh>
void NodeBuilder<nchild_thresh>::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();
template <unsigned nchild_thresh>
expr::NodeValue* NodeBuilder<nchild_thresh>::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.
* 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*)
}
// 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
// CONST VERSION OF NODE EXTRACTOR
template <unsigned nchild_thresh>
expr::NodeValue* NodeBuilder<nchild_thresh>::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.
* 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*)
}
// 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
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;
#include <stack>
#include <utility>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/listener.h"
#include "expr/attribute.h"
#include "expr/node_manager_attributes.h"
#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;
}
d_ownedDatatypes.clear();
- Assert(!d_attrManager->inGarbageCollection() );
+ Assert(!d_attrManager->inGarbageCollection());
std::vector<NodeValue*> order = TopologicalSort(d_maxedOut);
d_maxedOut.clear();
}
const Datatype & NodeManager::getDatatypeForIndex( unsigned index ) const{
- Assert( index<d_ownedDatatypes.size() );
+ Assert(index < d_ownedDatatypes.size());
return *d_ownedDatatypes[index];
}
Debug("gc") << "reclaiming " << d_zombies.size() << " zombie(s)!\n";
// during reclamation, reclaimZombies() is never supposed to be called
- Assert(! d_inReclaimZombies, "NodeManager::reclaimZombies() not re-entrant!");
+ Assert(!d_inReclaimZombies)
+ << "NodeManager::reclaimZombies() not re-entrant!";
// whether exit is normal or exceptional, the Reclaim dtor is called
// and ensures that d_inReclaimZombies is set back to false.
}
if( readyToCompute ) {
- Assert( check || m.getMetaKind()!=kind::metakind::NULLARY_OPERATOR );
+ Assert(check || m.getMetaKind() != kind::metakind::NULLARY_OPERATOR);
/* All the children have types, time to compute */
typeNode = TypeChecker::computeType(this, m, check);
worklist.pop();
} // end while
/* Last type computed in loop should be the type of n */
- Assert( typeNode == getAttribute(n, TypeAttr()) );
+ Assert(typeNode == getAttribute(n, TypeAttr()));
} else if( !hasType || needsCheck ) {
/* We can compute the type top-down, without worrying about
deep recursion. */
- Assert( check || n.getMetaKind()!=kind::metakind::NULLARY_OPERATOR );
+ Assert(check || n.getMetaKind() != kind::metakind::NULLARY_OPERATOR);
typeNode = TypeChecker::computeType(this, n, check);
}
/* The type should be have been computed and stored. */
- Assert( hasAttribute(n, TypeAttr()) );
+ Assert(hasAttribute(n, TypeAttr()));
/* The check should have happened, if we asked for it. */
- Assert( !check || getAttribute(n, TypeCheckedAttr()) );
+ Assert(!check || getAttribute(n, TypeCheckedAttr()));
Debug("getType") << "type of " << &n << " " << n << " is " << typeNode << endl;
return typeNode;
TypeNode NodeManager::mkSort(TypeNode constructor,
const std::vector<TypeNode>& 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;
}
Node NodeManager::getBoundVarListForFunctionType( TypeNode tn ) {
- Assert( tn.isFunction() );
+ Assert(tn.isFunction());
Node bvl = tn.getAttribute(LambdaBoundVarListAttr());
if( bvl.isNull() ){
std::vector< Node > vars;
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;
#include <string>
#include <unordered_set>
+#include "base/check.h"
#include "expr/kind.h"
#include "expr/metakind.h"
#include "expr/node_value.h"
/** 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<NodeManagerListener*>::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);
}
}
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
}
case kind::metakind::CONSTANT:
return false;
- default:
- Unhandled(mk);
+ default: Unhandled() << mk;
}
}
#include <iterator>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/node.h"
namespace CVC4 {
};/* 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());
}
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) :
}
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);
}
}
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);
}
}
#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"
default:
Debug("getType") << "FAILURE" << std::endl;
- Unhandled(n.getKind());
+ Unhandled() << n.getKind();
}
nodeManager->setAttribute(n, TypeAttr(), typeNode);
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;
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;
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> TypeNode::getTupleTypes() const {
Assert(isTuple());
const Datatype& dt = getDatatype();
- Assert(dt.getNumConstructors()==1);
+ Assert(dt.getNumConstructors() == 1);
vector<TypeNode> types;
for(unsigned i = 0; i < dt[0].getNumArgs(); ++i) {
types.push_back(TypeNode::fromType(dt[0][i].getRangeType()));
}
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());
}
}
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 ) ){
#include <unordered_map>
#include <vector>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/kind.h"
#include "expr/metakind.h"
#include "util/cardinality.h"
}
// 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));
inline TypeNode::TypeNode(const expr::NodeValue* ev) :
d_nv(const_cast<expr::NodeValue*> (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();
}
}
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;
template <class AttrKind>
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 <class AttrKind>
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 <class AttrKind>
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 <class AttrKind>
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);
}
DatatypeIndexConstant dic = getConst<DatatypeIndexConstant>();
return NodeManager::currentNM()->getDatatypeForIndex( dic.getIndex() );
}else{
- Assert( getKind() == kind::PARAMETRIC_DATATYPE );
+ Assert(getKind() == kind::PARAMETRIC_DATATYPE);
return (*this)[0].getDatatype();
}
}
/** Get the significand size of this floating-point type */
inline unsigned TypeNode::getFloatingPointSignificandSize() const {
- Assert(isFloatingPoint());
- return getConst<FloatingPointSize>().significand();
+ Assert(isFloatingPoint());
+ return getConst<FloatingPointSize>().significand();
}
/** Get the size of this bit-vector type */
#include <sstream>
-#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 {
* "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
case TYPE_CONSTANT:
return getCardinality(typeNode.getConst<TypeConstant>());
${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) */
case TYPE_CONSTANT:
return isWellFounded(typeNode.getConst<TypeConstant>());
${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<TypeConstant>());
+ switch (Kind k = typeNode.getKind())
+ {
+ case TYPE_CONSTANT:
+ return mkGroundTerm(typeNode.getConst<TypeConstant>());
${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 */
#include <sstream>
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
using namespace std;
#include <cstring>
#include <list>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/output.h"
#include "options/argument_extender.h"
#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"
#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"
#include <sstream>
#include <limits>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/exception.h"
#include "base/output.h"
#include "options/argument_extender.h"
#include "preprocessing/passes/ackermann.h"
+#include "base/check.h"
#include "options/options.h"
using namespace CVC4;
}
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)
{
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());
#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
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);
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)
}
#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
{ // 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)
}
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
}
}
}
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;
}
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
}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
#include <algorithm>
#include <utility>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/map_util.h"
#include "base/output.h"
#include "preprocessing/passes/ackermann.h"
}
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());
}
void DagificationVisitor::start(TNode node) {
- AlwaysAssert(!d_done, "DagificationVisitor cannot be re-used");
+ AlwaysAssert(!d_done) << "DagificationVisitor cannot be re-used";
d_top = 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
return unique_ptr<Printer>(
new printer::cvc::CvcPrinter(/* cvc3-mode = */ true));
- default:
- Unhandled(lang);
+ default: Unhandled() << lang;
}
}
case roundTowardNegative : out << "roundTowardNegative"; break;
case roundTowardZero : out << "roundTowardZero"; break;
default :
- Unreachable("Invalid value of rounding mode constant (%d)",n.getConst<RoundingMode>());
+ Unreachable() << "Invalid value of rounding mode constant ("
+ << n.getConst<RoundingMode>() << ")";
}
break;
case kind::CONST_BOOLEAN:
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)
{
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];
}
{
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)) {
{
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)) {
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 {
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();
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() << ")";
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() << ")";
// !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:
}
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;
}
{
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 _ _ _ ";
}
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;
}
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_- _ _ _ _ _ ";
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 {
} 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 << " ";
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() << ")";
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() << ")";
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);
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);
}
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
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: {
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);
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<BitVectorBitOf>().bitIndex;
Expr var = term[0];
void BitVectorProof::printConstant(Expr term, std::ostream& os)
{
- Assert (term.isConst());
+ Assert(term.isConst());
os << "(a_bv " << utils::getSize(term) << " ";
if (d_useConstantLetification) {
os << high <<" " << low << " " << utils::getSize(term[0]);
}
os <<" ";
- Assert (term.getNumChildren() == 1);
+ Assert(term.getNumChildren() == 1);
d_proofEngine->printBoundTerm(term[0], os, map);
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 << ")";
}
{
// 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())
return;
}
- default: Unreachable("BitVectorProof Unknown operator");
+ default: Unreachable() << "BitVectorProof Unknown operator";
}
}
return;
}
- default: Unreachable("BitVectorProof Unknown atom kind");
+ default: Unreachable() << "BitVectorProof Unknown atom kind";
}
}
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) << " ";
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
{
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,
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 ";
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 ";
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 =
}
ProofRule CnfProof::getProofRule(Node node) {
- Assert (isAssertion(node));
+ Assert(isAssertion(node));
NodeToProofRule::iterator it = d_assertionToProofRule.find(node);
return (*it).second;
}
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;
}
<< "from " << from << std::endl
<< " to " << to << std::endl;
- Assert (from != to);
+ Assert(from != to);
d_cnfDeps.insert(std::make_pair(from, to));
}
}
void CnfProof::popCurrentAssertion() {
- Assert (d_currentAssertionStack.size());
+ Assert(d_currentAssertionStack.size());
Debug("proof:cnf") << "CnfProof::popCurrentAssertion "
<< d_currentAssertionStack.back() << std::endl;
}
Node CnfProof::getCurrentAssertion() {
- Assert (d_currentAssertionStack.size());
+ Assert(d_currentAssertionStack.size());
return d_currentAssertionStack.back();
}
}
void CnfProof::popCurrentDefinition() {
- Assert (d_currentDefinitionStack.size());
+ Assert(d_currentDefinitionStack.size());
Debug("proof:cnf") << "CnfProof::popCurrentDefinition "
<< d_currentDefinitionStack.back() << std::endl;
}
Node CnfProof::getCurrentDefinition() {
- Assert (d_currentDefinitionStack.size());
+ Assert(d_currentDefinitionStack.size());
return d_currentDefinitionStack.back();
}
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);
// return;
- Assert( clause->size()>0 );
+ Assert(clause->size() > 0);
// If the clause contains x v ~x, it's easy!
//
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];
}
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() << ")";
#include "proof/dimacs.h"
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include <iostream>
os << '0' << std::endl;
break;
}
- default: { Unreachable("Unknown DRAT instruction kind");
+ default:
+ {
+ Unreachable() << "Unknown DRAT instruction kind";
}
}
}
os << "DRATProofd ";
break;
}
- default: { Unreachable("Unrecognized DRAT instruction kind");
+ default:
+ {
+ Unreachable() << "Unrecognized DRAT instruction kind";
}
}
for (const SatLiteral& l : i.d_clause)
#include <iterator>
#include <unordered_set>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/map_util.h"
#include "proof/dimacs.h"
#include "proof/lfsc_proof_printer.h"
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
}
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));
}
// 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";
}
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;
}
#include <sstream>
#include <unordered_map>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/output.h"
#include "proof/dimacs.h"
#include "proof/lfsc_proof_printer.h"
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
}
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)
#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"
}
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<proof::ResolutionBitVectorProof*>(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, "");
}
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;
}
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();
}
}
std::string ProofManager::sanitize(TNode node) {
- Assert (node.isVar() || node.isConst());
+ Assert(node.isVar() || node.isConst());
std::string name = node.toString();
if (node.isVar()) {
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<Node> deps = (*d_deps.find(n)).second;
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<Node> deps = (*d_deps.find(n)).second;
}
void ProofManager::traceUnsatCore() {
- Assert (options::unsatCores());
+ Assert(options::unsatCores());
d_satProof->refreshProof();
IdToSatClause used_lemmas;
IdToSatClause used_inputs;
}
void ProofManager::getLemmasInUnsatCore(theory::TheoryId theory, std::vector<Node> &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();
}
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))
}
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);
}
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, "")
Node& op = d_ops[n];
if(op.isNull()) {
- Assert((n.getConst<Kind>() == kind::SELECT) || (n.getConst<Kind>() == kind::STORE));
+ Assert((n.getConst<Kind>() == kind::SELECT)
+ || (n.getConst<Kind>() == kind::STORE));
Debug("mgd-pm-mkop") << "making an op for " << n << "\n";
}
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();
}
#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"
// 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);
}
inline unsigned getSize(Expr node) {
- Assert (node.getType().isBitVector());
+ Assert(node.getType().isBitVector());
return getSize(node.getType());
}
inline Expr mkOr(const std::vector<Expr>& nodes) {
std::set<Expr> 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
}/* 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<BitVector>().extract(i, i).getValue();
return (bit == 1u);
}
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);
}
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];
}
**/
#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"
bvp = new proof::LfscErBitVectorProof(thBv, this);
break;
}
- default: { Unreachable("Invalid BvProofFormat");
+ default:
+ {
+ Unreachable() << "Invalid BvProofFormat";
}
};
d_theoryProofTable[id] = bvp;
}
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];
Node node = pm->getCnfProof()->getAtom(lit.getSatVariable());
Expr atom = node.toExpr();
if (atom.isConst()) {
- Assert (atom == utils::mkTrue());
+ Assert(atom == utils::mkTrue());
continue;
}
}
// Ensure that the lemma is in the database.
- Assert (pm->getCnfProof()->haveProofRecipe(nodes));
+ Assert(pm->getCnfProof()->haveProofRecipe(nodes));
return pm->getCnfProof()->getProofRecipe(nodes).getTheory();
}
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
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();
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);
// 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;
}
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;
}
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;
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 (= ";
return;
}
- default:
- Unhandled(k);
+ default: Unhandled() << k;
}
}
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;
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;
{}
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);
}
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;
os << (term.getConst<bool>() ? "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";
}
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)
} 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 {
} 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 << " ";
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();
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() << ")";
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() << ")";
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 ||
return;
}
- Assert (term.getKind() == kind::APPLY_UF);
+ Assert(term.getKind() == kind::APPLY_UF);
if(term.getType().isBoolean()) {
os << "(p_app ";
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;
}
}
os << fparen.str() << "))\n";
} else {
- Assert (term.isVariable());
+ Assert(term.isVariable());
os << type << ")\n";
}
paren << ")";
#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"
// }
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;
}
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;
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){
// 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) {
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);
}
}
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);}
}
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])); }
}
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,
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; }
#include <queue>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/output.h"
#include "expr/expr.h"
#include "expr/node.h"
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;
}
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;
}
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;
}
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]);
}
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();
}
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();
}
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]);
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;
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]);
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;
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());
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());
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;
}
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();
}
SatValue CryptoMinisatSolver::value(SatLiteral l){
const std::vector<CMSat::lbool> 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);
}
}
unsigned CryptoMinisatSolver::getAssertionLevel() const {
- Unreachable("No interface to get assertion level in Cryptominisat");
+ Unreachable() << "No interface to get assertion level in Cryptominisat";
return -1;
}
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;
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) {
// 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;
// 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)
}
}
- 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();
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);
return ClauseIdUndef;
}
d_minisat->addClause(minisat_clause, removable, clause_id);
- PROOF( Assert (clause_id != ClauseIdError););
+ PROOF(Assert(clause_id != ClauseIdError););
return clause_id;
}
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,
#include <map>
#include <utility>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/output.h"
#include "decision/decision_engine.h"
#include "expr/expr.h"
#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"
}
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);
}
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
}
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;
}
/** Check satisfiability under assumptions */
virtual SatValue solve(const std::vector<SatLiteral>& assumptions)
{
- Unimplemented("Solving under assumptions not implemented");
+ Unimplemented() << "Solving under assumptions not implemented";
};
/** Interrupt the solver */
#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
}
#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
}
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 */
#include <utility>
#include <vector>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/output.h"
#include "expr/expr_iomanip.h"
#include "expr/node.h"
#include <ostream>
+#include "base/check.h"
#include "options/open_ostream.h"
#include "options/smt_options.h"
#include "smt/update_ostream.h"
}
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();
#include <utility>
#include <vector>
+#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"
// 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());
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();
}
"last result wasn't unknown!");
}
} else if(key == "assertion-stack-levels") {
- AlwaysAssert(d_userLevels.size() <=
- std::numeric_limits<unsigned long int>::max());
+ AlwaysAssert(d_userLevels.size()
+ <= std::numeric_limits<unsigned long int>::max());
return SExpr(static_cast<unsigned long int>(d_userLevels.size()));
} else if(key == "all-options") {
// get the options, like all-statistics
// 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;
}
//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<Node>::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; j<fcit->second.size(); j++ ){
fdf.d_input_arg_inj[f].push_back( fcit->second[j] );
}
// 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).
{
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<Expr> SmtEngine::getExpandedAssertions()
// 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) */
}
}
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();
}
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);
}
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
// 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
// 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;
}
<< "expected `true'." << endl
<< "Run with `--check-models -v' for additional diagnostics.";
if(hardFailure) {
- InternalError(ss.str());
+ InternalError() << ss.str();
} else {
Warning() << ss.str() << endl;
}
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();
}
// did we get an unexpected result?
if (isError)
{
- InternalError(serr.str().c_str());
+ InternalError() << serr.str();
}
}
}
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;
if( d_theoryEngine ){
d_theoryEngine->printSynthSolution( out );
}else{
- Assert( false );
+ Assert(false);
}
}
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;
qs.push_back( qs_n[i].toExpr() );
}
}else{
- Assert( false );
+ Assert(false);
}
}
insts.push_back( insts_n[i].toExpr() );
}
}else{
- Assert( false );
+ Assert(false);
}
}
tvecs.push_back( tvec );
}
}else{
- Assert( false );
+ Assert(false);
}
}
}
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;
}
#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"
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 */
}
#include <ostream>
-#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 {
#include <vector>
#include <algorithm>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/expr_manager_scope.h"
#include "expr/node.h"
/* 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);
}
unsigned N = n.getNumChildren();
Assert(N >= 2);
-
Node last = rePairAssocCommutativeOperators( n[N-1]);
Node nextToLast = rePairAssocCommutativeOperators(n[N-2]);
, d(coeff)
, y(bounding)
, c(orig)
- { Assert(k == kind::LEQ || k == kind::GEQ); }
+ {
+ Assert(k == kind::LEQ || k == kind::GEQ);
+ }
};
struct CutScratchPad {
Assert(numRows > 0);
Assert(numCols > 0);
-
-
glp_add_rows(d_inputProb, numRows);
glp_add_cols(d_inputProb, numCols);
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;
}
}
-
-
// Node explainSet(const set<ConstraintP>& inp){
// Assert(!inp.empty());
// NodeBuilder<> nb(kind::AND);
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) ?
// 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();
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);
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;
}
RewriteResponse ArithRewriter::rewriteMinus(TNode t, bool pre){
- Assert(t.getKind()== kind::MINUS);
+ Assert(t.getKind() == kind::MINUS);
if(pre){
if(t[0] == t[1]){
}
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<Rational>());
return RewriteResponse(REWRITE_DONE, t);
case kind::PI:
return RewriteResponse(REWRITE_DONE, t);
- default:
- Unhandled(k);
+ default: Unhandled() << k;
}
}
}
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
}
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));
}
RewriteResponse ArithRewriter::postRewritePlus(TNode t){
- Assert(t.getKind()== kind::PLUS);
+ Assert(t.getKind() == kind::PLUS);
std::vector<Monomial> monomials;
std::vector<Polynomial> polynomials;
}
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();
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,
}
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];
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)
Debug("arith::static") << "adding bound " << n << endl;
}
break;
- default:
- Unhandled(k);
- break;
+ default: Unhandled() << k; break;
}
}
}
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];
return Result::UNSAT;
}
}
- Assert( d_conflictVariables.empty() );
+ Assert(d_conflictVariables.empty());
if(d_errorSet.errorEmpty()){
return Result::SAT;
#include <stdint.h>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "theory/arith/arithvar.h"
#include "util/dense_map.h"
}
inline BoundCounts operator-(BoundCounts bc) const {
- Assert( *this >= bc );
+ Assert(*this >= bc);
return BoundCounts(d_lowerBoundCount - bc.d_lowerBoundCount,
d_upperBoundCount - bc.d_upperBoundCount);
}
/* 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 {
d_consequentSet = true;
}
- Assert(! d_consequent->negationHasProof() );
+ Assert(!d_consequent->negationHasProof());
Assert(d_consequentSet);
}
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);
reset();
Assert(!underConstruction());
- Assert( not_c->inConflict() );
+ Assert(not_c->inConflict());
Assert(!d_consequentSet);
return not_c;
}
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() ){
return Equality;
case DISTINCT:
return Disequality;
- default:
- Unhandled(k);
+ default: Unhandled() << k;
}
}
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();
}
}
out << "_";
}
out << " * (" << *antecedent << ")" << std::endl;
-
+
Assert((coeffs == RationalVectorCPSentinel) || coeffIterator > 0);
--p;
coeffIterator = (coeffs != RationalVectorCPSentinel) ? coeffIterator-1 : 0;
pair<SortedConstraintMapIterator, bool> 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;
}
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;
Assert(imp->hasProof());
Assert(negationHasProof() == nowInConflict);
-
d_database->d_antecedents.push_back(NullConstraint);
d_database->d_antecedents.push_back(imp);
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);
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];
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){
#include <ostream>
+#include "base/check.h"
#include "base/exception.h"
-#include "base/cvc4_assert.h"
#include "util/integer.h"
#include "util/rational.h"
void DioSolver::moveMinimumByAbsToQueueFront(){
Assert(!queueEmpty());
-
//Select the minimum element.
size_t indexInQueue = 0;
Monomial minMonomial = d_trail[d_currentF[indexInQueue]].d_minimalMonomial;
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;
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);
}
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;
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;
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;
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; }
}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;
}
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));
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)){
}
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);
}
Assert(d_conflictVariables.empty());
Assert(d_focusErrorVar == ARITHVAR_SENTINEL);
-
d_scores.purge();
d_focusErrorVar = constructInfeasiblityFunction(d_statistics.d_fcFocusConstructionTimer);
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);
if(verbose){
debugDualLike(w, Message(), instance, prevFocusSize, prevErrorSize);
}
- Assert(debugDualLike(w, Debug("dualLike"), instance, prevFocusSize, prevErrorSize));
+ Assert(debugDualLike(
+ w, Debug("dualLike"), instance, prevFocusSize, prevErrorSize));
}
<< "computed " << computed
<< " tracking " << d_btracking[ridx] << endl;
Assert(computed == d_btracking[ridx]);
-
}
}
}
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){
fcs.addConstraint(c, coeff, adjustSgn);
if(basicVar == v){
- Assert(! c->negationHasProof() );
+ Assert(!c->negationHasProof());
fcs.makeLastConsequent();
}
}
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;
}
}
Assert(newEntry.getCoefficient() != 0);
-
++d_entriesInUse;
d_rows[row].insert(newId);
Assert(mult != 0);
-
RowIterator i = getRow(to).begin();
RowIterator i_end = getRow(to).end();
while(i != i_end){
Assert(mult != 0);
-
RowIterator i = getRow(to).begin();
RowIterator i_end = getRow(to).end();
while(i != i_end){
{
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
/*
//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;
}
else
{
- Assert( false );
+ Assert(false);
}
}
// initialize pi if necessary
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;
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<Rational>().sgn();
Trace("nl-ext-debug") << "Process var " << av << "^" << aexp
<< ", model sign = " << sgn << std::endl;
// 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<Node> exp;
NodeMultiset a_exp_proc;
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);
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 <k> t => m*x <k'> t where y = m*x
// get the sign of mult
poly.push_back(NodeManager::currentNM()->mkNode(MULT, x, kf));
std::map<Node, std::vector<Node> >::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<Node, Node>::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(
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;
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;
Node mpv;
if( !mpoints[i].isNull() ){
mpv = computeModelValue( mpoints[i], 1 );
- Assert( mpv.isConst() );
+ Assert(mpv.isConst());
}
mpoints_vals.push_back( mpv );
}
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())
increment = true;
}else{
Node pval = mpoints_vals[mdir_index];
- Assert( pval.isConst() );
+ Assert(pval.isConst());
if( sargval.getConst<Rational>() < pval.getConst<Rational>() ){
increment = true;
Trace("nl-ext-tf-mono") << "...increment at " << sarg << " since model value is less than " << mpoints[mdir_index] << std::endl;
}
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(
(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()){
return Monomial::mkMonomial(newConstant, newVL);
}
-// vector<Monomial> Monomial::sumLikeTerms(const std::vector<Monomial> & monos) {
+// vector<Monomial> Monomial::sumLikeTerms(const std::vector<Monomial> & monos)
+// {
// Assert(isSorted(monos));
// vector<Monomial> outMonomials;
// typedef vector<Monomial>::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;
writePos++;
}
}
- Assert(rangeEnd>readPos);
+ Assert(rangeEnd > readPos);
readPos = rangeEnd;
}
if(writePos > 0 ){
//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()){
}
}
-Comparison::Comparison(TNode n)
- : NodeWrapper(n)
-{
- Assert(isNormalForm());
-}
-
-
+Comparison::Comparison(TNode n) : NodeWrapper(n) { Assert(isNormalForm()); }
SumPair Comparison::toSumPair() const {
Kind cmpKind = comparisonKind();
return SumPair(left - right, Constant::mkZero());
}
}
- default:
- Unhandled(cmpKind);
+ default: Unhandled() << cmpKind;
}
}
}
}
}
- default:
- Unhandled(cmpKind);
+ default: Unhandled() << cmpKind;
}
}
return DeltaRational(0, 0);
}
}
- default:
- Unhandled(cmpKind);
+ default: Unhandled() << cmpKind;
}
}
case kind::GEQ:
case kind::GT:
return NodeManager::currentNM()->mkNode(k, l.getNode(), r.getNode());
- default:
- Unhandled(k);
+ default: Unhandled() << k;
}
}
case kind::GT:
case kind::GEQ:
return getLeft().getComplexity() + getRight().getComplexity();
- default:
- Unhandled(comparisonKind());
- return -1;
+ default: Unhandled() << comparisonKind(); return -1;
}
}
case kind::GEQ:
left = getNode()[0];
break;
- default:
- Unhandled(k);
+ default: Unhandled() << k;
}
return Polynomial::parsePolynomial(left);
}
case kind::GEQ:
right = getNode()[1];
break;
- default:
- Unhandled(k);
+ default: Unhandled() << k;
}
return Polynomial::parsePolynomial(right);
}
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){
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);
if(n < m){
return -1;
}else{
- Assert( n != m );
+ Assert(n != m);
return 1;
}
}else{
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);
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));
}
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()));
}
Polynomial(const std::vector<Monomial>& 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){
}
Polynomial getTail() const {
- Assert(! singleton());
+ Assert(!singleton());
iterator tailStart = begin();
++tailStart;
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)))
{
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();
}
ConstraintCP SimplexDecisionProcedure::generateConflictForBasic(ArithVar basic) const {
-
Assert(d_tableau.isBasic(basic));
Assert(checkBasicForConflict(basic));
TimerStat::CodeTimer codeTimer(timer);
Assert(!d_errorSet.focusEmpty());
Assert(debugIsASet(set));
-
+
ArithVar inf = requestVariable();
Assert(inf != ARITHVAR_SENTINEL);
/** Sets the focusDirection. */
void setFocusDirection(int fd){
- Assert(-1 <= fd && fd <= 1);
+ Assert(-1 <= fd && fd <= 1);
d_focusDirection = fd;
updateWitness();
}
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)){
if(d_errorSize <= 2){
ArithVarVec inError;
d_errorSet.pushFocusInto(inError);
-
+
Assert(debugIsASet(inError));
subsets.push_back(inError);
return subsets;
if(hasParticipated.isMember(v)){ continue; }
hasParticipated.add(v);
-
+
Assert(d_soiVar == ARITHVAR_SENTINEL);
//d_soiVar's row = \sumofinfeasibilites underConstruction
ArithVarVec underConstruction;
// }
}
-
Assert(d_soiVar == ARITHVAR_SENTINEL);
Debug("arith::greedyConflictSubsets") << "greedyConflictSubsets done" << endl;
return subsets;
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;
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: "
// 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();
generateSOIConflict(d_qeConflict);
}else{
vector<ArithVarVec> subsets = greedyConflictSubsets();
- Assert( d_soiVar == ARITHVAR_SENTINEL);
+ Assert(d_soiVar == ARITHVAR_SENTINEL);
bool anySuccess = false;
Assert(!subsets.empty());
for(vector<ArithVarVec>::const_iterator i = subsets.begin(), end = subsets.end(); i != end; ++i){
}
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!
Assert(d_conflictVariables.empty());
Assert(d_soiVar == ARITHVAR_SENTINEL);
-
//d_scores.purge();
d_soiVar = constructInfeasiblityFunction(d_statistics.d_soiFocusConstructionTimer);
{
Assert(basic < getNumColumns());
Assert(debugIsASet(variables));
- Assert(coefficients.size() == variables.size() );
+ Assert(coefficients.size() == variables.size());
Assert(!isBasic(basic));
RowIndex newRow = Matrix<Rational>::addRow(coefficients, variables);
Assert(constraint->isLowerBound());
Assert(constraint->isTrue());
Assert(!constraint->negationHasProof());
-
ArithVar x_i = constraint->getVariable();
const DeltaRational& c_i = constraint->getValue();
const ValueCollection& vc = constraint->getValueCollection();
if(vc.hasEquality()){
-
Assert(vc.hasDisequality());
ConstraintP eq = vc.getEquality();
ConstraintP diseq = vc.getDisequality();
Assert(constraint->isUpperBound());
Assert(constraint->isTrue());
Assert(!constraint->negationHasProof());
-
+
ArithVar x_i = constraint->getVariable();
const DeltaRational& c_i = constraint->getValue();
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;
case kind::INTS_MODULUS:
case kind::DIVISION:
// these should be removed during expand definitions
- Assert( false );
+ Assert(false);
break;
case kind::INTS_DIVISION_TOTAL:
bestRowLength = rowLength;
}
}
- Assert(bestBasic == ARITHVAR_SENTINEL ||
- bestRowLength < std::numeric_limits<uint32_t>::max());
+ Assert(bestBasic == ARITHVAR_SENTINEL
+ || bestRowLength < std::numeric_limits<uint32_t>::max());
return bestBasic;
}
}
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]);
case INTS_DIVISION:
case INTS_MODULUS:
// these should be removed during expand definitions
- Assert( false );
+ Assert(false);
break;
case DIVISION_TOTAL:
lem = axiomIteForTotalDivision(vnode);
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);
Assert(isInteger(v));
Assert(d_partialModel.boundsAreEqual(v));
-
ConstraintP lb = d_partialModel.getLowerBoundConstraint(v);
ConstraintP ub = d_partialModel.getUpperBoundConstraint(v);
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));
if(reEq.getKind() == CONST_BOOLEAN){
if(reEq.getConst<bool>() == isDistinct){
// if is (not true), or false
- Assert((reEq.getConst<bool>() && isDistinct) ||
- (!reEq.getConst<bool>() && !isDistinct));
+ Assert((reEq.getConst<bool>() && isDistinct)
+ || (!reEq.getConst<bool>() && !isDistinct));
raiseBlackBoxConflict(assertion);
}
return NullConstraint;
// void TheoryArithPrivate::branchVector(const std::vector<ArithVar>& lemmas){
// //output the lemmas
-// for(vector<ArithVar>::const_iterator i = lemmas.begin(); i != lemmas.end(); ++i){
+// for(vector<ArithVar>::const_iterator i = lemmas.begin(); i != lemmas.end();
+// ++i){
// ArithVar v = *i;
// Assert(!d_cutInContext.contains(v));
// d_cutInContext.insert(v);
<< " " << 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);
pair<ConstraintP, ArithVar> p = replayGetConstraint(bci);
Assert(p.second == ARITHVAR_SENTINEL);
ConstraintP bc = p.first;
- Assert(bc != NullConstraint);
+ Assert(bc != NullConstraint);
if(bc->hasProof()){
return;
}
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());
}
Assert(d_acTmp.empty());
-
/* Garbage collect the constraints from this call */
while(d_replayConstraints.size() > rpcons_size){
ConstraintP c = d_replayConstraints.back();
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());
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:
d_constraintDatabase.unatePropEquality(curr, prevLB, prevUB);
break;
}
- default:
- Unhandled(curr->getType());
+ default: Unhandled() << curr->getType();
}
}
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;
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();
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();
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")){
d_constraintDatabase.outputUnateInequalityLemmas(lemmas);
d_constraintDatabase.outputUnateEqualityLemmas(lemmas);
break;
- default:
- Unhandled(options::arithUnateLemmaMode());
+ default: Unhandled() << options::arithUnateLemmaMode();
}
}
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);
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);
// 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());
// }
// {
// 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{
// }
// }
-
std::pair<bool, Node> TheoryArithPrivate::entailmentCheck(TNode lit, const ArithEntailmentCheckParameters& params, ArithEntailmentCheckSideEffects& out){
using namespace inferbounds;
<< " <= " << 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);
}
}
}
}
-// 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())){
// // 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){
// }
// }
-
// if(leaving == ARITHVAR_SENTINEL){
// finalState = NoBound;
// break;
// 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){
RationalEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr)
: TypeEnumeratorBase<RationalEnumerator>(type), d_rat(0)
{
- Assert(type.getKind() == kind::TYPE_CONSTANT &&
- type.getConst<TypeConstant>() == REAL_TYPE);
+ Assert(type.getKind() == kind::TYPE_CONSTANT
+ && type.getConst<TypeConstant>() == REAL_TYPE);
}
Node operator*() override { return NodeManager::currentNM()->mkConst(d_rat); }
IntegerEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr)
: TypeEnumeratorBase<IntegerEnumerator>(type), d_int(0)
{
- Assert(type.getKind() == kind::TYPE_CONSTANT &&
- type.getConst<TypeConstant>() == INTEGER_TYPE);
+ Assert(type.getKind() == kind::TYPE_CONSTANT
+ && type.getConst<TypeConstant>() == INTEGER_TYPE);
}
Node operator*() override
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 "<<a<<"["<<i<<"]\n";
CTNodeList* temp_indices;
void ArrayInfo::addStore(const Node a, const TNode st){
Assert(a.getType().isArray());
- Assert(st.getKind()== kind::STORE); // temporary for flat arrays
+ Assert(st.getKind() == kind::STORE); // temporary for flat arrays
CTNodeList* temp_store;
Info* temp_info;
* prints the information
*/
void print() const {
- Assert(indices != NULL && stores!= NULL && in_stores != NULL);
+ Assert(indices != NULL && stores != NULL && in_stores != NULL);
Trace("arrays-info")<<" indices ";
printList(indices);
Trace("arrays-info")<<" stores ";
#include <iostream>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/node.h"
#include "theory/arrays/static_fact_manager.h"
// 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];
// */
// 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)) {
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);
}
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));
}
}
}
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);
}
// 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());
}
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;
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;
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]);
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;
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);
// 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]);
}
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];
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);
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);
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 */
#include <iostream>
-#include "base/cvc4_assert.h"
#include "expr/node.h"
#include "theory/arrays/union_find.h"
}
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])) {
}
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]));
BooleanEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr)
: TypeEnumeratorBase<BooleanEnumerator>(type), d_value(FALSE)
{
- Assert(type.getKind() == kind::TYPE_CONSTANT &&
- type.getConst<TypeConstant>() == BOOLEAN_TYPE);
+ Assert(type.getKind() == kind::TYPE_CONSTANT
+ && type.getConst<TypeConstant>() == BOOLEAN_TYPE);
}
Node operator*() override {
namespace builtin {
Node TheoryBuiltinRewriter::blastDistinct(TNode in) {
-
Assert(in.getKind() == kind::DISTINCT);
if(in.getNumChildren() == 2) {
}
Node TheoryBuiltinRewriter::blastChain(TNode in) {
-
Assert(in.getKind() == kind::CHAIN);
Kind chainedOp = in.getOperator().getConst<Chain>().getOperator();
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 );
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);
}
if( it==visited.end() ){
Node ret;
if( bvlIndex<bvl.getNumChildren() ){
- Assert( a.getType().isArray() );
+ Assert(a.getType().isArray());
if( a.getKind()==kind::STORE ){
// convert the array recursively
Node body = getLambdaForArrayRepresentationRec( a[0], bvl, bvlIndex, visited );
// convert the value recursively (bounded by the number of arguments in bvl)
Node val = getLambdaForArrayRepresentationRec( a[2], bvl, bvlIndex+1, visited );
if( !val.isNull() ){
- Assert( !TypeNode::leastCommonTypeNode( a[1].getType(), bvl[bvlIndex].getType() ).isNull() );
- Assert( !TypeNode::leastCommonTypeNode( val.getType(), body.getType() ).isNull() );
+ Assert(!TypeNode::leastCommonTypeNode(a[1].getType(),
+ bvl[bvlIndex].getType())
+ .isNull());
+ Assert(!TypeNode::leastCommonTypeNode(val.getType(), body.getType())
+ .isNull());
Node cond = bvl[bvlIndex].eqNode( a[1] );
ret = NodeManager::currentNM()->mkNode( kind::ITE, cond, val, body );
}
}
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 );
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;
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;
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());
//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() );
if (isAbstraction(assertion)) {
Node interp = getInterpretation(assertion);
seen[assertion] = interp;
- Assert (interp.getType() == assertion.getType());
+ Assert(interp.getType() == assertion.getType());
return interp;
}
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;
}
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;
}
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);
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))
}
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];
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;
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++) {
// 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]);
}
}
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];
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);
std::vector<int> 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);
}
}
void AbstractionModule::makeFreshArgs(TNode func, std::vector<Node>& 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];
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);
fresh_args.push_back(skolem);
}
}
- Assert (fresh_args.size() == func.getNumChildren());
+ Assert(fresh_args.size() == func.getNumChildren());
}
Node AbstractionModule::tryMatching(const std::vector<Node>& ss, const std::vector<TNode>& 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")) {
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);
}
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() &&
}
void AbstractionModule::ArgsTableEntry::addArguments(const ArgsVec& args) {
- Assert (args.size() == d_arity);
+ Assert(args.size() == d_arity);
d_data.push_back(args);
}
}
AbstractionModule::ArgsTableEntry& AbstractionModule::ArgsTable::getEntry(TNode signature) {
- Assert (hasEntry(signature));
+ Assert(hasEntry(signature));
return d_data.find(signature)->second;
}
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 {
#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"
template <> inline
std::string toString<Abc_Obj_t*> (const std::vector<Abc_Obj_t*>& bits) {
- Unreachable("Don't know how to print AIG");
+ Unreachable() << "Don't know how to print AIG";
}
template <> inline
Abc_Obj_t* mkOr<Abc_Obj_t*>(const std::vector<Abc_Obj_t*>& children) {
- Assert (children.size());
+ Assert(children.size());
if (children.size() == 1)
return children[0];
template <> inline
Abc_Obj_t* mkAnd<Abc_Obj_t*>(const std::vector<Abc_Obj_t*>& children) {
- Assert (children.size());
+ Assert(children.size());
if (children.size() == 1)
return children[0];
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))
}
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]);
}
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]);
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]);
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) {
}
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));
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);
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;
}
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();
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();
// // 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);
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);
}
}
Abc_Obj_t* AigBitblaster::getBBAtom(TNode atom) const {
- Assert (hasBBAtom(atom));
+ Assert(hasBBAtom(atom));
return d_bbAtoms.find(atom)->second;
}
template <class T>
T DefaultEqBB(TNode node, TBitblaster<T>* bb) {
Debug("bitvector-bb") << "Bitblasting node " << node << "\n";
-
+
Assert(node.getKind() == kind::EQUAL);
std::vector<T> lhs, rhs;
bb->bbTerm(node[0], lhs);
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<T> not_b;
negateBits(b, not_b);
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;
bb->bbTerm(node[0], a);
bb->bbTerm(node[1], b);
Assert(a.size() == b.size());
-
+
T res = sLessThanBB(a, b, false);
return res;
}
bb->bbTerm(node[0], a);
bb->bbTerm(node[1], b);
Assert(a.size() == b.size());
-
+
T res = sLessThanBB(a, b, true);
return res;
}
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<BitVector>().extract(i, i).getValue();
if(bit == Integer(0)){
bits.push_back(mkFalse<T>());
} else {
- Assert (bit == Integer(1));
+ Assert(bit == Integer(1));
bits.push_back(mkTrue<T>());
}
}
void DefaultConcatBB (TNode node, std::vector<T>& bits, TBitblaster<T>* 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<T> current_bits;
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";
}
template <class T>
void DefaultAndBB (TNode node, std::vector<T>& bits, TBitblaster<T>* 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<T> current;
}
current.clear();
}
- Assert (bits.size() == utils::getSize(node));
+ Assert(bits.size() == utils::getSize(node));
}
template <class T>
void DefaultOrBB (TNode node, std::vector<T>& bits, TBitblaster<T>* 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<T> current;
}
current.clear();
}
- Assert (bits.size() == utils::getSize(node));
+ Assert(bits.size() == utils::getSize(node));
}
template <class T>
void DefaultXorBB (TNode node, std::vector<T>& bits, TBitblaster<T>* 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<T> current;
}
current.clear();
}
- Assert (bits.size() == utils::getSize(node));
+ Assert(bits.size() == utils::getSize(node));
}
template <class T>
void DefaultXnorBB (TNode node, std::vector<T>& bits, TBitblaster<T>* 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<T> 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]));
}
void DefaultCompBB (TNode node, std::vector<T>& bits, TBitblaster<T>* 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<T> a, b;
bb->bbTerm(node[0], a);
bb->bbTerm(node[1], b);
template <class T>
void DefaultMultBB (TNode node, std::vector<T>& res, TBitblaster<T>* 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<T> a;
template <class T>
void DefaultPlusBB (TNode node, std::vector<T>& res, TBitblaster<T>* 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);
rippleCarryAdder(res, current, newres, mkFalse<T>());
res = newres;
}
-
+
Assert(res.size() == utils::getSize(node));
}
template <class T>
void DefaultSubBB (TNode node, std::vector<T>& bits, TBitblaster<T>* 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<T> 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)
void DefaultNegBB (TNode node, std::vector<T>& bits, TBitblaster<T>* bb) {
Debug("bitvector-bb") << "theory::bv::DefaultNegBB bitblasting " << node << "\n";
Assert(node.getKind() == kind::BITVECTOR_NEG);
-
+
std::vector<T> a;
bb->bbTerm(node[0], a);
Assert(utils::getSize(node) == a.size());
template <class T>
void uDivModRec(const std::vector<T>& a, const std::vector<T>& b, std::vector<T>& q, std::vector<T>& 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());
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));
}
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));
}
bb->bbTerm(node[0], cond);
bb->bbTerm(node[1], thenpart);
bb->bbTerm(node[2], elsepart);
-
+
Assert(cond.size() == 1);
Assert(thenpart.size() == elsepart.size());
template <class T>
void DefaultExtractBB (TNode node, std::vector<T>& bits, TBitblaster<T>* bb) {
- Assert (node.getKind() == kind::BITVECTOR_EXTRACT);
+ Assert(node.getKind() == kind::BITVECTOR_EXTRACT);
Assert(bits.size() == 0);
-
+
std::vector<T> base_bits;
bb->bbTerm(node[0], base_bits);
unsigned high = utils::getExtractHigh(node);
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";
void DefaultSignExtendBB (TNode node, std::vector<T>& res_bits, TBitblaster<T>* 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<T> bits;
bb->bbTerm(node[0], bits);
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 <class T>
template <> inline
Node mkOr<Node>(const std::vector<Node>& children) {
- Assert (children.size());
+ Assert(children.size());
if (children.size() == 1)
return children[0];
return NodeManager::currentNM()->mkNode(kind::OR, children);
template <> inline
Node mkAnd<Node>(const std::vector<Node>& children) {
- Assert (children.size());
+ Assert(children.size());
if (children.size() == 1)
return children[0];
return NodeManager::currentNM()->mkNode(kind::AND, children);
template <class T>
void inline extractBits(const std::vector<T>& b, std::vector<T>& 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]);
}
template <class T>
void inline makeZero(std::vector<T>& bits, unsigned width) {
- Assert(bits.size() == 0);
+ Assert(bits.size() == 0);
for(unsigned i = 0; i < width; ++i) {
bits.push_back(mkFalse<T>());
}
template <class T>
T inline rippleCarryAdder(const std::vector<T>&a, const std::vector<T>& b, std::vector<T>& 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]),
template <class T>
T inline uLessThanBB(const std::vector<T>&a, const std::vector<T>& b, bool orEqual) {
- Assert (a.size() && b.size());
-
+ Assert(a.size() && b.size());
+
T res = mkAnd(mkNot(a[0]), b[0]);
if(orEqual) {
template <class T>
T inline sLessThanBB(const std::vector<T>&a, const std::vector<T>& 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]),
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(
getBBTerm(node, bits);
return;
}
- Assert( node.getType().isBitVector() );
+ Assert(node.getType().isBitVector());
d_bv->spendResource(options::bitblastStep());
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);
}
++(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<prop::SatLiteral>& literal_explanation = (*d_explanations)[lit].get();
for (unsigned i = 0; i < literal_explanation.size(); ++i) {
explanation.push_back(d_cnfStream->getNode(literal_explanation[i]));
} else {
atom = lit;
}
- Assert( utils::isBitblastAtom( atom ) );
+ Assert(utils::isBitblastAtom(atom));
- Assert (hasBBAtom(atom));
+ Assert(hasBBAtom(atom));
prop::SatLiteral markerLit = d_cnfStream->getLiteral(atom);
}
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) {
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
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 << " "
}
void TLazyBitblaster::clearSolver() {
- Assert (d_ctx->getLevel() == 0);
+ Assert(d_ctx->getLevel() == 0);
d_assertedAtoms->deleteSelf();
d_assertedAtoms = new(true) context::CDList<prop::SatLiteral>(d_ctx);
d_explanations->deleteSelf();
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);
// 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);
}
// it means we have an overflow and hence a conflict
std::vector<TermId> 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);
while(hasReason(to) && from != to && !seen.count(to)) {
seen.insert(to);
const ModelValue& exp = getModelValue(to);
- Assert (exp.reason != UndefinedReasonId);
+ Assert(exp.reason != UndefinedReasonId);
explanation.push_back(exp.reason);
- Assert (exp.parent != UndefinedTermId);
+ Assert(exp.parent != UndefinedTermId);
to = exp.parent;
Debug("bv-inequality-internal") << " parent: " << getTermNode(to) << "\n"
<< " reason: " << getReasonNode(exp.reason) << "\n";
}
void InequalityGraph::initializeModelValue(TNode node) {
- TermId id = getTermId(node);
- Assert (!hasModelValue(id));
+ TermId id = getTermId(node);
+ Assert(!hasModelValue(id));
bool isConst = node.getKind() == kind::CONST_BITVECTOR;
unsigned size = utils::getSize(node);
BitVector value = isConst? node.getConst<BitVector>() : BitVector(size, 0u);
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);
}
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<ReasonId>& conflict) {
- Assert (!d_inConflict);
+ Assert(!d_inConflict);
d_inConflict = true;
d_conflict.clear();
for (unsigned i = 0; i < conflict.size(); ++i) {
}
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;
}
}
BitVector InequalityGraph::getValue(TermId id) const {
- Assert (hasModelValue(id));
+ Assert(hasModelValue(id));
return (*(d_modelValues.find(id))).second.value;
}
}
// 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);
// }
// }
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();
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();
}
}
}
bool InequalityGraph::isLessThan(TNode a, TNode b) {
- Assert (isRegistered(a) && isRegistered(b));
+ Assert(isRegistered(a) && isRegistered(b));
Unimplemented();
}
}
BitVector InequalityGraph::getValueInModel(TNode node) const {
- TermId id = getTermId(node);
- Assert (hasModelValue(id));
+ TermId id = getTermId(node);
+ Assert(hasModelValue(id));
return getValue(id);
}
: 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;
}
};
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(); }
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) {
}
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);
unsigned QuickXPlain::selectUnsatCore(unsigned low, unsigned high,
std::vector<TNode>& 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
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<TNode>& conflict,
std::vector<TNode>& new_conflict) {
+ Assert(low <= high && high < conflict.size());
- Assert (low <= high && high < conflict.size());
-
if (low == high) {
new_conflict.push_back(conflict[low]);
return;
++d_numCalled;
++(d_statistics.d_numConflictsMinimized);
TimerStat::CodeTimer xplainTimer(d_statistics.d_xplainTime);
- Assert (confl.getNumChildren() > 2);
+ Assert(confl.getNumChildren() > 2);
std::vector<TNode> conflict;
for (unsigned i = 0; i < confl.getNumChildren(); ++i) {
conflict.push_back(confl[i]);
bool SubstitutionEx::addSubstitution(TNode from, TNode to, TNode reason) {
Debug("bv-substitution") << "SubstitutionEx::addSubstitution: "<< from
<<" => "<< to << "\n" << " reason "<<reason << "\n";
- Assert (from != to);
+ Assert(from != to);
if (d_substitutions.find(from) != d_substitutions.end()) {
return false;
}
if (current.getMetaKind() == kind::metakind::PARAMETERIZED) {
TNode op = current.getOperator();
- Assert (hasCache(op));
+ Assert(hasCache(op));
nb << getCache(op);
reasons.push_back(getReason(op));
}
for (unsigned i = 0; i < current.getNumChildren(); ++i) {
- Assert (hasCache(current[i]));
+ Assert(hasCache(current[i]));
nb << getCache(current[i]);
reasons.push_back(getReason(current[i]));
}
}
Node SubstitutionEx::getCache(TNode node) const {
- Assert (hasCache(node));
+ Assert(hasCache(node));
return d_cache.find(node)->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);
}
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;
}
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());
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);
// 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";
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);
}
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<Node> left_children;
for (unsigned i = 1; i < left.getNumChildren(); ++i) {
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);
}
bool AlgebraicSolver::collectModelInfo(TheoryModel* model, bool fullModel)
{
Debug("bitvector-model") << "AlgebraicSolver::collectModelInfo\n";
- AlwaysAssert (!d_quickSolver->inConflict());
+ AlwaysAssert(!d_quickSolver->inConflict());
set<Node> termSet;
d_bv->computeRelevantTerms(termSet);
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);
}
}
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;
std::vector<Node> 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);
}
}
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) {
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);
}
}
}
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));
}
}
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));
}
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];
bool check(Theory::Effort e) override;
void explain(TNode literal, std::vector<TNode>& 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;
}
void CoreSolver::enableSlicer() {
- AlwaysAssert (!d_preregisterCalled);
+ AlwaysAssert(!d_preregisterCalled);
d_useSlicer = true;
d_statistics.d_slicerEnabled.setData(true);
}
d_equalityEngine.addTriggerEquality(node);
if (d_useSlicer) {
d_slicer->processEquality(node);
- AlwaysAssert(!d_checkCalled);
+ AlwaysAssert(!d_checkCalled);
}
} else {
d_equalityEngine.addTerm(node);
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);
// 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);
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<Node> core_eqs;
}
void CoreSolver::eqNotifyNewClass(TNode t) {
- Assert( d_bv->getExtTheory()!=NULL );
+ Assert(d_bv->getExtTheory() != NULL);
d_bv->getExtTheory()->registerTerm( t );
}
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) {
}
void InequalitySolver::explain(TNode literal, std::vector<TNode>& 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<Node> 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;
}
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);
: 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)
}
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];
}
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;
}
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];
}
}
*/
std::pair<TermId, Index> 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]);
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]);
}
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;
// 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);
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;
}
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) {
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<TermId> intersection;
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);
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);
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;
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;
}
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);
}
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);
std::vector<TNode> 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]);
}
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;
}
if( getExtTheory()->doReductions( 0, terms, nredr ) ){
return true;
}
- Assert( nredr.empty() );
+ Assert(nredr.empty());
return false;
}
void TheoryBV::explain(TNode literal, std::vector<TNode>& assumptions) {
- Assert (wasPropagatedBySubtheory(literal));
+ Assert(wasPropagatedBySubtheory(literal));
SubTheory sub = getPropagatingSubtheory(literal);
d_subtheoryMap[sub]->explain(literal, assumptions);
}
{
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) {
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];
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();
}
/** Actually apply the rewrite rule */
static inline Node apply(TNode node) {
Unreachable();
+ SuppressWrongNoReturnWarning;
}
public:
}
- static inline bool applies(TNode node) {
+ static inline bool applies(TNode node)
+ {
Unreachable();
+ SuppressWrongNoReturnWarning;
}
template<bool checkApplies>
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));
// 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);
// 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);
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];
}
}
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<BitVectorSignExtend>().signExtendAmount;
return utils::mkSignExtend(node[0][0], amount1 + amount2);
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 */
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 */
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)
{
template<bool ref_count>
Node mkNaryNode(Kind k, const std::vector<NodeTemplate<ref_count>>& 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);
}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();
if( options::sygusFair()==SYGUS_FAIR_DT_SIZE ){
std::map<Node, std::unique_ptr<SygusSizeDecisionStrategy>>::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] ) );
<< 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<Node, std::unique_ptr<SygusSizeDecisionStrategy>>::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 ){
// 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 ){
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;
}
// 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 );
for( unsigned j=0; j<dt[tindex].getNumArgs(); j++ ){
Node sel = NodeManager::currentNM()->mkNode( 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 );
}
}
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] );
//register this term
std::unordered_map<Node, Node, NodeHashFunction>::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 );
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 );
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)
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
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 );
}
}
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 );
void SygusSymBreakNew::notifySearchSize( Node m, unsigned s, Node exp, std::vector< Node >& lemmas ) {
std::map<Node, std::unique_ptr<SygusSizeDecisionStrategy>>::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 );
}
}
*/
Trace("sygus-sb-debug2") << "get search size for term : " << n << std::endl;
std::unordered_map<Node, Node, NodeHashFunction>::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);
}
Trace("sygus-sb-debug2") << "get search size for measure : " << m << std::endl;
std::map<Node, std::unique_ptr<SygusSizeDecisionStrategy>>::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<Node, std::unique_ptr<SygusSizeDecisionStrategy>>::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();
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 ){
Trace("sygus-sb") << " Mv[" << prog << "] = " << progv << ", size = " << prog_szv << std::endl;
if( prog_szv.getConst<Rational>().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;
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;
}
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<dt[tindex].getNumArgs(); i++ ){
#include <map>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/datatype.h"
#include "expr/kind.h"
#include "options/datatypes_options.h"
if (done() && e<EFFORT_FULL) {
return;
}
- Assert( d_pending.empty() && d_pending_merge.empty() );
+ Assert(d_pending.empty() && d_pending_merge.empty());
d_addedLemma = false;
if( e == EFFORT_LAST_CALL ){
- Assert( d_sygus_sym_break );
+ Assert(d_sygus_sym_break);
std::vector< Node > lemmas;
d_sygus_sym_break->check( lemmas );
doSendLemmas( lemmas );
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 );
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;
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;
//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++;
}
}
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];
explain( atom[i], assumptions );
}
} else {
- Assert( atom.getKind()!=kind::AND );
+ Assert(atom.getKind() != kind::AND);
explainPredicate( atom, polarity, assumptions );
}
}
return -1;
}else{
int tindex = utils::isTester(lbl);
- Assert( tindex!=-1 );
+ Assert(tindex != -1);
return tindex;
}
}
}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++)
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 );
{
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 );
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++)
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() ){
}
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;
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) ){
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;
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; i<nc.getNumChildren(); i++ ){
expl.clear();
Node prev = cn;
cn = searchForCycle( cn, cn, visited, proc, expl );
- Assert( prev==cn );
+ Assert(prev == cn);
}
if( !cn.isNull() ) {
- Assert( expl.size()>0 );
+ Assert(expl.size() > 0);
d_conflictNode = mkAnd( expl );
Trace("dt-conflict") << "CONFLICT: Cycle conflict : " << d_conflictNode << std::endl;
d_out->conflict( d_conflictNode );
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 : ";
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;
}
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);
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 );
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());
//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( index<d_sel_types.size() );
- Assert( ctor.getNumArgs()-1<d_sel_types[index].size() );
+ Assert(index < d_sel_types.size());
+ Assert(ctor.getNumArgs() - 1 < d_sel_types[index].size());
lc = getTermEnum( d_sel_types[index][ctor.getNumArgs()-1], d_size_limit - d_sel_sum[index] );
if( lc.isNull() ){
Debug("dt-enum-debug") << "Current infeasible." << std::endl;
}
Debug("dt-enum-debug") << "Get arguments..." << std::endl;
if( ctor.getNumArgs()>0 ){
- Assert( index<d_sel_types.size() );
- Assert( index<d_sel_index.size() );
- Assert( d_sel_types[index].size()==ctor.getNumArgs() );
- Assert( d_sel_index[index].size()==ctor.getNumArgs()-1 );
+ Assert(index < d_sel_types.size());
+ Assert(index < d_sel_index.size());
+ Assert(d_sel_types[index].size() == ctor.getNumArgs());
+ Assert(d_sel_index[index].size() == ctor.getNumArgs() - 1);
for( int i=0; i<(int)(ctor.getNumArgs()-1); i++ ){
Node c = getTermEnum( d_sel_types[index][i], d_sel_index[index][i] );
- Assert( !c.isNull() );
+ Assert(!c.isNull());
b << c;
}
b << lc;
Debug("dt-enum-debug") << "make ground term..." << std::endl;
Node t = d_type.mkGroundTerm();
Debug("dt-enum-debug") << "done : " << t << std::endl;
- Assert( t.getKind()==kind::APPLY_CONSTRUCTOR );
+ Assert(t.getKind() == kind::APPLY_CONSTRUCTOR);
// start with the constructor for which a ground term is constructed
d_zeroCtor = datatypes::utils::indexOf(t.getOperator());
d_has_debruijn = 0;
d_size_limit = 0;
//set up initial conditions (should always succeed)
++*this; //increment( d_ctor );
- AlwaysAssert( !isFinished() );
+ AlwaysAssert(!isFinished());
}
*
* The above assumes that the code is working correctly.
*/
- Assert(ecN->getFirst() == 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);
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;
#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"
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
}
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
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 ********/
(*arg1).second));
break;
default:
- Unreachable("Unknown unary floating-point function");
+ Unreachable() << "Unknown unary floating-point function";
break;
}
}
(*arg1).second));
break;
default:
- Unreachable("Unknown unary rounded floating-point function");
+ Unreachable()
+ << "Unknown unary rounded floating-point function";
break;
}
}
break;
default:
- Unreachable("Unknown binary floating-point partial function");
+ Unreachable()
+ << "Unknown binary floating-point partial function";
break;
}
}
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:
(*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;
}
}
break;
default:
- Unreachable(
- "Unknown converstion from bit-vector to floating-point");
+ Unreachable() << "Unknown converstion from bit-vector to "
+ "floating-point";
break;
}
}
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;
}
}
}
break;
default:
- Unreachable("Unknown binary floating-point relation");
+ Unreachable() << "Unknown binary floating-point relation";
break;
}
}
break;
default:
- Unreachable("Unknown unary floating-point relation");
+ Unreachable() << "Unknown unary floating-point relation";
break;
}
}
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
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
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;
return result;
#else
- Unimplemented("Conversion is dependent on SymFPU");
+ Unimplemented() << "Conversion is dependent on SymFPU";
#endif
}
if (i == r.end())
{
- Unreachable("Asking for the value of an unregistered expression");
+ Unreachable() << "Asking for the value of an unregistered expression";
}
else
{
if (i == f.end())
{
- Unreachable("Asking for the value of an unregistered expression");
+ Unreachable() << "Asking for the value of an unregistered expression";
}
else
{
}
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
}
#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"
return nm->mkNode(op, node[0], node[1]);
}
- Unreachable("to_fp generic not rewritten");
+ Unreachable() << "to_fp generic not rewritten";
}
} // namespace removeToFPGeneric
}
else
{
- Unreachable("Unknown abstraction");
+ Unreachable() << "Unknown abstraction";
}
return false;
}
else
{
- Unreachable("Only isNaN, isInf and isZero have aliases");
+ Unreachable() << "Only isNaN, isInf and isZero have aliases";
}
handleLemma(nm->mkNode(kind::EQUAL, node, equalityAlias));
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) {
#include <algorithm>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "theory/fp/fp_converter.h"
#include "theory/fp/theory_fp_rewriter.h"
}
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) {
}
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) {
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) {
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));
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]);
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]);
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]);
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]);
}
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());
RewriteResponse fpLiteral (TNode node, bool) {
Assert(node.getKind() == kind::FLOATINGPOINT_FP);
-
+
BitVector bv(node[0].getConst<BitVector>());
bv = bv.concat(node[1].getConst<BitVector>());
bv = bv.concat(node[2].getConst<BitVector>());
RoundingMode rm(node[0].getConst<RoundingMode>());
FloatingPoint arg1(node[1].getConst<FloatingPoint>());
FloatingPoint arg2(node[2].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
-
+
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.plus(rm, arg2)));
}
RoundingMode rm(node[0].getConst<RoundingMode>());
FloatingPoint arg1(node[1].getConst<FloatingPoint>());
FloatingPoint arg2(node[2].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
-
+
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.mult(rm, arg2)));
}
FloatingPoint arg1(node[1].getConst<FloatingPoint>());
FloatingPoint arg2(node[2].getConst<FloatingPoint>());
FloatingPoint arg3(node[3].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
Assert(arg1.t == arg3.t);
-
+
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.fma(rm, arg2, arg3)));
}
RoundingMode rm(node[0].getConst<RoundingMode>());
FloatingPoint arg1(node[1].getConst<FloatingPoint>());
FloatingPoint arg2(node[2].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
-
+
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.div(rm, arg2)));
}
FloatingPoint arg1(node[0].getConst<FloatingPoint>());
FloatingPoint arg2(node[1].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
-
+
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1.rem(arg2)));
}
FloatingPoint arg1(node[0].getConst<FloatingPoint>());
FloatingPoint arg2(node[1].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
FloatingPoint::PartialFloatingPoint res(arg1.min(arg2));
FloatingPoint arg1(node[0].getConst<FloatingPoint>());
FloatingPoint arg2(node[1].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
FloatingPoint::PartialFloatingPoint res(arg1.max(arg2));
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>());
FloatingPoint arg2(node[1].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
-
+
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1 == arg2));
} else if (tn.isRoundingMode()) {
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1 == arg2));
}
- Unreachable("Equality of unknown type");
+ Unreachable() << "Equality of unknown type";
}
FloatingPoint arg1(node[0].getConst<FloatingPoint>());
FloatingPoint arg2(node[1].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
-
+
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1 <= arg2));
}
FloatingPoint arg1(node[0].getConst<FloatingPoint>());
FloatingPoint arg2(node[1].getConst<FloatingPoint>());
-
+
Assert(arg1.t == arg2.t);
-
+
return RewriteResponse(REWRITE_DONE, NodeManager::currentNM()->mkConst(arg1 < arg2));
}
RewriteResponse convertFromRealLiteral (TNode node, bool) {
Assert(node.getKind() == kind::FLOATINGPOINT_TO_FP_REAL);
-
+
TNode op = node.getOperator();
const FloatingPointToFPReal ¶m = op.getConst<FloatingPointToFPReal>();
RewriteResponse convertFromSBV (TNode node, bool) {
Assert(node.getKind() == kind::FLOATINGPOINT_TO_FP_SIGNED_BITVECTOR);
-
+
TNode op = node.getOperator();
const FloatingPointToFPSignedBitVector ¶m = op.getConst<FloatingPointToFPSignedBitVector>();
RewriteResponse convertFromUBV (TNode node, bool) {
Assert(node.getKind() == kind::FLOATINGPOINT_TO_FP_UNSIGNED_BITVECTOR);
-
+
TNode op = node.getOperator();
const FloatingPointToFPUnsignedBitVector ¶m = op.getConst<FloatingPointToFPUnsignedBitVector>();
RewriteResponse convertToUBV (TNode node, bool) {
Assert(node.getKind() == kind::FLOATINGPOINT_TO_UBV);
-
+
TNode op = node.getOperator();
const FloatingPointToUBV ¶m = op.getConst<FloatingPointToUBV>();
RewriteResponse convertToSBV (TNode node, bool) {
Assert(node.getKind() == kind::FLOATINGPOINT_TO_SBV);
-
+
TNode op = node.getOperator();
const FloatingPointToSBV ¶m = op.getConst<FloatingPointToSBV>();
RewriteResponse convertToReal (TNode node, bool) {
Assert(node.getKind() == kind::FLOATINGPOINT_TO_REAL);
-
+
FloatingPoint arg(node[0].getConst<FloatingPoint>());
FloatingPoint::PartialRational res(arg.convertToRational());
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);
break;
default:
- Unreachable("Unknown rounding mode in roundingModeBitBlast");
+ Unreachable() << "Unknown rounding mode in roundingModeBitBlast";
break;
}
#else
case roundNearestTiesToAway:
d_enumerationComplete = true;
break;
- default:
- Unreachable("Unknown rounding mode?");
- break;
+ default: Unreachable() << "Unknown rounding mode?"; break;
}
return *this;
}
#include <sstream>
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/kind.h"
-
using namespace std;
using namespace CVC4::theory;
++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) {
#include <memory>
-#include "base/cvc4_assert.h"
#include "proof/proof_manager.h"
#include "smt/logic_exception.h"
#include "theory/interrupted.h"
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;
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);
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 );
for( unsigned j=0; j<d_ask_types[q].size(); ){
TypeNode curr = d_ask_types[q][j];
for( unsigned k=0; k<indices[curr].size(); k++ ){
- Assert( d_ask_types[q][j]==curr );
+ Assert(d_ask_types[q][j] == curr);
d_ask_types_index[q].push_back( indices[curr][k] );
j++;
}
}
- Assert( d_ask_types_index[q].size()==d_ask_types[q].size() );
+ Assert(d_ask_types_index[q].size() == d_ask_types[q].size());
}else{
d_quant_sip.erase( q );
}
}
bool QuantAntiSkolem::sendAntiSkolemizeLemma( std::vector< Node >& 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
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 );
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()<quants.size() );
+ Assert(it->second.size() < quants.size());
bool ret = sendAntiSkolemizeLemma( it->second, false );
addedLemma = addedLemma || ret;
}
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<Node> sivars;
d_quant_sip[q].getSingleInvocationVariables(sivars);
for (unsigned j = 0, size = d_ask_types_index[q].size(); j < size; j++)
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);
//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
&& d_qe->getLogicInfo().isLinear())
{
Trace("cbqi-warn") << "Had to resort to model value." << std::endl;
- Assert( false );
+ Assert(false);
}
#endif
Node mv = getModelValue( pv );
}
void CegInstantiator::popStackVariable() {
- Assert( !d_stack_vars.empty() );
+ Assert(!d_stack_vars.empty());
d_stack_vars.pop_back();
}
<< ") ";
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;
Trace("cbqi-inst-debug2") << "Applying substitutions to previous substitution terms..." << std::endl;
for( unsigned j=0; j<sf.d_subs.size(); j++ ){
Trace("cbqi-inst-debug2") << " Apply for " << sf.d_subs[j] << std::endl;
- Assert( d_prog_var.find( sf.d_subs[j] )!=d_prog_var.end() );
+ Assert(d_prog_var.find(sf.d_subs[j]) != d_prog_var.end());
if( d_prog_var[sf.d_subs[j]].find( pv )!=d_prog_var[sf.d_subs[j]].end() ){
prev_subs[j] = sf.d_subs[j];
TNode tv = pv;
// if previously was basic, becomes non-basic
if( prev_basic && !sf.d_props[j].isBasic() ){
- Assert( std::find( sf.d_non_basic.begin(), sf.d_non_basic.end(), sf.d_vars[j] )==sf.d_non_basic.end() );
+ Assert(std::find(sf.d_non_basic.begin(),
+ sf.d_non_basic.end(),
+ sf.d_vars[j])
+ == sf.d_non_basic.end());
new_non_basic.push_back( sf.d_vars[j] );
sf.d_non_basic.push_back( sf.d_vars[j] );
}
}
if( sf.d_subs[j]!=prev_subs[j] ){
computeProgVars( sf.d_subs[j] );
- Assert( d_inelig.find( sf.d_subs[j] )==d_inelig.end() );
+ Assert(d_inelig.find(sf.d_subs[j]) == d_inelig.end());
}
Trace("cbqi-inst-debug2") << "Subs " << j << " " << sf.d_subs[j] << std::endl;
}else{
for (unsigned i = 0, size = d_input_vars.size(); i < size; ++i)
{
std::map<Node, Node>::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;
}
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<Node, NodeHashFunction>::iterator it =
d_prog_var[n].begin();
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.size(); i++ ){
Trace("cegqi-si-apply-subs-debug") << " " << vars[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;
std::vector< Node > nsubs;
for( unsigned i=0; i<vars.size(); i++ ){
if( !prop[i].d_coeff.isNull() ){
- Assert( vars[i].getType().isInteger() );
- Assert( prop[i].d_coeff.isConst() );
+ Assert(vars[i].getType().isInteger());
+ Assert(prop[i].d_coeff.isConst());
Node nn = NodeManager::currentNM()->mkNode( MULT, subs[i], NodeManager::currentNM()->mkConst( Rational(1)/prop[i].d_coeff.getConst<Rational>() ) );
nn = NodeManager::currentNM()->mkNode( kind::TO_INTEGER, nn );
nn = Rewriter::rewrite( nn );
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;
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 ){
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);
}
}
//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; j<itc->second.size(); j++ ){
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());
}
}
}
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 );
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;
//process from waitlist
while( d_nested_qe_waitlist_proc[q]<d_nested_qe_waitlist_size[q] ){
int index = d_nested_qe_waitlist_proc[q];
- Assert( index>=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 );
}
Trace("cbqi-debug") << "Found " << ninner.size() << " non-innermost." << std::endl;
for( unsigned i=0; i<ninner.size(); i++ ){
- Assert( d_active_quant.find( ninner[i] )!=d_active_quant.end() );
+ Assert(d_active_quant.find(ninner[i]) != d_active_quant.end());
d_active_quant.erase( ninner[i] );
}
- Assert( !d_active_quant.empty() );
+ Assert(!d_active_quant.empty());
Trace("cbqi-debug") << "...done removing." << std::endl;
}
}
{
if (quant_e == QEFFORT_STANDARD)
{
- Assert( !d_quantEngine->inConflict() );
+ Assert(!d_quantEngine->inConflict());
double clSet = 0;
if( Trace.isOn("cbqi-engine") ){
clSet = double(clock())/double(CLOCKS_PER_SEC);
}
}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 ){
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(),
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());
}
}
}
}
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;
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 );
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;
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] );
}
++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;
//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;
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
Trace("sg-rel-term-debug") << " ";
}
Trace("sg-rel-term-debug") << it->first << ":x" << it2->first << " -> " << it2->second;
- Assert( tindex+it2->first<gsubs_terms.size() );
+ Assert(tindex + it2->first < gsubs_terms.size());
gsubs_terms[tindex+it2->first] = it2->second;
}
}
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<depth ){
//consider against all LHS at depth
}
return sum;
}else{
- Assert( pat.getNumChildren()==0 );
+ Assert(pat.getNumChildren() == 0);
funcs[pat]++;
//for variables
if( pat.getKind()==BOUND_VARIABLE ){
d_patterns[TypeNode::null()].push_back( pat );
d_patterns[tpat].push_back( pat );
- Assert( d_pattern_fun_id.find( pat )==d_pattern_fun_id.end() );
- Assert( d_pattern_var_id.find( pat )==d_pattern_var_id.end() );
+ Assert(d_pattern_fun_id.find(pat) == d_pattern_fun_id.end());
+ Assert(d_pattern_var_id.find(pat) == d_pattern_var_id.end());
//collect functions
std::map< TypeNode, unsigned > mnvn;
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; i<patg.getNumChildren(); i++ ){
if( !isGeneralization( patg[i], pat[i], subs ) ){
return false;
children.push_back( n.getOperator() );
for( unsigned i=0; i<(vec.size()-1); i++ ){
Node nn = te->getEnumerateTerm(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 );
}
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 ){
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;
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;
}
}
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;
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 );
}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() ){
d_status_num = -1;
return getNextTerm( s, depth );
}else{
- Assert( d_children.empty() );
+ Assert(d_children.empty());
return false;
}
}
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{
}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;
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() );
}
}
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();
}
}
}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++;
}
}
}
- Assert( false );
+ Assert(false);
return false;
}
}
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() ){
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 );
return NodeManager::currentNM()->mkNode( s->d_func_kind[f], children );
}
}else{
- Assert( false );
+ Assert(false);
}
return Node::null();
}
}
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 ){
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{
}
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();
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();
}
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<d_tg_alloc.size() );
+ Assert(tg_id < d_tg_alloc.size());
if( options::conjectureFilterCanonical() ){
//check based on a canonicity of the term (if there is one)
Trace("sg-gen-tg-debug") << "Consider term canon ";
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 );
}
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;
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 );
}
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 );
d_mode(cand_term_none)
{
d_op = qe->getTermDatabase()->getMatchOperator( pat );
- Assert( !d_op.isNull() );
+ Assert(!d_op.isNull());
}
void CandidateGeneratorQE::resetInstantiationRound(){
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();
}
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;
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();
{
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;
//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++)
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 ){
//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 ){
}
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; i<gens.size(); i++ ){
for( unsigned i=0; i<pats_ordered.size(); i++ ){
Trace("multi-trigger-linear") << "...make for " << pats_ordered[i] << std::endl;
InstMatchGenerator* cimg = getInstMatchGenerator(q, pats_ordered[i]);
- Assert( cimg!=NULL );
+ Assert(cimg != NULL);
d_children.push_back( cimg );
if( i==0 ){ //TODO : improve
cimg->setIndependent();
}
bool InstMatchGeneratorMultiLinear::reset( Node eqc, QuantifiersEngine* qe ) {
- Assert( eqc.isNull() );
+ Assert(eqc.isNull());
if( options::multiTriggerLinear() ){
return true;
}else{
}
}
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;
int endChildIndex,
bool modEq)
{
- Assert( !qe->inConflict() );
+ Assert(!qe->inConflict());
if( childIndex==endChildIndex ){
// m is an instantiation
if (sendInstantiation(tparent, m))
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; i<d_match_pattern.getNumChildren(); i++ ){
if( d_match_pattern[i].getKind()==INST_CONSTANT ){
if( !options::cbqi() || quantifiers::TermUtil::getInstConstAttr(d_match_pattern[i])==q ){
Debug("simple-trigger-debug") << "Add inst " << argIndex << " " << d_match_pattern << std::endl;
if (argIndex == d_match_pattern.getNumChildren())
{
- Assert( !tat->d_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
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));
}
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;
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<patTermsF.size(); i++ ){
- Assert( tinfo.find( patTermsF[i] )!=tinfo.end() );
+ Assert(tinfo.find(patTermsF[i]) != tinfo.end());
Trace("auto-gen-trigger-debug") << " " << patTermsF[i] << std::endl;
Trace("auto-gen-trigger-debug2") << " info = [" << tinfo[patTermsF[i]].d_reqPol << ", " << tinfo[patTermsF[i]].d_reqPolEq << ", " << tinfo[patTermsF[i]].d_fv.size() << "]" << std::endl;
}
std::map< Node, bool > rmPatTermsF;
int last_weight = -1;
for( unsigned i=0; i<patTermsF.size(); i++ ){
- Assert( patTermsF[i].getKind()!=NOT );
+ Assert(patTermsF[i].getKind() != NOT);
bool newVar = false;
for( unsigned j=0; j<tinfo[ patTermsF[i] ].d_fv.size(); j++ ){
if( vcMap.find( tinfo[ patTermsF[i] ].d_fv[j] )==vcMap.end() ){
Trace("auto-gen-trigger-debug") << "...processing pattern " << pat << std::endl;
Node mpat = pat;
//process the pattern: if it has a required polarity, consider it
- Assert( tinfo.find( pat )!=tinfo.end() );
+ Assert(tinfo.find(pat) != tinfo.end());
int rpol = tinfo[pat].d_reqPol;
Node rpoleq = tinfo[pat].d_reqPolEq;
unsigned num_fv = tinfo[pat].d_fv.size();
Trace("auto-gen-trigger-debug") << "...required polarity for " << pat << " is " << rpol << ", eq=" << rpoleq << std::endl;
if( rpol!=0 ){
- Assert( rpol==1 || rpol==-1 );
+ Assert(rpol == 1 || rpol == -1);
if( Trigger::isRelationalTrigger( pat ) ){
pat = rpol==-1 ? pat.negate() : pat;
}else{
- Assert( Trigger::isAtomicTrigger( pat ) );
+ Assert(Trigger::isAtomicTrigger(pat));
if( pat.getType().isBoolean() && rpoleq.isNull() ){
if( options::literalMatchMode()==LITERAL_MATCH_USE ){
pat = NodeManager::currentNM()->mkNode( EQUAL, pat, NodeManager::currentNM()->mkConst( rpol==-1 ) ).negate();
pat = NodeManager::currentNM()->mkNode( EQUAL, pat, NodeManager::currentNM()->mkConst( rpol==1 ) );
}
}else{
- Assert( !rpoleq.isNull() );
+ Assert(!rpoleq.isNull());
if( rpol==-1 ){
if( options::literalMatchMode()!=LITERAL_MATCH_NONE ){
//all equivalence classes except rpoleq
sortQuantifiersForSymbol sqfs;
sqfs.d_quant_rel = d_quant_rel;
for( unsigned i=0; i<patTerms.size(); i++ ){
- Assert( d_pat_to_mpat.find( patTerms[i] )!=d_pat_to_mpat.end() );
- Assert( d_pat_to_mpat[patTerms[i]].hasOperator() );
+ Assert(d_pat_to_mpat.find(patTerms[i]) != d_pat_to_mpat.end());
+ Assert(d_pat_to_mpat[patTerms[i]].hasOperator());
sqfs.d_op_map[ patTerms[i] ] = d_pat_to_mpat[patTerms[i]].getOperator();
}
//sort based on # occurrences (this will cause Trigger to select rarer symbols)
}
void InstStrategyAutoGenTriggers::addUserNoPattern( Node q, Node pat ) {
- Assert( pat.getKind()==INST_NO_PATTERN && pat.getNumChildren()==1 );
+ Assert(pat.getKind() == INST_NO_PATTERN && pat.getNumChildren() == 1);
if( std::find( d_user_no_gen[q].begin(), d_user_no_gen[q].end(), pat[0] )==d_user_no_gen[q].end() ){
Trace("user-pat") << "Add user no-pattern: " << pat[0] << " for " << q << std::endl;
d_user_no_gen[q].push_back( pat[0] );
unsigned lastWaiting = d_quantEngine->getNumLemmasWaiting();
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;
bool foundVar = false;
for( unsigned j=0; j<varContains[ temp[i] ].size(); j++ ){
Node v = varContains[ temp[i] ][j];
- Assert( quantifiers::TermUtil::getInstConstAttr(v)==q );
+ Assert(quantifiers::TermUtil::getInstConstAttr(v) == q);
if( vars.find( v )==vars.end() ){
varCount++;
vars[ v ] = true;
}
Node Trigger::getIsUsableEq( Node q, Node n ) {
- Assert( isRelationalTrigger( n ) );
+ Assert(isRelationalTrigger(n));
for( unsigned i=0; i<2; i++) {
if( isUsableEqTerms( q, n[i], n[1-i] ) ){
if( i==1 && n.getKind()==EQUAL && !quantifiers::TermUtil::hasInstConstAttr(n[0]) ){
}
}
if( !nu.isNull() ){
- Assert( nu==n );
- Assert( nu.getKind()!=NOT );
+ Assert(nu == n);
+ Assert(nu.getKind() != NOT);
Trace("auto-gen-trigger-debug2") << "...found usable trigger : " << nu << std::endl;
Node reqEq;
if( nu.getKind()==EQUAL ){
nu = nu[0];
}
}
- Assert( reqEq.isNull() || !quantifiers::TermUtil::hasInstConstAttr( reqEq ) );
- Assert( isUsableTrigger( nu, q ) );
+ Assert(reqEq.isNull()
+ || !quantifiers::TermUtil::hasInstConstAttr(reqEq));
+ Assert(isUsableTrigger(nu, q));
//tinfo.find( nu )==tinfo.end()
Trace("auto-gen-trigger-debug2") << "...add usable trigger : " << nu << std::endl;
tinfo[ nu ].init( q, nu, hasEPol ? ( epol ? 1 : -1 ) : 0, reqEq );
bool rm_nu = false;
for( unsigned i=0; i<added2.size(); i++ ){
Trace("auto-gen-trigger-debug2") << "..." << nu << " added child " << i << " : " << added2[i] << std::endl;
- Assert( added2[i]!=nu );
+ Assert(added2[i] != nu);
// if child was not already removed
if( tinfo.find( added2[i] )!=tinfo.end() ){
if( tstrt==quantifiers::TRIGGER_SEL_MAX || ( tstrt==quantifiers::TRIGGER_SEL_MIN_SINGLE_MAX && !nu_single ) ){
if( n.getKind()==PLUS ){
x = NodeManager::currentNM()->mkNode( 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<Rational>().abs() );
if( !n[i].getConst<Rational>().abs().isOne() ){
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;
}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 );
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 );
children.push_back( NodeManager::currentNM()->mkNode( MULT, it->second, n ) );
}
}else{
- Assert( !it->second.isNull() );
+ Assert(!it->second.isNull());
children.push_back( it->second );
}
}
}
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 );
{
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;
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);
}
}
}
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;
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 ) {
//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 );
}
}
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);
}
}
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];
}
}
}
}
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; i<d_forall_asserts.size(); i++ ){
d_forall_rlv_assert.push_back( d_forall_asserts[i] );
bool FirstOrderModel::isQuantifierAsserted(TNode q) const
{
- Assert( d_forall_rlv_assert.size()==d_forall_asserts.size() );
+ Assert(d_forall_rlv_assert.size() == d_forall_asserts.size());
return std::find( d_forall_rlv_assert.begin(), d_forall_rlv_assert.end(), q )!=d_forall_rlv_assert.end();
}
for( int i=(d_models[op]->d_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
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;
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;
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] );
}
}
}
}else{
- Assert( n.getKind()!=LEQ && n.getKind()!=LT && n.getKind()!=GT );
+ Assert(n.getKind() != LEQ && n.getKind() != LT && n.getKind() != GT);
}
}
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]);
}
else
{
- Assert( it->second!=BOUND_INT_RANGE );
+ Assert(it->second != BOUND_INT_RANGE);
}
}
}
for( unsigned i=0; i<f[0].getNumChildren(); i++) {
Node v = f[0][i];
if( std::find( d_set[f].begin(), d_set[f].end(), v )!=d_set[f].end() ){
- Assert( d_bound_type[f].find( v )!=d_bound_type[f].end() );
+ Assert(d_bound_type[f].find(v) != d_bound_type[f].end());
if( d_bound_type[f][v]==BOUND_INT_RANGE ){
Trace("bound-int") << " " << d_bounds[0][f][v] << " <= " << v << " <= " << d_bounds[1][f][v] << " (range is " << d_range[f][v] << ")" << std::endl;
}else if( d_bound_type[f][v]==BOUND_SET_MEMBER ){
Trace("bound-int") << " " << v << " has small finite type." << std::endl;
}else{
Trace("bound-int") << " " << v << " has unknown bound." << std::endl;
- Assert( false );
+ Assert(false);
}
}else{
Trace("bound-int") << " " << "*** " << v << " is unbounded." << std::endl;
std::map< Node, Node >::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))
{
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; i<vindex; i++) {
- Assert( d_set_nums[q][d_set[q][i]]==i );
+ Assert(d_set_nums[q][d_set[q][i]] == i);
Trace("bound-int-rsi") << "Look up the value for " << d_set[q][i] << " " << i << std::endl;
int v = rsi->getVariableOrder( 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] );
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<Rational>().getNumerator().getLong()+1;
Trace("bound-int-rsi") << "Actual bound range is " << rr << std::endl;
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];
}
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);
}
<< "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() ){
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<Node, Def * >::iterator it = fm->d_models.begin(); it != fm->d_models.end(); ++it ){
Node f_def = getFunctionValue( fm, it->first, "$x" );
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) {
//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;
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; i<cond.size(); i++) {
if (cond[i] != c[i - 1] && !fm->isStar(cond[i]) && !fm->isStar(c[i - 1]))
{
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; i<cond.size(); i++) {
if( cond[i]!=c[i-1] ) {
if (fm->isStar(cond[i]))
cond.push_back(d_quant_cond[f]);
for (unsigned i=0; i<f[0].getNumChildren(); i++) {
Node ts = fm->getStar(f[0][i].getType());
- Assert( ts.getType()==f[0][i].getType() );
+ Assert(ts.getType() == f[0][i].getType());
cond.push_back(ts);
}
}
doCheck = quant_e == QEFFORT_MODEL;
}
if( doCheck ){
- Assert( !d_quantEngine->inConflict() );
+ Assert(!d_quantEngine->inConflict());
int addedLemmas = 0;
FirstOrderModel* fm = d_quantEngine->getModel();
if( d_addedLemmas>0 ){
break;
}else{
- Assert( !d_quantEngine->inConflict() );
+ Assert(!d_quantEngine->inConflict());
}
}
for( unsigned i=0; i<assertions.size(); i++ ){
Node n = QuantAttributes::getFunDefHead( assertions[i] );
if( !n.isNull() ){
- Assert( n.getKind()==APPLY_UF );
+ Assert(n.getKind() == APPLY_UF);
Node f = n.getOperator();
//check if already defined, if so, throw error
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() ){
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;
}
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))
{
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{
}
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;
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 ){
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 ) ){
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 ) ){
}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;
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 );
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;
}
}
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 ) ){
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;
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 );
ret_set = true;
}
}else{
- Assert( args.size()==n.getNumChildren() );
+ Assert(args.size() == n.getNumChildren());
}
if( !ret_set ){
if( n.getMetaKind() == kind::metakind::PARAMETERIZED ){
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();
//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;
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
Trace("qip-prop") << "...finished notify instantiation." << std::endl;
return !d_conflict;
}else{
- Assert( false );
+ Assert(false);
return false;
}
}
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 << " ";
}
}
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;
}
//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<props.size(); i++ ){
Trace("qip-prop-debug2") << "Process propagation " << props[i] << std::endl;
- Assert( d_qy.isPropagateLiteral( props[i] ) );
+ Assert(d_qy.isPropagateLiteral(props[i]));
//if we haven't propagated this literal yet
if( cacheConclusion( id, props[i], 1 ) ){
//watch list for propagated literal: may not yet be purely EE representatives
}else{
Trace("qip-prop-debug") << "...did not update." << std::endl;
}
- Assert( !d_conflict );
+ Assert(!d_conflict);
return true;
}
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;
}
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;
void InstPropagator::addRelevantInstances( std::vector< Node >& exp, const char * c ) {
for( unsigned i=0; i<exp.size(); i++ ){
- Assert( d_conc_to_id[0].find( exp[i] )!=d_conc_to_id[0].end() );
+ Assert(d_conc_to_id[0].find(exp[i]) != d_conc_to_id[0].end());
Trace(c) << " relevant instance id : " << d_conc_to_id[0][ exp[i] ] << std::endl;
d_relevant_inst[ d_conc_to_id[0][ exp[i] ] ] = true;
}
void InstPropagator::debugPrintExplanation( std::vector< Node >& exp, const char * c ) {
for( unsigned i=0; i<exp.size(); i++ ){
- Assert( d_conc_to_id[0].find( exp[i] )!=d_conc_to_id[0].end() );
+ Assert(d_conc_to_id[0].find(exp[i]) != d_conc_to_id[0].end());
Trace(c) << d_conc_to_id[0][ exp[i] ] << " ";
}
}
reset();
for( unsigned i=0; i<d_lte_asserts.size(); i++ ){
Node q = d_lte_asserts[i];
- Assert( d_do_inst.find( q )!=d_do_inst.end() && d_do_inst[q] );
+ Assert(d_do_inst.find(q) != d_do_inst.end() && d_do_inst[q]);
if( d_inst.find( q )==d_inst.end() ){
Trace("lte-partial-inst") << "LTE : Get partial instantiations for " << q << "..." << std::endl;
d_inst[q] = true;
- Assert( !d_vars[q].empty() );
+ Assert(!d_vars[q].empty());
//make bound list
Node bvl;
std::vector< Node > bvs;
}
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;
}
conj.push_back( nq );
}
}else{
- Assert( pindex<q[2][0].getNumChildren() );
+ Assert(pindex < q[2][0].getNumChildren());
Node pat = q[2][0][pindex];
- Assert( pat.getNumChildren()==0 || paindex<=pat.getNumChildren() );
+ Assert(pat.getNumChildren() == 0 || paindex <= pat.getNumChildren());
if( pat.getKind()==APPLY_UF ){
- Assert( paindex<=pat.getNumChildren() );
+ Assert(paindex <= pat.getNumChildren());
if( paindex==pat.getNumChildren() ){
getPartialInstantiations( conj, q, bvl, vars, terms, types, NULL, pindex+1, 0, iindex );
}else{
if( !curr ){
- Assert( paindex==0 );
+ Assert(paindex == 0);
//start traversing term index for the operator
curr = d_quantEngine->getTermDatabase()->getTermArgTrie( pat.getOperator() );
}
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() ){
}
}
}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;
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] );
}
}
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{
//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 ){
bool alreadySet = false;
if( !d_match[vn].isNull() ){
alreadySet = true;
- Assert( !isVar( d_match[vn] ) );
+ Assert(!isVar(d_match[vn]));
}
//copy or check disequalities
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{
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]++;
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{
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++)
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;
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);
//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->second<qi->getNumVars() );
+ Assert(it->second < qi->getNumVars());
qi->unsetMatch( p, it->second );
qi->d_match_term[ it->second ] = TNode::null();
}
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;
}
}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
}
}
}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;
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;
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];
}
//}
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<Rational>().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<Rational>().getNumerator().getLong();
Trace("quant-attr-debug") << "Set rewrite rule priority " << n << " to " << lvl << std::endl;
RrPriorityAttribute rrpa;
}
if( avar.getKind()==REWRITE_RULE ){
Trace("quant-attr") << "Attribute : rewrite rule : " << q << std::endl;
- Assert( i==0 );
+ Assert(i == 0);
qa.d_rr = avar;
}
}
std::vector<Node>& activeArgs,
Node n)
{
- Assert( activeArgs.empty() );
+ Assert(activeArgs.empty());
std::map< Node, bool > activeMap;
std::map< Node, bool > visited;
computeArgs( args, activeMap, n, visited );
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 );
}
if( !success ){
// tautology
- Assert( k==OR || k==AND );
+ Assert(k == OR || k == AND);
return NodeManager::currentNM()->mkConst( k==OR );
}
childrenChanged = childrenChanged || c!=body[i];
}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 ){
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<dt.getNumConstructors(); i++ ){
if( i!=index ){
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;
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;
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<conj.size(); i++ ){
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<body.getNumChildren(); i++ ){
}
ret = nnn;
}else{
- Assert( args.empty() );
- Assert( nargs.empty() );
+ Assert(args.empty());
+ Assert(nargs.empty());
}
}
visited[tindex][n] = ret;
}
Node QuantifiersRewriter::computeSplit( std::vector< Node >& 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;
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;
}
}
}else if( body.getKind()==NOT ){
- Assert( isLiteral( body[0] ) );
+ Assert(isLiteral(body[0]));
}
//remove variables that don't occur
std::vector< Node > activeArgs;
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<Node> qlitsh;
std::vector<Node> qlit2;
}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 );
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];
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)
{
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; i<d_terms.size(); i++ ){
r->addTerm( d_terms[i] );
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;
}
}
//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 ){
{
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() ){
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;
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];
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; i<d_single_inv_arg_sk.size(); i++ ){
Trace("csi-sol") << d_single_inv_arg_sk[i] << " ";
vars.push_back( d_single_inv_arg_sk[i] );
{
indices.push_back(i);
}
- Assert( !indices.empty() );
+ Assert(!indices.empty());
//sort indices based on heuristic : currently, do all constant returns first (leads to simpler conditions)
// TODO : to minimize solution size, put the largest term last
sortSiInstanceIndices ssii;
cond = TermUtil::simpleNegate(cond);
s = nm->mkNode(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;
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;
}
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;
//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 );
//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;
std::vector<int>& ids,
int& status)
{
- Assert( dtc.getNumArgs()==ts.size() );
+ Assert(dtc.getNumArgs() == ts.size());
for( unsigned i=0; i<ts.size(); i++ ){
TypeNode cstn = d_qe->getTermDatabaseSygus()->getArgType( dtc, i );
int cstatus;
std::map<Node, Node>::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
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(),
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<DatatypeType> 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] );
}
// 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<templ.getNumChildren(); i++ ){
std::vector<DatatypeType> types =
NodeManager::currentNM()->toExprManager()->mkMutualDatatypeTypes(
datatypes, unres, ExprManager::DATATYPE_FLAG_PLACEHOLDER);
- Assert( types.size()==1 );
+ Assert(types.size() == 1);
return TypeNode::fromType( types[0] );
}
}
std::vector<Node>& candidate_values,
std::vector<Node>& 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;
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
#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"
}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;
}
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];
}
std::map<int, Node>& 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;
}
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);
}
else
{
- Unreachable("Unknown enumerator mode in registerEnumerator");
+ Unreachable() << "Unknown enumerator mode in registerEnumerator";
}
}
Trace("sygus-db") << "isActiveGen for " << e << ", role = " << erole
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<var_list.getNumChildren(); j++ ){
vars.push_back( var_list[j] );
}
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;
#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"
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;
}
// 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;
if (options::sygusRewVerifyAbort())
{
- AlwaysAssert(false,
- "--sygus-rr-verify detected unsoundness in the rewriter!");
+ AlwaysAssert(false)
+ << "--sygus-rr-verify detected unsoundness in the rewriter!";
}
}
}
}
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; i<q[0].getNumChildren(); i++ ){
Node ic = d_quantEngine->getTermUtil()->getInstantiationConstant( q, i );
setTermInactive( ic );
}
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;
// 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<TNode> ops;
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 );
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;
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 );
}
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() ){
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{
}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 ){
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;
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 );
}else if( options::termDbMode()==TERM_DB_RELEVANT ){
return d_has_map.find( n )!=d_has_map.end();
}else{
- Assert( false );
+ Assert(false);
return false;
}
}
std::vector<Node>& 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() );
}
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{
#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"
//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
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");
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");
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 ){
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))
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 */
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 */
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 ){
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() ){
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],
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,
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");
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
return;
}else{
//should only fail reset if added a lemma
- Assert( false );
+ Assert(false);
}
}
}
if( d_hasAddedLemma ){
break;
}else{
- Assert( !d_conflict );
+ Assert(!d_conflict);
if (quant_e == QuantifiersModule::QEFFORT_CONFLICT)
{
if( e==Theory::EFFORT_FULL ){
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;
}
}
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++)
{
}
}
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 );
}
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++)
{
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; i<tn.getNumChildren()-1; i++ ){
d_types.push_back( tn[i] );
type_reps->begin(), type_reps->end());
}
}else{
- Assert( d_incomplete );
+ Assert(d_incomplete);
return false;
}
}
int RepSetIterator::incrementAtIndex(int i)
{
- Assert( !isFinished() );
+ Assert(!isFinished());
#ifdef DISABLE_EVAL_SKIP_MULTIPLE
i = (int)d_index.size()-1;
#endif
} 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);
// 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;
}
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 );
Trace("sep-model") << " [empty]" << std::endl;
}else{
for( unsigned j=0; j<d_label_model[it->second].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() ){
}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;
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] );
}else{
//labeled emp should be rewritten
- Assert( false );
+ Assert(false);
}
d_red_conc[s_lbl][s_atom] = conc;
}
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 );
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
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 );
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<Node, std::map<int, Node> >& lms = d_label_map[s_atom];
if (lms.find(s_lbl) != lms.end())
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
}
// 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
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;
computeLabelModel( it->second );
Trace("sep-process-debug") << "Check heap data for " << it->first << " -> " << data_type << std::endl;
for( unsigned j=0; j<d_label_model[it->second].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() ){
//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;
}
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;
}
}
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;
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;
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);
}
}
}
}
void TheorySep::setNilRef( TypeNode tn, Node n ) {
- Assert( n.getType()==tn );
+ Assert(n.getType() == tn);
d_nil_ref[tn] = n;
}
}else{
for( unsigned i=0; i<locs.size(); i++ ){
Node s = locs[i];
- Assert( !s.isNull() );
+ Assert(!s.isNull());
s = NodeManager::currentNM()->mkNode( kind::SINGLETON, s );
if( u.isNull() ){
u = s;
}
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 ){
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;
}
}
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() ){
}
}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();
void TheorySep::getLabelChildren( Node s_atom, Node lbl, std::vector< Node >& children, std::vector< Node >& labels ) {
for( unsigned i=0; i<s_atom.getNumChildren(); i++ ){
Node lblc = getLabel( s_atom, i, lbl );
- Assert( !lblc.isNull() );
+ Assert(!lblc.isNull());
std::map< Node, Node > 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 ) {
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];
}
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<d_label_model[lbl].d_heap_locs_model.size(); j++ ){
Node u = d_label_model[lbl].d_heap_locs_model[j];
- Assert( u.getKind()==kind::SINGLETON );
+ Assert(u.getKind() == kind::SINGLETON);
u = u[0];
Node tt;
std::map< Node, Node >::iterator itm = d_tmodel.find( u );
//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;
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 ) ){
}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 ){
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 );
}
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 ){
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; i<n.getNumChildren(); i++ ){
if( n[i].getKind()==kind::SEP_EMP ){
}
ns_children.push_back( schild );
}
- Assert( !ns_children.empty() );
+ Assert(!ns_children.empty());
if( ns_children.size()==1 ){
retNode = ns_children[0];
}else{
Node v = val.getModelValue(it->second);
Trace("sets-model") << "Cardinality of " << eqc << " is " << v
<< std::endl;
- Assert(v.getConst<Rational>() <= LONG_MAX,
- "Exceeded LONG_MAX in sets model");
+ Assert(v.getConst<Rational>() <= LONG_MAX)
+ << "Exceeded LONG_MAX in sets model";
unsigned vu = v.getConst<Rational>().getNumerator().toUnsignedInt();
Assert(els.size() <= vu);
NodeManager* nm = NodeManager::currentNM();
}
static Node reverseTuple( Node tuple ) {
- Assert( tuple.getType().isTuple() );
+ Assert(tuple.getType().isTuple());
std::vector<Node> elements;
std::vector<TypeNode> tuple_types = tuple.getType().getTupleTypes();
std::reverse( tuple_types.begin(), tuple_types.end() );
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; j<n_members; j++ ){
- Assert( j<(int)d_members_data[t1].size() && d_members_data[t1][j].getKind()==kind::MEMBER );
+ Assert(j < (int)d_members_data[t1].size()
+ && d_members_data[t1][j].getKind() == kind::MEMBER);
if (d_state.areEqual(m2[0], d_members_data[t1][j][0]))
{
add = false;
}
if( add ){
if( !s1.isNull() && s2.isNull() ){
- Assert( m2[1].getType().isComparableTo( s1.getType() ) );
+ Assert(m2[1].getType().isComparableTo(s1.getType()));
Assert(d_state.areEqual(m2[1], s1));
Node exp = NodeManager::currentNM()->mkNode( kind::AND, m2[1].eqNode( s1 ), m2 );
if( s1.getKind()==kind::SINGLETON ){
}
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++ ){
}
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;
++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;
}
{
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() ){
}
}
}else{
- Assert( k==kind::SETMINUS );
+ Assert(k == kind::SETMINUS);
std::map<Node, Node>::const_iterator itm = r2mem.find(xr);
if (itm == r2mem.end())
{
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 ) ){
}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;
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() ) {
std::vector< Node > reasons;
std::unordered_set<Node, NodeHashFunction> 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 );
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;
}
std::vector<Node> members = d_rReps_memberReps_cache[rel0_rep];
std::vector<Node> 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];
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] ||
}//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
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()) {
}
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 {
{
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()) {
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);
}
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 */
}
inline static bool computeIsConst(NodeManager* nodeManager, TNode n) {
- Assert(n.getKind() == kind::TCLOSURE);
- return false;
+ Assert(n.getKind() == kind::TCLOSURE);
+ return false;
}
};/* struct RelTransClosureTypeRule */
}
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,
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 ){
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 );
}
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();
}
// 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;
}
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 );
bool RegExpOpr::containC2(unsigned cnt, Node n) {
if(n.getKind() == kind::REGEXP_RV) {
- Assert(n[0].getConst<Rational>() <= Rational(String::maxSize()),
- "Exceeded UINT32_MAX in RegExpOpr::containC2");
+ Assert(n[0].getConst<Rational>() <= Rational(String::maxSize()))
+ << "Exceeded UINT32_MAX in RegExpOpr::containC2";
unsigned y = n[0].getConst<Rational>().getNumerator().toUnsignedInt();
return cnt == y;
} else if(n.getKind() == kind::REGEXP_CONCAT) {
r1 = d_emptySingleton;
r2 = d_emptySingleton;
} else if(n.getKind() == kind::REGEXP_RV) {
- Assert(n[0].getConst<Rational>() <= Rational(String::maxSize()),
- "Exceeded UINT32_MAX in RegExpOpr::convert2");
+ Assert(n[0].getConst<Rational>() <= Rational(String::maxSize()))
+ << "Exceeded UINT32_MAX in RegExpOpr::convert2";
unsigned y = n[0].getConst<Rational>().getNumerator().toUnsignedInt();
r1 = d_emptySingleton;
if(cnt == y) {
}
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;
{
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
}
return d_data;
}else{
- Assert( index<n.getNumChildren() );
+ Assert(index < n.getNumChildren());
TNode nir = s.getRepresentative(n[index]);
//if it is empty, and doing CONCAT, ignore
if( nir==er && n.getKind()==kind::STRING_CONCAT ){
}
bool TheoryStrings::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_STRINGS) && d_equalityEngine.isTriggerTerm(y, THEORY_STRINGS) ){
TNode x_shared = d_equalityEngine.getTriggerTermRepresentative(x, THEORY_STRINGS);
TNode y_shared = d_equalityEngine.getTriggerTermRepresentative(y, THEORY_STRINGS);
}
else
{
- Assert(len_value.getConst<Rational>() <= Rational(String::maxSize()),
- "Exceeded UINT32_MAX in string model");
+ Assert(len_value.getConst<Rational>() <= Rational(String::maxSize()))
+ << "Exceeded UINT32_MAX in string model";
unsigned lvalue =
len_value.getConst<Rational>().getNumerator().toUnsignedInt();
std::map<unsigned, Node>::iterator itvu = values_used.find(lvalue);
Trace("strings-model") << std::endl;
//use type enumerator
- Assert(lts_values[i].getConst<Rational>() <= Rational(String::maxSize()),
- "Exceeded UINT32_MAX in string model");
+ Assert(lts_values[i].getConst<Rational>() <= Rational(String::maxSize()))
+ << "Exceeded UINT32_MAX in string model";
StringEnumeratorLength sel(lts_values[i].getConst<Rational>().getNumerator().toUnsignedInt());
for (const Node& eqc : pure_eq)
{
std::map<Node, Node>::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))
{
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))
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);
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++ ) {
}
//explain equal components
if( count[0]<nc.getNumChildren() ){
- Assert( count[1]<n.getNumChildren() );
+ Assert(count[1] < n.getNumChildren());
if( nc[count[0]]!=n[count[1]] ){
exp.push_back( nc[count[0]].eqNode( n[count[1]] ) );
}
}
else
{
- Assert( !foundNEmpty );
+ Assert(!foundNEmpty);
ns = n[i];
foundNEmpty = true;
}
}
- AlwaysAssert( foundNEmpty );
+ AlwaysAssert(foundNEmpty);
//infer the equality
d_im.sendInference(exp, n.eqNode(ns), "I_Norm_S");
}
if (!d_state.areEqual(n[count], vecc[countc]))
{
Node nrr = d_state.getRepresentative(n[count]);
- Assert( !d_eqc_to_const_exp[nrr].isNull() );
+ Assert(!d_eqc_to_const_exp[nrr].isNull());
d_im.addToExplanation(n[count], d_eqc_to_const_base[nrr], exp);
exp.push_back( d_eqc_to_const_exp[nrr] );
}
}
}
//exp contains an explanation of n==c
- Assert( countc==vecc.size() );
+ Assert(countc == vecc.size());
if (d_state.hasTerm(c))
{
d_im.sendInference(exp, n.eqNode(c), "I_CONST_MERGE");
}
//if not reduced
if( !to_reduce.isNull() ){
- Assert( effort<3 );
+ Assert(effort < 3);
if( effort==1 ){
Trace("strings-extf") << " cannot rewrite extf : " << to_reduce << std::endl;
}
}
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;
}
}
//construct the normal form
- Assert( !normal_forms.empty() );
+ Assert(!normal_forms.empty());
unsigned nf_index = 0;
std::map<Node, unsigned>::iterator it = term_to_nf_index.find(eqc);
// we prefer taking the normal form whose base is the equivalence
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] );
}
NormalForm& nfnc = nfiv[index].isConst() ? nfj : nfi;
std::vector<Node>& 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);
Node const_str =
TheoryStringsRewriter::collectConstantStringAt(
nfcv, index_c_k, false);
- Assert( !const_str.isNull() );
+ Assert(!const_str.isNull());
CVC4::String stra = const_str.getConst<String>();
CVC4::String strb = next_const_str.getConst<String>();
//since non-empty, we start with charecter #1
}
if( info_valid ){
pinfer.push_back( info );
- Assert( !success );
+ Assert(!success);
}
}
}
if( ret!=0 ) {
return;
}else{
- Assert( index<nfi.size() && index<nfj.size() );
+ Assert(index < nfi.size() && index < nfj.size());
Node i = nfi[index];
Node j = nfj[index];
Trace("strings-solve-debug") << "...Processing(DEQ) " << i << " " << j << std::endl;
if (!d_state.areEqual(i, j))
{
- Assert( i.getKind()!=kind::CONST_STRING || j.getKind()!=kind::CONST_STRING );
+ Assert(i.getKind() != kind::CONST_STRING
+ || j.getKind() != kind::CONST_STRING);
std::vector< Node > lexp;
Node li = d_state.getLength(i, lexp);
Node lj = d_state.getLength(j, lexp);
index++;
}
}
- Assert( false );
+ Assert(false);
}
}
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;
}
//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;
}
std::map< unsigned, std::vector< Node > > eqc_to_strings;
for( unsigned i=0; i<n.size(); i++ ) {
Node eqc = n[i];
- Assert( d_equalityEngine.getRepresentative(eqc)==eqc );
+ Assert(d_equalityEngine.getRepresentative(eqc) == eqc);
EqcInfo* ei = d_state.getOrMakeEqcInfo(eqc, false);
Node lt = ei ? ei->d_lengthTerm : Node::null();
if( !lt.isNull() ){
}
return ret;
}else{
- Assert( new_nodes.empty() );
+ Assert(new_nodes.empty());
}
}
return atom;
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)
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();
}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 );
}
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
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;
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<Rational>().sgn() >= 0,
- "Negative integer in string REGEXP_LOOP (1)");
- Assert(n1.getConst<Rational>() <= rMaxInt,
- "Exceeded UINT32_MAX in string REGEXP_LOOP (1)");
+ AlwaysAssert(n1.isConst()) << "re.loop contains non-constant integer (1).";
+ AlwaysAssert(n1.getConst<Rational>().sgn() >= 0)
+ << "Negative integer in string REGEXP_LOOP (1)";
+ Assert(n1.getConst<Rational>() <= rMaxInt)
+ << "Exceeded UINT32_MAX in string REGEXP_LOOP (1)";
uint32_t l = n1.getConst<Rational>().getNumerator().toUnsignedInt();
std::vector<Node> vec_nodes;
for (unsigned i = 0; i < l; i++)
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<Rational>().sgn() >= 0,
- "Negative integer in string REGEXP_LOOP (2)");
- Assert(n2.getConst<Rational>() <= rMaxInt,
- "Exceeded UINT32_MAX in string REGEXP_LOOP (2)");
+ AlwaysAssert(n2.isConst()) << "re.loop contains non-constant integer (2).";
+ AlwaysAssert(n2.getConst<Rational>().sgn() >= 0)
+ << "Negative integer in string REGEXP_LOOP (2)";
+ Assert(n2.getConst<Rational>() <= rMaxInt)
+ << "Exceeded UINT32_MAX in string REGEXP_LOOP (2)";
uint32_t u = n2.getConst<Rational>().getNumerator().toUnsignedInt();
if (u <= l)
{
}
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();
if(r[0].getKind() == kind::CONST_STRING) {
return ( s2 == r[0].getConst<String>() );
} else {
- Assert( false, "RegExp contains variables" );
+ Assert(false) << "RegExp contains variables";
return false;
}
}
} 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<Rational>().getNumerator().toUnsignedInt();
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;
}
Node TheoryStringsRewriter::splitConstant( Node a, Node b, int& index, bool isRev ) {
- Assert( a.isConst() && b.isConst() );
+ Assert(a.isConst() && b.isConst());
index = a.getConst<String>().size() <= b.getConst<String>().size() ? 1 : 0;
unsigned len_short = index==1 ? a.getConst<String>().size() : b.getConst<String>().size();
bool cmp = isRev ? a.getConst<String>().rstrncmp(b.getConst<String>(), len_short): a.getConst<String>().strncmp(b.getConst<String>(), len_short);
}
bool TheoryStringsRewriter::canConstantContainConcat( Node c, Node n, int& firstc, int& lastc ) {
- Assert( c.isConst() );
+ Assert(c.isConst());
CVC4::String t = c.getConst<String>();
const std::vector<unsigned>& 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;
}
bool TheoryStringsRewriter::canConstantContainList( Node c, std::vector< Node >& l, int& firstc, int& lastc ) {
- Assert( c.isConst() );
+ Assert(c.isConst());
CVC4::String t = c.getConst<String>();
//must find constant components in order
size_t pos = 0;
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();
std::vector<Node>& ss,
std::vector<Node>& ls)
{
- Assert( ss.empty() );
- Assert( ls.empty() );
+ Assert(ss.empty());
+ Assert(ls.empty());
while (s.getKind() == STRING_SUBSTR)
{
ss.push_back(s[1]);
StringEnumerator(TypeNode type, TypeEnumeratorProperties* tep = nullptr)
: TypeEnumeratorBase<StringEnumerator>(type)
{
- Assert(type.getKind() == kind::TYPE_CONSTANT &&
- type.getConst<TypeConstant>() == STRING_TYPE);
+ Assert(type.getKind() == kind::TYPE_CONSTANT
+ && type.getConst<TypeConstant>() == STRING_TYPE);
d_cardinality = TheoryStringsRewriter::getAlphabetCardinality();
mkCurr();
}
// 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;
#include <iostream>
#include <string>
-#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"
* (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!";
}
/**
* via the syntax (! n :attr)
*/
virtual void setUserAttribute(const std::string& attr, Node n, std::vector<Node> 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 */
/** 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;
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];
#ifdef CVC4_FOR_EACH_THEORY_STATEMENT
#undef CVC4_FOR_EACH_THEORY_STATEMENT
#endif
-#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
- if (theory::TheoryTraits<THEORY>::hasPostsolve) { \
- theoryOf(THEORY)->postsolve(); \
- Assert(! d_inConflict || wasInConflict, "conflict raised during postsolve()"); \
- }
+#define CVC4_FOR_EACH_THEORY_STATEMENT(THEORY) \
+ if (theory::TheoryTraits<THEORY>::hasPostsolve) \
+ { \
+ theoryOf(THEORY)->postsolve(); \
+ Assert(!d_inConflict || wasInConflict) \
+ << "conflict raised during postsolve()"; \
+ }
// Postsolve for each theory using the statement above
CVC4_FOR_EACH_THEORY;
// 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);
}
if( d_quantEngine ){
d_quantEngine->getInstantiatedQuantifiedFormulas( qs );
}else{
- Assert( false );
+ Assert(false);
}
}
if( d_quantEngine ){
d_quantEngine->getInstantiations( q, insts );
}else{
- Assert( false );
+ Assert(false);
}
}
if( d_quantEngine ){
d_quantEngine->getInstantiationTermVectors( q, tvecs );
}else{
- Assert( false );
+ Assert(false);
}
}
if( d_quantEngine ){
d_quantEngine->getInstantiations( insts );
}else{
- Assert( false );
+ Assert(false);
}
}
if( d_quantEngine ){
d_quantEngine->getInstantiationTermVectors( insts );
}else{
- Assert( false );
+ Assert(false);
}
}
if( d_quantEngine ){
return d_quantEngine->getInstantiatedConjunction( q );
}else{
- Assert( false );
+ Assert(false);
return Node::null();
}
}
}
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;
}
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);
++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;
+ }
}
}
}
#include <vector>
#include <utility>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "context/cdhashset.h"
#include "expr/node.h"
#include "options/options.h"
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 */
}
}
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() ){
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
// 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() ){
<< "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";
}
}
}
{
retNode = Rewriter::rewrite(retNode);
Assert(retNode.getKind() == kind::APPLY_UF
- || !retNode.getType().isFirstClass()
- || retNode.isConst());
+ || !retNode.getType().isFirstClass() || retNode.isConst());
}
}
d_normalizedCache[r] = retNode;
#include <utility>
#include <vector>
-#include "base/cvc4_assert.h"
#include "expr/node.h"
#include "theory/interrupted.h"
#include "theory/output_channel.h"
${theory_constructors}
- default:
- Unhandled(id);
+default: Unhandled() << id;
}
}
};/* struct CVC4::theory::TheoryConstructor */
#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"
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
//
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) */
try {
Node n = **d_te;
Assert(n.isConst());
- Assert(! isFinished());
+ Assert(!isFinished());
return n;
} catch(NoMoreValuesException&) {
Assert(isFinished());
#include <sstream>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/kind.h"
#include "theory/type_enumerator.h"
TypeEnumeratorInterface* TypeEnumerator::mkTypeEnumerator(
TypeNode type, TypeEnumeratorProperties* tep)
{
- switch(type.getKind()) {
- case kind::TYPE_CONSTANT:
- switch(type.getConst<TypeConstant>()) {
-${mk_type_enumerator_type_constant_cases}
- default:
+ switch (type.getKind())
+ {
+ case kind::TYPE_CONSTANT:
+ switch (type.getConst<TypeConstant>())
{
- 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();
}
}
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
/** 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);
}
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() );
}
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
}
}
}
- Assert( maxNode!=Node::null() );
+ Assert(maxNode != Node::null());
newClique.push_back( maxNode );
}
//check splits internal to new members
if( d_regions_index<d_regions.size() ){
d_regions[ d_regions_index ]->debugPrint("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() ) );
}
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;
}
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
/** 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;
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 ] ]++;
}
<< "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;
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 ){
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;
}
#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;
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;
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 );
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();
}
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<Rational>().getNumerator().getSignedInt();
Node ct = d_rep_model[tn]->getCardinalityTerm();
Trace("uf-ss-debug") << "...check cardinality terms : " << lit[0] << " " << ct << std::endl;
}
}else{
// unhandled uf ss mode
- Assert( false );
+ Assert(false);
}
Trace("uf-ss-solver") << "Done CardinalityExtension: check " << level
<< std::endl;
/** 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;
~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 );
}
}
EqualityNodeId EqualityEngine::getNodeId(TNode node) const {
- Assert(hasTerm(node), node.toString().c_str());
+ Assert(hasTerm(node)) << node;
return (*d_nodeIds.find(node)).second;
}
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();
}
// 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];
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);
<< ", 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);
// 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) {
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,
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;
}
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;
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;
}
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;
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;
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;
// 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")) {
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";
}
}
// 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;
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 {
*/
template<typename memory_class>
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();
}
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;
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 {
}/* 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{
}
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;
}
// 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:
}
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);
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);
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();
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; i<n.getNumChildren(); i++ ){
curr = NodeManager::currentNM()->mkNode( kind::HO_APPLY, curr, n[i] );
}
// 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
// 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] ) ){
#include <sstream>
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
using namespace std;
#include <limits>
#include <functional>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/exception.h"
namespace CVC4 {
#include "util/cardinality.h"
-#include "base/cvc4_assert.h"
+#include "base/check.h"
namespace CVC4 {
// 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) {
#include <limits>
#include <vector>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "util/index.h"
if( x >= allocated()){
return false;
}else{
- Assert(x < allocated());
+ Assert(x < allocated());
return d_posVector[x] != +POSITION_SENTINEL;
}
}
#include "util/divisible.h"
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/exception.h"
using namespace std;
**/
#include "util/floatingpoint.h"
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "util/integer.h"
#include <math.h>
#ifndef CVC4_USE_SYMFPU
void FloatingPointLiteral::unfinished(void) const
{
- Unimplemented("Floating-point literals not yet implemented.");
+ Unimplemented() << "Floating-point literals not yet implemented.";
}
#endif
#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) :
// Compute the sticky bit
Rational remainder(r - workingSig);
- Assert(Rational(0,1) <= remainder);
+ Assert(Rational(0, 1) <= remainder);
if (!remainder.isZero()) {
sig = sig | one;
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) :
// 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);
}
}
- Unreachable("Convert float literal to real broken.");
+ Unreachable() << "Convert float literal to real broken.";
}
BitVector FloatingPoint::pack (void) const {
# 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;
#include "cvc4autoconfig.h"
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "util/rational.h"
#ifndef CVC4_GMP_IMP
#include "util/random.h"
#include <cfloat>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
namespace CVC4 {
# 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;
# 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 {
#include <iostream>
#include <sstream>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/exception.h"
using namespace std;
**/
#include "util/resource_manager.h"
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/output.h"
#include "options/smt_options.h"
/** 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;
}
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" <<std::endl;
return elapsed;
}
if (d_timeBudgetCumulative) {
-
AlwaysAssert(d_cumulativeTimer.on());
// timer was on since the option was set
d_cumulativeTimeUsed = d_cumulativeTimer.elapsed();
#include <iostream>
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "options/set_language.h"
using namespace std;
case VALIDITY_UNKNOWN:
return Result(SAT_UNKNOWN, d_unknownExplanation, d_inputName);
- default:
- Unhandled(d_validity);
+ default: Unhandled() << d_validity;
}
}
case SAT_UNKNOWN:
return Result(VALIDITY_UNKNOWN, d_unknownExplanation, d_inputName);
- default:
- Unhandled(d_sat);
+ default: Unhandled() << d_sat;
}
}
case Result::SAT_UNKNOWN:
out << "SAT_UNKNOWN";
break;
- default:
- Unhandled(s);
+ default: Unhandled() << s;
}
return out;
}
case Result::VALIDITY_UNKNOWN:
out << "VALIDITY_UNKNOWN";
break;
- default:
- Unhandled(v);
+ default: Unhandled() << v;
}
return out;
}
case Result::UNKNOWN_REASON:
out << "UNKNOWN_REASON";
break;
- default:
- Unhandled(e);
+ default: Unhandled() << e;
}
return out;
}
#include "util/sampler.h"
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "util/bitvector.h"
namespace CVC4 {
#include <sstream>
#include <vector>
-#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"
#include <cstdlib>
#include <iostream>
-#include "base/cvc4_assert.h"
-#include "base/cvc4_check.h"
+#include "base/check.h"
#include "lib/clock_gettime.h"
#include "util/ostream_util.h"
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;
}
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 */
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;
#include <cstdlib>
#include <iostream>
-#include "base/cvc4_check.h"
+#include "base/check.h"
namespace CVC4 {
#include <map>
-#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;
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(
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(
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(
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}}));
#include <cxxtest/TestSuite.h>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "context/cdhashmap.h"
+#include "test_utils.h"
using namespace std;
using namespace CVC4;
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());
}
};
#include <iostream>
#include <vector>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "context/cdlist.h"
#include "context/cdo.h"
#include "context/context.h"
#include <iostream>
#include <vector>
-#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;
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 */
}
#include <iostream>
#include "context/context_mm.h"
-
-#include "base/cvc4_assert.h"
+#include "test_utils.h"
using namespace std;
using namespace CVC4::context;
}
// 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 */
}
#include <cxxtest/TestSuite.h>
-#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;
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/attribute.h"
#include "expr/node.h"
#include "expr/node_builder.h"
#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;
#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
#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 */
}
}
#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 */
}
#include <limits.h>
#include <sstream>
-#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;
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);
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);
NodeBuilder<K> 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<K> ws_kind(specKind);
NodeBuilder<K> 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<K> ws_from_nm_kind(d_nm, specKind);
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<K> 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<K-10> 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<K+10> 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 */
}
Node n = noKind;
#ifdef CVC4_ASSERTIONS
- TS_ASSERT_THROWS(noKind.getKind(), AssertionException&);
+ TS_UTILS_EXPECT_ABORT(noKind.getKind());
#endif /* CVC4_ASSERTIONS */
NodeBuilder<> spec(PLUS);
NodeBuilder<> nb;
#ifdef CVC4_ASSERTIONS
- TS_ASSERT_THROWS(nb.getNumChildren(), AssertionException&);
+ TS_UTILS_EXPECT_ABORT(nb.getNumChildren());
#endif /* CVC4_ASSERTIONS */
nb << PLUS << x << x;
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);
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]);
}
*/
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;
#ifdef CVC4_ASSERTIONS
Node n = arr;
- TS_ASSERT_THROWS(arr[0], AssertionException&);
+ TS_UTILS_EXPECT_ABORT(arr[0]);
#endif /* CVC4_ASSERTIONS */
}
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;
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;
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 */
}
#ifdef CVC4_ASSERTIONS
NodeBuilder<> spec(specKind);
- TS_ASSERT_THROWS(spec << PLUS, AssertionException&);
+ TS_UTILS_EXPECT_ABORT(spec << PLUS);
#endif /* CVC4_ASSERTIONS */
NodeBuilder<> noSpec;
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;
#ifdef CVC4_ASSERTIONS
NodeBuilder<> testTwo;
- TS_ASSERT_THROWS(testTwo << specKind << PLUS, AssertionException&);
+ TS_UTILS_EXPECT_ABORT(testTwo << specKind << PLUS);
#endif /* CVC4_ASSERTIONS */
NodeBuilder<> testMixOrder1;
#ifdef CVC4_ASSERTIONS
Node n = nb;
- TS_ASSERT_THROWS(nb << n, AssertionException&);
+ TS_UTILS_EXPECT_ABORT(nb << n);
#endif /* CVC4_ASSERTIONS */
NodeBuilder<> overflow(specKind);
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);
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 */
}
#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"
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
}
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
}
};
#include <string>
#include "expr/node_manager.h"
+#include "test_utils.h"
#include "util/integer.h"
#include "util/rational.h"
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));
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 */
}
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "expr/node.h"
#include "expr/node_builder.h"
#include "expr/node_manager.h"
#include <sstream>
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "base/exception.h"
#include "context/context.h"
#include "expr/expr.h"
#include <sys/resource.h>
#include <sys/time.h>
+#include "base/check.h"
#include "base/configuration_private.h"
-#include "base/cvc4_assert.h"
// Conditionally define CVC4_MEMORY_LIMITING_DISABLED.
#ifdef __APPLE__
#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"
}
}
-template <class T>
-static void testGaussElimT(Integer prime,
- std::vector<Integer> rhs,
- std::vector<std::vector<Integer>> lhs)
-{
- TS_ASSERT_THROWS(BVGauss::gaussElim(prime, rhs, lhs), T);
-}
-
class TheoryBVGaussWhite : public CxxTest::TestSuite
{
ExprManager *d_em;
{Integer(2), Integer(3), Integer(5)},
{Integer(4), Integer(0), Integer(5)}};
std::cout << "matrix 0, modulo 0" << std::endl; // throws
- testGaussElimT<AssertionException>(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;
/* #include <gmock/gmock.h> */
/* #include <gtest/gtest.h> */
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "context/context.h"
#include "expr/expr_manager.h"
#include "expr/node_manager.h"
/**
* 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 \
#include <memory>
#include <string>
-#include "base/cvc4_assert.h"
+#include "base/check.h"
#include "context/context.h"
#include "expr/kind.h"
#include "expr/node.h"
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();
}
else
{
- Assert(k == EQUAL);
+ TS_ASSERT(k == EQUAL);
k = DISTINCT;
}
}
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());
}
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());
#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;
}
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))),
#include <string>
#include <cstring>
-#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");
}
};
#include <iostream>
#include <sstream>
+#include "test_utils.h"
#include "util/bin_heap.h"
using namespace CVC4;
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());
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
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
#include <cstring>
#include <string>
-#include "base/cvc4_check.h"
+#include "base/check.h"
#include "test_utils.h"
using namespace std;
"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));
}
};
// 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<string> refStr("stat #1", empty);