Skip to content

Commit 324696a

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 324696a

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

src/solvers/smt2/smt2_dec.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,17 +175,35 @@ 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(solver == solvert::Z3 &&
183+
message.find("must not contain quantifiers") != std::string::npos)
184+
{
185+
// We tried to "(get-value |XXXX|)" where |XXXX| is determined to
186+
// include a quantified expression
187+
// Nothing to do, this should be caught and value assigned by the
188+
// set_to defaults later.
189+
}
190+
// Unhandled error, log the error and report it back up to caller
191+
else
192+
{
193+
messaget log{message_handler};
194+
log.error() << "SMT2 solver returned error message:\n"
195+
<< "\t\"" << message << "\"" << messaget::eom;
196+
return decision_proceduret::resultt::D_ERROR;
197+
}
185198
}
186199
}
187200
}
188201

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

0 commit comments

Comments
 (0)