Skip to content

SMV: union operator #1186

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
3 changes: 1 addition & 2 deletions regression/smv/expressions/smv_union2.desc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
KNOWNBUG broken-smt-backend
CORE broken-smt-backend
smv_union2.smv

^\[spec1\] x != 3: PROVED \(CT=1\)$
Expand All @@ -8,4 +8,3 @@ smv_union2.smv
--
^warning: ignoring
--
The type checker rejects this.
48 changes: 31 additions & 17 deletions src/smvlang/smv_typecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,6 +999,37 @@ void smv_typecheckt::typecheck_expr_rec(exprt &expr, modet mode)
// only get added by type checker
PRECONDITION(false);
}
else if(expr.id() == ID_smv_union)
{
auto &lhs = to_binary_expr(expr).lhs();
auto &rhs = to_binary_expr(expr).rhs();

typecheck_expr_rec(lhs, mode);
typecheck_expr_rec(rhs, mode);

// create smv_set expression
exprt::operandst elements;

if(lhs.id() == ID_smv_set)
{
elements.insert(
elements.end(), lhs.operands().begin(), lhs.operands().end());
}
else
elements.push_back(lhs);

if(rhs.id() == ID_smv_set)
{
elements.insert(
elements.end(), rhs.operands().begin(), rhs.operands().end());
}
else
elements.push_back(rhs);

expr.id(ID_smv_set);
expr.operands() = std::move(elements);
expr.type() = typet{ID_smv_set};
}
else if(expr.id() == ID_smv_setin)
{
auto &lhs = to_binary_expr(expr).lhs();
Expand Down Expand Up @@ -1741,23 +1772,6 @@ void smv_typecheckt::convert(exprt &expr, expr_modet expr_mode)
expr.id(ID_next_symbol);
}
}
else if(expr.id()=="smv_nondet_choice" ||
expr.id()=="smv_union")
{
if(expr.operands().size()==0)
{
throw errort().with_location(expr.find_source_location())
<< "expected operand here";
}

std::string identifier=
module+"::var::"+std::to_string(nondet_count++);

expr.set(ID_identifier, identifier);
expr.set("#smv_nondet_choice", true);

expr.id(ID_constraint_select_one);
}
else if(expr.id()=="smv_cases") // cases
{
if(expr.operands().size()<1)
Expand Down
Loading