GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/smt/proof_final_callback.cpp Lines: 40 43 93.0 %
Date: 2021-09-07 Branches: 44 98 44.9 %

Line Exec Source
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
3786
ProofFinalCallback::ProofFinalCallback(ProofNodeManager* pnm)
32
3786
    : d_ruleCount(smtStatisticsRegistry().registerHistogram<PfRule>(
33
7572
          "finalProof::ruleCount")),
34
      d_instRuleIds(
35
3786
          smtStatisticsRegistry().registerHistogram<theory::InferenceId>(
36
7572
              "finalProof::instRuleId")),
37
      d_totalRuleCount(
38
7572
          smtStatisticsRegistry().registerInt("finalProof::totalRuleCount")),
39
      d_minPedanticLevel(
40
7572
          smtStatisticsRegistry().registerInt("finalProof::minPedanticLevel")),
41
      d_numFinalProofs(
42
7572
          smtStatisticsRegistry().registerInt("finalProofs::numFinalProofs")),
43
      d_pnm(pnm),
44
26502
      d_pedanticFailure(false)
45
{
46
3786
  d_minPedanticLevel += 10;
47
3786
}
48
49
2814
void ProofFinalCallback::initializeUpdate()
50
{
51
2814
  d_pedanticFailure = false;
52
2814
  d_pedanticFailureOut.str("");
53
2814
  ++d_numFinalProofs;
54
2814
}
55
56
2491245
bool ProofFinalCallback::shouldUpdate(std::shared_ptr<ProofNode> pn,
57
                                      const std::vector<Node>& fa,
58
                                      bool& continueUpdate)
59
{
60
2491245
  PfRule r = pn->getRule();
61
  // if not doing eager pedantic checking, fail if below threshold
62
2491245
  if (options::proofCheck() != options::ProofCheckMode::EAGER)
63
  {
64
2491245
    if (!d_pedanticFailure)
65
    {
66
2491245
      Assert(d_pedanticFailureOut.str().empty());
67
2491245
      if (d_pnm->getChecker()->isPedanticFailure(r, d_pedanticFailureOut))
68
      {
69
        d_pedanticFailure = true;
70
      }
71
    }
72
  }
73
2491245
  if (options::proofCheck() != options::ProofCheckMode::NONE)
74
  {
75
2491245
    d_pnm->ensureChecked(pn.get());
76
  }
77
2491245
  uint32_t plevel = d_pnm->getChecker()->getPedanticLevel(r);
78
2491245
  if (plevel != 0)
79
  {
80
5639
    d_minPedanticLevel.minAssign(plevel);
81
  }
82
  // record stats for the rule
83
2491245
  d_ruleCount << r;
84
2491245
  ++d_totalRuleCount;
85
  // take stats on the instantiations in the proof
86
2491245
  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
2491245
  return false;
100
}
101
102
2814
bool ProofFinalCallback::wasPedanticFailure(std::ostream& out) const
103
{
104
2814
  if (d_pedanticFailure)
105
  {
106
    out << d_pedanticFailureOut.str();
107
    return true;
108
  }
109
2814
  return false;
110
}
111
112
}  // namespace smt
113
29502
}  // namespace cvc5