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-2021 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 { |
26 |
|
|
27 |
|
std::ostream& operator<<(std::ostream& out, CDPOverwrite opol) |
28 |
|
{ |
29 |
|
switch (opol) |
30 |
|
{ |
31 |
|
case CDPOverwrite::ALWAYS: out << "ALWAYS"; break; |
32 |
|
case CDPOverwrite::ASSUME_ONLY: out << "ASSUME_ONLY"; break; |
33 |
|
case CDPOverwrite::NEVER: out << "NEVER"; break; |
34 |
|
default: out << "CDPOverwrite:unknown"; break; |
35 |
|
} |
36 |
|
return out; |
37 |
|
} |
38 |
|
|
39 |
1689285 |
ProofGenerator::ProofGenerator() {} |
40 |
|
|
41 |
1686617 |
ProofGenerator::~ProofGenerator() {} |
42 |
|
|
43 |
|
std::shared_ptr<ProofNode> ProofGenerator::getProofFor(Node f) |
44 |
|
{ |
45 |
|
Unreachable() << "ProofGenerator::getProofFor: " << identify() |
46 |
|
<< " has no implementation" << std::endl; |
47 |
|
return nullptr; |
48 |
|
} |
49 |
|
|
50 |
1562 |
bool ProofGenerator::addProofTo(Node f, |
51 |
|
CDProof* pf, |
52 |
|
CDPOverwrite opolicy, |
53 |
|
bool doCopy) |
54 |
|
{ |
55 |
1562 |
Trace("pfgen") << "ProofGenerator::addProofTo: " << f << "..." << std::endl; |
56 |
1562 |
Assert(pf != nullptr); |
57 |
|
// plug in the proof provided by the generator, if it exists |
58 |
3124 |
std::shared_ptr<ProofNode> apf = getProofFor(f); |
59 |
1562 |
if (apf != nullptr) |
60 |
|
{ |
61 |
1562 |
Trace("pfgen") << "...got proof " << *apf.get() << std::endl; |
62 |
1562 |
if (pf->addProof(apf, opolicy, doCopy)) |
63 |
|
{ |
64 |
1562 |
Trace("pfgen") << "...success!" << std::endl; |
65 |
1562 |
return true; |
66 |
|
} |
67 |
|
Trace("pfgen") << "...failed to add proof" << std::endl; |
68 |
|
} |
69 |
|
else |
70 |
|
{ |
71 |
|
Trace("pfgen") << "...failed, no proof" << std::endl; |
72 |
|
Assert(false) << "Failed to get proof from generator for fact " << f; |
73 |
|
} |
74 |
|
return false; |
75 |
|
} |
76 |
|
|
77 |
29577 |
} // namespace cvc5 |