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 : : * Assertion list 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__DECISION__ASSERTION_LIST_H 16 : : #define CVC5__DECISION__ASSERTION_LIST_H 17 : : 18 : : #include <iosfwd> 19 : : #include <unordered_set> 20 : : #include <vector> 21 : : 22 : : #include "context/cdlist.h" 23 : : #include "context/cdo.h" 24 : : #include "expr/node.h" 25 : : 26 : : namespace cvc5::internal { 27 : : namespace decision { 28 : : 29 : : /** 30 : : * For monitoring activity of assertions 31 : : */ 32 : : enum class DecisionStatus 33 : : { 34 : : // not currently watching status of the current assertion 35 : : INACTIVE, 36 : : // no decision was made considering the assertion 37 : : NO_DECISION, 38 : : // a decision was made considering the assertion 39 : : DECISION, 40 : : // we backtracked while considering the assertion 41 : : BACKTRACK 42 : : }; 43 : : const char* toString(DecisionStatus s); 44 : : std::ostream& operator<<(std::ostream& out, DecisionStatus s); 45 : : 46 : : /** 47 : : * An assertion list used by the justification heuristic. This tracks a list 48 : : * of formulas that we must justify. 49 : : */ 50 : : class AssertionList 51 : : { 52 : : public: 53 : : /** 54 : : * @param ac The context on which the assertions depends on. This is the 55 : : * user context for assertions. It is the SAT context for assertions that 56 : : * are dynamically relevant based on what is asserted, e.g. lemmas 57 : : * corresponding to skolem definitions. 58 : : * @param ic The context on which the current index of the assertions 59 : : * depends on. This is typically the SAT context. 60 : : * @param dyn Whether to use a dynamic ordering of the assertions. If this 61 : : * flag is true, then getNextAssertion will return the most important next 62 : : * assertion to consider based on heuristics in response to notifyStatus. 63 : : */ 64 : : AssertionList(context::Context* ac, 65 : : context::Context* ic, 66 : : bool useDyn = false); 67 : 42282 : virtual ~AssertionList() {} 68 : : /** Presolve, which clears the dynamic assertion order */ 69 : : void presolve(); 70 : : /** Add the assertion n */ 71 : : void addAssertion(TNode n); 72 : : /** 73 : : * Get the next assertion and increment d_assertionIndex. 74 : : */ 75 : : TNode getNextAssertion(); 76 : : /** Get the number of assertions */ 77 : : size_t size() const; 78 : : /** 79 : : * Notify status, which indicates the status of the assertion n, where n 80 : : * is the assertion last returned by getNextAssertion above (independent of 81 : : * the context). The status s indicates what happened when we were trying to 82 : : * justify n. This impacts its order if useDyn is true. 83 : : */ 84 : : void notifyStatus(TNode n, DecisionStatus s); 85 : : 86 : : private: 87 : : /** The list of assertions */ 88 : : context::CDList<Node> d_assertions; 89 : : /** The index of the next assertion to satify */ 90 : : context::CDO<size_t> d_assertionIndex; 91 : : // --------------------------- dynamic assertions 92 : : /** are we using dynamic assertions? */ 93 : : bool d_usingDynamic; 94 : : /** The list of assertions */ 95 : : std::vector<TNode> d_dlist; 96 : : /** The set of assertions for fast membership testing in the above vector */ 97 : : std::unordered_set<TNode> d_dlistSet; 98 : : /** The index of the next assertion to satify */ 99 : : context::CDO<size_t> d_dindex; 100 : : }; 101 : : 102 : : } // namespace decision 103 : : } // namespace cvc5::internal 104 : : 105 : : #endif /* CVC5__DECISION__ASSERTION_LIST_H */