10
10
11
11
#include < util/cmdline.h>
12
12
#include < util/config.h>
13
- #include < util/expr_util.h>
14
- #include < util/string2int.h>
15
13
16
- #include < solvers/prop/literal_expr.h>
17
- #include < solvers/sat/satcheck.h>
18
14
#include < trans-netlist/compute_ct.h>
19
15
#include < trans-netlist/ldg.h>
20
16
#include < trans-netlist/trans_to_netlist.h>
21
- #include < trans-netlist/trans_trace_netlist.h>
22
- #include < trans-netlist/unwind_netlist.h>
23
- #include < trans-word-level/trans_trace_word_level.h>
24
- #include < trans-word-level/unwind.h>
25
17
26
- #include " dimacs_writer.h"
27
18
#include " ebmc_error.h"
28
- #include " ebmc_solver_factory.h"
29
19
#include " ebmc_version.h"
30
- #include " output_file.h"
31
- #include " report_results.h"
32
20
33
- #include < chrono>
34
21
#include < iostream>
35
22
36
23
/* ******************************************************************\
@@ -54,260 +41,6 @@ ebmc_baset::ebmc_baset(
54
41
55
42
/* ******************************************************************\
56
43
57
- Function: ebmc_baset::finish_bit_level_bmc
58
-
59
- Inputs:
60
-
61
- Outputs:
62
-
63
- Purpose:
64
-
65
- \*******************************************************************/
66
-
67
- int ebmc_baset::finish_bit_level_bmc (const bmc_mapt &bmc_map, propt &solver)
68
- {
69
- auto sat_start_time = std::chrono::steady_clock::now ();
70
-
71
- message.status () << " Solving with " << solver.solver_text () << messaget::eom;
72
-
73
- for (propertyt &property : properties.properties )
74
- {
75
- if (property.is_disabled ())
76
- continue ;
77
-
78
- if (property.is_failure ())
79
- continue ;
80
-
81
- if (property.is_assumed ())
82
- continue ;
83
-
84
- message.status () << " Checking " << property.name << messaget::eom;
85
-
86
- literalt property_literal=!solver.land (property.timeframe_literals );
87
-
88
- bvt assumptions;
89
- assumptions.push_back (property_literal);
90
-
91
- propt::resultt prop_result = solver.prop_solve (assumptions);
92
-
93
- switch (prop_result)
94
- {
95
- case propt::resultt::P_SATISFIABLE:
96
- {
97
- property.refuted ();
98
- message.result () << " SAT: counterexample found" << messaget::eom;
99
-
100
- namespacet ns (transition_system.symbol_table );
101
-
102
- property.witness_trace =
103
- compute_trans_trace (property.timeframe_literals , bmc_map, solver, ns);
104
- }
105
- break ;
106
-
107
- case propt::resultt::P_UNSATISFIABLE:
108
- message.result () << " UNSAT: No counterexample found within bound"
109
- << messaget::eom;
110
- property.proved_with_bound (bound);
111
- break ;
112
-
113
- case propt::resultt::P_ERROR:
114
- message.error () << " Error from decision procedure" << messaget::eom;
115
- return 2 ;
116
-
117
- default :
118
- message.error () << " Unexpected result from decision procedure"
119
- << messaget::eom;
120
- return 1 ;
121
- }
122
- }
123
-
124
- auto sat_stop_time = std::chrono::steady_clock::now ();
125
-
126
- message.statistics ()
127
- << " Solver time: "
128
- << std::chrono::duration<double >(sat_stop_time - sat_start_time).count ()
129
- << messaget::eom;
130
-
131
- return properties.exit_code ();
132
- }
133
-
134
- /* ******************************************************************\
135
-
136
- Function: ebmc_baset::get_bound
137
-
138
- Inputs:
139
-
140
- Outputs:
141
-
142
- Purpose:
143
-
144
- \*******************************************************************/
145
-
146
- bool ebmc_baset::get_bound ()
147
- {
148
- if (!cmdline.isset (" bound" ))
149
- {
150
- message.warning () << " using default bound 1" << messaget::eom;
151
- bound=1 ;
152
- return false ;
153
- }
154
-
155
- bound=unsafe_string2unsigned (cmdline.get_value (" bound" ));
156
-
157
- return false ;
158
- }
159
-
160
- /* ******************************************************************\
161
-
162
- Function: ebmc_baset::do_bit_level_bmc
163
-
164
- Inputs:
165
-
166
- Outputs:
167
-
168
- Purpose:
169
-
170
- \*******************************************************************/
171
-
172
- int ebmc_baset::do_bit_level_bmc (cnft &solver, bool convert_only)
173
- {
174
- if (get_bound ()) return 1 ;
175
-
176
- int result;
177
-
178
- try
179
- {
180
- bmc_mapt bmc_map;
181
-
182
- if (!convert_only)
183
- if (properties.properties .empty ())
184
- throw " no properties" ;
185
-
186
- netlistt netlist;
187
- if (make_netlist (netlist))
188
- throw 0 ;
189
-
190
- message.status () << " Unwinding Netlist" << messaget::eom;
191
-
192
- bmc_map.map_timeframes (netlist, bound+1 , solver);
193
-
194
- ::unwind (netlist, bmc_map, message, solver);
195
-
196
- const namespacet ns (transition_system.symbol_table );
197
-
198
- // convert the properties
199
- for (propertyt &property : properties.properties )
200
- {
201
- if (property.is_disabled ())
202
- continue ;
203
-
204
- if (!netlist_bmc_supports_property (property.normalized_expr ))
205
- {
206
- property.failure (" property not supported by netlist BMC engine" );
207
- continue ;
208
- }
209
-
210
- // look up the property in the netlist
211
- auto netlist_property = netlist.properties .find (property.identifier );
212
- CHECK_RETURN (netlist_property != netlist.properties .end ());
213
-
214
- ::unwind_property (
215
- netlist_property->second, bmc_map, property.timeframe_literals);
216
-
217
- if (property.is_assumed ())
218
- {
219
- // force these to be true
220
- for (auto l : property.timeframe_literals )
221
- solver.l_set_to (l, true );
222
- }
223
- else
224
- {
225
- // freeze for incremental usage
226
- for (auto l : property.timeframe_literals )
227
- solver.set_frozen (l);
228
- }
229
- }
230
-
231
- if (convert_only)
232
- result=0 ;
233
- else
234
- {
235
- result = finish_bit_level_bmc (bmc_map, solver);
236
- report_results (cmdline, properties, ns, message.get_message_handler ());
237
- }
238
- }
239
-
240
- catch (const char *e)
241
- {
242
- message.error () << e << messaget::eom;
243
- return 10 ;
244
- }
245
-
246
- catch (const std::string &e)
247
- {
248
- message.error () << e << messaget::eom;
249
- return 10 ;
250
- }
251
-
252
- catch (int )
253
- {
254
- return 10 ;
255
- }
256
-
257
- return result;
258
- }
259
-
260
- /* ******************************************************************\
261
-
262
- Function: ebmc_baset::do_bit_level_bmc
263
-
264
- Inputs:
265
-
266
- Outputs:
267
-
268
- Purpose:
269
-
270
- \*******************************************************************/
271
-
272
- int ebmc_baset::do_bit_level_bmc ()
273
- {
274
- if (cmdline.isset (" dimacs" ))
275
- {
276
- if (cmdline.isset (" outfile" ))
277
- {
278
- auto outfile = output_filet{cmdline.get_value (" outfile" )};
279
-
280
- message.status () << " Writing DIMACS CNF to `" << outfile.name () << " '"
281
- << messaget::eom;
282
-
283
- dimacs_cnf_writert dimacs_cnf_writer{
284
- outfile.stream (), message.get_message_handler ()};
285
-
286
- return do_bit_level_bmc (dimacs_cnf_writer, true );
287
- }
288
- else
289
- {
290
- dimacs_cnf_writert dimacs_cnf_writer{
291
- std::cout, message.get_message_handler ()};
292
-
293
- return do_bit_level_bmc (dimacs_cnf_writer, true );
294
- }
295
- }
296
- else
297
- {
298
- if (cmdline.isset (" outfile" ))
299
- throw ebmc_errort ()
300
- << " Cannot write to outfile without file format option" ;
301
-
302
- satcheckt satcheck{message.get_message_handler ()};
303
-
304
- message.status () << " Using " << satcheck.solver_text () << messaget::eom;
305
-
306
- return do_bit_level_bmc (satcheck, false );
307
- }
308
- }
309
- /* ******************************************************************\
310
-
311
44
Function: ebmc_baset::get_properties
312
45
313
46
Inputs:
0 commit comments