Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds, Tim King, Kshitij Bansal 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2024 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. 11 : : * **************************************************************************** 12 : : * 13 : : * Sets theory. 14 : : */ 15 : : 16 : : #include "cvc5_private.h" 17 : : 18 : : #ifndef CVC5__THEORY__SETS__THEORY_SETS_H 19 : : #define CVC5__THEORY__SETS__THEORY_SETS_H 20 : : 21 : : #include <memory> 22 : : 23 : : #include "smt/logic_exception.h" 24 : : #include "theory/care_pair_argument_callback.h" 25 : : #include "theory/sets/inference_manager.h" 26 : : #include "theory/sets/proof_checker.h" 27 : : #include "theory/sets/skolem_cache.h" 28 : : #include "theory/sets/solver_state.h" 29 : : #include "theory/sets/theory_sets_rewriter.h" 30 : : #include "theory/theory.h" 31 : : #include "theory/theory_eq_notify.h" 32 : : 33 : : namespace cvc5::internal { 34 : : namespace theory { 35 : : namespace sets { 36 : : 37 : : class TheorySetsPrivate; 38 : : class TheorySetsScrutinize; 39 : : 40 : : class TheorySets : public Theory 41 : : { 42 : : friend class TheorySetsPrivate; 43 : : friend class TheorySetsRels; 44 : : public: 45 : : /** Constructs a new instance of TheorySets w.r.t. the provided contexts. */ 46 : : TheorySets(Env& env, OutputChannel& out, Valuation valuation); 47 : : ~TheorySets() override; 48 : : 49 : : //--------------------------------- initialization 50 : : /** get the official theory rewriter of this theory */ 51 : : TheoryRewriter* getTheoryRewriter() override; 52 : : /** get the proof checker of this theory */ 53 : : ProofRuleChecker* getProofChecker() override; 54 : : /** 55 : : * Returns true if we need an equality engine. If so, we initialize the 56 : : * information regarding how it should be setup. For details, see the 57 : : * documentation in Theory::needsEqualityEngine. 58 : : */ 59 : : bool needsEqualityEngine(EeSetupInfo& esi) override; 60 : : /** finish initialization */ 61 : : void finishInit() override; 62 : : //--------------------------------- end initialization 63 : : 64 : : //--------------------------------- standard check 65 : : /** Post-check, called after the fact queue of the theory is processed. */ 66 : : void postCheck(Effort level) override; 67 : : /** Notify fact */ 68 : : void notifyFact(TNode atom, bool pol, TNode fact, bool isInternal) override; 69 : : //--------------------------------- end standard check 70 : : /** Collect model values in m based on the relevant terms given by termSet */ 71 : : bool collectModelValues(TheoryModel* m, 72 : : const std::set<Node>& termSet) override; 73 : : void computeCareGraph() override; 74 : : TrustNode explain(TNode) override; 75 : : Node getCandidateModelValue(TNode) override; 76 : 0 : std::string identify() const override { return "THEORY_SETS"; } 77 : : void preRegisterTerm(TNode node) override; 78 : : /** 79 : : * If the sets-ext option is not set and we have an extended operator, 80 : : * we throw an exception. Additionally, we expand operators like choose 81 : : * and is_singleton. 82 : : */ 83 : : TrustNode ppRewrite(TNode n, std::vector<SkolemLemma>& lems) override; 84 : : PPAssertStatus ppAssert(TrustNode tin, 85 : : TrustSubstitutionMap& outSubstitutions) override; 86 : : void presolve() override; 87 : : bool isEntailed(Node n, bool pol); 88 : : 89 : : private: 90 : : /** 91 : : * Overrides to handle a special case of set membership. 92 : : */ 93 : : void processCarePairArgs(TNode a, TNode b) override; 94 : : /** Functions to handle callbacks from equality engine */ 95 : : class NotifyClass : public TheoryEqNotifyClass 96 : : { 97 : : public: 98 : 47599 : NotifyClass(TheorySetsPrivate& theory, TheoryInferenceManager& im) 99 : 47599 : : TheoryEqNotifyClass(im), d_theory(theory) 100 : : { 101 : 47599 : } 102 : : void eqNotifyNewClass(TNode t) override; 103 : : void eqNotifyMerge(TNode t1, TNode t2) override; 104 : : void eqNotifyDisequal(TNode t1, TNode t2, TNode reason) override; 105 : : 106 : : private: 107 : : TheorySetsPrivate& d_theory; 108 : : }; 109 : : /** The skolem cache */ 110 : : SkolemCache d_skCache; 111 : : /** The state of the sets solver at full effort */ 112 : : SolverState d_state; 113 : : /** The theory rewriter for this theory. */ 114 : : TheorySetsRewriter d_rewriter; 115 : : /** The inference manager */ 116 : : InferenceManager d_im; 117 : : /** The care pair argument callback, used for theory combination */ 118 : : CarePairArgumentCallback d_cpacb; 119 : : /** The internal theory */ 120 : : std::unique_ptr<TheorySetsPrivate> d_internal; 121 : : /** The proof checker */ 122 : : SetsProofRuleChecker d_checker; 123 : : /** Instance of the above class */ 124 : : NotifyClass d_notify; 125 : : }; /* class TheorySets */ 126 : : 127 : : } // namespace sets 128 : : } // namespace theory 129 : : } // namespace cvc5::internal 130 : : 131 : : #endif /* CVC5__THEORY__SETS__THEORY_SETS_H */