Skip to content

Commit a32efa9

Browse files
author
Daniel Kroening
committed
smt2 backend: support let with multiple bindings
This avoids deeply recursive expressions.
1 parent cd59447 commit a32efa9

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

src/solvers/smt2/smt2_conv.cpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Author: Daniel Kroening, [email protected]
2222
#include <util/invariant.h>
2323
#include <util/mathematical_expr.h>
2424
#include <util/pointer_offset_size.h>
25+
#include <util/range.h>
2526
#include <util/std_expr.h>
2627
#include <util/std_types.h>
2728
#include <util/string2int.h>
@@ -1855,11 +1856,28 @@ void smt2_convt::convert_expr(const exprt &expr)
18551856
else if(expr.id()==ID_let)
18561857
{
18571858
const let_exprt &let_expr=to_let_expr(expr);
1858-
out << "(let ((";
1859-
convert_expr(let_expr.symbol());
1860-
out << ' ';
1861-
convert_expr(let_expr.value());
1862-
out << ")) ";
1859+
const auto &variables = let_expr.variables();
1860+
const auto &values = let_expr.values();
1861+
1862+
out << "(let (";
1863+
bool first = true;
1864+
1865+
for(auto &binding : make_range(variables).zip(values))
1866+
{
1867+
if(first)
1868+
first = false;
1869+
else
1870+
out << ' ';
1871+
1872+
out << '(';
1873+
convert_expr(binding.first);
1874+
out << ' ';
1875+
convert_expr(binding.second);
1876+
out << ')';
1877+
}
1878+
1879+
out << ") "; // bindings
1880+
18631881
convert_expr(let_expr.where());
18641882
out << ')'; // let
18651883
}

0 commit comments

Comments
 (0)