Skip to content

SMV: disallow next(...) in INVAR #1143

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions regression/smv/invar/invar1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
invar1.smv
--bound 20
^\[.*\] G x != 10: PROVED up to bound 20$
^EXIT=0$
^SIGNAL=0$
--
--
11 changes: 11 additions & 0 deletions regression/smv/invar/invar1.smv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
MODULE main

VAR x : 1..10;

ASSIGN init(x) := 1;
ASSIGN next(x) := x = 10 ? 10 : x + 1;

-- x won't reach 10, since we won't reach 3
INVAR x != 3

LTLSPEC G x != 10
8 changes: 8 additions & 0 deletions regression/smv/invar/invar2.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CORE
invar2.smv

^file .* line 6: next\(...\) is not allowed here$
^EXIT=2$
^SIGNAL=0$
--
--
6 changes: 6 additions & 0 deletions regression/smv/invar/invar2.smv
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MODULE main

VAR x : 1..10;

-- next(...) is not allowed
INVAR next(x) != 3
5 changes: 5 additions & 0 deletions src/smvlang/smv_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class smv_typecheckt:public typecheckt
typedef enum
{
INIT,
INVAR,
TRANS,
OTHER,
LTL,
Expand Down Expand Up @@ -1562,6 +1563,10 @@ void smv_typecheckt::typecheck(
return;

case smv_parse_treet::modulet::itemt::INVAR:
typecheck(item.expr, INVAR);
convert_expr_to(item.expr, bool_typet{});
return;

case smv_parse_treet::modulet::itemt::FAIRNESS:
typecheck(item.expr, OTHER);
convert_expr_to(item.expr, bool_typet{});
Expand Down
Loading