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 |
3771 |
ProofFinalCallback::ProofFinalCallback(ProofNodeManager* pnm) |
32 |
3771 |
: d_ruleCount(smtStatisticsRegistry().registerHistogram<PfRule>( |
33 |
7542 |
"finalProof::ruleCount")), |
34 |
|
d_instRuleIds( |
35 |
3771 |
smtStatisticsRegistry().registerHistogram<theory::InferenceId>( |
36 |
7542 |
"finalProof::instRuleId")), |
37 |
|
d_totalRuleCount( |
38 |
7542 |
smtStatisticsRegistry().registerInt("finalProof::totalRuleCount")), |
39 |
|
d_minPedanticLevel( |
40 |
7542 |
smtStatisticsRegistry().registerInt("finalProof::minPedanticLevel")), |
41 |
|
d_numFinalProofs( |
42 |
7542 |
smtStatisticsRegistry().registerInt("finalProofs::numFinalProofs")), |
43 |
|
d_pnm(pnm), |
44 |
26397 |
d_pedanticFailure(false) |
45 |
|
{ |
46 |
3771 |
d_minPedanticLevel += 10; |
47 |
3771 |
} |
48 |
|
|
49 |
2805 |
void ProofFinalCallback::initializeUpdate() |
50 |
|
{ |
51 |
2805 |
d_pedanticFailure = false; |
52 |
2805 |
d_pedanticFailureOut.str(""); |
53 |
2805 |
++d_numFinalProofs; |
54 |
2805 |
} |
55 |
|
|
56 |
2482972 |
bool ProofFinalCallback::shouldUpdate(std::shared_ptr<ProofNode> pn, |
57 |
|
const std::vector<Node>& fa, |
58 |
|
bool& continueUpdate) |
59 |
|
{ |
60 |
2482972 |
PfRule r = pn->getRule(); |
61 |
|
// if not doing eager pedantic checking, fail if below threshold |
62 |
2482972 |
if (!options::proofEagerChecking()) |
63 |
|
{ |
64 |
2482972 |
if (!d_pedanticFailure) |
65 |
|
{ |
66 |
2482972 |
Assert(d_pedanticFailureOut.str().empty()); |
67 |
2482972 |
if (d_pnm->getChecker()->isPedanticFailure(r, d_pedanticFailureOut)) |
68 |
|
{ |
69 |
|
d_pedanticFailure = true; |
70 |
|
} |
71 |
|
} |
72 |
|
} |
73 |
2482972 |
uint32_t plevel = d_pnm->getChecker()->getPedanticLevel(r); |
74 |
2482972 |
if (plevel != 0) |
75 |
|
{ |
76 |
5584 |
d_minPedanticLevel.minAssign(plevel); |
77 |
|
} |
78 |
|
// record stats for the rule |
79 |
2482972 |
d_ruleCount << r; |
80 |
2482972 |
++d_totalRuleCount; |
81 |
|
// take stats on the instantiations in the proof |
82 |
2482972 |
if (r == PfRule::INSTANTIATE) |
83 |
|
{ |
84 |
2570 |
Node q = pn->getChildren()[0]->getResult(); |
85 |
1285 |
const std::vector<Node>& args = pn->getArguments(); |
86 |
1285 |
if (args.size() > q[0].getNumChildren()) |
87 |
|
{ |
88 |
|
InferenceId id; |
89 |
1285 |
if (getInferenceId(args[q[0].getNumChildren()], id)) |
90 |
|
{ |
91 |
1285 |
d_instRuleIds << id; |
92 |
|
} |
93 |
|
} |
94 |
|
} |
95 |
2482972 |
return false; |
96 |
|
} |
97 |
|
|
98 |
2805 |
bool ProofFinalCallback::wasPedanticFailure(std::ostream& out) const |
99 |
|
{ |
100 |
2805 |
if (d_pedanticFailure) |
101 |
|
{ |
102 |
|
out << d_pedanticFailureOut.str(); |
103 |
|
return true; |
104 |
|
} |
105 |
2805 |
return false; |
106 |
|
} |
107 |
|
|
108 |
|
} // namespace smt |
109 |
29358 |
} // namespace cvc5 |