1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Andrew Reynolds, Haniel Barbosa, Aina Niemetz |
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 module for final processing proof nodes. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "smt/proof_final_callback.h" |
17 |
|
|
18 |
|
#include "options/proof_options.h" |
19 |
|
#include "proof/proof_checker.h" |
20 |
|
#include "proof/proof_node_manager.h" |
21 |
|
#include "smt/smt_statistics_registry.h" |
22 |
|
#include "theory/builtin/proof_checker.h" |
23 |
|
#include "theory/theory_id.h" |
24 |
|
|
25 |
|
using namespace cvc5::kind; |
26 |
|
using namespace cvc5::theory; |
27 |
|
|
28 |
|
namespace cvc5 { |
29 |
|
namespace smt { |
30 |
|
|
31 |
3781 |
ProofFinalCallback::ProofFinalCallback(ProofNodeManager* pnm) |
32 |
3781 |
: d_ruleCount(smtStatisticsRegistry().registerHistogram<PfRule>( |
33 |
7562 |
"finalProof::ruleCount")), |
34 |
|
d_instRuleIds( |
35 |
3781 |
smtStatisticsRegistry().registerHistogram<theory::InferenceId>( |
36 |
7562 |
"finalProof::instRuleId")), |
37 |
|
d_totalRuleCount( |
38 |
7562 |
smtStatisticsRegistry().registerInt("finalProof::totalRuleCount")), |
39 |
|
d_minPedanticLevel( |
40 |
7562 |
smtStatisticsRegistry().registerInt("finalProof::minPedanticLevel")), |
41 |
|
d_numFinalProofs( |
42 |
7562 |
smtStatisticsRegistry().registerInt("finalProofs::numFinalProofs")), |
43 |
|
d_pnm(pnm), |
44 |
26467 |
d_pedanticFailure(false) |
45 |
|
{ |
46 |
3781 |
d_minPedanticLevel += 10; |
47 |
3781 |
} |
48 |
|
|
49 |
2813 |
void ProofFinalCallback::initializeUpdate() |
50 |
|
{ |
51 |
2813 |
d_pedanticFailure = false; |
52 |
2813 |
d_pedanticFailureOut.str(""); |
53 |
2813 |
++d_numFinalProofs; |
54 |
2813 |
} |
55 |
|
|
56 |
2464284 |
bool ProofFinalCallback::shouldUpdate(std::shared_ptr<ProofNode> pn, |
57 |
|
const std::vector<Node>& fa, |
58 |
|
bool& continueUpdate) |
59 |
|
{ |
60 |
2464284 |
PfRule r = pn->getRule(); |
61 |
|
// if not doing eager pedantic checking, fail if below threshold |
62 |
2464284 |
if (options::proofCheck() != options::ProofCheckMode::EAGER) |
63 |
|
{ |
64 |
2464284 |
if (!d_pedanticFailure) |
65 |
|
{ |
66 |
2464284 |
Assert(d_pedanticFailureOut.str().empty()); |
67 |
2464284 |
if (d_pnm->getChecker()->isPedanticFailure(r, d_pedanticFailureOut)) |
68 |
|
{ |
69 |
|
d_pedanticFailure = true; |
70 |
|
} |
71 |
|
} |
72 |
|
} |
73 |
2464284 |
if (options::proofCheck() != options::ProofCheckMode::NONE) |
74 |
|
{ |
75 |
2464284 |
d_pnm->ensureChecked(pn.get()); |
76 |
|
} |
77 |
2464284 |
uint32_t plevel = d_pnm->getChecker()->getPedanticLevel(r); |
78 |
2464284 |
if (plevel != 0) |
79 |
|
{ |
80 |
5634 |
d_minPedanticLevel.minAssign(plevel); |
81 |
|
} |
82 |
|
// record stats for the rule |
83 |
2464284 |
d_ruleCount << r; |
84 |
2464284 |
++d_totalRuleCount; |
85 |
|
// take stats on the instantiations in the proof |
86 |
2464284 |
if (r == PfRule::INSTANTIATE) |
87 |
|
{ |
88 |
2572 |
Node q = pn->getChildren()[0]->getResult(); |
89 |
1286 |
const std::vector<Node>& args = pn->getArguments(); |
90 |
1286 |
if (args.size() > q[0].getNumChildren()) |
91 |
|
{ |
92 |
|
InferenceId id; |
93 |
1286 |
if (getInferenceId(args[q[0].getNumChildren()], id)) |
94 |
|
{ |
95 |
1286 |
d_instRuleIds << id; |
96 |
|
} |
97 |
|
} |
98 |
|
} |
99 |
2464284 |
return false; |
100 |
|
} |
101 |
|
|
102 |
2813 |
bool ProofFinalCallback::wasPedanticFailure(std::ostream& out) const |
103 |
|
{ |
104 |
2813 |
if (d_pedanticFailure) |
105 |
|
{ |
106 |
|
out << d_pedanticFailureOut.str(); |
107 |
|
return true; |
108 |
|
} |
109 |
2813 |
return false; |
110 |
|
} |
111 |
|
|
112 |
|
} // namespace smt |
113 |
29511 |
} // namespace cvc5 |