Skip to content

Commit dd54106

Browse files
authored
Merge pull request #8430 from tautschnig/no-bound-var-rewrite
Contracts: remove bound-var-rewrite
2 parents faf92c5 + 02eb50c commit dd54106

File tree

5 files changed

+0
-81
lines changed

5 files changed

+0
-81
lines changed

src/goto-instrument/contracts/contracts.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,6 @@ void code_contractst::check_apply_loop_contracts(
6868
// at the start of and end of a loop body
6969
std::vector<symbol_exprt> old_decreases_vars, new_decreases_vars;
7070

71-
// replace bound variables by fresh instances
72-
if(has_subexpr(invariant, ID_exists) || has_subexpr(invariant, ID_forall))
73-
add_quantified_variable(symbol_table, invariant, mode);
74-
7571
// instrument
7672
//
7773
// ... preamble ...
@@ -571,13 +567,6 @@ static void generate_contract_constraints(
571567
goto_programt &program,
572568
const source_locationt &location)
573569
{
574-
if(
575-
has_subexpr(instantiated_clause, ID_exists) ||
576-
has_subexpr(instantiated_clause, ID_forall))
577-
{
578-
add_quantified_variable(symbol_table, instantiated_clause, mode);
579-
}
580-
581570
goto_programt constraint;
582571
if(location.get_property_class() == ID_assume)
583572
{

src/goto-instrument/contracts/dynamic-frames/dfcc_instrument_loop.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,6 @@ dfcc_instrument_loopt::add_prehead_instructions(
235235
// GOTO HEAD;
236236
// ```
237237

238-
// Replace bound variables by fresh instances in quantified formulas.
239-
if(has_subexpr(invariant, ID_exists) || has_subexpr(invariant, ID_forall))
240-
add_quantified_variable(symbol_table, invariant, language_mode);
241238
// initialize loop_entry history vars;
242239
auto replace_history_result = replace_history_loop_entry(
243240
symbol_table, invariant, loop_head_location, language_mode);
@@ -429,9 +426,6 @@ dfcc_instrument_loopt::add_step_instructions(
429426
dfcc_utilst::get_function_symbol(symbol_table, function_id).mode;
430427
{
431428
// Assume the loop invariant after havocing the state.
432-
// Replace bound variables by fresh instances in quantified formulas.
433-
if(has_subexpr(invariant, ID_exists) || has_subexpr(invariant, ID_forall))
434-
add_quantified_variable(symbol_table, invariant, language_mode);
435429
code_assumet assumption{invariant};
436430
assumption.add_source_location() = loop_head_location;
437431
converter.goto_convert(assumption, step_instrs, language_mode);
@@ -513,9 +507,6 @@ void dfcc_instrument_loopt::add_body_instructions(
513507
id2string(check_location.get_function()) + "." +
514508
std::to_string(cbmc_loop_id));
515509
// Assume the loop invariant after havocing the state.
516-
// Replace bound variables by fresh instances in quantified formulas.
517-
if(has_subexpr(invariant, ID_exists) || has_subexpr(invariant, ID_forall))
518-
add_quantified_variable(symbol_table, invariant, language_mode);
519510
code_assertt assertion{invariant};
520511
assertion.add_source_location() = check_location;
521512
converter.goto_convert(assertion, pre_loop_latch_instrs, language_mode);

src/goto-instrument/contracts/dynamic-frames/dfcc_wrapper_program.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -555,13 +555,6 @@ void dfcc_wrapper_programt::encode_requires_clauses()
555555
{
556556
exprt requires_lmbd =
557557
to_lambda_expr(r).application(contract_lambda_parameters);
558-
requires_lmbd.add_source_location() = r.source_location();
559-
if(
560-
has_subexpr(requires_lmbd, ID_exists) ||
561-
has_subexpr(requires_lmbd, ID_forall))
562-
add_quantified_variable(
563-
goto_model.symbol_table, requires_lmbd, language_mode);
564-
565558
source_locationt sl(r.source_location());
566559
if(statement_type == ID_assert)
567560
{
@@ -609,9 +602,6 @@ void dfcc_wrapper_programt::encode_ensures_clauses()
609602
.application(contract_lambda_parameters)
610603
.with_source_location(e);
611604

612-
if(has_subexpr(ensures, ID_exists) || has_subexpr(ensures, ID_forall))
613-
add_quantified_variable(goto_model.symbol_table, ensures, language_mode);
614-
615605
// this also rewrites ID_old expressions to fresh variables
616606
generate_history_variables_initialization(
617607
goto_model.symbol_table, ensures, language_mode, history);

src/goto-instrument/contracts/utils.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -381,48 +381,6 @@ void widen_assigns(assignst &assigns, const namespacet &ns)
381381
assigns = result;
382382
}
383383

384-
void add_quantified_variable(
385-
symbol_table_baset &symbol_table,
386-
exprt &expression,
387-
const irep_idt &mode)
388-
{
389-
auto visitor = [&symbol_table, &mode](exprt &expr) {
390-
if(expr.id() != ID_exists && expr.id() != ID_forall)
391-
return;
392-
// When a quantifier expression is found, create a fresh symbol for each
393-
// quantified variable and rewrite the expression to use those fresh
394-
// symbols.
395-
auto &quantifier_expression = to_quantifier_expr(expr);
396-
std::vector<symbol_exprt> fresh_variables;
397-
fresh_variables.reserve(quantifier_expression.variables().size());
398-
for(const auto &quantified_variable : quantifier_expression.variables())
399-
{
400-
// 1. create fresh symbol
401-
symbolt new_symbol = get_fresh_aux_symbol(
402-
quantified_variable.type(),
403-
id2string(quantified_variable.source_location().get_function()),
404-
"tmp_cc",
405-
quantified_variable.source_location(),
406-
mode,
407-
symbol_table);
408-
409-
// 2. add created fresh symbol to expression map
410-
fresh_variables.push_back(new_symbol.symbol_expr());
411-
}
412-
413-
// use fresh symbols
414-
exprt where = quantifier_expression.instantiate(fresh_variables);
415-
416-
// recursively check for nested quantified formulae
417-
add_quantified_variable(symbol_table, where, mode);
418-
419-
// replace previous variables and body
420-
quantifier_expression.variables() = fresh_variables;
421-
quantifier_expression.where() = std::move(where);
422-
};
423-
expression.visit_pre(visitor);
424-
}
425-
426384
static void replace_history_parameter_rec(
427385
symbol_table_baset &symbol_table,
428386
exprt &expr,

src/goto-instrument/contracts/utils.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,6 @@ void infer_loop_assigns(
232232
/// *(b+i) when `i` is a known constant, keep the expression in the result.
233233
void widen_assigns(assignst &assigns, const namespacet &ns);
234234

235-
/// This function recursively searches \p expression to find nested or
236-
/// non-nested quantified expressions. When a quantified expression is found,
237-
/// a fresh quantified variable is added to the symbol table and \p expression
238-
/// is updated to use this fresh variable.
239-
void add_quantified_variable(
240-
symbol_table_baset &symbol_table,
241-
exprt &expression,
242-
const irep_idt &mode);
243-
244235
struct replace_history_parametert
245236
{
246237
exprt expression_after_replacement;

0 commit comments

Comments
 (0)