-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathSATInference.cpp
108 lines (91 loc) · 2.15 KB
/
SATInference.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/*
* This file is part of the source code of the software program
* Vampire. It is protected by applicable
* copyright laws.
*
* This source code is distributed under the licence found here
* https://vprover.github.io/license.html
* and in the source directory
*/
/**
* @file SATInference.cpp
* Implements class SATInference.
*/
#include "Kernel/Clause.hpp"
#include "Shell/Statistics.hpp"
#include "SATInference.hpp"
#include "MinisatInterfacing.hpp"
namespace SAT
{
///////////////////////
// SATInference
//
/**
* Collect first-order premises of @c cl into @c res. Make sure that elements in @c res are unique.
*/
void SATInference::collectFOPremises(SATClause* cl, Stack<Unit*>& acc)
{
collectFilteredFOPremises(cl,acc, [](SATClause*) {return true; } );
}
UnitList* SATInference::getFOPremises(SATClause* cl)
{
ASS(cl);
ASS(cl->inference());
static Stack<Unit*> prems;
prems.reset();
collectFOPremises(cl, prems);
UnitList* res = 0;
while (prems.isNonEmpty()) {
Unit* us = prems.pop();
UnitList::push(us, res);
}
return res;
}
void SATInference::collectPropAxioms(SATClause* cl, SATClauseStack& res)
{
static Stack<SATClause*> toDo;
static DHSet<SATClause*> seen;
toDo.reset();
seen.reset();
toDo.push(cl);
while (toDo.isNonEmpty()) {
SATClause* cur = toDo.pop();
if (!seen.insert(cur)) {
continue;
}
SATInference* sinf = cur->inference();
ASS(sinf);
switch(sinf->getType()) {
case SATInference::FO_CONVERSION:
res.push(cur);
break;
case SATInference::ASSUMPTION:
break;
case SATInference::PROP_INF:
{
PropInference* pinf = static_cast<PropInference*>(sinf);
toDo.loadFromIterator(SATClauseList::Iterator(pinf->getPremises()));
break;
}
default:
ASSERTION_VIOLATION;
}
}
makeUnique(res);
}
///////////////////////
// FOConversionInference
//
FOConversionInference::FOConversionInference(Unit* origin) : _origin(origin)
{
_origin->incRefCnt();
}
FOConversionInference::FOConversionInference(Clause* cl) : _origin(cl)
{
_origin->incRefCnt();
}
FOConversionInference::~FOConversionInference()
{
_origin->decRefCnt();
}
}