Skip to content

Commit 06942bb

Browse files
committed
Fixed CEGIS control vector solution nondet
Nondet was added too late in _start, leading to a new nondet solution at each CEGIS counterexample loop iteration. The bug was not present in the verification phase, hence any solution produced by this was still sound. However, this severely affects CEGIS' ability to find adequate solutions and worst case leads to a "same counterexample" assertion violation.
1 parent 9d05835 commit 06942bb

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

regression/cegis/cegis_control_benchmark_04/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
CORE
22
safety_stability.c
3-
--gcc --round-to-minus-inf --cegis-control --cegis-statistics --cegis-max-size 1 --cegis-show-iterations -D CPROVER -D _CONTROL_FLOAT_WIDTH=64 -D _CONTORL_RADIX_WIDTH=24 -D NUMBERLOOPS=10
3+
--gcc --round-to-minus-inf --cegis-control --cegis-statistics --cegis-max-size 1 --cegis-show-iterations -D CPROVER -D _CONTROL_FLOAT_WIDTH=32 -D _CONTORL_RADIX_WIDTH=24 -D NUMBERLOOPS=10
44
EXIT=0
55
SIGNAL=0
66
--

src/cegis/control/learn/vector_solution_configuration.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,41 @@
22

33
#include <goto-programs/goto_trace.h>
44

5+
#include <cegis/cegis-util/program_helper.h>
6+
#include <cegis/instrument/literals.h>
57
#include <cegis/control/value/control_vars.h>
68
#include <cegis/control/value/control_vector_solution.h>
79
#include <cegis/control/preprocessing/propagate_controller_sizes.h>
810
#include <cegis/control/learn/print_control_solution.h>
911
#include <cegis/control/learn/vector_solution_configuration.h>
1012

13+
namespace
14+
{
15+
bool is_assignment_to_solution_var(const goto_programt::instructiont &instr)
16+
{
17+
if (goto_program_instruction_typet::ASSIGN != instr.type) return false;
18+
const std::string &var_name=id2string(get_affected_variable(instr));
19+
return CEGIS_CONTROL_VECTOR_SOLUTION_VAR_NAME == var_name;
20+
}
21+
}
22+
1123
void vector_solution_configurationt::nondeterminise_solution_configuration(
1224
symbol_tablet &st, goto_functionst &gf)
1325
{
26+
goto_programt &init_body=get_body(gf, CPROVER_INIT);
27+
goto_programt::instructionst &init_instrs=init_body.instructions;
28+
const goto_programt::targett assignment=std::find_if(init_instrs.begin(),
29+
init_instrs.end(), is_assignment_to_solution_var);
30+
goto_programt &entry_body=get_entry_body(gf);
31+
const goto_programt::targett first_entry=entry_body.instructions.begin();
32+
const goto_programt::targett new_assignment=entry_body.insert_before(
33+
first_entry);
34+
new_assignment->source_location=first_entry->source_location;
35+
new_assignment->type=assignment->type;
36+
new_assignment->code=assignment->code;
37+
init_body.instructions.erase(assignment);
38+
init_body.update();
39+
entry_body.update();
1440
}
1541

1642
namespace

0 commit comments

Comments
 (0)