Skip to content

Commit a010865

Browse files
authored
Merge pull request #7970 from qinheping/features/better-terminals-in-synthesizer
SYNTHESIZER: Use only symbols from the original goto as terminals
2 parents 10f277c + 535bf95 commit a010865

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/goto-synthesizer/enumerative_loop_contracts_synthesizer.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ void replace_tmp_post(
4949

5050
std::vector<exprt> construct_terminals(const std::set<symbol_exprt> &symbols)
5151
{
52+
// Construct a vector of terminal expressions.
53+
// Terminals include:
54+
// 1: scalar type variables and their loop_entry version.
55+
// 2: offsets of pointers and loop_entry of pointers.
56+
// 3: constants 0 and 1.
57+
5258
std::vector<exprt> result;
5359
for(const auto &e : symbols)
5460
{
@@ -244,6 +250,18 @@ enumerative_loop_contracts_synthesizert::compute_dependent_symbols(
244250
for(const auto &e : live_vars)
245251
find_symbols(e, result);
246252

253+
// Erase all variables added during loop transformations---they are not in
254+
// the original symbol table.
255+
for(auto it = result.begin(); it != result.end();)
256+
{
257+
if(original_symbol_table.lookup(it->get_identifier()) == nullptr)
258+
{
259+
it = result.erase(it);
260+
}
261+
else
262+
it++;
263+
}
264+
247265
return result;
248266
}
249267

src/goto-synthesizer/enumerative_loop_contracts_synthesizer.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class enumerative_loop_contracts_synthesizert
3636
messaget &log)
3737
: loop_contracts_synthesizer_baset(goto_model, log),
3838
options(options),
39-
ns(goto_model.symbol_table)
39+
ns(goto_model.symbol_table),
40+
original_symbol_table(goto_model.symbol_table)
4041
{
4142
}
4243

@@ -97,6 +98,9 @@ class enumerative_loop_contracts_synthesizert
9798

9899
/// Map from tmp_post variables to their original variables.
99100
std::unordered_map<exprt, exprt, irep_hash> tmp_post_map;
101+
102+
/// Symbol table of the input goto model
103+
const symbol_tablet original_symbol_table;
100104
};
101105

102106
// NOLINTNEXTLINE(whitespace/line_length)

0 commit comments

Comments
 (0)