Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds 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 : : * Model normal form finder for strings 14 : : */ 15 : : 16 : : #include "cvc5_private.h" 17 : : 18 : : #ifndef CVC5__THEORY__STRINGS__MODEL_CONS_H 19 : : #define CVC5__THEORY__STRINGS__MODEL_CONS_H 20 : : 21 : : #include "smt/env_obj.h" 22 : : 23 : : namespace cvc5::internal { 24 : : namespace theory { 25 : : class TheoryModel; 26 : : namespace strings { 27 : : 28 : : /** 29 : : * The base class for strings model construction. This is used by TheoryStrings 30 : : * during collectModeValues for specifying how to construct model values 31 : : * for string-like terms. 32 : : */ 33 : : class ModelCons : protected EnvObj 34 : : { 35 : : public: 36 : 49899 : ModelCons(Env& env) : EnvObj(env) {} 37 : 49554 : virtual ~ModelCons() {} 38 : : 39 : : /** 40 : : * Get string representatives from relevant term set. 41 : : * 42 : : * Based on the current set of relevant terms in termSet, this gets all 43 : : * representatives of string-like type to be used for model construction, 44 : : * and groups them by type. 45 : : * 46 : : * @param termSet The relevant term set 47 : : * @param repTypes The set of types of terms in the domain of repSet 48 : : * @param repSet Map from types to the representatives of that type 49 : : * @param auxEq A list of equalities to assert directly to the model, e.g. 50 : : * if some term was equated to another. 51 : : */ 52 : : virtual void getStringRepresentativesFrom( 53 : : const std::set<Node>& termSet, 54 : : std::unordered_set<TypeNode>& repTypes, 55 : : std::map<TypeNode, std::unordered_set<Node>>& repSet, 56 : : std::vector<Node>& auxEq) = 0; 57 : : /** 58 : : * Separate by length. 59 : : * 60 : : * Separate the string representatives in argument n into a partition cols 61 : : * whose collections have equal length. The i^th vector in cols has length 62 : : * lts[i] for all elements in col. 63 : : * 64 : : * Must assign lts to *concrete* lengths. 65 : : * 66 : : * @param m Pointer to the theory model. 67 : : * @param n The list of string terms. 68 : : * @param cols Populated as a partition of n based on their lengths. 69 : : * @param lts The list of lengths for each set in the parition cols. 70 : : */ 71 : : virtual void separateByLength(TheoryModel * m, 72 : : const std::vector<Node>& n, 73 : : std::vector<std::vector<Node>>& cols, 74 : : std::vector<Node>& lts) = 0; 75 : : /** 76 : : * Get the normal form for n. If the returned vector has length > 1, then the 77 : : * model value for (all variables in) the equivalence class of n will be 78 : : * assigned to the model value based on this list. If the returned vector 79 : : * has length 0, the equivalence class will be assigned the empty string. 80 : : * If the returned vector has size 1 and contains a constant, the equivalence 81 : : * class will be assigned that constant. Otherwise, the equivalence class 82 : : * will be assigned an arbitrary value whose length was determined by 83 : : * a call to separateByLength. 84 : : */ 85 : : virtual std::vector<Node> getNormalForm(Node n) = 0; 86 : : }; 87 : : 88 : : } // namespace strings 89 : : } // namespace theory 90 : : } // namespace cvc5::internal 91 : : 92 : : #endif /* CVC5__THEORY__STRINGS__MODEL_CONS_H */