コード例 #1
0
size_t get_x0_offset(const invariant_programt &prog)
{
  const invariant_programt::const_invariant_loopst l(prog.get_loops());
  return std::accumulate(l.begin(), l.end(), 0,
      [](const size_t sum, const invariant_programt::invariant_loopt * const loop)
      { return sum + loop->skolem_choices.size();});
}
コード例 #2
0
void safety_verify_configt::process(const candidatet &candidate)
{
  program=original_program;
  quantifiers.clear();
  const safety_programt &prog=program;
  const invariant_programt::const_invariant_loopst loops(prog.get_loops());
  assert(!loops.empty());
  const size_t offset(
      program.x0_choices.size() + loops.front()->skolem_choices.size());
  invariant_insert_constraint(quantifiers, program, create_safety_constraint,
      offset);
  safety_insert_candidate(program, candidate);
  program.gf.update();
}
コード例 #3
0
void safety_verify_configt::convert(counterexamplest &counterexamples,
    const goto_tracet &trace)
{
  counterexamples.push_back(counterexamplet());
  counterexamplet &new_ce=counterexamples.back();
  invariant_extract_counterexample(new_ce.x0, trace, program.x0_choices);
  counterexamplet::assignments_per_loopt &x=new_ce.x;
  // TODO: Implement for multiple loops (change constraint, instrumentation)
  x.push_back(counterexamplet::assignmentst());
  counterexamplet::assignmentst &ass=x.back();
  ass.clear();
  invariant_extract_counterexample(ass, trace, quantifiers);
  const safety_programt &prog=program;
  const invariant_programt::const_invariant_loopst loops(prog.get_loops());
  assert(!loops.empty());
  // TODO: Implement for multiple loops (change constraint, instrumentation)
  invariant_extract_counterexample(ass, trace, loops.front()->skolem_choices);
}
コード例 #4
0
ファイル: safety_learn_config.cpp プロジェクト: agriggio/cbmc
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();
}
コード例 #5
0
ファイル: safety_learn_config.cpp プロジェクト: agriggio/cbmc
void safety_learn_configt::process(const size_t max_solution_size)
{
  constraint_varst ce_vars;
  get_invariant_constraint_vars(ce_vars, original_program);
  const typet type(invariant_meta_type());  // XXX: Currently single data type
  const exprt zero(gen_zero(type));
  counterexamplet dummy_ce;
  dummy_ce.x.push_back(counterexamplet::assignmentst());
  counterexamplet::assignmentst &x=dummy_ce.x.front();
  for (const symbol_exprt &var : ce_vars)
    x.insert(std::make_pair(var.get_identifier(), zero));
  // TODO: Implement for multiple loops (change constraint, instrumentation)
  const safety_programt &prog=original_program;
  const invariant_programt::const_invariant_loopst loops=prog.get_loops();
  assert(!loops.empty());
  // XXX: We might have to handle skolem choices explicitly at some point
  for (const goto_programt::targett &skolem_choice : loops.front()->skolem_choices)
    x.insert(std::make_pair(get_affected_variable(*skolem_choice), zero));
  counterexamplet::assignmentst &x0=dummy_ce.x0;
  for (const goto_programt::targett &x0_choice : original_program.x0_choices)
    x0.insert(std::make_pair(get_affected_variable(*x0_choice), zero));
  counterexamplest empty(1, dummy_ce);
  process(empty, max_solution_size);
}