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 : : * Arithmetic preprocess. 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__THEORY__ARITH__ARITH_PREPROCESS_H 16 : : #define CVC5__THEORY__ARITH__ARITH_PREPROCESS_H 17 : : 18 : : #include "context/cdhashmap.h" 19 : : #include "smt/env_obj.h" 20 : : #include "theory/arith/operator_elim.h" 21 : : #include "theory/logic_info.h" 22 : : 23 : : namespace cvc5::internal { 24 : : namespace theory { 25 : : 26 : : class SkolemLemma; 27 : : 28 : : namespace arith { 29 : : 30 : : class InferenceManager; 31 : : class OperatorElim; 32 : : 33 : : /** 34 : : * This module can be used for (on demand) elimination of extended arithmetic 35 : : * operators like div, mod, to_int, is_int, sqrt, and so on. It uses the 36 : : * operator elimination utility for determining how to reduce formulas. It 37 : : * extends that utility with the ability to generate lemmas on demand via 38 : : * the provided inference manager. 39 : : */ 40 : : class ArithPreprocess : protected EnvObj 41 : : { 42 : : public: 43 : : ArithPreprocess(Env& env, InferenceManager& im, OperatorElim& oe); 44 : 50923 : ~ArithPreprocess() {} 45 : : /** 46 : : * Call eliminate operators on formula n, return the resulting trust node, 47 : : * which is of TrustNodeKind REWRITE and whose node is the result of 48 : : * eliminating extended operators from n. 49 : : * 50 : : * @param n The node to eliminate operators from 51 : : * @param partialOnly Whether we are eliminating partial operators only. 52 : : * @return the trust node proving (= n nr) where nr is the return of 53 : : * eliminating operators in n, or the null trust node if n was unchanged. 54 : : */ 55 : : TrustNode eliminate(TNode n, 56 : : std::vector<SkolemLemma>& lems, 57 : : bool partialOnly = false); 58 : : /** 59 : : * Reduce assertion. This sends a lemma via the inference manager if atom 60 : : * contains any extended operators. When applicable, the lemma is of the form: 61 : : * atom == d_opElim.eliminate(atom) 62 : : * This method returns true if a lemma of the above form was added to 63 : : * the inference manager. Note this returns true even if this lemma was added 64 : : * on a previous call. 65 : : */ 66 : : bool reduceAssertion(TNode atom); 67 : : /** 68 : : * Is the atom reduced? Returns true if a call to method reduceAssertion was 69 : : * made for the given atom and returned a lemma. In this case, the atom 70 : : * can be ignored. 71 : : */ 72 : : bool isReduced(TNode atom) const; 73 : : 74 : : private: 75 : : /** Reference to the inference manager */ 76 : : InferenceManager& d_im; 77 : : /** The operator elimination utility */ 78 : : OperatorElim& d_opElim; 79 : : /** The set of assertions that were reduced */ 80 : : context::CDHashMap<Node, bool> d_reduced; 81 : : }; 82 : : 83 : : } // namespace arith 84 : : } // namespace theory 85 : : } // namespace cvc5::internal 86 : : 87 : : #endif