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 : : * Management of a care graph based approach for theory combination. 11 : : */ 12 : : 13 : : #include "theory/combination_care_graph.h" 14 : : 15 : : #include "expr/node_visitor.h" 16 : : #include "prop/prop_engine.h" 17 : : #include "theory/care_graph.h" 18 : : #include "theory/model_manager.h" 19 : : #include "theory/shared_solver.h" 20 : : #include "theory/theory_engine.h" 21 : : 22 : : namespace cvc5::internal { 23 : : namespace theory { 24 : : 25 : 49981 : CombinationCareGraph::CombinationCareGraph( 26 : 49981 : Env& env, TheoryEngine& te, const std::vector<Theory*>& paraTheories) 27 : 49981 : : CombinationEngine(env, te, paraTheories) 28 : : { 29 : 49981 : } 30 : : 31 : 99272 : CombinationCareGraph::~CombinationCareGraph() {} 32 : : 33 : 65721 : void CombinationCareGraph::combineTheories() 34 : : { 35 [ + - ]: 65721 : Trace("combineTheories") << "TheoryEngine::combineTheories()" << std::endl; 36 : : 37 : : // Care graph we'll be building 38 : 65721 : CareGraph careGraph; 39 : : 40 : : // get the care graph from the parametric theories 41 [ + + ]: 337061 : for (Theory* t : d_paraTheories) 42 : : { 43 : 271340 : t->getCareGraph(&careGraph); 44 : : } 45 : : 46 [ + - ]: 131442 : Trace("combineTheories") 47 : 0 : << "TheoryEngine::combineTheories(): care graph size = " 48 : 65721 : << careGraph.size() << std::endl; 49 : : 50 : : // Now add splitters for the ones we are interested in 51 : 65721 : prop::PropEngine* propEngine = d_te.getPropEngine(); 52 [ + + ]: 148187 : for (const CarePair& carePair : careGraph) 53 : : { 54 [ + - ]: 164932 : Trace("combineTheories") 55 : 0 : << "TheoryEngine::combineTheories(): checking " << carePair.d_a << " = " 56 : 82466 : << carePair.d_b << " from " << carePair.d_theory << std::endl; 57 : : 58 : : // The equality in question (order for no repetition) 59 : 82466 : Node equality = carePair.d_a.eqNode(carePair.d_b); 60 : : 61 : : // We need to split on it 62 [ + - ]: 164932 : Trace("combineTheories") 63 : 82466 : << "TheoryEngine::combineTheories(): requesting a split " << std::endl; 64 : : 65 : 82466 : TrustNode tsplit; 66 [ + + ]: 82466 : if (isProofEnabled()) 67 : : { 68 : : // make proof of splitting lemma 69 : 38818 : tsplit = d_cmbsPg->mkTrustNodeSplit(equality); 70 : : } 71 : : else 72 : : { 73 : 43648 : Node split = equality.orNode(equality.notNode()); 74 : 43648 : tsplit = TrustNode::mkTrustLemma(split, nullptr); 75 : 43648 : } 76 : 164932 : d_sharedSolver->sendLemma( 77 : 82466 : tsplit, carePair.d_theory, InferenceId::COMBINATION_SPLIT); 78 : : 79 : : // Could check the equality status here: 80 : : // EqualityStatus es = getEqualityStatus(carePair.d_a, carePair.d_b); 81 : : // and only require true phase below if: 82 : : // es == EQUALITY_TRUE || es == EQUALITY_TRUE_IN_MODEL 83 : : // and require false phase below if: 84 : : // es == EQUALITY_FALSE_IN_MODEL 85 : : // This is supposed to force preference to follow what the theory models 86 : : // already have but it doesn't seem to make a big difference - need to 87 : : // explore more -Clark 88 : 82466 : Node e = d_valuation.ensureLiteral(equality); 89 : 82466 : propEngine->preferPhase(e, true); 90 : 82466 : } 91 : 65721 : } 92 : : 93 : 67686 : bool CombinationCareGraph::buildModel() 94 : : { 95 : : // building the model happens as a separate step 96 : 67686 : return d_mmanager->buildModel(); 97 : : } 98 : : 99 : : } // namespace theory 100 : : } // namespace cvc5::internal