72 assert(!loop.empty());
76 for(loopt::const_iterator
80 if((*it)->is_goto() &&
81 (*it)->get_target()==loop_head &&
82 (*it)->location_number>loop_end->location_number)
87 static_cast<const exprt&
>(
88 loop_end->guard.find(ID_C_spec_loop_invariant));
114 a->function=loop_head->function;
116 a->source_location.
set_comment(
"Loop invariant violated before entry");
125 assume->guard=invariant;
126 assume->function=loop_head->function;
131 if(!loop_head->is_goto())
136 jump->targets.push_back(loop_end);
137 jump->function=loop_head->function;
142 goto_function.body.insert_before_swap(loop_head, havoc_code);
151 goto_function.body.insert_before_swap(loop_end, a);
156 loop_end->targets.clear();
158 if(loop_head->is_goto())
159 loop_end->guard.make_false();
161 loop_end->guard.make_not();
179 static_cast<const exprt&
>(type.
find(ID_C_spec_requires));
181 static_cast<const exprt&
>(type.
find(ID_C_spec_ensures));
192 replace.
insert(
"__CPROVER_return_value", call.
lhs());
195 code_function_callt::argumentst::const_iterator a_it=
197 for(code_typet::parameterst::const_iterator
202 if(!p_it->get_identifier().empty())
203 replace.
insert(p_it->get_identifier(), *a_it);
219 target->make_assumption(ensures);
231 for(natural_loops_mutablet::loop_mapt::const_iterator
232 l_it=natural_loops.
loop_map.begin();
243 if(it->is_function_call())
266 goto_functionst::function_mapt::iterator f_it=
272 const exprt &requires=
273 static_cast<const exprt&
>(gf.type.find(ID_C_spec_requires));
274 const exprt &ensures=
275 static_cast<const exprt&
>(gf.type.find(ID_C_spec_ensures));
300 g->function=skip->function;
301 g->source_location=skip->source_location;
312 d->function=skip->function;
313 d->source_location=skip->source_location;
317 d->source_location).symbol_expr();
322 replace.
insert(
"__CPROVER_return_value",
r);
326 for(code_typet::parameterst::const_iterator
327 p_it=gf.type.parameters().begin();
328 p_it!=gf.type.parameters().end();
332 d->function=skip->function;
333 d->source_location=skip->source_location;
337 d->source_location).symbol_expr();
342 if(!p_it->get_identifier().empty())
343 replace.
insert(p_it->get_identifier(), p);
350 a->make_assumption(requires);
351 a->function=skip->function;
360 f->make_function_call(call);
361 f->function=skip->function;
362 f->source_location=skip->source_location;
366 a->make_assertion(ensures);
367 a->function=skip->function;
376 af->function=skip->function;
389 goto_functionst::function_mapt::iterator i_it=
exprt guard
Guard for gotos, assume, assert.
irep_idt function
The function this instruction belongs to.
The type of an expression.
const std::string & id2string(const irep_idt &d)
void insert_before_swap(targett target)
Insertion that preserves jumps to "target".
goto_functionst & goto_functions
void add_contract_check(const irep_idt &function, goto_programt &dest)
const code_typet & to_code_type(const typet &type)
Cast a generic typet to a code_typet.
void set_comment(const irep_idt &comment)
const irep_idt & get_function() const
std::unordered_set< irep_idt > summarized
Fresh auxiliary symbol creation.
void apply_contract(goto_programt &goto_program, goto_programt::targett target)
void destructive_append(goto_programt &p)
Appends the given program, which is destroyed.
const natural_loops_mutablet::natural_loopt loopt
function_mapt function_map
symbol_tablet symbol_table
Symbol table.
Symbol table entry.This is a symbol in the symbol table, stored in an object of type symbol_tablet...
symbol_tablet & symbol_table
This class represents an instruction in the GOTO intermediate representation.
void code_contracts(goto_functionst::goto_functiont &goto_function)
const irep_idt & id() const
instructionst::iterator targett
A declaration of a local variable.
code_contractst(symbol_tablet &_symbol_table, goto_functionst &_goto_functions)
#define INITIALIZE_FUNCTION
instructionst instructions
The list of instructions in the goto program.
::goto_functiont goto_functiont
std::set< exprt > modifiest
A side effect that returns a non-deterministically chosen value.
void destructive_insert(const_targett target, goto_programt &p)
Inserts the given program at the given location.
const symbol_exprt & to_symbol_expr(const exprt &expr)
Cast a generic exprt to a symbol_exprt.
dstringt has one field, an unsigned integer no which is an index into a static table of strings...
Helper functions for k-induction and loop invariants.
The boolean constant false.
const source_locationt & source_location() const
A generic container class for the GOTO intermediate representation of one function.
Verify and use annotated invariants and pre/post-conditions.
typet type
Type of symbol.
void get_modifies(const local_may_aliast &local_may_alias, const loopt &loop, modifiest &modifies)
symbolt & get_fresh_aux_symbol(const typet &type, const std::string &name_prefix, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &symbol_mode, symbol_table_baset &symbol_table)
Installs a fresh-named symbol with the requested name pattern.
source_locationt source_location
The location of the instruction in the source file.
targett add_instruction()
Adds an instruction at the end.
Base class for all expressions.
const parameterst & parameters() const
void remove_skip(goto_programt &goto_program, goto_programt::targett begin, goto_programt::targett end)
remove unnecessary skip statements
#define Forall_goto_functions(it, functions)
const source_locationt & source_location() const
unsigned temporary_counter
goto_programt & goto_program
void insert(const irep_idt &identifier, const exprt &expr)
#define Forall_goto_program_instructions(it, program)
void build_havoc_code(const goto_programt::targett loop_head, const modifiest &modifies, goto_programt &dest)
Expression to hold a symbol (variable)
void code_contracts(goto_modelt &goto_model)
const irept & find(const irep_namet &name) const
goto_functionst goto_functions
GOTO functions.
const typet & return_type() const
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See namespace_baset::lookup().
const symbolt & new_tmp_symbol(const typet &type, const source_locationt &source_location)
static void check_apply_invariants(goto_functionst::goto_functiont &goto_function, const local_may_aliast &local_may_alias, const goto_programt::targett loop_head, const loopt &loop)
Field-insensitive, location-sensitive may-alias analysis.
const code_function_callt & to_code_function_call(const codet &code)