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
/*
* 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 EquationalTautologyRemoval.cpp
* Implements class EquationalTautologyRemoval.
*/
#include "EquationalTautologyRemoval.hpp"
#include "Lib/DHSet.hpp"
#include "Lib/Environment.hpp"
#include "Shell/Statistics.hpp"
#include "Kernel/Clause.hpp"
namespace Inferences
{
using namespace std;
Clause* EquationalTautologyRemoval::simplify(Clause* cl)
{
// first check whether it makes sense to trigger CC:
// 1) there should be at least one negative equality and
// 2a) there should also be a positive one or
// 2b) there should be complementary non-equality literals
bool has_neg_eq = false;
bool has_pos_eq = false;
bool has_complement = false;
static DHSet<int> preds;
preds.reset();
for (unsigned i = 0; i < cl->length(); i++) {
Literal* lit = (*cl)[i];
if (lit->isEquality()) {
if (lit->isNegative()) {
has_neg_eq = true;
} else {
has_pos_eq = true;
}
} else {
ASS_G(lit->functor(),0);
int pred = lit->isNegative() ? -lit->functor() : lit->functor();
if (preds.find(-pred)) {
has_complement = true;
}
preds.insert(pred);
}
}
if (!has_neg_eq || (!has_pos_eq && !has_complement)) {
return cl;
}
_cc.reset();
// insert complements of literals from cl, that could possibly lead to a conflict
for (unsigned i = 0; i < cl->length(); i++) {
Literal* lit = (*cl)[i];
if (!lit->isEquality()) {
int pred = lit->isNegative() ? -lit->functor() : lit->functor();
if (!preds.find(-pred)) {
continue;
}
}
// equality predicate and those who have complements go in
Literal* oplit = Literal::complementaryLiteral(lit);
_cc.addLiteral(oplit);
}
if (_cc.getStatus(false) == DP::DecisionProcedure::UNSATISFIABLE) {
// cout << "Deep equational: " << cl->toString() << endl;
env.statistics->deepEquationalTautologies++;
return 0;
} else {
return cl;
}
}
}