Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * This file is part of the cvc5 project. 3 : : * 4 : : * Copyright (c) 2009-2026 by the authors listed in the file AUTHORS 5 : : * in the top-level source directory and their institutional affiliations. 6 : : * All rights reserved. See the file COPYING in the top-level source 7 : : * directory for licensing information. 8 : : * **************************************************************************** 9 : : * 10 : : * Theory of bit-vectors. 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__THEORY__BV__THEORY_BV_H 16 : : #define CVC5__THEORY__BV__THEORY_BV_H 17 : : 18 : : #include "theory/bv/bv_pp_assert.h" 19 : : #include "theory/bv/proof_checker.h" 20 : : #include "theory/bv/theory_bv_rewriter.h" 21 : : #include "theory/theory.h" 22 : : #include "theory/theory_eq_notify.h" 23 : : #include "theory/theory_state.h" 24 : : 25 : : namespace cvc5::internal { 26 : : 27 : : class ProofRuleChecker; 28 : : 29 : : namespace theory { 30 : : namespace bv { 31 : : 32 : : class BVSolver; 33 : : 34 : : class TheoryBV : public Theory 35 : : { 36 : : public: 37 : : TheoryBV(Env& env, 38 : : OutputChannel& out, 39 : : Valuation valuation, 40 : : std::string name = ""); 41 : : 42 : : ~TheoryBV(); 43 : : 44 : : /** get the official theory rewriter of this theory */ 45 : : TheoryRewriter* getTheoryRewriter() override; 46 : : /** get the proof checker of this theory */ 47 : : ProofRuleChecker* getProofChecker() override; 48 : : 49 : : /** 50 : : * Returns true if we need an equality engine. If so, we initialize the 51 : : * information regarding how it should be setup. For details, see the 52 : : * documentation in Theory::needsEqualityEngine. 53 : : */ 54 : : bool needsEqualityEngine(EeSetupInfo& esi) override; 55 : : 56 : : void finishInit() override; 57 : : 58 : : void preRegisterTerm(TNode n) override; 59 : : 60 : : bool preCheck(Effort e) override; 61 : : 62 : : void postCheck(Effort e) override; 63 : : 64 : : bool preNotifyFact(TNode atom, 65 : : bool pol, 66 : : TNode fact, 67 : : bool isPrereg, 68 : : bool isInternal) override; 69 : : 70 : : void notifyFact(TNode atom, bool pol, TNode fact, bool isInternal) override; 71 : : 72 : : bool needsCheckLastEffort() override; 73 : : 74 : : void propagate(Effort e) override; 75 : : 76 : : TrustNode explain(TNode n) override; 77 : : 78 : : void computeRelevantTerms(std::set<Node>& termSet) override; 79 : : 80 : : /** Collect model values in m based on the relevant terms given by termSet */ 81 : : bool collectModelValues(TheoryModel* m, 82 : : const std::set<Node>& termSet) override; 83 : : 84 : 0 : std::string identify() const override { return std::string("TheoryBV"); } 85 : : 86 : : bool ppAssert(TrustNode in, TrustSubstitutionMap& outSubstitutions) override; 87 : : 88 : : TrustNode ppRewrite(TNode t, std::vector<SkolemLemma>& lems) override; 89 : : 90 : : TrustNode ppStaticRewrite(TNode atom) override; 91 : : 92 : : void ppStaticLearn(TNode in, std::vector<TrustNode>& learned) override; 93 : : 94 : : void presolve() override; 95 : : 96 : : EqualityStatus getEqualityStatus(TNode a, TNode b) override; 97 : : 98 : : private: 99 : : void notifySharedTerm(TNode t) override; 100 : : 101 : : Node getValue(TNode node); 102 : : 103 : : /** Internal BV solver. */ 104 : : std::unique_ptr<BVSolver> d_internal; 105 : : 106 : : /** The preprocess assertion utility */ 107 : : BvPpAssert d_ppAssert; 108 : : 109 : : /** The theory rewriter for this theory. */ 110 : : TheoryBVRewriter d_rewriter; 111 : : 112 : : /** A (default) theory state object */ 113 : : TheoryState d_state; 114 : : 115 : : /** A (default) theory inference manager. */ 116 : : TheoryInferenceManager d_im; 117 : : 118 : : /** The notify class for equality engine. */ 119 : : TheoryEqNotifyClass d_notify; 120 : : 121 : : /** Flag indicating whether `d_modelCache` should be invalidated. */ 122 : : context::CDO<bool> d_invalidateModelCache; 123 : : 124 : : /** 125 : : * Cache for getValue() calls. 126 : : * 127 : : * Is cleared at the beginning of a getValue() call if the 128 : : * `d_invalidateModelCache` flag is set to true. 129 : : */ 130 : : std::unordered_map<Node, Node> d_modelCache; 131 : : 132 : : /** TheoryBV statistics. */ 133 : : struct Statistics 134 : : { 135 : : Statistics(StatisticsRegistry& reg, const std::string& name); 136 : : IntStat d_solveSubstitutions; 137 : : } d_stats; 138 : : 139 : : /** Proof rule checker */ 140 : : BVProofRuleChecker d_checker; 141 : : }; /* class TheoryBV */ 142 : : 143 : : } // namespace bv 144 : : } // namespace theory 145 : : } // namespace cvc5::internal 146 : : 147 : : #endif /* CVC5__THEORY__BV__THEORY_BV_H */