GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/prop/proof_post_processor.h Lines: 1 1 100.0 %
Date: 2021-05-22 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Haniel Barbosa
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
 * The module for processing proof nodes in the prop engine.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__PROP__PROOF_POST_PROCESSOR_H
19
#define CVC5__PROP__PROOF_POST_PROCESSOR_H
20
21
#include <map>
22
#include <unordered_set>
23
24
#include "expr/proof_node_updater.h"
25
#include "prop/proof_cnf_stream.h"
26
27
namespace cvc5 {
28
29
namespace prop {
30
31
/**
32
 * A callback class used by PropEngine for post-processing proof nodes by
33
 * connecting proofs of resolution, whose leaves are clausified preprocessed
34
 * assertions and lemmas, with the CNF transformation of these formulas, while
35
 * expanding the generators of lemmas.
36
 */
37
class ProofPostprocessCallback : public ProofNodeUpdaterCallback
38
{
39
 public:
40
  ProofPostprocessCallback(ProofNodeManager* pnm,
41
                           ProofCnfStream* proofCnfStream);
42
1197
  ~ProofPostprocessCallback() {}
43
  /**
44
   * Initialize, called once for each new ProofNode to process. This initializes
45
   * static information to be used by successive calls to update. For this
46
   * callback it resets d_assumpToProof.
47
   */
48
  void initializeUpdate();
49
  /** Should proof pn be updated?
50
   *
51
   * For this callback a proof node is updatable if it's an assumption for which
52
   * the proof cnf straem has a proof. However if the proof node is blocked
53
   * (which is the case for proof nodes introduced into the proof cnf stream's
54
   * proof via expansion of its generators) then traversal is the proof node is
55
   * cancelled, i.e., continueUpdate is set to false.
56
   */
57
  bool shouldUpdate(std::shared_ptr<ProofNode> pn,
58
                    const std::vector<Node>& fa,
59
                    bool& continueUpdate) override;
60
  /** Update the proof rule application.
61
   *
62
   * Replaces assumptions by their proof in proof cnf stream. Note that in doing
63
   * this the proof node is blocked, so that future post-processing does not
64
   * traverse it.
65
   *
66
   * This method uses the cache in d_assumpToProof to avoid recomputing proofs
67
   * for the same assumption (in the same scope).
68
   */
69
  bool update(Node res,
70
              PfRule id,
71
              const std::vector<Node>& children,
72
              const std::vector<Node>& args,
73
              CDProof* cdp,
74
              bool& continueUpdate) override;
75
76
 private:
77
  /** The proof node manager */
78
  ProofNodeManager* d_pnm;
79
  /** The cnf stream proof generator */
80
  ProofCnfStream* d_proofCnfStream;
81
  //---------------------------------reset at the begining of each update
82
  /** Mapping assumptions to their proof from cnf transformation */
83
  std::map<Node, std::shared_ptr<ProofNode> > d_assumpToProof;
84
  //---------------------------------end reset at the begining of each update
85
};
86
87
/**
88
 * The proof postprocessor module. This postprocesses the refutation proof
89
 * produced by the SAT solver. Its main task is to connect the refutation's
90
 * assumptions to the CNF transformation proof in ProofCnfStream.
91
 */
92
class ProofPostproccess
93
{
94
 public:
95
  ProofPostproccess(ProofNodeManager* pnm, ProofCnfStream* proofCnfStream);
96
  ~ProofPostproccess();
97
  /** post-process
98
   *
99
   * The post-processing is done via a proof node updater run on pf with this
100
   * class's callback d_cb.
101
   */
102
  void process(std::shared_ptr<ProofNode> pf);
103
104
 private:
105
  /** The post process callback */
106
  ProofPostprocessCallback d_cb;
107
  /** The proof node manager */
108
  ProofNodeManager* d_pnm;
109
};
110
111
}  // namespace prop
112
}  // namespace cvc5
113
114
#endif