Skip to content

Commit 9f21481

Browse files
committed
SMV: reject CTL in LTLSPEC, and LTL in CTLSPEC
The SMV typechecker now rejects CTL when checking LTLSPEC, and LTL when checking CTLSPEC.
1 parent f49ade4 commit 9f21481

File tree

5 files changed

+53
-15
lines changed

5 files changed

+53
-15
lines changed

regression/ebmc/smv/smv_ctlspec1.desc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
smv_ctlspec1.smv
3+
4+
^file .* line 4: LTL operator not permitted here$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--

regression/ebmc/smv/smv_ctlspec1.smv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MODULE main
2+
3+
-- error, this is LTL
4+
SPEC F FALSE

regression/ebmc/smv/smv_ltlspec5.desc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
smv_ltlspec5.smv
3+
4+
^file .* line 4: CTL operator not permitted here$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--

regression/ebmc/smv/smv_ltlspec5.smv

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
MODULE main
2+
3+
-- error, this is CTL
4+
LTLSPEC AF FALSE

src/smvlang/smv_typecheck.cpp

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class smv_typecheckt:public typecheckt
4141

4242
virtual ~smv_typecheckt() { }
4343

44-
typedef enum { INIT, TRANS, OTHER } modet;
44+
typedef enum { INIT, TRANS, OTHER, LTL, CTL } modet;
4545

4646
void convert(smv_parse_treet::modulet &smv_module);
4747
void convert(smv_parse_treet::mc_varst &vars);
@@ -936,25 +936,35 @@ void smv_typecheckt::typecheck(
936936
}
937937
else if(
938938
expr.id() == ID_AG || expr.id() == ID_AX || expr.id() == ID_AF ||
939-
expr.id() == ID_EG || expr.id() == ID_EX || expr.id() == ID_EF ||
940-
expr.id() == ID_X || expr.id() == ID_F || expr.id() == ID_G)
939+
expr.id() == ID_EG || expr.id() == ID_EX || expr.id() == ID_EF)
941940
{
942-
if(expr.operands().size()!=1)
943-
{
944-
error().source_location=expr.find_source_location();
945-
error() << "Expected one operand for " << expr.id()
946-
<< " operator" << eom;
947-
throw 0;
948-
}
949-
941+
if(mode != CTL)
942+
throw errort().with_location(expr.source_location()) << "CTL operator not permitted here";
943+
expr.type()=bool_typet();
944+
typecheck(to_unary_expr(expr).op(), expr.type(), mode);
945+
}
946+
else if(expr.id() == ID_X || expr.id() == ID_F || expr.id() == ID_G)
947+
{
948+
if(mode != LTL)
949+
throw errort().with_location(expr.source_location()) << "LTL operator not permitted here";
950950
expr.type()=bool_typet();
951-
952951
typecheck(to_unary_expr(expr).op(), expr.type(), mode);
953952
}
954953
else if(
955954
expr.id() == ID_EU || expr.id() == ID_ER || expr.id() == ID_AU ||
956-
expr.id() == ID_AR || expr.id() == ID_U || expr.id() == ID_R)
955+
expr.id() == ID_AR)
956+
{
957+
if(mode != CTL)
958+
throw errort().with_location(expr.source_location()) << "CTL operator not permitted here";
959+
auto &binary_expr = to_binary_expr(expr);
960+
expr.type() = bool_typet();
961+
typecheck(binary_expr.lhs(), expr.type(), mode);
962+
typecheck(binary_expr.rhs(), expr.type(), mode);
963+
}
964+
else if(expr.id() == ID_U || expr.id() == ID_R)
957965
{
966+
if(mode != LTL)
967+
throw errort().with_location(expr.source_location()) << "LTL operator not permitted here";
958968
auto &binary_expr = to_binary_expr(expr);
959969
expr.type() = bool_typet();
960970
typecheck(binary_expr.lhs(), expr.type(), mode);
@@ -1194,11 +1204,17 @@ void smv_typecheckt::typecheck(
11941204
mode=TRANS;
11951205
break;
11961206

1207+
case smv_parse_treet::modulet::itemt::CTLSPEC:
1208+
mode = CTL;
1209+
break;
1210+
1211+
case smv_parse_treet::modulet::itemt::LTLSPEC:
1212+
mode = LTL;
1213+
break;
1214+
11971215
case smv_parse_treet::modulet::itemt::DEFINE:
11981216
case smv_parse_treet::modulet::itemt::INVAR:
11991217
case smv_parse_treet::modulet::itemt::FAIRNESS:
1200-
case smv_parse_treet::modulet::itemt::CTLSPEC:
1201-
case smv_parse_treet::modulet::itemt::LTLSPEC:
12021218
default:
12031219
mode=OTHER;
12041220
}

0 commit comments

Comments
 (0)