1 /********************* */
2 /*! \file inference_manager_buffered.cpp
4 ** Top contributors (to current version):
5 ** Andrew Reynolds, Gereon Kremer
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
8 ** in the top-level source directory and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief A buffered inference manager
15 #include "theory/inference_manager_buffered.h"
17 #include "theory/rewriter.h"
18 #include "theory/theory.h"
20 using namespace CVC4::kind
;
25 InferenceManagerBuffered::InferenceManagerBuffered(Theory
& t
,
27 ProofNodeManager
* pnm
)
28 : TheoryInferenceManager(t
, state
, pnm
), d_processingPendingLemmas(false)
32 bool InferenceManagerBuffered::hasPending() const
34 return hasPendingFact() || hasPendingLemma();
37 bool InferenceManagerBuffered::hasPendingFact() const
39 return !d_pendingFact
.empty();
42 bool InferenceManagerBuffered::hasPendingLemma() const
44 return !d_pendingLem
.empty();
47 void InferenceManagerBuffered::addPendingLemma(Node lem
,
51 // make the simple theory lemma
52 d_pendingLem
.emplace_back(new SimpleTheoryLemma(lem
, p
, pg
));
55 void InferenceManagerBuffered::addPendingLemma(
56 std::unique_ptr
<TheoryInference
> lemma
)
58 d_pendingLem
.emplace_back(std::move(lemma
));
61 void InferenceManagerBuffered::addPendingFact(Node conc
,
65 // make a simple theory internal fact
66 Assert(conc
.getKind() != AND
&& conc
.getKind() != OR
);
67 d_pendingFact
.emplace_back(new SimpleTheoryInternalFact(conc
, exp
, pg
));
70 void InferenceManagerBuffered::addPendingFact(
71 std::unique_ptr
<TheoryInference
> fact
)
73 d_pendingFact
.emplace_back(std::move(fact
));
76 void InferenceManagerBuffered::addPendingPhaseRequirement(Node lit
, bool pol
)
78 // it is the responsibility of the caller to ensure lit is rewritten
79 d_pendingReqPhase
[lit
] = pol
;
82 void InferenceManagerBuffered::doPendingFacts()
85 while (!d_theoryState
.isInConflict() && i
< d_pendingFact
.size())
87 // process this fact, which notice may enqueue more pending facts in this
89 d_pendingFact
[i
]->process(this, false);
92 d_pendingFact
.clear();
95 void InferenceManagerBuffered::doPendingLemmas()
97 if (d_processingPendingLemmas
)
102 d_processingPendingLemmas
= true;
104 while (i
< d_pendingLem
.size())
106 // process this lemma, which notice may enqueue more pending lemmas in this
107 // loop, or clear the lemmas.
108 d_pendingLem
[i
]->process(this, true);
111 d_pendingLem
.clear();
112 d_processingPendingLemmas
= false;
115 void InferenceManagerBuffered::doPendingPhaseRequirements()
117 // process the pending require phase calls
118 for (const std::pair
<const Node
, bool>& prp
: d_pendingReqPhase
)
120 requirePhase(prp
.first
, prp
.second
);
122 d_pendingReqPhase
.clear();
124 void InferenceManagerBuffered::clearPending()
126 d_pendingFact
.clear();
127 d_pendingLem
.clear();
128 d_pendingReqPhase
.clear();
130 void InferenceManagerBuffered::clearPendingFacts() { d_pendingFact
.clear(); }
131 void InferenceManagerBuffered::clearPendingLemmas() { d_pendingLem
.clear(); }
132 void InferenceManagerBuffered::clearPendingPhaseRequirements()
134 d_pendingReqPhase
.clear();
138 std::size_t InferenceManagerBuffered::numPendingLemmas() const {
139 return d_pendingLem
.size();
141 std::size_t InferenceManagerBuffered::numPendingFacts() const {
142 return d_pendingFact
.size();
145 } // namespace theory