Skip to content

Commit 72371ed

Browse files
committed
ebmc: netlist unwinding now uses netlist property node
Instead of doing its own expression conversion, netlist unwinding now uses the netlist node given in the netlist property datastructure.
1 parent 57e0c27 commit 72371ed

File tree

7 files changed

+35
-89
lines changed

7 files changed

+35
-89
lines changed

src/ebmc/bdd_engine.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,10 @@ void bdd_enginet::compute_counterexample(
364364
propertyt &property,
365365
unsigned number_of_timeframes)
366366
{
367+
// Supported by BMC engine?
368+
if(!netlist_bmc_supports_property(property.normalized_expr))
369+
return;
370+
367371
message.status() << "Computing counterexample with " << number_of_timeframes
368372
<< " timeframe(s)" << messaget::eom;
369373

@@ -372,16 +376,14 @@ void bdd_enginet::compute_counterexample(
372376
satcheckt solver{message.get_message_handler()};
373377
bmc_map.map_timeframes(netlist, number_of_timeframes, solver);
374378

375-
const namespacet ns(transition_system.symbol_table);
376-
377379
::unwind(netlist, bmc_map, message, solver);
380+
381+
// find the netlist property
382+
auto netlist_property = netlist.properties.find(property.identifier);
383+
CHECK_RETURN(netlist_property != netlist.properties.end());
384+
378385
::unwind_property(
379-
property.normalized_expr,
380-
property.timeframe_literals,
381-
message.get_message_handler(),
382-
solver,
383-
bmc_map,
384-
ns);
386+
netlist_property->second, bmc_map, property.timeframe_literals);
385387

386388
// we need the propertyt to fail in one of the timeframes
387389
bvt clause=property.timeframe_literals;
@@ -402,6 +404,8 @@ void bdd_enginet::compute_counterexample(
402404
throw "unexpected result from SAT solver";
403405
}
404406

407+
const namespacet ns(transition_system.symbol_table);
408+
405409
property.witness_trace =
406410
compute_trans_trace(property.timeframe_literals, bmc_map, solver, ns);
407411
}

src/ebmc/ebmc_base.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,13 +208,12 @@ int ebmc_baset::do_bit_level_bmc(cnft &solver, bool convert_only)
208208
continue;
209209
}
210210

211+
// look up the property in the netlist
212+
auto netlist_property = netlist.properties.find(property.identifier);
213+
CHECK_RETURN(netlist_property != netlist.properties.end());
214+
211215
::unwind_property(
212-
property.normalized_expr,
213-
property.timeframe_literals,
214-
message.get_message_handler(),
215-
solver,
216-
bmc_map,
217-
ns);
216+
netlist_property->second, bmc_map, property.timeframe_literals);
218217

219218
// freeze for incremental usage
220219
for(auto l : property.timeframe_literals)

