1 /********************* */
2 /*! \file inference_manager.h
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 Customized inference manager for the theory of nonlinear arithmetic
15 #include "cvc4_private.h"
17 #ifndef CVC4__THEORY__ARITH__INFERENCE_MANAGER_H
18 #define CVC4__THEORY__ARITH__INFERENCE_MANAGER_H
23 #include "theory/arith/arith_lemma.h"
24 #include "theory/arith/arith_state.h"
25 #include "theory/arith/inference_id.h"
26 #include "theory/arith/nl/nl_lemma_utils.h"
27 #include "theory/inference_manager_buffered.h"
36 * A specialized variant of the InferenceManagerBuffered, tailored to the
39 * It adds some convenience methods to send ArithLemma and adds a mechanism for
40 * waiting lemmas that can be flushed into the pending lemmas of the this
41 * buffered inference manager.
42 * It also extends the caching mechanism of TheoryInferenceManager to cache
43 * preprocessing lemmas and non-preprocessing lemmas separately. For the former,
44 * it uses the cache provided by the TheoryInferenceManager base class.
46 class InferenceManager
: public InferenceManagerBuffered
48 using NodeSet
= context::CDHashSet
<Node
, NodeHashFunction
>;
51 InferenceManager(TheoryArith
& ta
, ArithState
& astate
, ProofNodeManager
* pnm
);
54 * Add a lemma as pending lemma to the this inference manager.
55 * If isWaiting is true, the lemma is first stored as waiting lemma and only
56 * added as pending lemma when calling flushWaitingLemmas.
58 void addPendingArithLemma(std::unique_ptr
<ArithLemma
> lemma
,
59 bool isWaiting
= false);
61 * Add a lemma as pending lemma to the this inference manager.
62 * If isWaiting is true, the lemma is first stored as waiting lemma and only
63 * added as pending lemma when calling flushWaitingLemmas.
65 void addPendingArithLemma(const ArithLemma
& lemma
, bool isWaiting
= false);
67 * Add a lemma as pending lemma to the this inference manager.
68 * If isWaiting is true, the lemma is first stored as waiting lemma and only
69 * added as pending lemma when calling flushWaitingLemmas.
71 void addPendingArithLemma(const Node
& lemma
,
73 bool isWaiting
= false);
76 * Flush all waiting lemmas to the this inference manager (as pending
77 * lemmas). To actually send them, call doPendingLemmas() afterwards.
79 void flushWaitingLemmas();
82 * Removes all waiting lemmas without sending them anywhere.
84 void clearWaitingLemmas();
86 /** Add a conflict to the this inference manager. */
87 void addConflict(const Node
& conf
, InferenceId inftype
);
90 * Checks whether we have made any progress, that is whether a conflict, lemma
91 * or fact was added or whether a lemma or fact is pending.
95 /** Checks whether we have waiting lemmas. */
96 bool hasWaitingLemma() const;
98 /** Returns the number of pending lemmas. */
99 std::size_t numWaitingLemmas() const;
101 /** Checks whether the given lemma is already present in the cache. */
102 virtual bool hasCachedLemma(TNode lem
, LemmaProperty p
) override
;
106 * Adds the given lemma to the cache. Returns true if it has not been in the
109 virtual bool cacheLemma(TNode lem
, LemmaProperty p
) override
;
113 * Checks whether the lemma is entailed to be false. In this case, it is a
116 bool isEntailedFalse(const ArithLemma
& lem
);
118 /** The waiting lemmas. */
119 std::vector
<std::unique_ptr
<ArithLemma
>> d_waitingLem
;
121 /** cache of all preprocessed lemmas sent on the output channel
122 * (user-context-dependent) */
127 } // namespace theory