Skip to content

Commit a3fe258

Browse files
thomasspriggsTGWDB
authored andcommitted
Ignore quantifier errors running get-value commands with z3
Due to how we call z3 it is possible to have values that contain quantifiers appear in the results. However, z3 cannot give a real value in response to a "(get-value |XXX|)" request. This catches these any simply ignores them, allowing the rest of the code to continue. Note that this becomes necessary to handle since cbmc now produces quantifiers in expressions sent to z3.
1 parent 403a129 commit a3fe258

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/solvers/smt2/smt2_dec.cpp

+25-6
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,36 @@ decision_proceduret::resultt smt2_dect::read_result(std::istream &in)
175175
{
176176
// We ignore errors after UNSAT because get-value after check-sat
177177
// returns unsat will give an error.
178-
if(res!=resultt::D_UNSATISFIABLE)
178+
if(res != resultt::D_UNSATISFIABLE)
179179
{
180-
messaget log{message_handler};
181-
log.error() << "SMT2 solver returned error message:\n"
182-
<< "\t\"" << parsed.get_sub()[1].id() << "\""
183-
<< messaget::eom;
184-
return decision_proceduret::resultt::D_ERROR;
180+
const auto &message = id2string(parsed.get_sub()[1].id());
181+
// Special case error handling
182+
if(
183+
solver == solvert::Z3 &&
184+
message.find("must not contain quantifiers") != std::string::npos)
185+
{
186+
// We tried to "(get-value |XXXX|)" where |XXXX| is determined to
187+
// include a quantified expression
188+
// Nothing to do, this should be caught and value assigned by the
189+
// set_to defaults later.
190+
}
191+
// Unhandled error, log the error and report it back up to caller
192+
else
193+
{
194+
messaget log{message_handler};
195+
log.error() << "SMT2 solver returned error message:\n"
196+
<< "\t\"" << message << "\"" << messaget::eom;
197+
return decision_proceduret::resultt::D_ERROR;
198+
}
185199
}
186200
}
187201
}
188202

203+
// If the result is satisfiable don't bother updating the assignments and
204+
// values (since we didn't get any), just return.
205+
if(res != resultt::D_SATISFIABLE)
206+
return res;
207+
189208
for(auto &assignment : identifier_map)
190209
{
191210
std::string conv_id=convert_identifier(assignment.first);

0 commit comments

Comments
 (0)