src/ebmc/ebmc_properties.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,8 @@ ebmc_propertiest ebmc_propertiest::from_transition_system(
6767

6868
properties.properties.push_back(propertyt());
6969
properties.properties.back().number = properties.properties.size() - 1;
70-
71-
if(symbol.pretty_name.empty())
72-
properties.properties.back().name = symbol.name;
73-
else
74-
properties.properties.back().name = symbol.pretty_name;
75-
70+
properties.properties.back().identifier = symbol.name;
71+
properties.properties.back().name = symbol.display_name();
7672
properties.properties.back().original_expr = symbol.value;
7773
properties.properties.back().normalized_expr =
7874
normalize_property(symbol.value);

src/ebmc/ebmc_properties.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ebmc_propertiest
2626
{
2727
public:
2828
std::size_t number = 0;
29-
irep_idt name;
29+
irep_idt identifier, name;
3030
source_locationt location;
3131
std::string expr_string;
3232
irep_idt mode;

src/ebmc/report_results.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ void report_results(
5555
continue;
5656

5757
json_objectt json_property;
58-
json_property["identifier"] = json_stringt(id2string(property.name));
58+
json_property["identifier"] =
59+
json_stringt(id2string(property.identifier));
5960
json_property["status"] = json_stringt(property.status_as_string());
6061

6162
if(property.has_witness_trace())
@@ -77,7 +78,7 @@ void report_results(
7778
continue;
7879

7980
xmlt xml_result("result");
80-
xml_result.set_attribute("property", id2string(property.name));
81+
xml_result.set_attribute("property", id2string(property.identifier));
8182
xml_result.set_attribute("status", property.status_as_string());
8283

8384
if(property.has_witness_trace())

src/trans-netlist/unwind_netlist.cpp

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void unwind(
3434
messaget &message,
3535
cnft &solver,
3636
bool add_initial_state,
37-
unsigned t)
37+
std::size_t t)
3838
{
3939
bool first=(t==0);
4040
bool last=(t==bmc_map.timeframe_map.size()-1);
@@ -123,7 +123,7 @@ void unwind(
123123
cnft &solver,
124124
bool add_initial_state)
125125
{
126-
for(unsigned t=0; t<bmc_map.timeframe_map.size(); t++)
126+
for(std::size_t t = 0; t < bmc_map.timeframe_map.size(); t++)
127127
unwind(netlist, bmc_map, message, solver, add_initial_state, t);
128128
}
129129

@@ -140,15 +140,16 @@ Function: unwind_property
140140
\*******************************************************************/
141141

142142
void unwind_property(
143+
const netlistt::propertyt &property,
143144
const bmc_mapt &bmc_map,
144-
literalt property_node,
145145
bvt &prop_bv)
146146
{
147+
PRECONDITION(std::holds_alternative<netlistt::Gpt>(property));
148+
auto property_node = std::get<netlistt::Gpt>(property).p;
149+
147150
prop_bv.resize(bmc_map.timeframe_map.size());
148151

149-
for(unsigned t=0;
150-
t<bmc_map.timeframe_map.size();
151-
t++)
152+
for(std::size_t t = 0; t < bmc_map.timeframe_map.size(); t++)
152153
{
153154
literalt l=bmc_map.translate(t, property_node);
154155
prop_bv[t]=l;
@@ -157,51 +158,6 @@ void unwind_property(
157158

158159
/*******************************************************************\
159160
160-
Function: unwind_property
161-
162-
Inputs:
163-
164-
Outputs:
165-
166-
Purpose:
167-
168-
\*******************************************************************/
169-
170-
void unwind_property(
171-
const exprt &property_expr,
172-
bvt &prop_bv,
173-
message_handlert &message_handler,
174-
propt &solver,
175-
const bmc_mapt &map,
176-
const namespacet &ns)
177-
{
178-
if(property_expr.is_true())
179-
{
180-
prop_bv.resize(map.get_no_timeframes(), const_literal(true));
181-
return;
182-
}
183-
184-
// We want AG p.
185-
auto &p = [](const exprt &expr) -> const exprt & {
186-
if(expr.id() == ID_AG)
187-
return to_AG_expr(expr).op();
188-
else if(expr.id() == ID_G)
189-
return to_G_expr(expr).op();
190-
else if(expr.id() == ID_sva_always)
191-
return to_sva_always_expr(expr).op();
192-
else
193-
PRECONDITION(false);
194-
}(property_expr);
195-
196-
for(unsigned c=0; c<map.get_no_timeframes(); c++)
197-
{
198-
literalt l=instantiate_convert(solver, map, p, c, c+1, ns, message_handler);
199-
prop_bv.push_back(l);
200-
}
201-
}
202-
203-
/*******************************************************************\
204-
205161
Function: netlist_bmc_supports_property
206162
207163
Inputs:

src/trans-netlist/unwind_netlist.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ Author: Daniel Kroening, kroening@kroening.com
1010
#define CPROVER_TRANS_UNWIND_NETLIST_GRAPH_H
1111

1212
#include <util/message.h>
13-
#include <util/namespace.h>
1413

1514
#include <solvers/sat/cnf.h>
1615

17-
#include "netlist.h"
1816
#include "bmc_map.h"
17+
#include "netlist.h"
1918

2019
void unwind(
2120
const netlistt &netlist,
@@ -31,24 +30,15 @@ void unwind(
3130
messaget &message,
3231
cnft &solver,
3332
bool add_initial_state,
34-
unsigned timeframe);
35-
36-
// unwind a property that has not yet been converted
37-
void unwind_property(
38-
const exprt &property_expr,
39-
bvt &prop_bv,
40-
message_handlert &,
41-
propt &solver,
42-
const bmc_mapt &,
43-
const namespacet &);
33+
std::size_t timeframe);
4434

4535
// Is the property supported?
46-
bool netlist_bmc_supports_property(const exprt &);
36+
bool netlist_bmc_supports_property(const class exprt &);
4737

48-
// unwind a property that is given as netlist node
38+
// unwind a netlist property
4939
void unwind_property(
40+
const netlistt::propertyt &,
5041
const bmc_mapt &,
51-
literalt property_node,
5242
bvt &prop_bv);
5343

5444
#endif

0 commit comments

Comments
 (0)