Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds, Mathias Preiner, Andres Noetzli 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 : : * dynamic quantifiers splitting 14 : : */ 15 : : 16 : : #include "cvc5_private.h" 17 : : 18 : : #ifndef CVC5__THEORY__QUANT_SPLIT_H 19 : : #define CVC5__THEORY__QUANT_SPLIT_H 20 : : 21 : : #include "context/cdhashmap.h" 22 : : #include "context/cdo.h" 23 : : #include "smt/env_obj.h" 24 : : #include "theory/quantifiers/quant_module.h" 25 : : 26 : : namespace cvc5::internal { 27 : : namespace theory { 28 : : 29 : : class QuantifiersEngine; 30 : : 31 : : namespace quantifiers { 32 : : 33 : : /** Quantifiers dynamic splitting 34 : : * 35 : : * This module identifies quantified formulas that should be "split", e.g. 36 : : * based on datatype constructor case splitting. 37 : : * 38 : : * An example of a quantified formula that we may split is the following. Let: 39 : : * optionPair := mkPair( U, U ) | none 40 : : * where U is an uninterpreted sort. The quantified formula: 41 : : * forall x : optionPair. P( x ) 42 : : * may be "split" via the lemma: 43 : : * forall x : optionPair. P( x ) <=> 44 : : * ( forall xy : U. P( mkPair( x, y ) ) OR P( none ) ) 45 : : * 46 : : * Notice that such splitting may lead to exponential behavior, say if we 47 : : * quantify over 32 variables of type optionPair above gives 2^32 disjuncts. 48 : : * This class is used to compute this splitting dynamically, by splitting 49 : : * one variable per quantified formula at a time. 50 : : */ 51 : : class QuantDSplit : public QuantifiersModule { 52 : : using NodeSet = context::CDHashSet<Node>; 53 : : using NodeIntMap = context::CDHashMap<Node, int>; 54 : : 55 : : public: 56 : : QuantDSplit(Env& env, 57 : : QuantifiersState& qs, 58 : : QuantifiersInferenceManager& qim, 59 : : QuantifiersRegistry& qr, 60 : : TermRegistry& tr); 61 : : /** determine whether this quantified formula will be reduced */ 62 : : void checkOwnership(Node q) override; 63 : : /* whether this module needs to check this round */ 64 : : bool needsCheck(Theory::Effort e) override; 65 : : /* Call during quantifier engine's check */ 66 : : void check(Theory::Effort e, QEffort quant_e) override; 67 : : /** check complete for */ 68 : : bool checkCompleteFor(Node q) override; 69 : : /** Identify this module (for debugging, dynamic configuration, etc..) */ 70 : 0 : std::string identify() const override { return "QuantDSplit"; } 71 : : 72 : : private: 73 : : /** list of relevant quantifiers asserted in the current context */ 74 : : NodeIntMap d_quant_to_reduce; 75 : : /** whether we have instantiated quantified formulas */ 76 : : NodeSet d_added_split; 77 : : }; 78 : : 79 : : } 80 : : } 81 : : } // namespace cvc5::internal 82 : : 83 : : #endif