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