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 : : * The strings eager preprocess utility. 11 : : */ 12 : : 13 : : #include "preprocessing/passes/strings_eager_pp.h" 14 : : 15 : : #include "preprocessing/assertion_pipeline.h" 16 : : #include "theory/rewriter.h" 17 : : #include "theory/strings/theory_strings_preprocess.h" 18 : : 19 : : using namespace cvc5::internal::theory; 20 : : 21 : : namespace cvc5::internal { 22 : : namespace preprocessing { 23 : : namespace passes { 24 : : 25 : 50669 : StringsEagerPp::StringsEagerPp(PreprocessingPassContext* preprocContext) 26 : 50669 : : PreprocessingPass(preprocContext, "strings-eager-pp"){}; 27 : : 28 : 68 : PreprocessingPassResult StringsEagerPp::applyInternal( 29 : : AssertionPipeline* assertionsToPreprocess) 30 : : { 31 : 68 : NodeManager* nm = nodeManager(); 32 : 68 : theory::strings::SkolemCache skc(nm, nullptr); 33 : 68 : theory::strings::StringsPreprocess pp(d_env, &skc); 34 [ + + ]: 269 : for (size_t i = 0, nasserts = assertionsToPreprocess->size(); i < nasserts; 35 : : ++i) 36 : : { 37 : 201 : Node prev = (*assertionsToPreprocess)[i]; 38 : 201 : std::vector<Node> asserts; 39 : 201 : Node rew = pp.processAssertion(prev, asserts); 40 [ + + ]: 201 : if (!asserts.empty()) 41 : : { 42 : 51 : std::vector<Node> conj; 43 : 51 : conj.push_back(rew); 44 : 51 : conj.insert(conj.end(), asserts.begin(), asserts.end()); 45 : 51 : rew = nm->mkAnd(conj); 46 : 51 : } 47 [ + + ]: 201 : if (prev != rew) 48 : : { 49 : 51 : assertionsToPreprocess->replace( 50 : : i, rew, nullptr, TrustId::PREPROCESS_STRINGS_EAGER_PP); 51 : 51 : assertionsToPreprocess->ensureRewritten(i); 52 [ - + ]: 51 : if (assertionsToPreprocess->isInConflict()) 53 : : { 54 : 0 : return PreprocessingPassResult::CONFLICT; 55 : : } 56 : : } 57 [ + - ][ + - ]: 201 : } [ + - ] 58 : : 59 : 68 : return PreprocessingPassResult::NO_CONFLICT; 60 : 68 : } 61 : : 62 : : } // namespace passes 63 : : } // namespace preprocessing 64 : : } // namespace cvc5::internal