diff options
author | Andres Noetzli <andres.noetzli@gmail.com> | 2019-06-04 14:48:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-04 14:48:21 -0700 |
commit | 29959bec6e023f64cad0a5d43b18052f08ac94c5 (patch) | |
tree | 46d059840df3e2e274981b9ee762c0ad17a2999f /src/smt | |
parent | 23baea2452d765bb76bd576b4cd01dd67215d095 (diff) |
Add check that result matches benchmark status (#3028)
This commit adds a check to make sure that the result of a `(check-sat)`
call matches the expected result set via `(set-info :status ...)`. In
doing so, it also fixes an issue where CVC4 would crash if asked for the
unsat core after setting the status to `unsat` but before calling
`(check-sat)` (see regression for concrete example). This happened
because CVC4 was storing the expected result and the computed result
both in the same variable (the expected result wasn't really being used
though). This commit keeps track of the expected result and the computed
result in separate variables to fix that issue.
Diffstat (limited to 'src/smt')
-rw-r--r-- | src/smt/smt_engine.cpp | 11 | ||||
-rw-r--r-- | src/smt/smt_engine.h | 5 |
2 files changed, 15 insertions, 1 deletions
diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp index 66198946f..8f2d95a0f 100644 --- a/src/smt/smt_engine.cpp +++ b/src/smt/smt_engine.cpp @@ -31,6 +31,7 @@ #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" @@ -888,6 +889,7 @@ SmtEngine::SmtEngine(ExprManager* em) d_earlyTheoryPP(true), d_globalNegation(false), d_status(), + d_expectedStatus(), d_replayStream(NULL), d_private(NULL), d_statisticsRegistry(NULL), @@ -2420,7 +2422,7 @@ void SmtEngine::setInfo(const std::string& key, const CVC4::SExpr& value) throw OptionException("argument to (set-info :status ..) must be " "`sat' or `unsat' or `unknown'"); } - d_status = Result(s, d_filename); + d_expectedStatus = Result(s, d_filename); return; } throw UnrecognizedOptionException(); @@ -3747,6 +3749,13 @@ Result SmtEngine::checkSatisfiability(const vector<Expr>& assumptions, // Remember the status d_status = r; + if (!d_expectedStatus.isUnknown() && !d_status.isUnknown() + && d_status != d_expectedStatus) + { + CVC4_FATAL() << "Expected result " << d_expectedStatus << " but got " + << d_status; + } + d_expectedStatus = Result(); setProblemExtended(false); diff --git a/src/smt/smt_engine.h b/src/smt/smt_engine.h index 165e93997..5913716e6 100644 --- a/src/smt/smt_engine.h +++ b/src/smt/smt_engine.h @@ -263,6 +263,11 @@ class CVC4_PUBLIC SmtEngine { Result d_status; /** + * The expected status of the next satisfiability check. + */ + Result d_expectedStatus; + + /** * The input file name (if any) or the name set through setInfo (if any) */ std::string d_filename; |