Skip to content

Commit a72e2ce

Browse files
committed
Checks only strengthening clauses
1 parent e0fb994 commit a72e2ce

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/goto-synthesizer/cegis_verifier.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Qinheping Hu
1313

1414
#include <util/arith_tools.h>
1515
#include <util/c_types.h>
16+
#include <util/format_expr.h>
1617
#include <util/options.h>
1718
#include <util/pointer_offset_size.h>
1819
#include <util/pointer_predicates.h>
@@ -39,7 +40,6 @@ Author: Qinheping Hu
3940
#include <pointer-analysis/add_failed_symbols.h>
4041
#include <solvers/prop/prop.h>
4142

42-
#include <util/format_expr.h>
4343
#include <iostream>
4444

4545
static bool contains_symbol_prefix(const exprt &expr, const std::string &prefix)
@@ -747,9 +747,9 @@ optionalt<cext> cegis_verifiert::verify()
747747
return_cex.violation_location = violation_location;
748748
return_cex.violation_type = violation_type;
749749

750-
for(const auto &e: return_cex.loop_entry_values)
750+
for(const auto &e : return_cex.loop_entry_values)
751751
{
752-
std::cout << format(e.first) << " = "<< e.second << "\n";
752+
std::cout << format(e.first) << " = " << e.second << "\n";
753753
}
754754

755755
// The pointer checked in the null-pointer-check violation.

src/goto-synthesizer/enumerative_loop_contracts_synthesizer.cpp

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Qinheping Hu
1313

1414
#include <util/arith_tools.h>
1515
#include <util/c_types.h>
16+
#include <util/expr_iterator.h>
1617
#include <util/find_symbols.h>
1718
#include <util/format_expr.h>
1819
#include <util/pointer_predicates.h>
@@ -31,6 +32,21 @@ Author: Qinheping Hu
3132

3233
#include <iostream>
3334

35+
static bool contains_tmp_symbol(const exprt &expr)
36+
{
37+
for(auto it = expr.depth_begin(), itend = expr.depth_end(); it != itend; ++it)
38+
{
39+
if(
40+
it->id() == ID_symbol &&
41+
id2string(to_symbol_expr(*it).get_identifier()).find("$tmp::") !=
42+
std::string::npos)
43+
{
44+
return true;
45+
}
46+
}
47+
return false;
48+
}
49+
3450
// substitute all tmp_post variables with their origins in `expr`
3551
void replace_tmp_post(
3652
exprt &dest,
@@ -257,8 +273,11 @@ enumerative_loop_contracts_synthesizert::compute_dependent_symbols(
257273
// the original symbol table.
258274
for(auto it = result.begin(); it != result.end();)
259275
{
260-
if(original_symbol_table.lookup(it->get_identifier()) == nullptr)
276+
if(
277+
contains_tmp_symbol(*it) ||
278+
original_symbol_table.lookup(it->get_identifier()) == nullptr)
261279
{
280+
std::cout << format(*it) << " erased\n";
262281
it = result.erase(it);
263282
}
264283
else
@@ -323,7 +342,8 @@ exprt enumerative_loop_contracts_synthesizert::synthesize_strengthening_clause(
323342
ID_plus,
324343
start_ph,
325344
start_ph,
326-
[](const partitiont &partition) {
345+
[](const partitiont &partition)
346+
{
327347
if(partition.size() <= 1)
328348
return true;
329349
return partition.front() == 1;
@@ -376,13 +396,11 @@ exprt enumerative_loop_contracts_synthesizert::synthesize_strengthening_clause(
376396
new_in_clauses, new_pos_clauses, neg_guards);
377397

378398
log.progress() << "Verifying candidate: "
379-
<< format(combined_invariant.at(cause_loop_id))
380-
<< messaget::eom;
399+
<< format(strengthening_candidate) << messaget::eom;
381400

382401
// Quick filter:
383402
// Rule out a candidate if its evaluation is inconsistent with examples.
384-
cegis_evaluator evaluator(
385-
combined_invariant.at(cause_loop_id), cexs, log);
403+
cegis_evaluator evaluator(strengthening_candidate, cexs, log);
386404
count_all++;
387405
if(!evaluator.evaluate())
388406
{

0 commit comments

Comments
 (0)