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 : : * Equivalence class info for the theory of strings. 11 : : */ 12 : : 13 : : #include "cvc5_private.h" 14 : : 15 : : #ifndef CVC5__THEORY__STRINGS__EQC_INFO_H 16 : : #define CVC5__THEORY__STRINGS__EQC_INFO_H 17 : : 18 : : #include <map> 19 : : 20 : : #include "context/cdo.h" 21 : : #include "context/context.h" 22 : : #include "expr/node.h" 23 : : 24 : : namespace cvc5::internal { 25 : : namespace theory { 26 : : namespace strings { 27 : : 28 : : /** 29 : : * SAT-context-dependent information about an equivalence class. This 30 : : * information is updated eagerly as assertions are processed by the theory of 31 : : * strings at standard effort. 32 : : */ 33 : : class EqcInfo 34 : : { 35 : : public: 36 : : EqcInfo(context::Context* c); 37 : 128137 : ~EqcInfo() {} 38 : : /** add prefix constant 39 : : * 40 : : * This informs this equivalence class info that a term t in its 41 : : * equivalence class has a constant prefix (if isSuf=true) or suffix 42 : : * (if isSuf=false). The constant c (if non-null) is the value of that 43 : : * constant, if it has been computed already. 44 : : * 45 : : * If this method returns a non-null node ret, then ret is a conjunction 46 : : * corresponding to a conflict that holds in the current context. 47 : : */ 48 : : Node addEndpointConst(Node t, Node c, bool isSuf); 49 : : /** 50 : : * If non-null, this is a term x from this eq class such that str.len( x ) 51 : : * occurs as a term in this SAT context. 52 : : */ 53 : : context::CDO<Node> d_lengthTerm; 54 : : /** 55 : : * If non-null, this is a term x from this eq class such that str.code( x ) 56 : : * occurs as a term in this SAT context. 57 : : */ 58 : : context::CDO<Node> d_codeTerm; 59 : : context::CDO<unsigned> d_cardinalityLemK; 60 : : context::CDO<Node> d_normalizedLength; 61 : : /** 62 : : * If this is a string equivalence class, this is 63 : : * a node that explains the longest constant prefix known of this 64 : : * equivalence class. This can either be: 65 : : * (1) A term from this equivalence class, including a constant "ABC" or 66 : : * concatenation term (str.++ "ABC" ...), or 67 : : * (2) A membership of the form (str.in.re x R) where x is in this 68 : : * equivalence class and R is a regular expression of the form 69 : : * (str.to.re "ABC") or (re.++ (str.to.re "ABC") ...). 70 : : * 71 : : * If this is an integer equivalence class, this is the lower bound 72 : : * of the value of this equivalence class. 73 : : */ 74 : : context::CDO<Node> d_firstBound; 75 : : /** same as above, for suffix and integer upper bounds. */ 76 : : context::CDO<Node> d_secondBound; 77 : : /** 78 : : * Make merge conflict. Let "bound term" refer to a term that is set 79 : : * as the data member of this class for d_firstBound or d_secondBound. 80 : : * This method is called when this implies that two terms occur in an 81 : : * equivalence class that have conflicting properties. For example, 82 : : * t may be (str.in_re x (re.++ (str.to_re "A") R2)) and prev may be 83 : : * (str.++ "B" y), where the equivalence class of x has merged into 84 : : * the equivalence class of (str.++ "B" y). This method would return 85 : : * the conflict: 86 : : * (and (= x (str.++ "B" y)) (str.in_re x (re.++ (str.to_re "A") R2))) 87 : : * for this input. 88 : : * 89 : : * @param t The first bound term 90 : : * @param prev The second bound term 91 : : * @param isArith Whether this is an arithmetic conflict. This impacts 92 : : * whether (str.in_re x R) is processed as x or (str.len x). 93 : : * @return The node corresponding to the conflict. 94 : : */ 95 : : static Node mkMergeConflict(Node t, Node prev, bool isArith); 96 : : }; 97 : : 98 : : } // namespace strings 99 : : } // namespace theory 100 : : } // namespace cvc5::internal 101 : : 102 : : #endif /* CVC5__THEORY__STRINGS__EQC_INFO_H */