Skip to content

Commit aa6df74

Browse files
Yakir Vizelyvizel
Yakir Vizel
authored andcommitted
Removing redundant include, and fixing function arguments
1 parent 193da7a commit aa6df74

File tree

3 files changed

+42
-48
lines changed

3 files changed

+42
-48
lines changed

src/cprover/chc_db.cpp

+37-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,42 @@
77
chc_dbt::chc_sett chc_dbt::m_empty_set;
88
std::unordered_set<exprt, irep_hash> chc_grapht::m_expr_empty_set;
99

10+
void horn_clauset::used_relations(chc_dbt &db, std::vector<symbol_exprt> & out) const
11+
{
12+
const exprt *body = this->body();
13+
if (body == nullptr) return;
14+
std::set<symbol_exprt> symbols = find_symbols(*body);
15+
16+
chc_dbt::is_state_pred filter(db);
17+
for (auto & symb : symbols) {
18+
if (filter(symb)) {
19+
out.push_back(symb);
20+
}
21+
}
22+
}
23+
24+
void horn_clauset::used_func_app(chc_dbt &db, std::vector<function_application_exprt> & out) const
25+
{
26+
const exprt *body = this->body();
27+
if (body == nullptr) return;
28+
29+
std::unordered_set<function_application_exprt, irep_hash> funcs;
30+
body->visit_pre([&funcs](const exprt &expr) {
31+
if (can_cast_expr<function_application_exprt>(expr))
32+
{
33+
const function_application_exprt & f = to_function_application_expr(expr);
34+
funcs.insert(f);
35+
}
36+
});
37+
38+
chc_dbt::is_state_pred filter(db);
39+
for (auto & f : funcs) {
40+
if (filter(to_symbol_expr(f.function()))) {
41+
out.push_back(f);
42+
}
43+
}
44+
}
45+
1046
void chc_dbt::reset_indices()
1147
{
1248
m_body_idx.clear();
@@ -28,7 +64,7 @@ void chc_dbt::build_indices()
2864
m_head_idx[func].insert(i);
2965

3066
std::vector<symbol_exprt> use;
31-
r.used_relations(*this,std::back_inserter(use));
67+
r.used_relations(*this, use);
3268
for (auto & symb : use)
3369
{
3470
m_body_idx[symb].insert(i);

src/cprover/chc_db.h

+2-43
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <util/mathematical_expr.h>
99
#include <util/std_expr.h>
1010
#include <util/find_symbols.h>
11-
#include <language_util.h>
1211

1312
#include <vector>
1413
#include <map>
@@ -101,10 +100,8 @@ class horn_clauset
101100
return m_chc < other.m_chc;
102101
}
103102

104-
template <typename OutputIterator>
105-
void used_relations(chc_dbt &db, OutputIterator out) const;
106-
template <typename OutputIterator>
107-
void used_func_app(chc_dbt &db, OutputIterator out) const;
103+
void used_relations(chc_dbt &db, std::vector<symbol_exprt> & out) const;
104+
void used_func_app(chc_dbt &db, std::vector<function_application_exprt> & out) const;
108105
};
109106

110107
/*
@@ -192,44 +189,6 @@ class chc_dbt
192189
chcst::const_iterator end() const { return m_clauses.end(); }
193190
};
194191

195-
template <typename OutputIterator>
196-
void horn_clauset::used_relations(chc_dbt &db, OutputIterator out) const
197-
{
198-
const exprt *body = this->body();
199-
if (body == nullptr) return;
200-
std::set<symbol_exprt> symbols = find_symbols(*body);
201-
202-
chc_dbt::is_state_pred filter(db);
203-
for (auto & symb : symbols) {
204-
if (filter(symb)) {
205-
*out = symb;
206-
}
207-
}
208-
}
209-
210-
template <typename OutputIterator>
211-
void horn_clauset::used_func_app(chc_dbt &db, OutputIterator out) const
212-
{
213-
const exprt *body = this->body();
214-
if (body == nullptr) return;
215-
216-
std::unordered_set<function_application_exprt, irep_hash> funcs;
217-
body->visit_pre([&funcs](const exprt &expr) {
218-
if (can_cast_expr<function_application_exprt>(expr))
219-
{
220-
const function_application_exprt & f = to_function_application_expr(expr);
221-
funcs.insert(f);
222-
}
223-
});
224-
225-
chc_dbt::is_state_pred filter(db);
226-
for (auto & f : funcs) {
227-
if (filter(to_symbol_expr(f.function()))) {
228-
*out = f;
229-
}
230-
}
231-
}
232-
233192
/*
234193
* The CHC dependency graph.
235194
* Uninterpreted relations are vertices, dependency is based on clauses:

src/cprover/chc_large_step.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class resolution_visitort : public wto_element_visitort
5858
{
5959
if(clause.is_query())
6060
{
61-
clause.used_relations(m_db, std::back_inserter(rels));
61+
clause.used_relations(m_db, rels);
6262
}
6363
}
6464

@@ -91,8 +91,7 @@ class resolution_visitort : public wto_element_visitort
9191
{
9292
auto & clause = m_db.get_clause(idx);
9393
std::vector<symbol_exprt> use;
94-
95-
clause.used_relations(m_db,std::back_inserter(use));
94+
clause.used_relations(m_db, use);
9695
if (use.size() > 1) {
9796
throw incorrect_goto_program_exceptiont("Non-linear CHCs not supported yet");
9897
}
@@ -150,7 +149,7 @@ class resolution_visitort : public wto_element_visitort
150149
const exprt &head2 = *c2.head();
151150

152151
std::vector<function_application_exprt> use2;
153-
c2.used_func_app(m_db,std::back_inserter(use2));
152+
c2.used_func_app(m_db,use2);
154153

155154
INVARIANT(use2.size() == 1, "Only handling linear case");
156155
if (use2.size() != 1)

0 commit comments

Comments
 (0)