Skip to content

Commit a2d37be

Browse files
committed
SMV: properties must not contain next(...)
This adds a check to the SMV type checker that prohibits the use of next(...) inside temporal-logic properties. This matches the behavior of NuSMV.
1 parent b97a3e7 commit a2d37be

File tree

7 files changed

+42
-4
lines changed

7 files changed

+42
-4
lines changed

regression/smv/CTL/smv_ctlspec2.desc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
smv_ctlspec2.smv
3+
4+
^file .* line 6: next\(...\) is not allowed here$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--

regression/smv/CTL/smv_ctlspec2.smv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MODULE main
2+
3+
VAR x : boolean;
4+
5+
-- error, next(...) is not allowed
6+
SPEC AG next(x)

regression/smv/LTL/smv_ltlspec7.desc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
smv_ltlspec7.smv
3+
4+
^file .* line 6: next\(...\) is not allowed here$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--

regression/smv/LTL/smv_ltlspec7.smv

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
MODULE main
2+
3+
VAR x : boolean;
4+
5+
-- error, next(...) is not allowed
6+
LTLSPEC G next(x)

src/smvlang/smv_typecheck.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,11 @@ void smv_typecheckt::typecheck_expr_rec(exprt &expr, modet mode)
642642
if(expr.id()==ID_symbol ||
643643
expr.id()==ID_next_symbol)
644644
{
645+
// next_symbol is only allowed in TRANS mode
646+
if(expr.id() == ID_next_symbol && mode != TRANS)
647+
throw errort().with_location(expr.find_source_location())
648+
<< "next(...) is not allowed here";
649+
645650
const irep_idt &identifier=expr.get(ID_identifier);
646651
bool next=expr.id()==ID_next_symbol;
647652

src/trans-word-level/instantiate_word_level.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ symbol_exprt timeframe_symbol(const mp_integer &timeframe, symbol_exprt src)
7272
class wl_instantiatet
7373
{
7474
public:
75-
explicit wl_instantiatet(const mp_integer &_no_timeframes)
76-
: no_timeframes(_no_timeframes)
75+
wl_instantiatet(const mp_integer &_no_timeframes, bool _next_symbol_allowed)
76+
: no_timeframes(_no_timeframes), next_symbol_allowed(_next_symbol_allowed)
7777
{
7878
}
7979

@@ -86,6 +86,7 @@ class wl_instantiatet
8686

8787
protected:
8888
const mp_integer &no_timeframes;
89+
bool next_symbol_allowed;
8990

9091
[[nodiscard]] std::pair<mp_integer, exprt>
9192
instantiate_rec(exprt, const mp_integer &t) const;
@@ -111,6 +112,7 @@ wl_instantiatet::instantiate_rec(exprt expr, const mp_integer &t) const
111112

112113
if(expr.id() == ID_next_symbol)
113114
{
115+
PRECONDITION(next_symbol_allowed);
114116
expr.id(ID_symbol);
115117
auto u = t + 1;
116118
return {u, timeframe_symbol(u, to_symbol_expr(std::move(expr)))};
@@ -205,7 +207,7 @@ exprt instantiate(
205207
const mp_integer &t,
206208
const mp_integer &no_timeframes)
207209
{
208-
wl_instantiatet wl_instantiate(no_timeframes);
210+
wl_instantiatet wl_instantiate(no_timeframes, true);
209211
return wl_instantiate(expr, t).second;
210212
}
211213

@@ -226,6 +228,6 @@ std::pair<mp_integer, exprt> instantiate_property(
226228
const mp_integer &current,
227229
const mp_integer &no_timeframes)
228230
{
229-
wl_instantiatet wl_instantiate(no_timeframes);
231+
wl_instantiatet wl_instantiate(no_timeframes, false);
230232
return wl_instantiate(expr, current);
231233
}

src/trans-word-level/instantiate_word_level.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ Author: Daniel Kroening, [email protected]
1212
#include <util/mp_arith.h>
1313
#include <util/std_expr.h>
1414

15+
// Instantiate a expression in the given time frame.
16+
// May contain next_symbol, but must not contain any temporal operators.
1517
exprt instantiate(
1618
const exprt &expr,
1719
const mp_integer &current,
1820
const mp_integer &no_timeframes);
1921

22+
// Instantiate an atomic state predicate in the given time frame.
23+
// Must not contain next_symbol or any temporal operators.
2024
std::pair<mp_integer, exprt> instantiate_property(
2125
const exprt &,
2226
const mp_integer &current,
@@ -25,6 +29,7 @@ std::pair<mp_integer, exprt> instantiate_property(
2529
std::string
2630
timeframe_identifier(const mp_integer &timeframe, const irep_idt &identifier);
2731

32+
// Instantiate a symbol in the given time frame.
2833
symbol_exprt timeframe_symbol(const mp_integer &timeframe, symbol_exprt);
2934

3035
#endif

0 commit comments

Comments
 (0)