Skip to content

Commit e684b79

Browse files
authored
Merge pull request #389 from diffblue/bmc-unsupported-property
ebmc: reporting when unsupported property is given
2 parents b7c534c + 29c6839 commit e684b79

File tree

10 files changed

+118
-16
lines changed

10 files changed

+118
-16
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
bdd_unsupported_property.smv
3+
--bdd
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main::spec1\] !G main::var::x = FALSE: FAILURE: property not supported by BDD engine$
7+
^\[main::spec2\] G main::var::x = FALSE: REFUTED$
8+
--
9+
^warning: ignoring
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
MODULE main
2+
3+
VAR x : boolean;
4+
5+
ASSIGN init(x) := 1;
6+
7+
LTLSPEC !G x=0
8+
LTLSPEC G x=0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
bmc_unsupported_property1.smv
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main::spec1\] !G main::var::x = FALSE: FAILURE: property not supported by BMC engine$
7+
^\[main::spec2\] G main::var::x = FALSE: REFUTED$
8+
--
9+
^warning: ignoring
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
MODULE main
2+
3+
VAR x : boolean;
4+
5+
ASSIGN init(x) := 1;
6+
7+
LTLSPEC !G x=0
8+
LTLSPEC G x=0
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
CORE
2+
bmc_unsupported_property2.smv
3+
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
^\[main::spec1\] !G main::var::x = FALSE: FAILURE: property not supported by BMC engine$
7+
^\[main::spec2\] G main::var::x = TRUE: PROVED up to bound 1$
8+
--
9+
^warning: ignoring
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MODULE main
2+
3+
VAR x : boolean;
4+
5+
ASSIGN init(x) := 1;
6+
ASSIGN next(x) := x;
7+
8+
LTLSPEC !G x=0 -- unsupported
9+
LTLSPEC G x=1 -- should pass

src/ebmc/bmc.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ void bmc(
4646
if(property.is_disabled() || property.is_failure())
4747
continue;
4848

49+
// Is it supported by the BMC engine?
50+
if(!bmc_supports_property(property.expr))
51+
{
52+
property.failure("property not supported by BMC engine");
53+
continue;
54+
}
55+
4956
::property(
5057
property.expr,
5158
property.timeframe_handles,

src/trans-netlist/unwind_netlist.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@ Author: Daniel Kroening, [email protected]
77
\*******************************************************************/
88

99
#include "unwind_netlist.h"
10-
#include "instantiate_netlist.h"
1110

1211
#include <util/ebmc_util.h>
1312

13+
#include <temporal-logic/temporal_expr.h>
14+
#include <verilog/sva_expr.h>
15+
16+
#include "instantiate_netlist.h"
17+
1418
/*******************************************************************\
1519
1620
Function: unwind
@@ -175,12 +179,18 @@ void unwind_property(
175179
prop_bv.resize(map.get_no_timeframes(), const_literal(true));
176180
return;
177181
}
178-
179-
if(property_expr.id()!=ID_AG &&
180-
property_expr.id()!=ID_sva_always)
181-
throw "unsupported property - only SVA always implemented";
182182

183-
const exprt &p = to_unary_expr(property_expr).op();
183+
// We want AG p.
184+
auto &p = [](const exprt &expr) -> const exprt & {
185+
if(expr.id() == ID_AG)
186+
return to_AG_expr(expr).op();
187+
else if(expr.id() == ID_G)
188+
return to_G_expr(expr).op();
189+
else if(expr.id() == ID_sva_always)
190+
return to_sva_always_expr(expr).op();
191+
else
192+
PRECONDITION(false);
193+
}(property_expr);
184194

185195
for(unsigned c=0; c<map.get_no_timeframes(); c++)
186196
{

src/trans-word-level/property.cpp

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,41 @@ Author: Daniel Kroening, [email protected]
1313
#include <util/std_expr.h>
1414
#include <util/symbol_table.h>
1515

16+
#include <temporal-logic/temporal_expr.h>
17+
#include <verilog/sva_expr.h>
18+
1619
#include "instantiate_word_level.h"
1720

1821
#include <cstdlib>
1922

2023
/*******************************************************************\
2124
25+
Function: bmc_supports_property
26+
27+
Inputs:
28+
29+
Outputs:
30+
31+
Purpose:
32+
33+
\*******************************************************************/
34+
35+
bool bmc_supports_property(const exprt &expr)
36+
{
37+
if(expr.is_constant())
38+
return true;
39+
else if(expr.id() == ID_AG)
40+
return true;
41+
else if(expr.id() == ID_G)
42+
return true;
43+
else if(expr.id() == ID_sva_always)
44+
return true;
45+
else
46+
return false;
47+
}
48+
49+
/*******************************************************************\
50+
2251
Function: property
2352
2453
Inputs:
@@ -45,16 +74,17 @@ void property(
4574
return;
4675
}
4776

48-
if(
49-
property_expr.id() != ID_AG && property_expr.id() != ID_G &&
50-
property_expr.id() != ID_sva_always)
51-
{
52-
message.error() << "unsupported property - only SVA always implemented"
53-
<< messaget::eom;
54-
exit(1);
55-
}
56-
57-
const exprt &p = to_unary_expr(property_expr).op();
77+
// We want AG p.
78+
auto &p = [](const exprt &expr) -> const exprt & {
79+
if(expr.id() == ID_AG)
80+
return to_AG_expr(expr).op();
81+
else if(expr.id() == ID_G)
82+
return to_G_expr(expr).op();
83+
else if(expr.id() == ID_sva_always)
84+
return to_sva_always_expr(expr).op();
85+
else
86+
PRECONDITION(false);
87+
}(property_expr);
5888

5989
for(std::size_t c = 0; c < no_timeframes; c++)
6090
{

src/trans-word-level/property.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ void property(
2323
std::size_t no_timeframes,
2424
const namespacet &);
2525

26+
/// Is the given property supported by word-level unwinding?
27+
bool bmc_supports_property(const exprt &);
28+
2629
/// Adds a constraint that can be used to determine whether the
2730
/// given state has already been seen earlier in the trace.
2831
void lasso_constraints(

0 commit comments

Comments
 (0)