blob: f684045c615ced400ad81c78692f1f072e2d2a41 (
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
|
/********************* */
/*! \file proof_set.h
** \verbatim
** Top contributors (to current version):
** Gereon Kremer, 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 Proof set utility
**/
#include "cvc4_private.h"
#ifndef CVC5__EXPR__PROOF_SET_H
#define CVC5__EXPR__PROOF_SET_H
#include <memory>
#include "context/cdlist.h"
#include "context/context.h"
#include "expr/proof_node_manager.h"
namespace cvc5 {
/**
* A (context-dependent) set of proofs, which is used for memory
* management purposes.
*/
template <typename T>
class CDProofSet
{
public:
CDProofSet(ProofNodeManager* pnm,
context::Context* c,
std::string namePrefix = "Proof")
: d_pnm(pnm), d_proofs(c), d_namePrefix(namePrefix)
{
}
/**
* Allocate a new proof.
*
* This returns a fresh proof object that remains alive in the context given
* to this class. Internally, this adds a new proof of type T to a
* context-dependent list of proofs and passes the following arguments to the
* T constructor:
* pnm, args..., name
* where pnm is the proof node manager
* provided to this proof set upon construction, args... are the arguments to
* allocateProof() and name is the namePrefix with an appended index.
*/
template <typename... Args>
T* allocateProof(Args&&... args)
{
d_proofs.push_back(std::make_shared<T>(
d_pnm,
std::forward<Args>(args)...,
d_namePrefix + "_" + std::to_string(d_proofs.size())));
return d_proofs.back().get();
}
protected:
/** The proof node manager */
ProofNodeManager* d_pnm;
/** A context-dependent list of lazy proofs. */
context::CDList<std::shared_ptr<T>> d_proofs;
/** The name prefix of the lazy proofs */
std::string d_namePrefix;
};
} // namespace cvc5
#endif /* CVC5__EXPR__LAZY_PROOF_SET_H */
|