Skip to content

Commit 49b4407

Browse files
author
Daniel Kroening
committed
goto symex now uses decision_proceduret interface
Use the the decision_proceduret interface in goto_symext instead of prop_convt. literalt values are replaced by handles.
1 parent a5b114e commit 49b4407

8 files changed

+119
-103
lines changed

src/goto-checker/bmc_util.cpp

Lines changed: 2 additions & 2 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.get(step->cond_handle).is_false();
61+
decision_procedure.get(step->cond_handle).is_false();
6262
};
6363
}
6464

src/goto-checker/counterexample_beautification.cpp

Lines changed: 0 additions & 1 deletion
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(

src/goto-checker/goto_symex_fault_localizer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +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_handle.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-
literalt guard_literal = solver.convert(step.guard_handle);
65-
localization_points.emplace(guard_literal, emplace_result.first);
65+
localization_points.emplace(l, emplace_result.first);
6666
}
6767
}
6868

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-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.get(SSA_step.guard_handle).is_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.get(SSA_step.cond_handle).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.get(step->cond_handle).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
}

src/goto-symex/build_goto_trace.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,45 +20,46 @@ Date: July 2005
2020
/// Build a trace by going through the steps of \p target and stopping at the
2121
/// first failing assertion
2222
/// \param target: SSA form of the program
23-
/// \param prop_conv: solver from which to get valuations
23+
/// \param decision_procedure: solver from which to get valuations
2424
/// \param ns: namespace
2525
/// \param [out] goto_trace: trace to which the steps of the trace get appended
2626
void build_goto_trace(
2727
const symex_target_equationt &target,
28-
const prop_convt &prop_conv,
28+
const decision_proceduret &decision_procedure,
2929
const namespacet &ns,
3030
goto_tracet &goto_trace);
3131

3232
/// Build a trace by going through the steps of \p target and stopping after
3333
/// the given step
3434
/// \param target: SSA form of the program
3535
/// \param last_step_to_keep: iterator pointing to the last step to keep
36-
/// \param prop_conv: solver from which to get valuations
36+
/// \param decision_procedure: solver from which to get valuations
3737
/// \param ns: namespace
3838
/// \param [out] goto_trace: trace to which the steps of the trace get appended
3939
void build_goto_trace(
4040
const symex_target_equationt &target,
4141
symex_target_equationt::SSA_stepst::const_iterator last_step_to_keep,
42-
const prop_convt &prop_conv,
42+
const decision_proceduret &decision_procedure,
4343
const namespacet &ns,
4444
goto_tracet &goto_trace);
4545

46-
typedef std::function<
47-
bool(symex_target_equationt::SSA_stepst::const_iterator, const prop_convt &)>
46+
typedef std::function<bool(
47+
symex_target_equationt::SSA_stepst::const_iterator,
48+
const decision_proceduret &)>
4849
ssa_step_predicatet;
4950

5051
/// Build a trace by going through the steps of \p target and stopping after
5152
/// the step matching a given condition
5253
/// \param target: SSA form of the program
5354
/// \param stop_after_predicate: function with an SSA step iterator and solver
5455
/// as argument, which should return true for the last step to keep
55-
/// \param prop_conv: solver from which to get valuations
56+
/// \param decision_procedure: solver from which to get valuations
5657
/// \param ns: namespace
5758
/// \param [out] goto_trace: trace to which the steps of the trace get appended
5859
void build_goto_trace(
5960
const symex_target_equationt &target,
6061
ssa_step_predicatet stop_after_predicate,
61-
const prop_convt &prop_conv,
62+
const decision_proceduret &decision_procedure,
6263
const namespacet &ns,
6364
goto_tracet &goto_trace);
6465

0 commit comments

Comments
 (0)