Skip to content

Commit c50315a

Browse files
authored
Merge pull request #1005 from diffblue/completeness_threshold
EBMC: completeness threshold engine
2 parents 4ab77d7 + fba2847 commit c50315a

File tree

11 files changed

+146
-17
lines changed

11 files changed

+146
-17
lines changed

regression/smv/expressions/smv_if2.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
smv_if2.smv
33

4-
^\[.*\] X \(b = 2 \| b = 4\): PROVED up to bound 5$
4+
^\[.*\] X \(b = 2 \| b = 4\): PROVED$
55
^EXIT=0$
66
^SIGNAL=0$
77
--

regression/smv/smv/initial1.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
initial1.smv
3-
--bound 0
4-
^\[spec1\] tmp1 = TRUE: PROVED up to bound 0$
3+
4+
^\[spec1\] tmp1 = TRUE: PROVED$
55
^\[spec2\] tmp2 = TRUE: REFUTED$
66
^EXIT=10$
77
^SIGNAL=0$

regression/verilog/SVA/initial1.desc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
CORE
22
initial1.sv
3-
--module main --bound 1
4-
^\[main\.p0\] main\.counter == 0: PROVED up to bound 1$
3+
--module main
4+
^\[main\.p0\] main\.counter == 0: PROVED$
55
^\[main\.p1\] main\.counter == 100: REFUTED$
6-
^\[main\.p2\] ##1 main\.counter == 1: PROVED up to bound 1$
6+
^\[main\.p2\] ##1 main\.counter == 1: PROVED up to bound 5$
77
^\[main\.p3\] ##1 main\.counter == 100: REFUTED$
8-
^\[main\.p4\] s_nexttime main\.counter == 1: PROVED up to bound 1$
8+
^\[main\.p4\] s_nexttime main\.counter == 1: PROVED$
99
^EXIT=10$
1010
^SIGNAL=0$
1111
--

regression/verilog/SVA/initial2.desc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CORE
22
initial2.sv
3-
--module main --bound 1
4-
^\[main\.assert\.1\] main\.counter == 1: PROVED up to bound 1
5-
^\[main\.assert\.2\] main\.counter == 2: PROVED up to bound 1
3+
--module main
4+
^\[main\.assert\.1\] main\.counter == 1: PROVED$
5+
^\[main\.assert\.2\] main\.counter == 2: PROVED$
66
^EXIT=0$
77
^SIGNAL=0$
88
--

regression/verilog/SVA/sequence5.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
CORE
22
sequence5.sv
33

4-
^\[main\.p0\] 1: PROVED up to bound 5$
4+
^\[main\.p0\] 1: PROVED$
55
^\[main\.p1\] 0: REFUTED$
66
^\[main\.p2\] 1'bx: REFUTED$
77
^\[main\.p3\] 1'bz: REFUTED$

regression/verilog/SVA/sequence_or1.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
CORE
22
sequence_or1.sv
33

4-
^\[main\.p0\] main\.x == 0 or main\.x == 1: PROVED up to bound \d+$
5-
^\[main\.p1\] strong\(main\.x == 0 or main\.x == 1\): PROVED up to bound \d+$
4+
^\[main\.p0\] main\.x == 0 or main\.x == 1: PROVED$
5+
^\[main\.p1\] strong\(main\.x == 0 or main\.x == 1\): PROVED$
66
^\[main\.p2\] main\.x == 0 or \(nexttime main\.x == 1\): PROVED up to bound \d+$
77
^\[main\.p3\] \(nexttime main\.x == 1\) or main\.x == 1: PROVED up to bound \d+$
88
^EXIT=0$

src/ebmc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ SRC = \
77
cegar/refine.cpp \
88
cegar/simulate.cpp \
99
cegar/verify.cpp \
10+
completeness_threshold.cpp \
1011
diameter.cpp \
1112
diatest.cpp \
1213
dimacs_writer.cpp \

