blob: 28be23e54ad3356a6bbe21c2162d1902dfcc00ec (
plain)
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/********************* */
/*! \file proof_manager.h
** \verbatim
** Top contributors (to current version):
** Liana Hadarean, Haniel Barbosa, Andrew Reynolds
** This file is part of the CVC4 project.
** Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
** in the top-level source directory and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief A manager for Proofs
**
** A manager for Proofs.
**/
#include "cvc4_private.h"
#ifndef CVC5__PROOF_MANAGER_H
#define CVC5__PROOF_MANAGER_H
#include <memory>
#include <unordered_map>
#include <unordered_set>
#include "context/cdhashmap.h"
#include "context/cdhashset.h"
#include "expr/node.h"
#include "proof/clause_id.h"
namespace cvc5 {
// forward declarations
namespace Minisat {
class Solver;
}/* Minisat namespace */
namespace prop {
class CnfStream;
} // namespace prop
class SmtEngine;
template <class Solver> class TSatProof;
typedef TSatProof<cvc5::Minisat::Solver> CoreSatProof;
class CnfProof;
typedef TSatProof<cvc5::Minisat::Solver> CoreSatProof;
namespace prop {
typedef uint64_t SatVariable;
class SatLiteral;
typedef std::vector<SatLiteral> SatClause;
} // namespace prop
typedef std::unordered_map<ClauseId, prop::SatClause*> IdToSatClause;
typedef context::CDHashSet<Node, NodeHashFunction> CDNodeSet;
typedef context::CDHashMap<Node, std::vector<Node>, NodeHashFunction> CDNodeToNodes;
typedef std::unordered_set<ClauseId> IdHashSet;
class ProofManager {
context::Context* d_context;
std::unique_ptr<CoreSatProof> d_satProof;
std::unique_ptr<CnfProof> d_cnfProof;
// information that will need to be shared across proofs
CDNodeSet d_inputCoreFormulas;
CDNodeSet d_outputCoreFormulas;
int d_nextId;
CDNodeToNodes d_deps;
public:
ProofManager(context::Context* context);
~ProofManager();
static ProofManager* currentPM();
// initialization
void initSatProof(Minisat::Solver* solver);
void initCnfProof(cvc5::prop::CnfStream* cnfStream, context::Context* ctx);
// getting various proofs
static CoreSatProof* getSatProof();
static CnfProof* getCnfProof();
/** Public unsat core methods **/
void addCoreAssertion(Node formula);
void addDependence(TNode n, TNode dep);
void addUnsatCore(Node formula);
// trace dependences back to unsat core
void traceDeps(TNode n, CDNodeSet* coreAssertions);
void traceUnsatCore();
typedef CDNodeSet::const_iterator output_core_iterator;
output_core_iterator begin_unsat_core() const
{
return d_outputCoreFormulas.begin();
}
output_core_iterator end_unsat_core() const
{
return d_outputCoreFormulas.end();
}
size_t size_unsat_core() const { return d_outputCoreFormulas.size(); }
std::vector<Node> extractUnsatCore();
bool unsatCoreAvailable() const;
void getLemmasInUnsatCore(std::vector<Node>& lemmas);
int nextId() { return d_nextId++; }
private:
void constructSatProof();
};/* class ProofManager */
} // namespace cvc5
#endif /* CVC5__PROOF_MANAGER_H */
|