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 proof generator utility. 11 : : */ 12 : : 13 : : #include "proof/proof_generator.h" 14 : : 15 : : #include <sstream> 16 : : 17 : : #include "options/smt_options.h" 18 : : #include "proof/proof.h" 19 : : #include "proof/proof_node.h" 20 : : #include "proof/proof_node_algorithm.h" 21 : : 22 : : namespace cvc5::internal { 23 : : 24 : 0 : std::ostream& operator<<(std::ostream& out, CDPOverwrite opol) 25 : : { 26 [ - - ][ - - ]: 0 : switch (opol) 27 : : { 28 : 0 : case CDPOverwrite::ALWAYS: out << "ALWAYS"; break; 29 : 0 : case CDPOverwrite::ASSUME_ONLY: out << "ASSUME_ONLY"; break; 30 : 0 : case CDPOverwrite::NEVER: out << "NEVER"; break; 31 : 0 : default: out << "CDPOverwrite:unknown"; break; 32 : : } 33 : 0 : return out; 34 : : } 35 : : 36 : 9959018 : ProofGenerator::ProofGenerator() {} 37 : : 38 : 9958829 : ProofGenerator::~ProofGenerator() {} 39 : : 40 : 0 : std::shared_ptr<ProofNode> ProofGenerator::getProofFor(CVC5_UNUSED Node f) 41 : : { 42 : 0 : Unreachable() << "ProofGenerator::getProofFor: " << identify() 43 : 0 : << " has no implementation" << std::endl; 44 : : return nullptr; 45 : : } 46 : : 47 : 7786 : bool ProofGenerator::addProofTo(Node f, 48 : : CDProof* pf, 49 : : CDPOverwrite opolicy, 50 : : bool doCopy) 51 : : { 52 [ + - ]: 7786 : Trace("pfgen") << "ProofGenerator::addProofTo: " << f << "..." << std::endl; 53 [ - + ][ - + ]: 7786 : Assert(pf != nullptr); [ - - ] 54 : : // plug in the proof provided by the generator, if it exists 55 : 7786 : std::shared_ptr<ProofNode> apf = getProofFor(f); 56 [ + - ]: 7786 : if (apf != nullptr) 57 : : { 58 [ + - ]: 7786 : Trace("pfgen") << "...got proof " << *apf.get() << std::endl; 59 [ + - ]: 7786 : if (pf->addProof(apf, opolicy, doCopy)) 60 : : { 61 [ + - ]: 7786 : Trace("pfgen") << "...success!" << std::endl; 62 : 7786 : return true; 63 : : } 64 [ - - ]: 0 : Trace("pfgen") << "...failed to add proof" << std::endl; 65 : : } 66 : : else 67 : : { 68 [ - - ]: 0 : Trace("pfgen") << "...failed, no proof" << std::endl; 69 : 0 : DebugUnhandled() << "Failed to get proof from generator for fact " << f; 70 : : } 71 : 0 : return false; 72 : 7786 : } 73 : : 74 : : } // namespace cvc5::internal