cprover
Loading...
Searching...
No Matches
single_loop_incremental_symex_checker.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: Goto Checker using Multi-Path Symbolic Execution
4 with Incremental Unwinding of a specified Loop
5
6Author: Daniel Kroening, Peter Schrammel
7
8\*******************************************************************/
9
13
15
17
18#include <goto-symex/slice.h>
19
20#include "bmc_util.h"
22
24 const optionst &options,
29 ns(goto_model.get_symbol_table(), symex_symbol_table),
31 symex(
33 goto_model.get_symbol_table(),
35 options,
39 ui_message_handler.get_ui()),
41{
42 unwindset.parse_unwind(options.get_option("unwind"));
43 unwindset.parse_unwindset(
44 options.get_list_option("unwindset"), goto_model, ui_message_handler);
45
46 // Freeze all symbols if we are using a prop_conv_solvert
47 prop_conv_solvert *prop_conv_solver = dynamic_cast<prop_conv_solvert *>(
48 &property_decider.get_decision_procedure());
49 if(prop_conv_solver != nullptr)
50 prop_conv_solver->set_all_frozen();
51}
52
54 const propertiest &properties,
55 messaget &message_hander)
56{
57 const auto any_failures = std::any_of(
58 properties.begin(),
59 properties.end(),
60 [](const std::pair<irep_idt, property_infot> &property) {
61 return property.second.status == property_statust::FAIL;
62 });
63 std::string status = any_failures ? "FAILURE" : "INCONCLUSIVE";
64 structured_datat incremental_status{
65 {{labelt({"incremental", "status"}),
67 message_hander.statistics() << incremental_status;
68}
69
71operator()(propertiest &properties)
72{
73 resultt result(resultt::progresst::DONE);
74
75 std::chrono::duration<double> solver_runtime(0);
76
77 // we haven't got an equation yet
79 {
80 full_equation_generated = !symex.from_entry_point_of(
82
83 // This might add new properties such as unwinding assertions, for instance.
85 properties, result.updated_properties, equation);
86
88 }
89
90 while(has_properties_to_check(properties))
91 {
92 // There are NOT_CHECKED or UNKNOWN properties.
93
95 {
96 // We have UNKNOWN properties, i.e. properties that we can check
97 // on the current equation.
98
99 log.status()
100 << "Passing problem to "
101 << property_decider.get_decision_procedure().decision_procedure_text()
102 << messaget::eom;
103
104 const auto solver_start = std::chrono::steady_clock::now();
105
107 {
109
110 log.status() << "converting SSA" << messaget::eom;
111 equation.convert_without_assertions(
112 property_decider.get_decision_procedure());
113
114 property_decider.update_properties_goals_from_symex_target_equation(
115 properties);
116
117 // We convert the assertions in a new context.
118 property_decider.get_decision_procedure().push();
119 equation.convert_assertions(
120 property_decider.get_decision_procedure(), false);
121 property_decider.convert_goals();
122
124 }
125
126 property_decider.add_constraint_from_goals(
127 [&properties](const irep_idt &property_id) {
128 return is_property_to_check(properties.at(property_id).status);
129 });
130
131 log.status()
132 << "Running "
133 << property_decider.get_decision_procedure().decision_procedure_text()
134 << messaget::eom;
135
137
138 property_decider.update_properties_status_from_goals(
139 properties, result.updated_properties, dec_result, false);
140
141 const auto solver_stop = std::chrono::steady_clock::now();
142 solver_runtime +=
143 std::chrono::duration<double>(solver_stop - solver_start);
144 log.status() << "Runtime decision procedure: " << solver_runtime.count()
145 << "s" << messaget::eom;
146
147 result.progress =
149 ? resultt::progresst::FOUND_FAIL
150 : resultt::progresst::DONE;
151
152 // We've got a trace to report.
153 if(result.progress == resultt::progresst::FOUND_FAIL)
154 break;
155
156 // Nothing else to do with the current set of assertions.
157 // Let's pop them.
158 property_decider.get_decision_procedure().pop();
159 }
160
161 // Now we are finally done.
163 {
164 // For now, we assume that UNKNOWN properties are PASS.
166 properties, result.updated_properties);
167
168 // For now, we assume that NOT_REACHED properties are PASS.
170 properties, result.updated_properties);
171
172 break;
173 }
174
175 output_incremental_status(properties, log);
176
177 // We continue symbolic execution
181
182 // This might add new properties such as unwinding assertions, for instance.
184 properties, result.updated_properties, equation);
185
187 }
188
189 return result;
190}
191
193{
194 goto_tracet goto_trace;
196 equation,
197 equation.SSA_steps.end(),
198 property_decider.get_decision_procedure(),
199 ns,
200 goto_trace);
201
202 return goto_trace;
203}
204
206{
207 if(options.get_bool_option("beautify"))
208 {
209 // NOLINTNEXTLINE(whitespace/braces)
211 property_decider.get_boolbv_decision_procedure(), equation);
212 }
213
214 goto_tracet goto_trace;
216 equation, property_decider.get_decision_procedure(), ns, goto_trace);
217
218 return goto_trace;
219}
220
222 const irep_idt &property_id) const
223{
224 goto_tracet goto_trace;
226 equation,
228 property_decider.get_decision_procedure(),
229 ns,
230 goto_trace);
231
232 return goto_trace;
233}
234
239
244
void update_status_of_unknown_properties(propertiest &properties, std::unordered_set< irep_idt > &updated_properties)
Sets the property status of UNKNOWN properties to PASS.
Definition bmc_util.cpp:268
void update_properties_status_from_symex_target_equation(propertiest &properties, std::unordered_set< irep_idt > &updated_properties, const symex_target_equationt &equation)
Sets property status to PASS for properties whose conditions are constant true in the equation.
Definition bmc_util.cpp:216
void update_status_of_not_checked_properties(propertiest &properties, std::unordered_set< irep_idt > &updated_properties)
Sets the property status of NOT_CHECKED properties to PASS.
Definition bmc_util.cpp:252
ssa_step_predicatet ssa_step_matches_failing_property(const irep_idt &property_id)
Returns a function that checks whether an SSA step is an assertion with property_id.
Definition bmc_util.cpp:51
void output_graphml(const goto_tracet &goto_trace, const namespacet &ns, const optionst &options)
outputs an error witness in graphml format
Definition bmc_util.cpp:105
void postprocess_equation(symex_bmct &symex, symex_target_equationt &equation, const optionst &options, const namespacet &ns, ui_message_handlert &ui_message_handler)
Post process the equation.
Definition bmc_util.cpp:300
Bounded Model Checking Utilities.
void build_goto_trace(const symex_target_equationt &target, ssa_step_predicatet is_last_step_to_keep, const decision_proceduret &decision_procedure, const namespacet &ns, goto_tracet &goto_trace)
Build a trace by going through the steps of target and stopping after the step matching a given condi...
Abstract interface to eager or lazy GOTO models.
resultt
Result of running the decision procedure.
static get_goto_functiont get_goto_function(abstract_goto_modelt &goto_model)
Return a function to get/load a goto function from the given goto model Create a default delegate to ...
Trace of a GOTO program.
Definition goto_trace.h:177
ui_message_handlert & ui_message_handler
Class that provides messages with a built-in verbosity 'level'.
Definition message.h:154
mstreamt & statistics() const
Definition message.h:411
static eomt eom
Definition message.h:289
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition namespace.h:91
goto_tracet build_trace(const irep_idt &) const override
Builds and returns the trace for the FAILed property with the given property_id.
goto_tracet build_shortest_trace() const override
Builds and returns the trace up to the first failed property.
resultt operator()(propertiest &) override
Check whether the given properties with status NOT_CHECKED, UNKNOWN or properties newly discovered by...
single_loop_incremental_symex_checkert(const optionst &options, ui_message_handlert &ui_message_handler, abstract_goto_modelt &goto_model)
goto_tracet build_full_trace() const override
Builds and returns the complete trace.
const namespacet & get_namespace() const override
Returns the namespace associated with the traces.
A way of representing nested key/value data.
Counterexample Beautification.
bool has_properties_to_check(const propertiest &properties)
Return true if there as a property with NOT_CHECKED or UNKNOWN status.
bool is_property_to_check(property_statust status)
Return true if the status is NOT_CHECKED or UNKNOWN.
std::size_t count_properties(const propertiest &properties, property_statust status)
Return the number of properties with given status.
@ UNKNOWN
The checker was unable to determine the status of the property.
Definition properties.h:30
std::map< irep_idt, property_infot > propertiest
A map of property IDs to property infos.
Definition properties.h:76
void output_incremental_status(const propertiest &properties, messaget &message_hander)
Goto Checker using multi-path symbolic execution with incremental unwinding of a specified loop.
void revert_slice(symex_target_equationt &equation)
Undo whatever has been done by slice.
Definition slice.cpp:261
Slicer for symex traces.
std::unordered_set< irep_idt > updated_properties
Changed properties since the last call to incremental_goto_checkert::operator().
static structured_data_entryt data_node(const jsont &data)
dstringt irep_idt