Skip to content

Commit a59dcd5

Browse files
committed
move bit-level BMC to property_checker
This moves the bit-level BMC engine invocation from ebmc_baset to property_checker(...).
1 parent 0fc2ab6 commit a59dcd5

File tree

5 files changed

+278
-287
lines changed

5 files changed

+278
-287
lines changed

src/ebmc/ebmc_base.cpp

Lines changed: 0 additions & 267 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,14 @@ Author: Daniel Kroening, [email protected]
1010

1111
#include <util/cmdline.h>
1212
#include <util/config.h>
13-
#include <util/expr_util.h>
14-
#include <util/string2int.h>
1513

16-
#include <solvers/prop/literal_expr.h>
17-
#include <solvers/sat/satcheck.h>
1814
#include <trans-netlist/compute_ct.h>
1915
#include <trans-netlist/ldg.h>
2016
#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>
2517

26-
#include "dimacs_writer.h"
2718
#include "ebmc_error.h"
28-
#include "ebmc_solver_factory.h"
2919
#include "ebmc_version.h"
30-
#include "output_file.h"
31-
#include "report_results.h"
3220

33-
#include <chrono>
3421
#include <iostream>
3522

3623
/*******************************************************************\
@@ -54,260 +41,6 @@ ebmc_baset::ebmc_baset(
5441

5542
/*******************************************************************\
5643
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-
31144
Function: ebmc_baset::get_properties
31245
31346
Inputs:

src/ebmc/ebmc_base.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ class ebmc_baset
4343
messaget message;
4444
const cmdlinet &cmdline;
4545

46-
bool get_bound();
47-
48-
// bit-level
49-
int do_bit_level_bmc(cnft &solver, bool convert_only);
50-
int finish_bit_level_bmc(const bmc_mapt &bmc_map, propt &solver);
51-
5246
bool parse_property(const std::string &property);
5347
bool get_model_properties();
5448
void show_properties();
@@ -63,7 +57,6 @@ class ebmc_baset
6357

6458
public:
6559
int do_compute_ct();
66-
int do_bit_level_bmc();
6760
};
6861

6962
#endif

src/ebmc/ebmc_parse_options.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -304,14 +304,11 @@ int ebmc_parse_optionst::doit()
304304
if(cmdline.isset("compute-ct"))
305305
return ebmc_base.do_compute_ct();
306306

307-
if(cmdline.isset("aig") || cmdline.isset("dimacs"))
308-
return ebmc_base.do_bit_level_bmc();
309-
else
310-
return property_checker(
311-
cmdline,
312-
ebmc_base.transition_system,
313-
ebmc_base.properties,
314-
ui_message_handler);
307+
return property_checker(
308+
cmdline,
309+
ebmc_base.transition_system,
310+
ebmc_base.properties,
311+
ui_message_handler);
315312
}
316313
}
317314
catch(const ebmc_errort &ebmc_error)

0 commit comments

Comments
 (0)