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 : : * Implementation of inference information utility. 11 : : */ 12 : : 13 : : #include "theory/strings/infer_info.h" 14 : : 15 : : #include "theory/strings/inference_manager.h" 16 : : #include "theory/strings/theory_strings_utils.h" 17 : : #include "theory/theory.h" 18 : : 19 : : namespace cvc5::internal { 20 : : namespace theory { 21 : : namespace strings { 22 : : 23 : 228817 : InferInfo::InferInfo(InferenceId id) 24 [ + + ]: 686451 : : TheoryInference(id), d_sim(nullptr), d_idRev(false) 25 : : { 26 : 228817 : } 27 : : 28 : 49507 : TrustNode InferInfo::processLemma(LemmaProperty& p) 29 : : { 30 : 49507 : return d_sim->processLemma(*this, p); 31 : : } 32 : : 33 : 115717 : Node InferInfo::processFact(std::vector<Node>& exp, ProofGenerator*& pg) 34 : : { 35 [ + + ]: 393607 : for (const Node& ec : d_premises) 36 : : { 37 : 277890 : utils::flattenOp(Kind::AND, ec, exp); 38 : : } 39 : 115717 : d_sim->processFact(*this, pg); 40 : 115717 : return d_conc; 41 : : } 42 : : 43 : 216781 : bool InferInfo::isTrivial() const 44 : : { 45 [ - + ][ - + ]: 216781 : Assert(!d_conc.isNull()); [ - - ] 46 [ + + ][ - + ]: 216781 : return d_conc.isConst() && d_conc.getConst<bool>(); 47 : : } 48 : : 49 : 216781 : bool InferInfo::isConflict() const 50 : : { 51 [ - + ][ - + ]: 216781 : Assert(!d_conc.isNull()); [ - - ] 52 [ + + ][ + - ]: 216781 : return d_conc.isConst() && !d_conc.getConst<bool>() && d_noExplain.empty(); [ + + ] 53 : : } 54 : : 55 : 121655 : bool InferInfo::isFact() const 56 : : { 57 [ - + ][ - + ]: 121655 : Assert(!d_conc.isNull()); [ - - ] 58 [ + + ]: 121655 : TNode atom = d_conc.getKind() == Kind::NOT ? d_conc[0] : d_conc; 59 : : // we could process inferences with conjunctive conclusions as facts, where 60 : : // the explanation is copied. However, for simplicity, we always send these 61 : : // as lemmas. This case happens very infrequently. 62 [ + + ][ - - ]: 243228 : return !atom.isConst() && Theory::theoryOf(atom) == THEORY_STRINGS 63 [ + + ][ + + ]: 364924 : && d_noExplain.empty(); [ + + ] 64 : 121655 : } 65 : : 66 : 0 : Node InferInfo::getPremises(NodeManager* nm) const 67 : : { 68 : : // d_noExplain is a subset of d_ant 69 : 0 : return utils::mkAnd(nm, d_premises); 70 : : } 71 : : 72 : 0 : std::ostream& operator<<(std::ostream& out, const InferInfo& ii) 73 : : { 74 : 0 : out << "(infer " << ii.getId() << " " << ii.d_conc; 75 [ - - ]: 0 : if (ii.d_idRev) 76 : : { 77 : 0 : out << " :rev"; 78 : : } 79 [ - - ]: 0 : if (!ii.d_premises.empty()) 80 : : { 81 : 0 : out << " :ant (" << ii.d_premises << ")"; 82 : : } 83 [ - - ]: 0 : if (!ii.d_noExplain.empty()) 84 : : { 85 : 0 : out << " :no-explain (" << ii.d_noExplain << ")"; 86 : : } 87 : 0 : out << ")"; 88 : 0 : return out; 89 : : } 90 : : 91 : : } // namespace strings 92 : : } // namespace theory 93 : : } // namespace cvc5::internal