Skip to content

Commit 17c6986

Browse files
author
Daniel Kroening
committed
switch ssa_stept to handles
'Handles' more general than the literalt data structure, which is specific to propositional, CNF-based SAT.
1 parent 02c1d1a commit 17c6986

9 files changed

+36
-51
lines changed

src/goto-checker/bmc_util.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ssa_step_matches_failing_property(const irep_idt &property_id)
5858
symex_target_equationt::SSA_stepst::const_iterator step,
5959
const prop_convt &prop_conv) {
6060
return step->is_assert() && step->get_property_id() == property_id &&
61-
prop_conv.l_get(step->cond_literal).is_false();
61+
prop_conv.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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void counterexample_beautificationt::get_minimization_list(
4141
it->is_assignment() &&
4242
it->assignment_type == symex_targett::assignment_typet::STATE)
4343
{
44-
if(!prop_conv.l_get(it->guard_literal).is_false())
44+
if(!prop_conv.get(it->guard_handle).is_false())
4545
{
4646
const typet &type = it->ssa_lhs.type();
4747

@@ -78,10 +78,14 @@ counterexample_beautificationt::get_failed_property(
7878
equation.SSA_steps.begin();
7979
it != equation.SSA_steps.end();
8080
it++)
81+
{
8182
if(
82-
it->is_assert() && prop_conv.l_get(it->guard_literal).is_true() &&
83-
prop_conv.l_get(it->cond_literal).is_false())
83+
it->is_assert() && prop_conv.get(it->guard_handle).is_true() &&
84+
prop_conv.get(it->cond_handle).is_false())
85+
{
8486
return it;
87+
}
88+
}
8589

8690
UNREACHABLE;
8791
return equation.SSA_steps.end();
@@ -95,7 +99,7 @@ operator()(boolbvt &boolbv, const symex_target_equationt &equation)
9599
failed = get_failed_property(boolbv, equation);
96100

97101
// lock the failed assertion
98-
boolbv.set_to(literal_exprt(failed->cond_literal), false);
102+
boolbv.set_to(failed->cond_handle, false);
99103

100104
{
101105
log.status() << "Beautifying counterexample (guards)" << messaget::eom;
@@ -113,8 +117,9 @@ operator()(boolbvt &boolbv, const symex_target_equationt &equation)
113117
it->is_assignment() &&
114118
it->assignment_type != symex_targett::assignment_typet::HIDDEN)
115119
{
116-
if(!it->guard_literal.is_constant())
117-
guard_count[it->guard_literal]++;
120+
literalt l = boolbv.convert(it->guard_handle);
121+
if(!l.is_constant())
122+
guard_count[l]++;
118123
}
119124

120125
// 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+
if(!step.guard_handle.is_constant())
6262
{
6363
auto emplace_result = fault_location.scores.emplace(step.source.pc, 0);
64-
localization_points.emplace(step.guard_literal, emplace_result.first);
64+
literalt guard_literal = solver.convert(step.guard_handle);
65+
localization_points.emplace(guard_literal, 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_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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void build_goto_trace(
225225

226226
const SSA_stept &SSA_step = *it;
227227

228-
if(prop_conv.l_get(SSA_step.guard_literal)!=tvt(true))
228+
if(!prop_conv.get(SSA_step.guard_handle).is_true())
229229
continue;
230230

231231
if(it->is_constraint() ||
@@ -388,7 +388,7 @@ void build_goto_trace(
388388
goto_trace_step.cond_expr = SSA_step.cond_expr;
389389

390390
goto_trace_step.cond_value =
391-
prop_conv.l_get(SSA_step.cond_literal).is_true();
391+
prop_conv.get(SSA_step.cond_handle).is_true();
392392
}
393393

394394
if(ssa_step_it == last_step_to_keep)
@@ -417,7 +417,7 @@ static bool is_failed_assertion_step(
417417
symex_target_equationt::SSA_stepst::const_iterator step,
418418
const prop_convt &prop_conv)
419419
{
420-
return step->is_assert() && prop_conv.l_get(step->cond_literal).is_false();
420+
return step->is_assert() && prop_conv.get(step->cond_handle).is_false();
421421
}
422422

423423
void build_goto_trace(

src/goto-symex/ssa_step.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Author: Romain Brenguier <[email protected]>
1010
#define CPROVER_GOTO_SYMEX_SSA_STEP_H
1111

1212
#include <goto-programs/goto_trace.h>
13-
#include <solvers/prop/literal.h>
1413

1514
#include "symex_target.h"
1615

@@ -35,7 +34,7 @@ Author: Romain Brenguier <[email protected]>
3534
/// which represent the condition guarding this step, i.e. what must hold for
3635
/// this step to be taken. Both `guard` and `cond_expr` will later be
3736
/// translated into verification condition for the SAT/SMT solver (or some
38-
/// other decision procedure), to be referred by their respective literals.
37+
/// other decision procedure), to be referred by their respective handles.
3938
/// Constraints usually arise from external conditions, such as memory models
4039
/// or partial orders: they represent assumptions with global effect.
4140
///
@@ -136,7 +135,7 @@ class SSA_stept
136135
bool hidden = false;
137136

138137
exprt guard;
139-
literalt guard_literal;
138+
exprt guard_handle;
140139

141140
// for ASSIGNMENT and DECL
142141
ssa_exprt ssa_lhs;
@@ -146,7 +145,7 @@ class SSA_stept
146145

147146
// for ASSUME/ASSERT/GOTO/CONSTRAINT
148147
exprt cond_expr;
149-
literalt cond_literal;
148+
exprt cond_handle;
150149
std::string comment;
151150

152151
// for INPUT/OUTPUT
@@ -177,14 +176,14 @@ class SSA_stept
177176
type(_type),
178177
hidden(false),
179178
guard(static_cast<const exprt &>(get_nil_irep())),
180-
guard_literal(const_literal(false)),
179+
guard_handle(false_exprt()),
181180
ssa_lhs(static_cast<const ssa_exprt &>(get_nil_irep())),
182181
ssa_full_lhs(static_cast<const exprt &>(get_nil_irep())),
183182
original_full_lhs(static_cast<const exprt &>(get_nil_irep())),
184183
ssa_rhs(static_cast<const exprt &>(get_nil_irep())),
185184
assignment_type(symex_targett::assignment_typet::STATE),
186185
cond_expr(static_cast<const exprt &>(get_nil_irep())),
187-
cond_literal(const_literal(false)),
186+
cond_handle(false_exprt()),
188187
formatted(false),
189188
atomic_section_id(0),
190189
ignore(false)

src/goto-symex/symex_target_equation.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Author: Daniel Kroening, [email protected]
1818
#include <util/unwrap_nested_exception.h>
1919

2020
#include <solvers/flattening/bv_conversion_exceptions.h>
21-
#include <solvers/prop/literal_expr.h>
2221
#include <solvers/prop/prop.h>
2322
#include <solvers/prop/prop_conv.h>
2423

@@ -399,7 +398,7 @@ void symex_target_equationt::convert_guards(
399398
for(auto &step : SSA_steps)
400399
{
401400
if(step.ignore)
402-
step.guard_literal=const_literal(false);
401+
step.guard_handle = false_exprt();
403402
else
404403
{
405404
log.conditional_output(log.debug(), [&step](messaget::mstreamt &mstream) {
@@ -409,7 +408,7 @@ void symex_target_equationt::convert_guards(
409408

410409
try
411410
{
412-
step.guard_literal = prop_conv.convert(step.guard);
411+
step.guard_handle = prop_conv.handle(step.guard);
413412
}
414413
catch(const bitvector_conversion_exceptiont &)
415414
{
@@ -429,7 +428,7 @@ void symex_target_equationt::convert_assumptions(
429428
if(step.is_assume())
430429
{
431430
if(step.ignore)
432-
step.cond_literal=const_literal(true);
431+
step.cond_handle = true_exprt();
433432
else
434433
{
435434
log.conditional_output(
@@ -440,7 +439,7 @@ void symex_target_equationt::convert_assumptions(
440439

441440
try
442441
{
443-
step.cond_literal = prop_conv.convert(step.cond_expr);
442+
step.cond_handle = prop_conv.handle(step.cond_expr);
444443
}
445444
catch(const bitvector_conversion_exceptiont &)
446445
{
@@ -461,7 +460,7 @@ void symex_target_equationt::convert_goto_instructions(
461460
if(step.is_goto())
462461
{
463462
if(step.ignore)
464-
step.cond_literal=const_literal(true);
463+
step.cond_handle = true_exprt();
465464
else
466465
{
467466
log.conditional_output(
@@ -472,7 +471,7 @@ void symex_target_equationt::convert_goto_instructions(
472471

473472
try
474473
{
475-
step.cond_literal = prop_conv.convert(step.cond_expr);
474+
step.cond_handle = prop_conv.handle(step.cond_expr);
476475
}
477476
catch(const bitvector_conversion_exceptiont &)
478477
{
@@ -534,7 +533,7 @@ void symex_target_equationt::convert_assertions(
534533
{
535534
step.converted = true;
536535
prop_conv.set_to_false(step.cond_expr);
537-
step.cond_literal=const_literal(false);
536+
step.cond_handle = false_exprt();
538537
return; // prevent further assumptions!
539538
}
540539
else if(step.is_assume())
@@ -573,7 +572,7 @@ void symex_target_equationt::convert_assertions(
573572
// do the conversion
574573
try
575574
{
576-
step.cond_literal = prop_conv.convert(implication);
575+
step.cond_handle = prop_conv.handle(implication);
577576
}
578577
catch(const bitvector_conversion_exceptiont &)
579578
{
@@ -583,17 +582,16 @@ void symex_target_equationt::convert_assertions(
583582
}
584583

585584
// store disjunct
586-
disjuncts.push_back(literal_exprt(!step.cond_literal));
585+
disjuncts.push_back(not_exprt(step.cond_handle));
587586
}
588587
else if(step.is_assume())
589588
{
590589
// the assumptions have been converted before
591590
// avoid deep nesting of ID_and expressions
592591
if(assumption.id()==ID_and)
593-
assumption.copy_to_operands(literal_exprt(step.cond_literal));
592+
assumption.copy_to_operands(step.cond_handle);
594593
else
595-
assumption=
596-
and_exprt(assumption, literal_exprt(step.cond_literal));
594+
assumption = and_exprt(assumption, step.cond_handle);
597595
}
598596
}
599597

0 commit comments

Comments
 (0)