goto_programt::targett add_inv_prog(invariant_programt &prog,
    goto_programt::targett pos, const size_t max_solution_size,
    const goto_programt::targett &decl)
{
  symbol_tablet &st=prog.st;
  goto_functionst &gf=prog.gf;
  const std::string base_name(get_prog_var_name(st, decl));
  const typet size_type(unsigned_int_type());
  const constant_exprt size(from_integer(max_solution_size, size_type));
  const symbol_typet instr_type(CEGIS_INSTRUCTION_TYPE_NAME);
  const array_typet prog_type(instr_type, size);
  pos=declare_cegis_meta_variable(st, gf, pos, base_name, prog_type);
  execute_inv_prog(st, gf, max_solution_size, decl);
  return pos;
}
예제 #2
0
void safety_learn_configt::process(const counterexamplest &ces,
    const size_t max_sz)
{
  program=original_program;
  var_ids.clear();
  const symbol_tablet &st=program.st;
  num_consts=get_invariant_variable_ids(st, var_ids);
  const size_t num_vars=var_ids.size();
  null_message_handlert msg;
  const std::string name(DANGER_EXECUTE);
  add_invariant_library(program, msg, num_vars, num_consts, max_sz, name);
  add_safety_learning_variable_refs(program, var_ids, max_sz);
  goto_functionst &gf=program.gf;
  link_result_var(st, gf, var_ids.size(), max_sz, program.Ix0);
  add_invariant_progs_to_learn(program, max_sz);
  const invariant_programt &prog=program;
  const invariant_programt::const_invariant_loopst loops(prog.get_loops());
  const invariant_programt::invariant_loopt &first_loop=*loops.front();
  const std::string I0=get_prog_var_name(st, first_loop.meta_variables.Ix);
  execute_inv_prog(st, gf, max_sz, program.Ix0, I0);
  safety_add_learned_counterexamples(program, ces, create_safety_constraint);
  gf.update();
}
void execute_inv_prog(const symbol_tablet &st, goto_functionst &gf,
    const size_t max_solution_size, const goto_programt::targett &decl)
{
  execute_inv_prog(st, gf, max_solution_size, decl,
      get_prog_var_name(st, decl));
}