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 : : * Remove ITEs from the assertions. 11 : : * 12 : : * [[ Add lengthier description here ]] 13 : : * \todo document this file 14 : : */ 15 : : 16 : : #include "preprocessing/passes/ite_removal.h" 17 : : 18 : : #include "options/smt_options.h" 19 : : #include "preprocessing/assertion_pipeline.h" 20 : : #include "preprocessing/preprocessing_pass_context.h" 21 : : #include "prop/prop_engine.h" 22 : : #include "theory/rewriter.h" 23 : : #include "theory/theory_preprocessor.h" 24 : : 25 : : namespace cvc5::internal { 26 : : namespace preprocessing { 27 : : namespace passes { 28 : : 29 : : using namespace cvc5::internal::theory; 30 : : 31 : : // TODO (project #42): note this preprocessing pass is deprecated 32 : 28740 : IteRemoval::IteRemoval(PreprocessingPassContext* preprocContext) 33 : 28740 : : PreprocessingPass(preprocContext, "ite-removal") 34 : : { 35 : 28740 : } 36 : : 37 : 10 : PreprocessingPassResult IteRemoval::applyInternal(AssertionPipeline* assertions) 38 : : { 39 : 10 : d_preprocContext->spendResource(Resource::PreprocessStep); 40 : : 41 : 10 : IteSkolemMap& imap = assertions->getIteSkolemMap(); 42 : : // Remove all of the ITE occurrences and normalize 43 : 10 : prop::PropEngine* pe = d_preprocContext->getPropEngine(); 44 [ + + ]: 1352 : for (unsigned i = 0, size = assertions->size(); i < size; ++i) 45 : : { 46 : 1342 : Node assertion = (*assertions)[i]; 47 : 1342 : std::vector<SkolemLemma> newAsserts; 48 : 1342 : TrustNode trn = pe->removeItes(assertion, newAsserts); 49 [ + + ]: 1342 : if (!trn.isNull()) 50 : : { 51 : : // process 52 : 246 : assertions->replaceTrusted(i, trn); 53 : : } 54 [ + + ]: 1680 : for (const SkolemLemma& lem : newAsserts) 55 : : { 56 : 338 : imap[assertions->size()] = lem.d_skolem; 57 : 338 : assertions->pushBackTrusted(lem.d_lemma); 58 : : } 59 : 1342 : } 60 [ + + ]: 1690 : for (unsigned i = 0, size = assertions->size(); i < size; ++i) 61 : : { 62 : 1680 : assertions->ensureRewritten(i); 63 : : } 64 : : 65 : 10 : return PreprocessingPassResult::NO_CONFLICT; 66 : : } 67 : : 68 : : } // namespace passes 69 : : } // namespace preprocessing 70 : : } // namespace cvc5::internal