| 1 |
/****************************************************************************** |
| 2 |
* Top contributors (to current version): |
| 3 |
* Gereon Kremer, Aina Niemetz |
| 4 |
* |
| 5 |
* This file is part of the cvc5 project. |
| 6 |
* |
| 7 |
* Copyright (c) 2009-2025 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 |
* Implements a way to track the origins of ICP-style contractions. |
| 14 |
*/ |
| 15 |
|
| 16 |
#ifndef CVC5__THEORY__ARITH__ICP__CONTRACTION_ORIGINS_H |
| 17 |
#define CVC5__THEORY__ARITH__ICP__CONTRACTION_ORIGINS_Hcxx . . $ `src/theory/arith/nl/icp/contraction_origins.h:17:9`! |
| 18 |
|
| 19 |
#include <memory> |
| 20 |
#include <vector> |
| 21 |
|
| 22 |
#include "expr/node.h"cxx . . $ `<file>/src/expr/node.h`/ |
| 23 |
|
| 24 |
namespace cvc5cxx . . $ cvc5/::internalcxx . . $ cvc5/internal/ { |
| 25 |
namespace theorycxx . . $ cvc5/internal/theory/ { |
| 26 |
namespace arithcxx . . $ cvc5/internal/theory/arith/ { |
| 27 |
namespace nlcxx . . $ cvc5/internal/theory/arith/nl/ { |
| 28 |
namespace icpcxx . . $ cvc5/internal/theory/arith/nl/icp/ { |
| 29 |
|
| 30 |
/** |
| 31 |
* This class tracks origins of ICP-style contractions of variable intervals. |
| 32 |
* For every variable, it holds one origin object that may recursively depend on |
| 33 |
* previous contraction origins. Initially, a immediate bound on a variable |
| 34 |
* (like x>0) yields an origin for this variable. For every contraction, we then |
| 35 |
* add a new origin that recursively holds the old origins, usually those of all |
| 36 |
* variables involved in the contraction. When generating a conflict or a lemma, |
| •37 |
* a recursive walk through this structure allows one to retrieve all input theory |
| 38 |
* atoms that contributed to the new fact or the conflict. |
| 39 |
*/ |
| 40 |
class ContractionOriginManagercxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager# |
| 41 |
{ |
| 42 |
public: |
| 43 |
/** |
| 44 |
* Origin of one particular contraction step. |
| 45 |
* Usually, this is either a direct bound or the application of a contraction |
| 46 |
* candidate. The direct bound is stored in the candidate while origins |
| 47 |
* remains empty. The contraction candidate is stored in the candidate while |
| 48 |
* origins hold the origins of all variables used in the contraction. |
| 49 |
*/ |
| 50 |
struct ContractionOrigincxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#ContractionOrigin# |
| 51 |
{ |
| 52 |
/** The theory atom used to do this contraction. */ |
| 53 |
Nodecxx . . $ cvc5/internal/Node# candidatecxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#ContractionOrigin#candidate.; |
| 54 |
/** All origins required for this contraction. */ |
| 55 |
stdcxx . . $ std/::vectorcxx . . $ std/vector#<ContractionOrigincxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#ContractionOrigin#*> originscxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#ContractionOrigin#origins.; |
| 56 |
}; |
| 57 |
|
| 58 |
private: |
| 59 |
/** |
| 60 |
* Recursively walks through the data structure, collecting all theory atoms. |
| 61 |
*/ |
| 62 |
void getOriginscxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#getOrigins(3e6a2f8c538beae5).(ContractionOrigincxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#ContractionOrigin# const* const origin, |
| 63 |
stdcxx . . $ std/::setcxx . . $ std/set#<Nodecxx . . $ cvc5/internal/Node#>& res) const; |
| 64 |
|
| 65 |
public: |
| 66 |
/** Return the current origins for all variables. */ |
| 67 |
const stdcxx . . $ std/::mapcxx . . $ std/map#<Nodecxx . . $ cvc5/internal/Node#, ContractionOrigincxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#ContractionOrigin#*>& currentOriginscxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#currentOrigins(f163f58404bd6f44).() const; |
| 68 |
/** |
| 69 |
* Add a new contraction for the targetVariable. |
| 70 |
* Adds a new origin with the given candidate and origins. |
| 71 |
* If addTarget is set to true, we also add the current origin of the |
| 72 |
* targetVariable to origins. This corresponds to whether we intersected the |
| 73 |
* new interval with the previous interval, or whether the new interval was a |
| 74 |
* subset of the previous one in the first place. |
| 75 |
*/ |
| 76 |
void addcxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#add(bd616382fa2f43fa).(const Nodecxx . . $ cvc5/internal/Node#& targetVariable, |
| 77 |
const Nodecxx . . $ cvc5/internal/Node#& candidate, |
| 78 |
const stdcxx . . $ std/::vectorcxx . . $ std/vector#<Nodecxx . . $ cvc5/internal/Node#>& originVariables, |
| 79 |
bool addTarget = true); |
| 80 |
|
| 81 |
/** |
| 82 |
* Collect all theory atoms from the origins of the given variable. |
| 83 |
*/ |
| 84 |
stdcxx . . $ std/::vectorcxx . . $ std/vector#<Nodecxx . . $ cvc5/internal/Node#> getOriginscxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#getOrigins(17d48ac93560aec9).(const Nodecxx . . $ cvc5/internal/Node#& variable) const; |
| 85 |
|
| 86 |
/** Check whether a node c is among the origins of a variable. */ |
| 87 |
bool isInOriginscxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#isInOrigins(b175c236aa4de380).(const Nodecxx . . $ cvc5/internal/Node#& variable, const Nodecxx . . $ cvc5/internal/Node#& c) const; |
| 88 |
|
| 89 |
private: |
| 90 |
/** The current origins for every variable. */ |
| 91 |
stdcxx . . $ std/::mapcxx . . $ std/map#<Nodecxx . . $ cvc5/internal/Node#, ContractionOrigincxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#ContractionOrigin#*> d_currentOriginscxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#d_currentOrigins.; |
| 92 |
/** All allocated origins to allow for proper deallocation. */ |
| 93 |
stdcxx . . $ std/::vectorcxx . . $ std/vector#<stdcxx . . $ std/::unique_ptrcxx . . $ std/unique_ptr#<ContractionOrigincxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#ContractionOrigin#>> d_allocationscxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#d_allocations.; |
| 94 |
}; |
| 95 |
|
| 96 |
/** Stream the constration origins to an ostream. */ |
| 97 |
stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& operatorcxx . . $ cvc5/internal/theory/arith/nl/icp/`operator<<`(37fb75f46d57ad19).<<(stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& os, const ContractionOriginManagercxx . . $ cvc5/internal/theory/arith/nl/icp/ContractionOriginManager#& com); |
| 98 |
|
| 99 |
} // namespace icp |
| 100 |
} // namespace nl |
| 101 |
} // namespace arith |
| 102 |
} // namespace theory |
| 103 |
} // namespace cvc5::internal |
| 104 |
|
| 105 |
#endif |