Skip to content

Commit 9a86fca

Browse files
committed
SMV: use ID_iff for <->
This changes the SMV front-end to use ID_iff for <->. Support for ID_iff is added to the BDD engine.
1 parent f49ade4 commit 9a86fca

File tree

7 files changed

+48
-6
lines changed

7 files changed

+48
-6
lines changed

regression/ebmc/smv/smv_iff1.desc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
smv_iff1.smv
3+
4+
^file .* line 9: Expected expression of type `boolean', but got expression `x', which is of type `0..10'$
5+
^EXIT=2$
6+
^SIGNAL=0$
7+
--

regression/ebmc/smv/smv_iff1.smv

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MODULE main
2+
3+
VAR x : 0..10;
4+
5+
ASSIGN init(x) := 1;
6+
next(x) := x;
7+
8+
-- type error: lhs is not Boolean
9+
SPEC x <-> (x != 0)

regression/ebmc/smv/smv_iff2.desc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CORE
2+
smv_iff2.smv
3+
4+
^\[.*\] AG x != 5 <-> x != 5 & AX AG x != 5: PROVED$
5+
^EXIT=0$
6+
^SIGNAL=0$
7+
--

regression/ebmc/smv/smv_iff2.smv

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
MODULE main
2+
3+
VAR x : 0..10;
4+
5+
ASSIGN
6+
init(x) := 1;
7+
8+
next(x) :=
9+
case
10+
x>=3 : 3;
11+
TRUE: x+1;
12+
esac;
13+
14+
SPEC AG x != 5 <-> (x != 5 & AX AG x != 5)

src/ebmc/bdd_engine.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,11 @@ bdd_enginet::BDD bdd_enginet::CTL(const exprt &expr)
659659
{
660660
return (!CTL(to_binary_expr(expr).lhs())) | CTL(to_binary_expr(expr).rhs());
661661
}
662+
else if(expr.id() == ID_iff)
663+
{
664+
return (
665+
!(CTL(to_binary_expr(expr).lhs())) ^ CTL(to_binary_expr(expr).rhs()));
666+
}
662667
else if(expr.id()==ID_and)
663668
{
664669
BDD result=mgr.True();
@@ -891,7 +896,8 @@ void bdd_enginet::get_atomic_propositions(const exprt &expr)
891896
{
892897
if(
893898
expr.id() == ID_and || expr.id() == ID_or || expr.id() == ID_not ||
894-
expr.id() == ID_implies || is_temporal_operator(expr))
899+
expr.id() == ID_implies || expr.id() == ID_iff ||
900+
is_temporal_operator(expr))
895901
{
896902
for(const auto & op : expr.operands())
897903
if(op.type().id() == ID_bool)

src/smvlang/parser.y

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ term : variable_name
455455
| term DIVIDE_Token term { binary_arith($$, $1, ID_div, $3); }
456456
| term PLUS_Token term { binary_arith($$, $1, ID_plus, $3); }
457457
| term MINUS_Token term { binary_arith($$, $1, ID_minus, $3); }
458-
| term EQUIV_Token term { binary($$, $1, ID_equal, $3, bool_typet{}); }
458+
| term EQUIV_Token term { binary($$, $1, ID_iff, $3, bool_typet{}); }
459459
| term IMPLIES_Token term { binary($$, $1, ID_implies, $3, bool_typet{}); }
460460
| term XOR_Token term { j_binary($$, $1, ID_xor, $3, bool_typet{}); }
461461
| term OR_Token term { j_binary($$, $1, ID_or, $3, bool_typet{}); }

src/smvlang/smv_typecheck.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,9 @@ void smv_typecheckt::typecheck(
674674
}
675675
}
676676
}
677-
else if(expr.id()==ID_and ||
678-
expr.id()==ID_or ||
679-
expr.id()==ID_xor ||
680-
expr.id()==ID_not)
677+
else if(
678+
expr.id() == ID_and || expr.id() == ID_or || expr.id() == ID_xor ||
679+
expr.id() == ID_not || expr.id() == ID_iff)
681680
{
682681
typecheck_op(expr, bool_typet(), mode);
683682
}

0 commit comments

Comments
 (0)