Skip to content

Commit 9cef5fc

Browse files
committed
SMV: IDs and test for set operators
This adds IDs and a test for SMV set expressions.
1 parent 8cce1ce commit 9cef5fc

File tree

7 files changed

+36
-6
lines changed

7 files changed

+36
-6
lines changed

lib/cbmc

Submodule cbmc updated 123 files

regression/ebmc/smv/smv_set1.desc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
smv_set1.smv
3+
--bdd
4+
^\[.*\] x != 3: PROVED$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--
8+
^warning: ignoring

regression/ebmc/smv/smv_set1.smv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
MODULE main
2+
3+
VAR x : 1..3;
4+
ASSIGN init(x) := {1, 2};
5+
next(x) := x;
6+
7+
SPEC x != 3;

src/hw_cbmc_irep_ids.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ IREP_ID_ONE(F)
1515
IREP_ID_ONE(E)
1616
IREP_ID_ONE(G)
1717
IREP_ID_ONE(X)
18+
IREP_ID_ONE(smv_setin)
19+
IREP_ID_ONE(smv_setnotin)
20+
IREP_ID_ONE(smv_union)
1821
IREP_ID_ONE(sva_accept_on)
1922
IREP_ID_ONE(sva_reject_on)
2023
IREP_ID_ONE(sva_sync_accept_on)

src/smvlang/expr2smv.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,15 @@ bool expr2smvt::convert(
444444
else if(src.id()==ID_mult || src.id()==ID_div)
445445
return convert_binary(src, dest, src.id_string(), precedence=16);
446446

447+
else if(src.id() == ID_smv_setin)
448+
return convert_binary(src, dest, "in", precedence = 16);
449+
450+
else if(src.id() == ID_smv_setnotin)
451+
return convert_binary(src, dest, "notin", precedence = 16);
452+
453+
else if(src.id() == ID_smv_union)
454+
return convert_binary(src, dest, "union", precedence = 16);
455+
447456
else if(src.id()==ID_lt || src.id()==ID_gt ||
448457
src.id()==ID_le || src.id()==ID_ge)
449458
return convert_binary(src, dest, src.id_string(), precedence=11);
@@ -496,6 +505,9 @@ bool expr2smvt::convert(
496505
else if(src.id()=="smv_nondet_choice")
497506
return convert_nondet_choice(src, dest, precedence);
498507

508+
else if(src.id() == ID_constraint_select_one)
509+
return convert_nondet_choice(src, dest, precedence);
510+
499511
else if(src.id()==ID_nondet_bool)
500512
{
501513
exprt nondet_choice_expr("smv_nondet_choice");

src/smvlang/parser.y

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ term : variable_name
482482
| term LE_Token term { binary($$, $1, ID_le, $3, bool_typet{}); }
483483
| term GT_Token term { binary($$, $1, ID_gt, $3, bool_typet{}); }
484484
| term GE_Token term { binary($$, $1, ID_ge, $3, bool_typet{}); }
485-
| term UNION_Token term { binary($$, $1, "smv_union", $3, bool_typet{}); }
486-
| term IN_Token term { binary($$, $1, "smv_setin", $3, bool_typet{}); }
487-
| term NOTIN_Token term { binary($$, $1, "smv_setnotin", $3, bool_typet{}); }
485+
| term UNION_Token term { binary($$, $1, ID_smv_union, $3, bool_typet{}); }
486+
| term IN_Token term { binary($$, $1, ID_smv_setin, $3, bool_typet{}); }
487+
| term NOTIN_Token term { binary($$, $1, ID_smv_setnotin, $3, bool_typet{}); }
488488
;
489489

490490
formula_list: formula { init($$); mto($$, $1); }

src/smvlang/smv_typecheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,11 +984,11 @@ void smv_typecheckt::typecheck(
984984
else if(expr.id()==ID_typecast)
985985
{
986986
}
987-
else if(expr.id()=="smv_setin")
987+
else if(expr.id() == ID_smv_setin)
988988
{
989989
expr.type()=bool_typet();
990990
}
991-
else if(expr.id()=="smv_setnotin")
991+
else if(expr.id() == ID_smv_setnotin)
992992
{
993993
expr.type()=bool_typet();
994994
}

0 commit comments

Comments
 (0)