Skip to content

Commit 956afe4

Browse files
committed
Keep symbols as nondet rather than using their symbol table values
Because the value of an expression is not intended to be defined until it has been expressed via expressions explicitly passed to the decision procedure.
1 parent 64fe4d0 commit 956afe4

File tree

2 files changed

+12
-62
lines changed

2 files changed

+12
-62
lines changed

src/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

+6-22
Original file line numberDiff line numberDiff line change
@@ -210,28 +210,12 @@ void smt2_incremental_decision_proceduret::define_dependent_functions(
210210
continue;
211211
if(const auto symbol_expr = expr_try_dynamic_cast<symbol_exprt>(current))
212212
{
213-
const irep_idt &identifier = symbol_expr->get_identifier();
214-
const symbolt *symbol = nullptr;
215-
if(ns.lookup(identifier, symbol) || symbol->value.is_nil())
216-
{
217-
send_function_definition(
218-
*symbol_expr,
219-
symbol_expr->get_identifier(),
220-
solver_process,
221-
expression_identifiers,
222-
identifier_table);
223-
}
224-
else
225-
{
226-
const exprt lowered = lower(symbol->value);
227-
if(push_dependencies_needed(lowered))
228-
continue;
229-
const smt_define_function_commandt function{
230-
symbol->name, {}, convert_expr_to_smt(lowered)};
231-
expression_identifiers.emplace(*symbol_expr, function.identifier());
232-
identifier_table.emplace(identifier, function.identifier());
233-
solver_process->send(function);
234-
}
213+
send_function_definition(
214+
*symbol_expr,
215+
symbol_expr->get_identifier(),
216+
solver_process,
217+
expression_identifiers,
218+
identifier_table);
235219
}
236220
else if(const auto array_expr = expr_try_dynamic_cast<array_exprt>(current))
237221
define_array_function(*array_expr);

unit/solvers/smt2_incremental/smt2_incremental_decision_procedure.cpp

+6-40
Original file line numberDiff line numberDiff line change
@@ -242,31 +242,7 @@ TEST_CASE(
242242
REQUIRE(
243243
test.sent_commands ==
244244
std::vector<smt_commandt>{
245-
smt_declare_function_commandt{nondet_int_a_term, {}},
246-
smt_define_function_commandt{
247-
"forty_two", {}, smt_bit_vector_constant_termt{42, 16}},
248-
smt_define_function_commandt{
249-
"first_comparison",
250-
{},
251-
smt_core_theoryt::equal(nondet_int_a_term, forty_two_term)},
252-
smt_declare_function_commandt{nondet_int_b_term, {}},
253-
smt_define_function_commandt{
254-
"second_comparison",
255-
{},
256-
smt_core_theoryt::make_not(
257-
smt_core_theoryt::equal(nondet_int_b_term, forty_two_term))},
258-
smt_define_function_commandt{
259-
"third_comparison",
260-
{},
261-
smt_core_theoryt::equal(nondet_int_a_term, nondet_int_b_term)},
262-
smt_define_function_commandt{
263-
"comparison_conjunction",
264-
{},
265-
smt_core_theoryt::make_and(
266-
smt_core_theoryt::make_and(
267-
smt_identifier_termt{"first_comparison", smt_bool_sortt{}},
268-
smt_identifier_termt{"second_comparison", smt_bool_sortt{}}),
269-
smt_identifier_termt{"third_comparison", smt_bool_sortt{}})},
245+
smt_declare_function_commandt{comparison_conjunction_term, {}},
270246
smt_assert_commandt{comparison_conjunction_term}});
271247
}
272248
SECTION("Set with nondet_padding")
@@ -326,8 +302,8 @@ TEST_CASE(
326302
REQUIRE(
327303
test.sent_commands ==
328304
std::vector<smt_commandt>{
329-
smt_define_function_commandt{
330-
"bar", {}, smt_bit_vector_constant_termt{42, 8}},
305+
smt_declare_function_commandt{
306+
smt_identifier_termt{"bar", smt_bit_vector_sortt{8}}, {}},
331307
smt_define_function_commandt{
332308
"B0", {}, smt_identifier_termt{"bar", smt_bit_vector_sortt{8}}}});
333309
}
@@ -1210,19 +1186,9 @@ TEST_CASE(
12101186
test.procedure.set_to(equal_expr, true);
12111187

12121188
std::vector<smt_commandt> expected_commands{
1213-
smt_define_function_commandt(
1214-
inner_symbol_with_value.name,
1215-
{},
1216-
smt_bit_vector_theoryt::concat(
1217-
smt_bit_vector_constant_termt{10, 32},
1218-
smt_bit_vector_constant_termt{23, 16})),
1219-
smt_define_function_commandt(
1220-
symbol_with_value.name,
1221-
{},
1222-
smt_bit_vector_theoryt::concat(
1223-
smt_bit_vector_constant_termt{1, config.ansi_c.bool_width},
1224-
smt_identifier_termt{
1225-
inner_symbol_with_value.name, smt_bit_vector_sortt{48}})),
1189+
smt_declare_function_commandt{
1190+
smt_identifier_termt{symbol_with_value.name, smt_bit_vector_sortt{56}},
1191+
{}},
12261192
smt_assert_commandt{smt_core_theoryt::equal(
12271193
smt_identifier_termt{symbol_with_value.name, smt_bit_vector_sortt{56}},
12281194
smt_identifier_termt{symbol_with_value.name, smt_bit_vector_sortt{56}})}};

0 commit comments

Comments
 (0)