Skip to content

Commit 8931632

Browse files
author
Daniel Kroening
committed
let_exprt can now do multiple bindings
This matches what the SMT-LIB standard does. It also matches what our own binding_exprt can do, i.e., let_exprt can be re-written into a lambda binding plus a function application in the standard way.
1 parent 9a3ffde commit 8931632

File tree

1 file changed

+44
-10
lines changed

1 file changed

+44
-10
lines changed

src/util/std_expr.h

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4283,47 +4283,81 @@ class infinity_exprt : public nullary_exprt
42834283
};
42844284

42854285
/// \brief A let expression
4286-
class let_exprt : public ternary_exprt
4286+
class let_exprt : public binary_exprt
42874287
{
42884288
public:
42894289
let_exprt(symbol_exprt symbol, exprt value, const exprt &where)
4290-
: ternary_exprt(
4290+
: binary_exprt(
4291+
multi_ary_exprt(
4292+
ID_tuple,
4293+
{std::move(symbol), std::move(value)},
4294+
typet(ID_tuple)),
4295+
ID_let,
4296+
where,
4297+
where.type())
4298+
{
4299+
}
4300+
4301+
using symbol_value_sequencet = std::vector<exprt>;
4302+
4303+
let_exprt(symbol_value_sequencet symbol_value_sequence, const exprt &where)
4304+
: binary_exprt(
4305+
multi_ary_exprt(
4306+
ID_tuple,
4307+
std::move(symbol_value_sequence),
4308+
typet(ID_tuple)),
42914309
ID_let,
4292-
std::move(symbol),
4293-
std::move(value),
42944310
where,
42954311
where.type())
42964312
{
42974313
}
42984314

4315+
symbol_value_sequencet &symbol_value_sequence()
4316+
{
4317+
return (symbol_value_sequencet &)op0().operands();
4318+
}
4319+
4320+
const symbol_value_sequencet &symbol_value_sequence() const
4321+
{
4322+
return (symbol_value_sequencet &)op0().operands();
4323+
}
4324+
42994325
symbol_exprt &symbol()
43004326
{
4301-
return static_cast<symbol_exprt &>(op0());
4327+
auto &sequence = symbol_value_sequence();
4328+
PRECONDITION(sequence.size() == 2);
4329+
return to_symbol_expr(sequence[0]);
43024330
}
43034331

43044332
const symbol_exprt &symbol() const
43054333
{
4306-
return static_cast<const symbol_exprt &>(op0());
4334+
const auto &sequence = symbol_value_sequence();
4335+
PRECONDITION(sequence.size() == 2);
4336+
return to_symbol_expr(sequence[0]);
43074337
}
43084338

43094339
exprt &value()
43104340
{
4311-
return op1();
4341+
auto &sequence = symbol_value_sequence();
4342+
PRECONDITION(sequence.size() == 2);
4343+
return sequence[1];
43124344
}
43134345

43144346
const exprt &value() const
43154347
{
4316-
return op1();
4348+
const auto &sequence = symbol_value_sequence();
4349+
PRECONDITION(sequence.size() == 2);
4350+
return sequence[1];
43174351
}
43184352

43194353
exprt &where()
43204354
{
4321-
return op2();
4355+
return op1();
43224356
}
43234357

43244358
const exprt &where() const
43254359
{
4326-
return op2();
4360+
return op1();
43274361
}
43284362
};
43294363

0 commit comments

Comments
 (0)