Go to the documentation of this file.
53 for(
const auto &
id :
id_map)
55 if(
id.second.type.id() == ID_mathematical_function)
58 if(
id.second.definition.is_nil())
61 const irep_idt &identifier =
id.first;
69 exprt def =
id.second.definition;
81 if(expr.
id()==ID_function_application)
85 if(app.function().id() == ID_symbol)
89 auto f_it =
id_map.find(identifier);
93 const auto &f = f_it->second;
96 f.type.id() == ID_mathematical_function,
97 "type of function symbol must be mathematical_function_type");
102 domain.size() == app.arguments().size(),
103 "number of parameters must match number of arguments");
106 if(!f.definition.is_nil())
108 exprt body = f.definition;
110 if(body.
id() == ID_lambda)
140 std::cout <<
"sat\n";
145 std::cout <<
"unsat\n";
150 std::cout <<
"error\n";
155 commands[
"check-sat-assuming"] = [
this]() {
156 std::vector<exprt> assumptions;
159 throw error(
"check-sat-assuming expects list as argument");
170 throw error(
"check-sat-assuming expects ')' at end of list");
181 std::cout <<
"sat\n";
186 std::cout <<
"unsat\n";
191 std::cout <<
"error\n";
206 commands[
"get-unsat-assumptions"] = [
this]() {
207 throw error(
"not yet implemented");
211 std::vector<exprt> ops;
214 throw error(
"get-value expects list as argument");
223 throw error(
"get-value expects ')' at end of list");
226 throw error(
"model is not available");
228 std::vector<exprt> values;
229 values.reserve(ops.size());
231 for(
const auto &op : ops)
233 if(op.id() != ID_symbol)
234 throw error(
"get-value expects symbol");
238 const auto id_map_it =
id_map.find(identifier);
240 if(id_map_it ==
id_map.end())
241 throw error() <<
"unexpected symbol '" << identifier <<
'\'';
246 throw error() <<
"no value for '" << identifier <<
'\'';
248 values.push_back(value);
253 for(std::size_t op_nr = 0; op_nr < ops.size(); op_nr++)
266 if(
next_token() != smt2_tokenizert::STRING_LITERAL)
267 throw error(
"expected string literal");
274 commands[
"get-assignment"] = [
this]() {
278 throw error(
"model is not available");
290 if(value.is_constant())
295 std::cout <<
'\n' <<
' ';
297 std::cout <<
'(' <<
smt2_format(named_term.second.name) <<
' '
301 std::cout <<
')' <<
'\n';
308 throw error(
"model is not available");
316 for(
const auto &
id :
id_map)
321 if(value.is_not_nil())
326 std::cout <<
'\n' <<
' ';
328 std::cout <<
"(define-fun " <<
smt2_format(name) <<
' ';
330 if(
id.second.type.id() == ID_mathematical_function)
331 throw error(
"models for functions unimplemented");
338 std::cout <<
')' <<
'\n';
356 | ( declare-
const hsymboli hsorti )
357 | ( declare-datatype hsymboli hdatatype_deci)
358 | ( declare-datatypes ( hsort_deci n+1 ) ( hdatatype_deci n+1 ) )
359 | ( declare-fun hsymboli ( hsorti ??? ) hsorti )
360 | ( declare-
sort hsymboli hnumerali )
361 | ( define-fun hfunction_def i )
362 | ( define-fun-rec hfunction_def i )
363 | ( define-funs-rec ( hfunction_deci n+1 ) ( htermi n+1 ) )
364 | ( define-
sort hsymboli ( hsymboli ??? ) hsorti )
366 | ( get-info hinfo_flag i )
367 | ( get-option hkeywordi )
369 | ( get-unsat-assumptions )
374 | ( reset-assertions )
375 | ( set-info hattributei )
376 | ( set-option hoptioni )
383 void print(
unsigned level,
const std::string &message)
override
388 std::cout <<
"(error \"" << message <<
"\")\n";
390 std::cout <<
"; " << message <<
'\n';
403 std::cout << std::flush;
418 satcheckt satcheck{message_handler};
419 boolbvt boolbv{ns, satcheck, message_handler};
422 bool error_found =
false;
424 while(!smt2_solver.exit)
432 smt2_solver.skip_to_end_of_list();
439 smt2_solver.skip_to_end_of_list();
451 int main(
int argc,
const char *argv[])
458 std::cerr <<
"usage: smt2_solver file\n";
462 std::ifstream in(argv[1]);
465 std::cerr <<
"failed to open " << argv[1] <<
'\n';
Class that provides messages with a built-in verbosity 'level'.
virtual exprt get(const exprt &expr) const =0
Return expr with variables replaced by values from satisfying assignment if available.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
void expand_function_applications(exprt &)
const lambda_exprt & to_lambda_expr(const exprt &expr)
Cast an exprt to a lambda_exprt.
void print(unsigned, const xmlt &) override
virtual void push(const std::vector< exprt > &assumptions)=0
Pushes a new context on the stack that consists of the given (possibly empty vector of) assumptions.
std::set< irep_idt > constants_done
const mathematical_function_typet & to_mathematical_function_type(const typet &type)
Cast a typet to a mathematical_function_typet.
Base class for all expressions.
void set_to_true(const exprt &expr)
For a Boolean expression expr, add the constraint 'expr'.
std::unordered_map< std::string, std::function< void()> > commands
Expression to hold a symbol (variable)
enum smt2_solvert::@5 status
virtual void print(unsigned level, const std::string &message)=0
void set_line(const irep_idt &line)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
stack_decision_proceduret & solver
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
source_locationt source_location
const irep_idt & get_identifier() const
exprt simplify_expr(exprt src, const namespacet &ns)
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast an exprt to a symbol_exprt.
const irep_idt & id() const
virtual exprt handle(const exprt &expr)=0
Generate a handle, which is an expression that has the same value as the argument in any model that i...
unsigned get_line_no() const
smt2_solvert(std::istream &_in, stack_decision_proceduret &_solver)
void set_verbosity(unsigned _verbosity)
void print(unsigned, const jsont &) override
int solver(std::istream &in)
virtual std::string what() const
A human readable description of what went wrong.
smt2_tokenizert::tokent next_token()
int main(int argc, const char *argv[])
virtual void pop()=0
Pop whatever is on top of the stack.
smt2_tokenizert smt2_tokenizer
void print(unsigned level, const std::string &message) override
A constant literal expression.
exprt application(const operandst &arguments) const
const function_application_exprt & to_function_application_expr(const exprt &expr)
Cast an exprt to a function_application_exprt.
void flush(unsigned) override
const std::string & get_buffer() const
Thrown when an unexpected error occurs during the analysis (e.g., when the SAT solver returns an erro...
smt2_tokenizert::smt2_errort error() const