src/ebmc/completeness_threshold.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*******************************************************************\
2+
3+
Module: Completeness Threshold
4+
5+
Author: Daniel Kroening, dkr@amazon.com
6+
7+
\*******************************************************************/
8+
9+
#include "completeness_threshold.h"
10+
11+
#include <temporal-logic/ltl.h>
12+
#include <temporal-logic/temporal_logic.h>
13+
#include <verilog/sva_expr.h>
14+
15+
#include "bmc.h"
16+
17+
bool has_low_completeness_threshold(const exprt &expr)
18+
{
19+
if(!has_temporal_operator(expr))
20+
{
21+
return true; // state predicate only
22+
}
23+
else if(expr.id() == ID_X)
24+
{
25+
// X p
26+
return !has_temporal_operator(to_X_expr(expr).op());
27+
}
28+
else if(expr.id() == ID_sva_nexttime)
29+
{
30+
// nexttime p
31+
return !has_temporal_operator(to_sva_nexttime_expr(expr).op());
32+
}
33+
else
34+
return false;
35+
}
36+
37+
bool has_low_completeness_threshold(const ebmc_propertiest::propertyt &property)
38+
{
39+
return has_low_completeness_threshold(property.normalized_expr);
40+
}
41+
42+
bool have_low_completeness_threshold(const ebmc_propertiest &properties)
43+
{
44+
for(auto &property : properties.properties)
45+
if(has_low_completeness_threshold(property))
46+
return true;
47+
return false;
48+
}
49+
50+
property_checker_resultt completeness_threshold(
51+
const cmdlinet &cmdline,
52+
const transition_systemt &transition_system,
53+
const ebmc_propertiest &properties,
54+
const ebmc_solver_factoryt &solver_factory,
55+
message_handlert &message_handler)
56+
{
57+
// Do we have an eligibile property?
58+
if(!have_low_completeness_threshold(properties))
59+
return property_checker_resultt{properties}; // give up
60+
61+
// Do BMC with two timeframes
62+
auto result = bmc(
63+
1, // bound
64+
false, // convert_only
65+
cmdline.isset("bmc-with-assumptions"),
66+
transition_system,
67+
properties,
68+
solver_factory,
69+
message_handler);
70+
71+
for(auto &property : result.properties)
72+
{
73+
if(property.is_proved_with_bound())
74+
{
75+
// Turn "PROVED up to bound k" into "PROVED" if k>=CT
76+
if(has_low_completeness_threshold(property) && property.bound >= 1)
77+
property.proved();
78+
else
79+
property.unknown();
80+
}
81+
}
82+
83+
return result;
84+
}

src/ebmc/completeness_threshold.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*******************************************************************\
2+
3+
Module: Completeness Threshold
4+
5+
Author: Daniel Kroening, dkr@amazon.com
6+
7+
\*******************************************************************/
8+
9+
#ifndef CPROVER_EBMC_COMPLETENESS_THRESHOLD_H
10+
#define CPROVER_EBMC_COMPLETENESS_THRESHOLD_H
11+
12+
#include "ebmc_solver_factory.h"
13+
#include "property_checker.h"
14+
15+
class cmdlinet;
16+
class ebmc_propertiest;
17+
class message_handlert;
18+
class transition_systemt;
19+
20+
[[nodiscard]] property_checker_resultt completeness_threshold(
21+
const cmdlinet &,
22+
const transition_systemt &,
23+
const ebmc_propertiest &,
24+
const ebmc_solver_factoryt &,
25+
message_handlert &);
26+
27+
#endif

src/ebmc/k_induction.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,11 +184,12 @@ void k_inductiont::operator()()
184184
}
185185
}
186186

187-
// Fail unsupported properties
187+
// Fail unsupported properties that are not proved yet
188188
for(auto &property : properties.properties)
189189
{
190190
if(
191-
!supported(property) && !property.is_assumed() && !property.is_disabled())
191+
!supported(property) && !property.is_assumed() &&
192+
!property.is_disabled() && !property.is_proved())
192193
{
193194
property.unsupported("unsupported by k-induction");
194195
}
@@ -264,7 +265,7 @@ void k_inductiont::induction_step()
264265
{
265266
if(
266267
p_it.is_disabled() || p_it.is_failure() || p_it.is_assumed() ||
267-
p_it.is_unsupported())
268+
p_it.is_unsupported() || p_it.is_proved())
268269
{
269270
continue;
270271
}

0 commit comments

Comments
 (0)