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 : : * Rewrite proof generator utility. 11 : : */ 12 : : 13 : : #include "proof/rewrite_proof_generator.h" 14 : : 15 : : #include "proof/proof_node_manager.h" 16 : : #include "smt/env.h" 17 : : 18 : : namespace cvc5::internal { 19 : : 20 : 59521 : RewriteProofGenerator::RewriteProofGenerator(Env& env, MethodId id) 21 : 59521 : : EnvObj(env), ProofGenerator(), d_id(id) 22 : : { 23 : : // initialize the proof args 24 : 59521 : addMethodIds(nodeManager(), 25 : 59521 : d_pargs, 26 : : MethodId::SB_DEFAULT, 27 : : MethodId::SBA_SEQUENTIAL, 28 : : d_id); 29 : 59521 : } 30 : 118958 : RewriteProofGenerator::~RewriteProofGenerator() {} 31 : : 32 : 902 : std::shared_ptr<ProofNode> RewriteProofGenerator::getProofFor(Node fact) 33 : : { 34 [ - + ]: 902 : if (fact.getKind() != Kind::EQUAL) 35 : : { 36 : 0 : DebugUnhandled() << "Expected an equality in RewriteProofGenerator, got " 37 : : << fact; 38 : : return nullptr; 39 : : } 40 : 902 : ProofNodeManager* pnm = d_env.getProofNodeManager(); 41 : 902 : const Node& t = fact[0]; 42 : 902 : Node tp = d_env.rewriteViaMethod(t, d_id); 43 [ - + ]: 902 : if (tp != fact[1]) 44 : : { 45 : 0 : DebugUnhandled() << "Could not prove " << fact << " via RewriteProofGenerator"; 46 : : return nullptr; 47 : : } 48 : 2706 : std::vector<Node> pargs{t}; 49 : 902 : pargs.insert(pargs.end(), d_pargs.begin(), d_pargs.end()); 50 : : std::shared_ptr<ProofNode> pf = 51 : 1804 : pnm->mkNode(ProofRule::MACRO_SR_EQ_INTRO, {}, pargs, fact); 52 : 902 : return pf; 53 : 902 : } 54 : : 55 : 0 : std::string RewriteProofGenerator::identify() const 56 : : { 57 : 0 : return "RewriteProofGenerator"; 58 : : } 59 : : 60 : : } // namespace cvc5::internal