CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
resolution_proof.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#include "resolution_proof.h"
10
11#include <util/invariant.h>
12
13#include <stack>
14
15template<class T>
16void resolution_prooft<T>::build_core(std::vector<bool> &in_core)
17{
18 PRECONDITION(!clauses.empty());
19
20 std::stack<typename clausest::size_type> s;
21 std::vector<bool> seen;
22
23 seen.resize(clauses.size(), false);
24
25 s.push(clauses.size()-1);
26
27 while(!s.empty())
28 {
29 typename clausest::size_type c_id=s.top();
30 s.pop();
31
32 if(seen[c_id])
33 continue;
34 seen[c_id]=true;
35
36 const T &c=clauses[c_id];
37
38 if(c.is_root)
39 {
40 for(std::size_t i=0; i<c.root_clause.size(); i++)
41 {
42 unsigned v=c.root_clause[i].var_no();
44 v < in_core.size(), "variable number should be within bounds");
45 in_core[v]=true;
46 }
47 }
48 else
49 {
51 c.first_clause_id < c_id,
52 "id of the clause to be pushed onto the clause stack shall be smaller "
53 "than the id of the current clause");
54 s.push(c.first_clause_id);
55
56 for(clauset::stepst::size_type i=0; i<c.steps.size(); i++)
57 {
58 // must decrease
60 c.steps[i].clause_id < c_id,
61 "id of the clause to be pushed onto the clause stack shall be "
62 "smaller than the id of the current clause");
63 s.push(c.steps[i].clause_id);
64 }
65 }
66 }
67}
68
69template class resolution_prooft<clauset>;
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
ait()
Definition ai.h:565
void build_core(std::vector< bool > &in_core)
#define PRECONDITION(CONDITION)
Definition invariant.h:463
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
Definition invariant.h:423