Skip to content

Commit 8df40d1

Browse files
Yakir Vizelyvizel
authored andcommitted
Some comments and minor modifications
1 parent 7638533 commit 8df40d1

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

src/cprover/chc_large_step.h

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
#include <util/substitute_symbols.h>
1010
#include <util/format_expr.h>
1111

12-
/*
13-
* Traverses the clauses in order and resolving all predicates (symbols)
14-
* that are not a head (e.g. a head of a loop).
12+
/**
13+
* Traverses the clauses in order (wto) and resolving all predicates (symbols)
14+
* that are not a head of a component (e.g. a head of a loop).
1515
* This is similar to variable elimination in SAT.
1616
*/
1717
class resolution_visitort : public wto_element_visitort
@@ -38,15 +38,19 @@ class resolution_visitort : public wto_element_visitort
3838
{
3939
const symbol_exprt* head = comp.head();
4040
m_heads.insert(head->hash());
41-
std::string str = head->get_identifier().c_str();
42-
std::cout << "Head: " << str << "\n";
41+
if (m_verbose)
42+
{
43+
std::string str = head->get_identifier().c_str();
44+
std::cout << "Head: " << str << "\n";
45+
}
4346
for (auto it = comp.begin(); it != comp.end(); it++)
4447
{
4548
it->get()->accept(this);
4649
}
4750
eliminate(head);
4851
}
4952

53+
// Create the new CHC db after eliminating uninterpreted predicates.
5054
void populate_new_db()
5155
{
5256
std::vector<symbol_exprt> rels;
@@ -131,6 +135,13 @@ class resolution_visitort : public wto_element_visitort
131135
}
132136
}
133137

138+
/** Assuming the following shapes:
139+
* c1 := Sxx(ς) ∧ ς(COND1) ⇒ Syy(ς[update1])
140+
* c2 := Syy(ς) ∧ ς(COND2) ⇒ Szz(ς[update2])
141+
* In this case, Syy(ς) is eliminated and we use substitution for c2 such
142+
* that it "operates" over ς[update1]. This results in:
143+
* Sxx(ς) ∧ ς(COND1) ∧ ς[update1](COND2) ⇒ Szz(ς[update1][update2])
144+
*/
134145
forall_exprt resolve_clauses(const horn_clauset & c1, const horn_clauset & c2)
135146
{
136147
const exprt &body1 = *c1.body();

src/cprover/chc_wto.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@
1717
class wto_singletont;
1818
class wto_componentt;
1919

20+
/**
21+
* Bourdoncle Components over the cut-point graph of CHCs is a weak topological
22+
* ordering (wto) on cut-points. This is mainly known from the work on
23+
* widening operations in abstract interpretation. The most common intuition
24+
* is an ordering of graph vertices with well-formed (aka well-matched)
25+
* parentheses that mark components.
26+
*
27+
* For example, 1 (2 (3 4 5 6) 7) 8 is a wto with two components, where the
28+
* inner componenet includes vertices 3-6, the outter component includes
29+
* vertices 2 and 7. In this simple example, vertex 1 is the entry point, and
30+
* vertex 8 is the exit point. Vertex 2 can be though of as the head of the
31+
* outer loop, while vertex 3 is the head of the inner loop.
32+
*
33+
* The wto is used to guide the elimination step.
34+
*/
35+
2036
class wto_element_visitort
2137
{
2238
public:
@@ -171,7 +187,6 @@ class chc_wtot
171187
}
172188

173189
inf_numt visit(const symbol_exprt* v, std::deque<wto_element_ptr> &partition) {
174-
std::string name = as_string(v->get_identifier());
175190
m_stack.push_back(v);
176191
m_dfn[v->hash()] = m_cur_dfn_num++;
177192
auto head = get_dfn(v);
@@ -276,6 +291,10 @@ class chc_wtot
276291
}
277292
};
278293

294+
/**
295+
* Simple Visitor prints the components of the WTO with well-formed
296+
* parentheses.
297+
*/
279298
class simple_visitort : public wto_element_visitort
280299
{
281300
virtual void visit(const wto_singletont & s)

src/cprover/cutpoint_graph.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,16 @@
1414
* 1. Entry node
1515
* 2. Exit node
1616
* 3. Every node that has a back-edge - namely, a loop head.
17+
* This graph is used for large-step encoding of CHCs. Uninterpreted predicates
18+
* are only needed where there are cut-points.
1719
*/
1820

1921
class cutpoint_grapht;
2022
class cutpointt;
2123

24+
/**
25+
* A class that represents an edge in the graph
26+
*/
2227
class cutpoint_edget
2328
{
2429
friend class cutpoint_grapht;
@@ -55,6 +60,9 @@ class cutpoint_edget
5560

5661
typedef std::shared_ptr<cutpoint_edget> cutpoint_edge_ptr;
5762

63+
/**
64+
* A class that represents a cutpoint in the graph
65+
*/
5866
class cutpointt
5967
{
6068
const cutpoint_grapht &m_graph;
@@ -87,6 +95,9 @@ class cutpointt
8795
}
8896
};
8997

98+
/**
99+
* The graph
100+
*/
90101
class cutpoint_grapht
91102
{
92103
const goto_modelt & m_goto_model;

0 commit comments

Comments
 (0)