1 /********************* */
2 /*! \file inference_manager_buffered.cpp
4 ** Top contributors (to current version):
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
)
32 bool InferenceManagerBuffered::hasProcessed() const
34 return d_theoryState
.isInConflict() || !d_pendingLem
.empty()
35 || !d_pendingFact
.empty();
38 bool InferenceManagerBuffered::hasPendingFact() const
40 return !d_pendingFact
.empty();
43 bool InferenceManagerBuffered::hasPendingLemma() const
45 return !d_pendingLem
.empty();
48 void InferenceManagerBuffered::addPendingLemma(Node lem
,
52 // make the simple theory lemma
53 d_pendingLem
.push_back(std::make_shared
<SimpleTheoryLemma
>(lem
, p
, pg
));
56 void InferenceManagerBuffered::addPendingLemma(
57 std::shared_ptr
<TheoryInference
> lemma
)
59 d_pendingLem
.emplace_back(std::move(lemma
));
62 void InferenceManagerBuffered::addPendingFact(Node conc
,
66 // make a simple theory internal fact
67 Assert(conc
.getKind() != AND
&& conc
.getKind() != OR
);
68 d_pendingFact
.push_back(
69 std::make_shared
<SimpleTheoryInternalFact
>(conc
, exp
, pg
));
72 void InferenceManagerBuffered::addPendingFact(
73 std::shared_ptr
<TheoryInference
> fact
)
75 d_pendingFact
.emplace_back(std::move(fact
));
78 void InferenceManagerBuffered::addPendingPhaseRequirement(Node lit
, bool pol
)
80 // must ensure rewritten
81 lit
= Rewriter::rewrite(lit
);
82 d_pendingReqPhase
[lit
] = pol
;
85 void InferenceManagerBuffered::doPendingFacts()
88 while (!d_theoryState
.isInConflict() && i
< d_pendingFact
.size())
90 // process this fact, which notice may enqueue more pending facts in this
92 d_pendingFact
[i
]->process(this);
95 d_pendingFact
.clear();
98 void InferenceManagerBuffered::doPendingLemmas()
100 for (const std::shared_ptr
<TheoryInference
>& plem
: d_pendingLem
)
102 // process this lemma
105 d_pendingLem
.clear();
108 void InferenceManagerBuffered::doPendingPhaseRequirements()
110 // process the pending require phase calls
111 for (const std::pair
<const Node
, bool>& prp
: d_pendingReqPhase
)
113 d_out
.requirePhase(prp
.first
, prp
.second
);
115 d_pendingReqPhase
.clear();
117 void InferenceManagerBuffered::clearPendingFacts() { d_pendingFact
.clear(); }
118 void InferenceManagerBuffered::clearPendingLemmas() { d_pendingLem
.clear(); }
119 void InferenceManagerBuffered::clearPendingPhaseRequirements()
121 d_pendingReqPhase
.clear();
124 } // namespace theory