Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds, Mathias Preiner, Gereon Kremer 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 : : * The TheoryPreprocess preprocessing pass. 14 : : * 15 : : * Calls Theory::preprocess(...) on every assertion of the formula. 16 : : */ 17 : : 18 : : #include "preprocessing/passes/theory_preprocess.h" 19 : : 20 : : #include "options/smt_options.h" 21 : : #include "preprocessing/assertion_pipeline.h" 22 : : #include "preprocessing/preprocessing_pass_context.h" 23 : : #include "prop/prop_engine.h" 24 : : #include "theory/rewriter.h" 25 : : #include "theory/theory_engine.h" 26 : : 27 : : namespace cvc5::internal { 28 : : namespace preprocessing { 29 : : namespace passes { 30 : : 31 : : using namespace cvc5::internal::theory; 32 : : 33 : 50585 : TheoryPreprocess::TheoryPreprocess(PreprocessingPassContext* preprocContext) 34 : 50585 : : PreprocessingPass(preprocContext, "theory-preprocess"){}; 35 : : 36 : 35231 : PreprocessingPassResult TheoryPreprocess::applyInternal( 37 : : AssertionPipeline* assertions) 38 : : { 39 : 35231 : d_preprocContext->spendResource(Resource::PreprocessStep); 40 : : 41 : 35231 : IteSkolemMap& imap = assertions->getIteSkolemMap(); 42 : 35231 : prop::PropEngine* propEngine = d_preprocContext->getPropEngine(); 43 : : // Remove all of the ITE occurrences and normalize 44 [ + + ]: 493981 : for (unsigned i = 0, size = assertions->size(); i < size; ++i) 45 : : { 46 : 458900 : Node assertion = (*assertions)[i]; 47 : 458900 : std::vector<SkolemLemma> newAsserts; 48 : 458910 : TrustNode trn = propEngine->preprocess(assertion, newAsserts); 49 [ + + ]: 458890 : if (!trn.isNull()) 50 : : { 51 : : // process 52 : 33619 : assertions->replaceTrusted(i, trn, TrustId::THEORY_PREPROCESS); 53 [ + + ]: 33619 : if (assertions->isInConflict()) 54 : : { 55 : 140 : return PreprocessingPassResult::CONFLICT; 56 : : } 57 : : } 58 [ + + ]: 484776 : for (const SkolemLemma& lem : newAsserts) 59 : : { 60 : 26026 : imap[assertions->size()] = lem.d_skolem; 61 : 26026 : assertions->pushBackTrusted(lem.d_lemma, 62 : : TrustId::THEORY_PREPROCESS_LEMMA); 63 : : } 64 [ + + ][ + + ]: 459190 : } [ + + ] 65 : : 66 : 35081 : return PreprocessingPassResult::NO_CONFLICT; 67 : : } 68 : : 69 : : 70 : : } // namespace passes 71 : : } // namespace preprocessing 72 : : } // namespace cvc5::internal