Skip to content

Commit 154024f

Browse files
authored
Merge pull request #1143 from diffblue/invar1
SMV: disallow `next(...)` in `INVAR`
2 parents bac5ad6 + be27d85 commit 154024f

File tree

5 files changed

+38
-0
lines changed

5 files changed

+38
-0
lines changed

regression/smv/invar/invar1.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
invar1.smv
3+
--bound 20
4+
^\[.*\] G x != 10: PROVED up to bound 20$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
--

regression/smv/invar/invar1.smv

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
MODULE main
2+
3+
VAR x : 1..10;
4+
5+
ASSIGN init(x) := 1;
6+
ASSIGN next(x) := x = 10 ? 10 : x + 1;
7+
8+
-- x won't reach 10, since we won't reach 3
9+
INVAR x != 3
10+
11+
LTLSPEC G x != 10

regression/smv/invar/invar2.desc

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

regression/smv/invar/invar2.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 : 1..10;
4+
5+
-- next(...) is not allowed
6+
INVAR next(x) != 3

src/smvlang/smv_typecheck.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class smv_typecheckt:public typecheckt
4949
typedef enum
5050
{
5151
INIT,
52+
INVAR,
5253
TRANS,
5354
OTHER,
5455
LTL,
@@ -1562,6 +1563,10 @@ void smv_typecheckt::typecheck(
15621563
return;
15631564

15641565
case smv_parse_treet::modulet::itemt::INVAR:
1566+
typecheck(item.expr, INVAR);
1567+
convert_expr_to(item.expr, bool_typet{});
1568+
return;
1569+
15651570
case smv_parse_treet::modulet::itemt::FAIRNESS:
15661571
typecheck(item.expr, OTHER);
15671572
convert_expr_to(item.expr, bool_typet{});

0 commit comments

Comments
 (0)