Skip to content

Commit 35c31bb

Browse files
authored
Merge pull request #4533 from diffblue/goto_symex_decision_procedure
goto_symex now uses decision_proceduret API
2 parents e39318d + 49b4407 commit 35c31bb

14 files changed

+166
-143
lines changed

src/goto-checker/bmc_util.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ ssa_step_matches_failing_property(const irep_idt &property_id)
5656
{
5757
return [property_id](
5858
symex_target_equationt::SSA_stepst::const_iterator step,
59-
const prop_convt &prop_conv) {
59+
const decision_proceduret &decision_procedure) {
6060
return step->is_assert() && step->get_property_id() == property_id &&
61-
prop_conv.l_get(step->cond_literal).is_false();
61+
decision_procedure.get(step->cond_handle).is_false();
6262
};
6363
}
6464

@@ -103,19 +103,6 @@ void output_error_trace(
103103
}
104104
}
105105

106-
void freeze_guards(
107-
const symex_target_equationt &equation,
108-
prop_convt &prop_conv)
109-
{
110-
for(const auto &step : equation.SSA_steps)
111-
{
112-
if(!step.guard_literal.is_constant())
113-
prop_conv.set_frozen(step.guard_literal);
114-
if(step.is_assert() && !step.cond_literal.is_constant())
115-
prop_conv.set_frozen(step.cond_literal);
116-
}
117-
}
118-
119106
/// outputs an error witness in graphml format
120107
void output_graphml(
121108
const goto_tracet &goto_trace,

src/goto-checker/bmc_util.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ void output_error_trace(
6060
const trace_optionst &,
6161
ui_message_handlert &);
6262

63-
void freeze_guards(const symex_target_equationt &, prop_convt &);
64-
6563
void output_graphml(const goto_tracet &, const namespacet &, const optionst &);
6664
void output_graphml(
6765
const symex_target_equationt &,

src/goto-checker/counterexample_beautification.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Author: Daniel Kroening, [email protected]
1616
#include <util/symbol.h>
1717
#include <util/threeval.h>
1818

19-
#include <solvers/prop/literal_expr.h>
2019
#include <solvers/prop/prop_minimize.h>
2120

2221
counterexample_beautificationt::counterexample_beautificationt(
@@ -41,7 +40,7 @@ void counterexample_beautificationt::get_minimization_list(
4140
it->is_assignment() &&
4241
it->assignment_type == symex_targett::assignment_typet::STATE)
4342
{
44-
if(!prop_conv.l_get(it->guard_literal).is_false())
43+
if(!prop_conv.get(it->guard_handle).is_false())
4544
{
4645
const typet &type = it->ssa_lhs.type();
4746

@@ -78,10 +77,14 @@ counterexample_beautificationt::get_failed_property(
7877
equation.SSA_steps.begin();
7978
it != equation.SSA_steps.end();
8079
it++)
80+
{
8181
if(
82-
it->is_assert() && prop_conv.l_get(it->guard_literal).is_true() &&
83-
prop_conv.l_get(it->cond_literal).is_false())
82+
it->is_assert() && prop_conv.get(it->guard_handle).is_true() &&
83+
prop_conv.get(it->cond_handle).is_false())
84+
{
8485
return it;
86+
}
87+
}
8588

8689
UNREACHABLE;
8790
return equation.SSA_steps.end();
@@ -95,7 +98,7 @@ operator()(boolbvt &boolbv, const symex_target_equationt &equation)
9598
failed = get_failed_property(boolbv, equation);
9699

97100
// lock the failed assertion
98-
boolbv.set_to(literal_exprt(failed->cond_literal), false);
101+
boolbv.set_to(failed->cond_handle, false);
99102

100103
{
101104
log.status() << "Beautifying counterexample (guards)" << messaget::eom;
@@ -113,8 +116,9 @@ operator()(boolbvt &boolbv, const symex_target_equationt &equation)
113116
it->is_assignment() &&
114117
it->assignment_type != symex_targett::assignment_typet::HIDDEN)
115118
{
116-
if(!it->guard_literal.is_constant())
117-
guard_count[it->guard_literal]++;
119+
literalt l = boolbv.convert(it->guard_handle);
120+
if(!l.is_constant())
121+
guard_count[l]++;
118122
}
119123

120124
// reached failed assertion?

src/goto-checker/goto_symex_fault_localizer.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ const SSA_stept &goto_symex_fault_localizert::collect_guards(
5858
step.assignment_type == symex_targett::assignment_typet::STATE &&
5959
!step.ignore)
6060
{
61-
if(!step.guard_literal.is_constant())
61+
literalt l = solver.convert(step.guard_handle);
62+
if(!l.is_constant())
6263
{
6364
auto emplace_result = fault_location.scores.emplace(step.source.pc, 0);
64-
localization_points.emplace(step.guard_literal, emplace_result.first);
65+
localization_points.emplace(l, emplace_result.first);
6566
}
6667
}
6768

@@ -90,7 +91,7 @@ bool goto_symex_fault_localizert::check(
9091
}
9192

9293
// lock the failed assertion
93-
assumptions.push_back(!failed_step.cond_literal);
94+
assumptions.push_back(!solver.convert(failed_step.cond_handle));
9495

9596
solver.set_assumptions(assumptions);
9697

src/goto-checker/goto_symex_fault_localizer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Author: Peter Schrammel
1818

1919
#include <goto-symex/symex_target_equation.h>
2020

21+
#include <solvers/prop/prop_conv.h>
22+
2123
#include "fault_localization_provider.h"
2224

2325
class goto_symex_fault_localizert

src/goto-checker/goto_symex_property_decider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ exprt goto_symex_property_decidert::goalt::as_expr() const
3636
exprt::operandst conjuncts;
3737
conjuncts.reserve(instances.size());
3838
for(const auto &inst : instances)
39-
conjuncts.push_back(literal_exprt(inst->cond_literal));
39+
conjuncts.push_back(inst->cond_handle);
4040
return conjunction(conjuncts);
4141
}
4242

src/goto-checker/multi_path_symex_checker.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,6 @@ multi_path_symex_checkert::prepare_property_decider(propertiest &properties)
7272
std::chrono::duration<double> solver_runtime = ::prepare_property_decider(
7373
properties, equation, property_decider, ui_message_handler);
7474

75-
if(options.get_bool_option("localize-faults"))
76-
freeze_guards(equation, property_decider.get_solver());
77-
7875
return solver_runtime;
7976
}
8077

src/goto-symex/build_goto_trace.cpp

Lines changed: 60 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,12 @@ Author: Daniel Kroening
2020

2121
#include <goto-programs/goto_functions.h>
2222

23-
#include <solvers/prop/prop_conv.h>
24-
#include <solvers/prop/prop.h>
23+
#include <solvers/decision_procedure.h>
2524

2625
#include "partial_order_concurrency.h"
2726

2827
static exprt build_full_lhs_rec(
29-
const prop_convt &prop_conv,
28+
const decision_proceduret &decision_procedure,
3029
const namespacet &ns,
3130
const exprt &src_original, // original identifiers
3231
const exprt &src_ssa) // renamed identifiers
@@ -39,17 +38,18 @@ static exprt build_full_lhs_rec(
3938
if(id==ID_index)
4039
{
4140
// get index value from src_ssa
42-
exprt index_value=prop_conv.get(to_index_expr(src_ssa).index());
41+
exprt index_value = decision_procedure.get(to_index_expr(src_ssa).index());
4342

4443
if(index_value.is_not_nil())
4544
{
4645
simplify(index_value, ns);
4746
index_exprt tmp=to_index_expr(src_original);
4847
tmp.index()=index_value;
49-
tmp.array()=
50-
build_full_lhs_rec(prop_conv, ns,
51-
to_index_expr(src_original).array(),
52-
to_index_expr(src_ssa).array());
48+
tmp.array() = build_full_lhs_rec(
49+
decision_procedure,
50+
ns,
51+
to_index_expr(src_original).array(),
52+
to_index_expr(src_ssa).array());
5353
return std::move(tmp);
5454
}
5555

@@ -58,22 +58,29 @@ static exprt build_full_lhs_rec(
5858
else if(id==ID_member)
5959
{
6060
member_exprt tmp=to_member_expr(src_original);
61-
tmp.struct_op()=build_full_lhs_rec(
62-
prop_conv, ns,
61+
tmp.struct_op() = build_full_lhs_rec(
62+
decision_procedure,
63+
ns,
6364
to_member_expr(src_original).struct_op(),
6465
to_member_expr(src_ssa).struct_op());
6566
}
6667
else if(id==ID_if)
6768
{
6869
if_exprt tmp2=to_if_expr(src_original);
6970

70-
tmp2.false_case()=build_full_lhs_rec(prop_conv, ns,
71-
tmp2.false_case(), to_if_expr(src_ssa).false_case());
71+
tmp2.false_case() = build_full_lhs_rec(
72+
decision_procedure,
73+
ns,
74+
tmp2.false_case(),
75+
to_if_expr(src_ssa).false_case());
7276

73-
tmp2.true_case()=build_full_lhs_rec(prop_conv, ns,
74-
tmp2.true_case(), to_if_expr(src_ssa).true_case());
77+
tmp2.true_case() = build_full_lhs_rec(
78+
decision_procedure,
79+
ns,
80+
tmp2.true_case(),
81+
to_if_expr(src_ssa).true_case());
7582

76-
exprt tmp=prop_conv.get(to_if_expr(src_ssa).cond());
83+
exprt tmp = decision_procedure.get(to_if_expr(src_ssa).cond());
7784

7885
if(tmp.is_true())
7986
return tmp2.true_case();
@@ -85,16 +92,19 @@ static exprt build_full_lhs_rec(
8592
else if(id==ID_typecast)
8693
{
8794
typecast_exprt tmp=to_typecast_expr(src_original);
88-
tmp.op()=build_full_lhs_rec(prop_conv, ns,
89-
to_typecast_expr(src_original).op(), to_typecast_expr(src_ssa).op());
95+
tmp.op() = build_full_lhs_rec(
96+
decision_procedure,
97+
ns,
98+
to_typecast_expr(src_original).op(),
99+
to_typecast_expr(src_ssa).op());
90100
return std::move(tmp);
91101
}
92102
else if(id==ID_byte_extract_little_endian ||
93103
id==ID_byte_extract_big_endian)
94104
{
95105
byte_extract_exprt tmp = to_byte_extract_expr(src_original);
96106
tmp.op() = build_full_lhs_rec(
97-
prop_conv, ns, tmp.op(), to_byte_extract_expr(src_ssa).op());
107+
decision_procedure, ns, tmp.op(), to_byte_extract_expr(src_ssa).op());
98108

99109
// re-write into big case-split
100110
}
@@ -169,7 +179,8 @@ static void update_internal_field(
169179

170180
/// Replace nondet values that appear in \p type by their values as found by
171181
/// \p solver.
172-
static void replace_nondet_in_type(typet &type, const prop_convt &solver)
182+
static void
183+
replace_nondet_in_type(typet &type, const decision_proceduret &solver)
173184
{
174185
if(type.id() == ID_array)
175186
{
@@ -182,7 +193,8 @@ static void replace_nondet_in_type(typet &type, const prop_convt &solver)
182193

183194
/// Replace nondet values that appear in the type of \p expr and its
184195
/// subexpressions type by their values as found by \p solver.
185-
static void replace_nondet_in_type(exprt &expr, const prop_convt &solver)
196+
static void
197+
replace_nondet_in_type(exprt &expr, const decision_proceduret &solver)
186198
{
187199
replace_nondet_in_type(expr.type(), solver);
188200
for(auto &sub : expr.operands())
@@ -192,7 +204,7 @@ static void replace_nondet_in_type(exprt &expr, const prop_convt &solver)
192204
void build_goto_trace(
193205
const symex_target_equationt &target,
194206
ssa_step_predicatet is_last_step_to_keep,
195-
const prop_convt &prop_conv,
207+
const decision_proceduret &decision_procedure,
196208
const namespacet &ns,
197209
goto_tracet &goto_trace)
198210
{
@@ -218,14 +230,14 @@ void build_goto_trace(
218230
{
219231
if(
220232
last_step_to_keep == target.SSA_steps.end() &&
221-
is_last_step_to_keep(it, prop_conv))
233+
is_last_step_to_keep(it, decision_procedure))
222234
{
223235
last_step_to_keep = it;
224236
}
225237

226238
const SSA_stept &SSA_step = *it;
227239

228-
if(prop_conv.l_get(SSA_step.guard_literal)!=tvt(true))
240+
if(!decision_procedure.get(SSA_step.guard_handle).is_true())
229241
continue;
230242

231243
if(it->is_constraint() ||
@@ -250,7 +262,7 @@ void build_goto_trace(
250262
// these are just used to get the time stamp -- the clock type is
251263
// computed to be of the minimal necessary size, but we don't need to
252264
// know it to get the value so just use typeless
253-
exprt clock_value = prop_conv.get(
265+
exprt clock_value = decision_procedure.get(
254266
symbol_exprt::typeless(partial_order_concurrencyt::rw_clock_id(it)));
255267

256268
const auto cv = numeric_cast<mp_integer>(clock_value);
@@ -342,7 +354,7 @@ void build_goto_trace(
342354
goto_trace_step.function_arguments = SSA_step.converted_function_arguments;
343355

344356
for(auto &arg : goto_trace_step.function_arguments)
345-
arg = prop_conv.get(arg);
357+
arg = decision_procedure.get(arg);
346358

347359
// update internal field for specific variables in the counterexample
348360
update_internal_field(SSA_step, goto_trace_step, ns);
@@ -359,15 +371,20 @@ void build_goto_trace(
359371
if(SSA_step.original_full_lhs.is_not_nil())
360372
{
361373
goto_trace_step.full_lhs = build_full_lhs_rec(
362-
prop_conv, ns, SSA_step.original_full_lhs, SSA_step.ssa_full_lhs);
363-
replace_nondet_in_type(goto_trace_step.full_lhs, prop_conv);
374+
decision_procedure,
375+
ns,
376+
SSA_step.original_full_lhs,
377+
SSA_step.ssa_full_lhs);
378+
replace_nondet_in_type(goto_trace_step.full_lhs, decision_procedure);
364379
}
365380

366381
if(SSA_step.ssa_full_lhs.is_not_nil())
367382
{
368-
goto_trace_step.full_lhs_value = prop_conv.get(SSA_step.ssa_full_lhs);
383+
goto_trace_step.full_lhs_value =
384+
decision_procedure.get(SSA_step.ssa_full_lhs);
369385
simplify(goto_trace_step.full_lhs_value, ns);
370-
replace_nondet_in_type(goto_trace_step.full_lhs_value, prop_conv);
386+
replace_nondet_in_type(
387+
goto_trace_step.full_lhs_value, decision_procedure);
371388
}
372389

373390
for(const auto &j : SSA_step.converted_io_args)
@@ -378,7 +395,7 @@ void build_goto_trace(
378395
}
379396
else
380397
{
381-
exprt tmp = prop_conv.get(j);
398+
exprt tmp = decision_procedure.get(j);
382399
goto_trace_step.io_args.push_back(tmp);
383400
}
384401
}
@@ -388,7 +405,7 @@ void build_goto_trace(
388405
goto_trace_step.cond_expr = SSA_step.cond_expr;
389406

390407
goto_trace_step.cond_value =
391-
prop_conv.l_get(SSA_step.cond_literal).is_true();
408+
decision_procedure.get(SSA_step.cond_handle).is_true();
392409
}
393410

394411
if(ssa_step_it == last_step_to_keep)
@@ -400,31 +417,33 @@ void build_goto_trace(
400417
void build_goto_trace(
401418
const symex_target_equationt &target,
402419
symex_target_equationt::SSA_stepst::const_iterator last_step_to_keep,
403-
const prop_convt &prop_conv,
420+
const decision_proceduret &decision_procedure,
404421
const namespacet &ns,
405422
goto_tracet &goto_trace)
406423
{
407-
const auto is_last_step_to_keep = [last_step_to_keep](
408-
symex_target_equationt::SSA_stepst::const_iterator it, const prop_convt &) {
409-
return last_step_to_keep == it;
410-
};
424+
const auto is_last_step_to_keep =
425+
[last_step_to_keep](
426+
symex_target_equationt::SSA_stepst::const_iterator it,
427+
const decision_proceduret &) { return last_step_to_keep == it; };
411428

412429
return build_goto_trace(
413-
target, is_last_step_to_keep, prop_conv, ns, goto_trace);
430+
target, is_last_step_to_keep, decision_procedure, ns, goto_trace);
414431
}
415432

416433
static bool is_failed_assertion_step(
417434
symex_target_equationt::SSA_stepst::const_iterator step,
418-
const prop_convt &prop_conv)
435+
const decision_proceduret &decision_procedure)
419436
{
420-
return step->is_assert() && prop_conv.l_get(step->cond_literal).is_false();
437+
return step->is_assert() &&
438+
decision_procedure.get(step->cond_handle).is_false();
421439
}
422440

423441
void build_goto_trace(
424442
const symex_target_equationt &target,
425-
const prop_convt &prop_conv,
443+
const decision_proceduret &decision_procedure,
426444
const namespacet &ns,
427445
goto_tracet &goto_trace)
428446
{
429-
build_goto_trace(target, is_failed_assertion_step, prop_conv, ns, goto_trace);
447+
build_goto_trace(
448+
target, is_failed_assertion_step, decision_procedure, ns, goto_trace);
430449
}

0 commit comments

Comments
 (0)