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 preprocessing pass context for passes. 11 : : */ 12 : : 13 : : #include "preprocessing/preprocessing_pass_context.h" 14 : : 15 : : #include "expr/node_algorithm.h" 16 : : #include "options/base_options.h" 17 : : #include "prop/prop_engine.h" 18 : : #include "smt/env.h" 19 : : #include "theory/theory_engine.h" 20 : : #include "theory/theory_model.h" 21 : : 22 : : namespace cvc5::internal { 23 : : namespace preprocessing { 24 : : 25 : 27063 : PreprocessingPassContext::PreprocessingPassContext( 26 : : Env& env, 27 : : TheoryEngine* te, 28 : : prop::PropEngine* pe, 29 : 27063 : theory::booleans::CircuitPropagator* circuitPropagator) 30 : : : EnvObj(env), 31 : 27063 : d_theoryEngine(te), 32 : 27063 : d_propEngine(pe), 33 : 27063 : d_circuitPropagator(circuitPropagator), 34 : 27063 : d_llm(env), 35 : 27063 : d_symsInAssertions(userContext()) 36 : : { 37 : 27063 : } 38 : : 39 : : theory::TrustSubstitutionMap& 40 : 55647 : PreprocessingPassContext::getTopLevelSubstitutions() const 41 : : { 42 : 55647 : return d_env.getTopLevelSubstitutions(); 43 : : } 44 : : 45 : 1016821 : TheoryEngine* PreprocessingPassContext::getTheoryEngine() const 46 : : { 47 : 1016821 : return d_theoryEngine; 48 : : } 49 : 23979 : prop::PropEngine* PreprocessingPassContext::getPropEngine() const 50 : : { 51 : 23979 : return d_propEngine; 52 : : } 53 : : 54 : 526675 : void PreprocessingPassContext::spendResource(Resource r) 55 : : { 56 : 526675 : d_env.getResourceManager()->spendResource(r); 57 : 526675 : } 58 : 6743 : void PreprocessingPassContext::recordSymbolsInAssertions( 59 : : const std::vector<Node>& assertions) 60 : : { 61 : 6743 : std::unordered_set<TNode> visited; 62 : 6743 : std::unordered_set<Node> syms; 63 [ + + ]: 39545 : for (TNode cn : assertions) 64 : : { 65 : 32802 : expr::getSymbols(cn, syms, visited); 66 : 32802 : } 67 [ + + ]: 36767 : for (const Node& s : syms) 68 : : { 69 : 30024 : d_symsInAssertions.insert(s); 70 : : } 71 : 6743 : } 72 : : 73 : 141138 : void PreprocessingPassContext::notifyLearnedLiteral(TNode lit) 74 : : { 75 : 141138 : d_llm.notifyLearnedLiteral(lit); 76 : 141138 : } 77 : : 78 : 20 : std::vector<Node> PreprocessingPassContext::getLearnedLiterals() const 79 : : { 80 : 20 : return d_llm.getLearnedLiterals(); 81 : : } 82 : : 83 : 1998 : void PreprocessingPassContext::addSubstitution(const Node& lhs, 84 : : const Node& rhs, 85 : : ProofGenerator* pg) 86 : : { 87 : 1998 : d_propEngine->notifyTopLevelSubstitution(lhs, rhs); 88 : 1998 : d_env.getTopLevelSubstitutions().addSubstitution(lhs, rhs, pg); 89 : 1998 : } 90 : : 91 : 0 : void PreprocessingPassContext::addSubstitution(const Node& lhs, 92 : : const Node& rhs, 93 : : ProofRule id, 94 : : const std::vector<Node>& args) 95 : : { 96 : 0 : d_propEngine->notifyTopLevelSubstitution(lhs, rhs); 97 : 0 : d_env.getTopLevelSubstitutions().addSubstitution(lhs, rhs, id, {}, args); 98 : 0 : } 99 : : 100 : 25080 : void PreprocessingPassContext::addSubstitutions( 101 : : theory::TrustSubstitutionMap& tm) 102 : : { 103 : 25080 : std::unordered_map<Node, Node> subs = tm.get().getSubstitutions(); 104 [ + + ]: 71409 : for (const std::pair<const Node, Node>& s : subs) 105 : : { 106 : 46329 : d_propEngine->notifyTopLevelSubstitution(s.first, s.second); 107 : : } 108 : 25080 : d_env.getTopLevelSubstitutions().addSubstitutions(tm); 109 : 25080 : } 110 : : 111 : : } // namespace preprocessing 112 : : } // namespace cvc5::internal