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