Skip to content

Commit fafad88

Browse files
committed
SMV: union operator
The SMV union operator computes the union of two set expressions.
1 parent a152b63 commit fafad88

File tree

2 files changed

+32
-19
lines changed

2 files changed

+32
-19
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG broken-smt-backend
1+
CORE broken-smt-backend
22
smv_union2.smv
33

44
^\[spec1\] x != 3: PROVED \(CT=1\)$
@@ -8,4 +8,3 @@ smv_union2.smv
88
--
99
^warning: ignoring
1010
--
11-
The type checker rejects this.

src/smvlang/smv_typecheck.cpp

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,37 @@ void smv_typecheckt::typecheck_expr_rec(exprt &expr, modet mode)
950950
// only get added by type checker
951951
PRECONDITION(false);
952952
}
953+
else if(expr.id() == ID_smv_union)
954+
{
955+
auto &lhs = to_binary_expr(expr).lhs();
956+
auto &rhs = to_binary_expr(expr).rhs();
957+
958+
typecheck_expr_rec(lhs, mode);
959+
typecheck_expr_rec(rhs, mode);
960+
961+
// create smv_set expression
962+
exprt::operandst elements;
963+
964+
if(lhs.id() == ID_smv_set)
965+
{
966+
elements.insert(
967+
elements.end(), lhs.operands().begin(), lhs.operands().end());
968+
}
969+
else
970+
elements.push_back(lhs);
971+
972+
if(rhs.id() == ID_smv_set)
973+
{
974+
elements.insert(
975+
elements.end(), rhs.operands().begin(), rhs.operands().end());
976+
}
977+
else
978+
elements.push_back(rhs);
979+
980+
expr.id(ID_smv_set);
981+
expr.operands() = std::move(elements);
982+
expr.type() = typet{ID_smv_set};
983+
}
953984
else if(expr.id() == ID_smv_setin)
954985
{
955986
auto &lhs = to_binary_expr(expr).lhs();
@@ -1719,23 +1750,6 @@ void smv_typecheckt::convert(exprt &expr, expr_modet expr_mode)
17191750
expr.id(ID_next_symbol);
17201751
}
17211752
}
1722-
else if(expr.id()=="smv_nondet_choice" ||
1723-
expr.id()=="smv_union")
1724-
{
1725-
if(expr.operands().size()==0)
1726-
{
1727-
throw errort().with_location(expr.find_source_location())
1728-
<< "expected operand here";
1729-
}
1730-
1731-
std::string identifier=
1732-
module+"::var::"+std::to_string(nondet_count++);
1733-
1734-
expr.set(ID_identifier, identifier);
1735-
expr.set("#smv_nondet_choice", true);
1736-
1737-
expr.id(ID_constraint_select_one);
1738-
}
17391753
else if(expr.id()=="smv_cases") // cases
17401754
{
17411755
if(expr.operands().size()<1)

0 commit comments

Comments
 (0)