Skip to content

SMV: reject CTL in LTLSPEC, and LTL in CTLSPEC #705

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

Merged
merged 1 commit into from
Sep 19, 2024
Merged
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
7 changes: 7 additions & 0 deletions regression/ebmc/smv/smv_ctlspec1.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
smv_ctlspec1.smv

^file .* line 4: LTL operator not permitted here$
^EXIT=2$
^SIGNAL=0$
--
4 changes: 4 additions & 0 deletions regression/ebmc/smv/smv_ctlspec1.smv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MODULE main

-- error, this is LTL
SPEC F FALSE
7 changes: 7 additions & 0 deletions regression/ebmc/smv/smv_ltlspec5.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CORE
smv_ltlspec5.smv

^file .* line 4: CTL operator not permitted here$
^EXIT=2$
^SIGNAL=0$
--
4 changes: 4 additions & 0 deletions regression/ebmc/smv/smv_ltlspec5.smv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
MODULE main

-- error, this is CTL
LTLSPEC AF FALSE
59 changes: 43 additions & 16 deletions src/smvlang/smv_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ class smv_typecheckt:public typecheckt

virtual ~smv_typecheckt() { }

typedef enum { INIT, TRANS, OTHER } modet;
typedef enum
{
INIT,
TRANS,
OTHER,
LTL,
CTL
} modet;

void convert(smv_parse_treet::modulet &smv_module);
void convert(smv_parse_treet::mc_varst &vars);
Expand Down Expand Up @@ -936,25 +943,39 @@ void smv_typecheckt::typecheck(
}
else if(
expr.id() == ID_AG || expr.id() == ID_AX || expr.id() == ID_AF ||
expr.id() == ID_EG || expr.id() == ID_EX || expr.id() == ID_EF ||
expr.id() == ID_X || expr.id() == ID_F || expr.id() == ID_G)
expr.id() == ID_EG || expr.id() == ID_EX || expr.id() == ID_EF)
{
if(expr.operands().size()!=1)
{
error().source_location=expr.find_source_location();
error() << "Expected one operand for " << expr.id()
<< " operator" << eom;
throw 0;
}

expr.type()=bool_typet();

if(mode != CTL)
throw errort().with_location(expr.source_location())
<< "CTL operator not permitted here";
expr.type() = bool_typet();
typecheck(to_unary_expr(expr).op(), expr.type(), mode);
}
else if(expr.id() == ID_X || expr.id() == ID_F || expr.id() == ID_G)
{
if(mode != LTL)
throw errort().with_location(expr.source_location())
<< "LTL operator not permitted here";
expr.type() = bool_typet();
typecheck(to_unary_expr(expr).op(), expr.type(), mode);
}
else if(
expr.id() == ID_EU || expr.id() == ID_ER || expr.id() == ID_AU ||
expr.id() == ID_AR || expr.id() == ID_U || expr.id() == ID_R)
expr.id() == ID_AR)
{
if(mode != CTL)
throw errort().with_location(expr.source_location())
<< "CTL operator not permitted here";
auto &binary_expr = to_binary_expr(expr);
expr.type() = bool_typet();
typecheck(binary_expr.lhs(), expr.type(), mode);
typecheck(binary_expr.rhs(), expr.type(), mode);
}
else if(expr.id() == ID_U || expr.id() == ID_R)
{
if(mode != LTL)
throw errort().with_location(expr.source_location())
<< "LTL operator not permitted here";
auto &binary_expr = to_binary_expr(expr);
expr.type() = bool_typet();
typecheck(binary_expr.lhs(), expr.type(), mode);
Expand Down Expand Up @@ -1194,11 +1215,17 @@ void smv_typecheckt::typecheck(
mode=TRANS;
break;

case smv_parse_treet::modulet::itemt::CTLSPEC:
mode = CTL;
break;

case smv_parse_treet::modulet::itemt::LTLSPEC:
mode = LTL;
break;

case smv_parse_treet::modulet::itemt::DEFINE:
case smv_parse_treet::modulet::itemt::INVAR:
case smv_parse_treet::modulet::itemt::FAIRNESS:
case smv_parse_treet::modulet::itemt::CTLSPEC:
case smv_parse_treet::modulet::itemt::LTLSPEC:
default:
mode=OTHER;
}
Expand Down