Branch data Line data Source code
1 : : /****************************************************************************** 2 : : * Top contributors (to current version): 3 : : * Andrew Reynolds 4 : : * 5 : : * This file is part of the cvc5 project. 6 : : * 7 : : * Copyright (c) 2009-2025 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 : : * Implementation of proof generator utility. 14 : : */ 15 : : 16 : : #include "proof/proof_generator.h" 17 : : 18 : : #include <sstream> 19 : : 20 : : #include "options/smt_options.h" 21 : : #include "proof/proof.h" 22 : : #include "proof/proof_node.h" 23 : : #include "proof/proof_node_algorithm.h" 24 : : 25 : : namespace cvc5::internal { 26 : : 27 : 0 : std::ostream& operator<<(std::ostream& out, CDPOverwrite opol) 28 : : { 29 [ - - ][ - - ]: 0 : switch (opol) 30 : : { 31 : 0 : case CDPOverwrite::ALWAYS: out << "ALWAYS"; break; 32 : 0 : case CDPOverwrite::ASSUME_ONLY: out << "ASSUME_ONLY"; break; 33 : 0 : case CDPOverwrite::NEVER: out << "NEVER"; break; 34 : 0 : default: out << "CDPOverwrite:unknown"; break; 35 : : } 36 : 0 : return out; 37 : : } 38 : : 39 : 10082900 : ProofGenerator::ProofGenerator() {} 40 : : 41 : 10078000 : ProofGenerator::~ProofGenerator() {} 42 : : 43 : 0 : std::shared_ptr<ProofNode> ProofGenerator::getProofFor(Node f) 44 : : { 45 : 0 : Unreachable() << "ProofGenerator::getProofFor: " << identify() 46 : 0 : << " has no implementation" << std::endl; 47 : : return nullptr; 48 : : } 49 : : 50 : 8781 : bool ProofGenerator::addProofTo(Node f, 51 : : CDProof* pf, 52 : : CDPOverwrite opolicy, 53 : : bool doCopy) 54 : : { 55 [ + - ]: 8781 : Trace("pfgen") << "ProofGenerator::addProofTo: " << f << "..." << std::endl; 56 [ - + ][ - + ]: 8781 : Assert(pf != nullptr); [ - - ] 57 : : // plug in the proof provided by the generator, if it exists 58 : 17562 : std::shared_ptr<ProofNode> apf = getProofFor(f); 59 [ + - ]: 8781 : if (apf != nullptr) 60 : : { 61 [ + - ]: 8781 : Trace("pfgen") << "...got proof " << *apf.get() << std::endl; 62 [ + - ]: 8781 : if (pf->addProof(apf, opolicy, doCopy)) 63 : : { 64 [ + - ]: 8781 : Trace("pfgen") << "...success!" << std::endl; 65 : 8781 : return true; 66 : : } 67 [ - - ]: 0 : Trace("pfgen") << "...failed to add proof" << std::endl; 68 : : } 69 : : else 70 : : { 71 [ - - ]: 0 : Trace("pfgen") << "...failed, no proof" << std::endl; 72 : 0 : Assert(false) << "Failed to get proof from generator for fact " << f; 73 : : } 74 : 0 : return false; 75 : : } 76 : : 77 : : } // namespace cvc5::internal