1 /********************* */
4 ** Top contributors (to current version):
5 ** Andrew Reynolds, Mathias Preiner, Tim King
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 Bitvector theory.
17 #include "cvc4_private.h"
19 #ifndef CVC4__THEORY__BV__THEORY_BV_H
20 #define CVC4__THEORY__BV__THEORY_BV_H
22 #include <unordered_map>
24 #include "theory/bv/theory_bv_rewriter.h"
25 #include "theory/theory.h"
33 class TheoryBV
: public Theory
35 /* BVSolverLazy accesses methods from theory in a way that is deprecated and
36 * will be removed in the future. For now we allow direct access. */
37 friend class BVSolverLazy
;
40 TheoryBV(context::Context
* c
,
41 context::UserContext
* u
,
44 const LogicInfo
& logicInfo
,
45 ProofNodeManager
* pnm
= nullptr,
46 std::string name
= "");
50 /** get the official theory rewriter of this theory */
51 TheoryRewriter
* getTheoryRewriter() override
;
54 * Returns true if we need an equality engine. If so, we initialize the
55 * information regarding how it should be setup. For details, see the
56 * documentation in Theory::needsEqualityEngine.
58 bool needsEqualityEngine(EeSetupInfo
& esi
) override
;
60 void finishInit() override
;
62 TrustNode
expandDefinition(Node node
) override
;
64 void preRegisterTerm(TNode n
) override
;
66 bool preCheck(Effort e
) override
;
68 void postCheck(Effort e
) override
;
70 bool preNotifyFact(TNode atom
,
74 bool isInternal
) override
;
76 void notifyFact(TNode atom
, bool pol
, TNode fact
, bool isInternal
) override
;
78 bool needsCheckLastEffort() override
;
80 void propagate(Effort e
) override
;
82 TrustNode
explain(TNode n
) override
;
84 /** Collect model values in m based on the relevant terms given by termSet */
85 bool collectModelValues(TheoryModel
* m
,
86 const std::set
<Node
>& termSet
) override
;
88 std::string
identify() const override
{ return std::string("TheoryBV"); }
90 PPAssertStatus
ppAssert(TNode in
, SubstitutionMap
& outSubstitutions
) override
;
92 TrustNode
ppRewrite(TNode t
) override
;
94 void ppStaticLearn(TNode in
, NodeBuilder
<>& learned
) override
;
96 void presolve() override
;
98 /** Called by abstraction preprocessing pass. */
99 bool applyAbstraction(const std::vector
<Node
>& assertions
,
100 std::vector
<Node
>& new_assertions
);
103 void notifySharedTerm(TNode t
) override
;
106 * Return the UF symbol corresponding to division-by-zero for this particular
108 * @param k should be UREM or UDIV
109 * @param width bit-width
111 Node
getUFDivByZero(Kind k
, unsigned width
);
113 /** Internal BV solver. */
114 std::unique_ptr
<BVSolver
> d_internal
;
117 * Maps from bit-vector width to division-by-zero uninterpreted
120 std::unordered_map
<unsigned, Node
> d_ufDivByZero
;
121 std::unordered_map
<unsigned, Node
> d_ufRemByZero
;
123 /** The theory rewriter for this theory. */
124 TheoryBVRewriter d_rewriter
;
126 /** A (default) theory state object */
129 /** A (default) theory inference manager. */
130 TheoryInferenceManager d_inferMgr
;
132 }; /* class TheoryBV */
135 } // namespace theory
138 #endif /* CVC4__THEORY__BV__THEORY_BV_H */