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
/*
* 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 FormulaUnit.cpp
* Defines class FormulaUnit for units consisting of formulas.
*
* @since 19/05/2007 Manchester
*/
#include "Lib/Int.hpp"
#include "Formula.hpp"
#include "FormulaUnit.hpp"
#include "Inference.hpp"
#include "FormulaVarIterator.hpp"
using namespace std;
using namespace Lib;
using namespace Kernel;
/**
* Destroy the unit by deleting it.
* @since 19/05/2007 Manchester
*/
void FormulaUnit::destroy()
{
_inference.destroy(); // decrease counters on parents and release heap allocated things own by _inference
delete this;
} // FormulaUnit::destroy
/**
* Convert the unit to the std::string representation.
* @since 20/05/2007 Manchester
*/
std::string FormulaUnit::toString() const
{
return Int::toString(_number) + ". " + _formula->toString() +
' ' + inferenceAsString();
} // FormulaUnit::toString
unsigned FormulaUnit::varCnt()
{
Formula* frm = formula();
VList* fv = freeVariables(frm);
VList* bv = frm->boundVariables();
unsigned res = VList::length(fv) + VList::length(bv);
VList::destroy(fv);
VList::destroy(bv);
return res;
}
/**
* Return color of the formula
*
* We do not store the color of the formula, so it gets
* computed again each time the function is called.
*/
Color FormulaUnit::getColor()
{
ASS_ALLOC_TYPE(this, "FormulaUnit");
if (_cachedColor == COLOR_INVALID) {
_cachedColor = this->formula()->getColor();
}
return _cachedColor;
}
unsigned FormulaUnit::weight()
{
ASS_ALLOC_TYPE(this, "FormulaUnit");
if (!_cachedWeight) {
_cachedWeight = this->formula()->weight();
}
return _cachedWeight;
}