Skip to content

Commit 710f96f

Browse files
author
Yakir Vizel
committed
Extracting new chcs after transformation
1 parent 05277f4 commit 710f96f

File tree

2 files changed

+32
-36
lines changed

2 files changed

+32
-36
lines changed

src/cprover/chc_large_step.h

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class ResolutionVisitor : public wto_element_visitort
2020
public:
2121
ResolutionVisitor(chc_db & db) : m_db(db) {}
2222

23+
chc_db &giveme_new_db() { return m_new_db; }
24+
2325
virtual void visit(const wto_singletont & s)
2426
{
2527
const symbol_exprt* symb = s.get();
@@ -39,23 +41,37 @@ class ResolutionVisitor : public wto_element_visitort
3941
resolve(head);
4042
}
4143

42-
std::vector<horn_clause> getClauses()
44+
void populate_new_db()
4345
{
44-
std::vector<horn_clause> all;
45-
for (auto it = m_heads.begin(); it != m_heads.end(); it++)
46+
std::vector<symbol_exprt> rels;
47+
for (auto &clause : m_db)
48+
{
49+
if(clause.is_query())
50+
{
51+
clause.used_relations(m_db, std::back_inserter(rels));
52+
}
53+
}
54+
55+
std::set<std::size_t > preds_hash(m_heads.begin(), m_heads.end());
56+
for (auto p : rels) {
57+
preds_hash.insert(p.hash());
58+
}
59+
60+
for (auto it : preds_hash)
4661
{
47-
auto c = m_def.find(*it);
62+
auto c = m_def.find(it);
4863
INVARIANT(c != m_def.end(), "No clauses");
49-
all.insert(all.begin(), c->second.begin(), c->second.end());
64+
for (auto clause : c->second)
65+
m_new_db.add_clause(clause.get_chc());
5066
}
51-
return all;
52-
}
5367

54-
const std::vector<horn_clause>& getClauses(const symbol_exprt* symb)
55-
{
56-
auto it = m_def.find(symb->hash());
57-
INVARIANT(it != m_def.end(), "No clauses");
58-
return it->second;
68+
for (auto &clause : m_db)
69+
{
70+
if(clause.is_query())
71+
{
72+
m_new_db.add_clause(clause.get_chc());
73+
}
74+
}
5975
}
6076

6177
private:

src/cprover/state_encoding.cpp

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,45 +1261,25 @@ void large_step_encoding(const container_encoding_targett & small_step_container
12611261
{
12621262
db.add_state_pred(s);
12631263
}
1264-
12651264
}
12661265
chc_graph chc_g(db);
12671266
chc_g.build_graph();
12681267

12691268
chc_wtot wto(chc_g);
12701269
wto.build_wto();
12711270

1272-
SimpleVisitor v;
1273-
for (auto it = wto.begin(); it != wto.end(); it++)
1274-
{
1275-
auto x = (*it);
1276-
x->accept(&v);
1277-
}
1278-
1279-
std::cout << "\n";
1280-
12811271
ResolutionVisitor rv(db);
12821272
for (auto it = wto.begin(); it != wto.end(); it++)
12831273
{
12841274
auto x = (*it);
12851275
x->accept(&rv);
12861276
}
12871277

1288-
std::vector<horn_clause> all = rv.getClauses();
1289-
for (auto &clause : db) {
1290-
if (clause.is_query()) {
1291-
std::vector<symbol_exprt> rels;
1292-
clause.used_relations(db, std::back_inserter(rels));
1293-
for (auto pred : rels)
1294-
{
1295-
all.insert(all.end(), rv.getClauses(&pred).begin(), rv.getClauses(&pred).end());
1296-
}
1297-
all.push_back(clause.get_chc());
1298-
}
1299-
1300-
}
1278+
rv.populate_new_db();
13011279

1302-
for (auto ce : all)
1280+
container_encoding_targett container2;
1281+
std::vector<horn_clause> all2;
1282+
for (auto & ce : rv.giveme_new_db())
13031283
{
13041284
large_step_container << ce.get_chc();
13051285
}

0 commit comments

Comments
 (0)