blob: 3013c9b55f16065786ed712ef16b168becdd213a (
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
126
127
128
129
|
/********************* */
/*! \file proof_manager.h
** \verbatim
** Top contributors (to current version):
** Liana Hadarean, Guy Katz, Andres Noetzli
** This file is part of the CVC4 project.
** Copyright (c) 2009-2020 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 CVC4__PROOF_MANAGER_H
#define CVC4__PROOF_MANAGER_H
#include <iosfwd>
#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"
#include "util/statistics_registry.h"
namespace CVC4 {
// forward declarations
namespace Minisat {
class Solver;
}/* Minisat namespace */
namespace prop {
class CnfStream;
}/* CVC4::prop namespace */
class SmtEngine;
template <class Solver> class TSatProof;
typedef TSatProof< CVC4::Minisat::Solver> CoreSatProof;
class CnfProof;
typedef TSatProof<CVC4::Minisat::Solver> CoreSatProof;
namespace prop {
typedef uint64_t SatVariable;
class SatLiteral;
typedef std::vector<SatLiteral> SatClause;
}/* CVC4::prop namespace */
typedef std::unordered_map<ClauseId, prop::SatClause*> IdToSatClause;
typedef context::CDHashSet<Expr, ExprHashFunction> CDExprSet;
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
CDExprSet d_inputCoreFormulas;
CDExprSet 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(CVC4::prop::CnfStream* cnfStream, context::Context* ctx);
// getting various proofs
static CoreSatProof* getSatProof();
static CnfProof* getCnfProof();
/** Public unsat core methods **/
void addCoreAssertion(Expr formula);
void addDependence(TNode n, TNode dep);
void addUnsatCore(Expr formula);
// trace dependences back to unsat core
void traceDeps(TNode n, CDExprSet* coreAssertions);
void traceUnsatCore();
typedef CDExprSet::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<Expr> extractUnsatCore();
bool unsatCoreAvailable() const;
void getLemmasInUnsatCore(std::vector<Node>& lemmas);
int nextId() { return d_nextId++; }
private:
void constructSatProof();
};/* class ProofManager */
}/* CVC4 namespace */
#endif /* CVC4__PROOF_MANAGER_H */
|