Skip to content

Commit 055e5bb

Browse files
authored
Merge pull request #703 from diffblue/bmc-CTL
BMC: extend CTL fragment
2 parents f49ade4 + 9d40dee commit 055e5bb

File tree

7 files changed

+95
-26
lines changed

7 files changed

+95
-26
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE broken-smt-backend
2+
smv_ctlspec_F1.smv
3+
--bound 10
4+
^\[.*\] AF x = 0: REFUTED$
5+
^\[.*\] AF x = 1: PROVED up to bound 10$
6+
^\[.*\] AF x = 2: PROVED up to bound 10$
7+
^\[.*\] AF x = 1 & AF x = 2: PROVED up to bound 10$
8+
^\[.*\] AF x = 0 & AF x = 1: REFUTED$
9+
^\[.*\] EF x = 0: FAILURE: property not supported by BMC engine$
10+
^EXIT=10$
11+
^SIGNAL=0$
12+
--
13+
^warning: ignoring
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
MODULE main
2+
3+
VAR x : 0..3;
4+
5+
ASSIGN
6+
init(x) := 1;
7+
8+
next(x) :=
9+
case
10+
x=3 : 3;
11+
TRUE: x+1;
12+
esac;
13+
14+
SPEC AF x = 0 -- should fail
15+
SPEC AF x = 1 -- should pass
16+
SPEC AF x = 2 -- should pass
17+
SPEC AF x = 1 & AF x = 2 -- should pass
18+
SPEC AF x = 0 & AF x = 1 -- should fail
19+
SPEC EF x = 0 -- not supported
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE broken-smt-backend
2+
smv_ctlspec_G1.smv
3+
--bound 10
4+
^\[.*\] AG x != 5: PROVED up to bound 10$
5+
^\[.*\] AG x != 6: PROVED up to bound 10$
6+
^\[.*\] AG x != 2: REFUTED$
7+
^\[.*\] AG x != 5 & AG x != 6: PROVED up to bound 10$
8+
^\[.*\] AG x != 2 & AG x != 5: REFUTED$
9+
^\[.*\] EG x != 2: FAILURE: property not supported by BMC engine$
10+
^EXIT=10$
11+
^SIGNAL=0$
12+
--
13+
^warning: ignoring
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
MODULE main
2+
3+
VAR x : 0..10;
4+
5+
ASSIGN
6+
init(x) := 1;
7+
8+
next(x) :=
9+
case
10+
x>=3 : 3;
11+
TRUE: x+1;
12+
esac;
13+
14+
SPEC AG x != 5 -- should pass
15+
SPEC AG x != 6 -- should pass
16+
SPEC AG x != 2 -- should fail
17+
SPEC AG x != 5 & AG x != 6 -- should pass
18+
SPEC AG x != 2 & AG x != 5 -- should fail
19+
SPEC EG x != 2 -- not supported

src/temporal-logic/temporal_logic.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ bool is_CTL_operator(const exprt &expr)
3434
id == ID_AR || id == ID_ER;
3535
}
3636

37+
bool has_CTL_operator(const exprt &expr)
38+
{
39+
return has_subexpr(expr, is_CTL_operator);
40+
}
41+
3742
bool is_CTL(const exprt &expr)
3843
{
3944
auto non_CTL_operator = [](const exprt &expr) {

src/temporal-logic/temporal_logic.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ bool is_CTL(const exprt &);
2929
/// as its root
3030
bool is_CTL_operator(const exprt &);
3131

32+
/// Returns true iff the given expression contains a CTL operator
33+
bool has_CTL_operator(const exprt &);
34+
3235
/// Returns true iff the given expression is an LTL formula
3336
bool is_LTL(const exprt &);
3437

src/trans-word-level/property.cpp

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -93,42 +93,39 @@ Function: bmc_supports_CTL_property
9393

9494
bool bmc_supports_CTL_property(const exprt &expr)
9595
{
96-
// We support
97-
// * formulas that contain no temporal operator besides AX
98-
// * GFφ, where φ contains no temporal operator besides AX
99-
// * AFφ, where φ contains no temporal operator besides AX
100-
// * AGAFφ, where φ contains no temporal operator besides AX
101-
// * conjunctions of supported CTL properties
102-
auto non_AX_CTL_operator = [](const exprt &expr)
103-
{ return is_CTL_operator(expr) && expr.id() != ID_AX; };
104-
105-
if(!has_subexpr(expr, non_AX_CTL_operator))
96+
// We map a subset of ACTL to LTL, following
97+
// Monika Maidl. "The common fragment of CTL and LTL"
98+
// http://dx.doi.org/10.1109/SFCS.2000.892332
99+
//
100+
// Specificially, we allow
101+
// * state predicates
102+
// * conjunctions of allowed formulas
103+
// * AX φ, where φ is allowed
104+
// * AF φ, where φ is allowed
105+
// * AG φ, where φ is allowed
106+
if(!has_CTL_operator(expr))
106107
{
107108
return true;
108109
}
109-
else if(expr.id() == ID_AF)
110-
{
111-
return !has_subexpr(to_AF_expr(expr).op(), non_AX_CTL_operator);
112-
}
113-
else if(expr.id() == ID_AG)
114-
{
115-
auto &op = to_AG_expr(expr).op();
116-
if(op.id() == ID_AF)
117-
{
118-
return !has_subexpr(to_AF_expr(op).op(), non_AX_CTL_operator);
119-
}
120-
else
121-
{
122-
return !has_subexpr(op, non_AX_CTL_operator);
123-
}
124-
}
125110
else if(expr.id() == ID_and)
126111
{
127112
for(auto &op : expr.operands())
128113
if(!bmc_supports_CTL_property(op))
129114
return false;
130115
return true;
131116
}
117+
else if(expr.id() == ID_AX)
118+
{
119+
return bmc_supports_CTL_property(to_AX_expr(expr).op());
120+
}
121+
else if(expr.id() == ID_AF)
122+
{
123+
return bmc_supports_CTL_property(to_AF_expr(expr).op());
124+
}
125+
else if(expr.id() == ID_AG)
126+
{
127+
return bmc_supports_CTL_property(to_AG_expr(expr).op());
128+
}
132129
else
133130
return false;
134131
}

0 commit comments

Comments
 (0)