GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/prop/prop_proof_manager.cpp Lines: 19 50 38.0 %
Date: 2021-05-22 Branches: 19 182 10.4 %

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
 * Implementation of the proof manager for the PropPfManager.
14
 */
15
16
#include "prop/prop_proof_manager.h"
17
18
#include "expr/proof_ensure_closed.h"
19
#include "expr/proof_node_algorithm.h"
20
#include "prop/prop_proof_manager.h"
21
#include "prop/sat_solver.h"
22
23
namespace cvc5 {
24
namespace prop {
25
26
1197
PropPfManager::PropPfManager(context::UserContext* userContext,
27
                             ProofNodeManager* pnm,
28
                             CDCLTSatSolverInterface* satSolver,
29
1197
                             ProofCnfStream* cnfProof)
30
    : d_pnm(pnm),
31
1197
      d_pfpp(new ProofPostproccess(pnm, cnfProof)),
32
      d_satSolver(satSolver),
33
2394
      d_assertions(userContext)
34
{
35
  // add trivial assumption. This is so that we can check the that the prop
36
  // engine's proof is closed, as the SAT solver's refutation proof may use True
37
  // as an assumption even when True is not given as an assumption. An example
38
  // is when a propagated literal has an empty explanation (i.e., it is a valid
39
  // literal), which leads to adding True as its explanation, since for creating
40
  // a learned clause we need at least two literals.
41
1197
  d_assertions.push_back(NodeManager::currentNM()->mkConst(true));
42
1197
}
43
44
20959
void PropPfManager::registerAssertion(Node assertion)
45
{
46
20959
  d_assertions.push_back(assertion);
47
20959
}
48
49
void PropPfManager::checkProof(context::CDList<Node>* assertions)
50
{
51
  Trace("sat-proof") << "PropPfManager::checkProof: Checking if resolution "
52
                        "proof of false is closed\n";
53
  std::shared_ptr<ProofNode> conflictProof = d_satSolver->getProof();
54
  Assert(conflictProof);
55
  // connect it with CNF proof
56
  d_pfpp->process(conflictProof);
57
  // add given assertions d_assertions
58
  for (const Node& assertion : *assertions)
59
  {
60
    d_assertions.push_back(assertion);
61
  }
62
  std::vector<Node> avec{d_assertions.begin(), d_assertions.end()};
63
  pfnEnsureClosedWrt(
64
      conflictProof.get(), avec, "sat-proof", "PropPfManager::checkProof");
65
}
66
67
2698
std::shared_ptr<ProofNode> PropPfManager::getProof()
68
{
69
  // retrieve the SAT solver's refutation proof
70
5396
  Trace("sat-proof")
71
2698
      << "PropPfManager::getProof: Getting resolution proof of false\n";
72
2698
  std::shared_ptr<ProofNode> conflictProof = d_satSolver->getProof();
73
2698
  Assert(conflictProof);
74
2698
  if (Trace.isOn("sat-proof"))
75
  {
76
    std::vector<Node> fassumps;
77
    expr::getFreeAssumptions(conflictProof.get(), fassumps);
78
    Trace("sat-proof")
79
        << "PropPfManager::getProof: initial free assumptions are:\n";
80
    for (const Node& a : fassumps)
81
    {
82
      Trace("sat-proof") << "- " << a << "\n";
83
    }
84
    Trace("sat-proof-debug")
85
        << "PropPfManager::getProof: proof is " << *conflictProof.get() << "\n";
86
    Trace("sat-proof")
87
        << "PropPfManager::getProof: Connecting with CNF proof\n";
88
  }
89
  // connect it with CNF proof
90
2698
  d_pfpp->process(conflictProof);
91
2698
  if (Trace.isOn("sat-proof"))
92
  {
93
    std::vector<Node> fassumps;
94
    expr::getFreeAssumptions(conflictProof.get(), fassumps);
95
    Trace("sat-proof")
96
        << "PropPfManager::getProof: new free assumptions are:\n";
97
    for (const Node& a : fassumps)
98
    {
99
      Trace("sat-proof") << "- " << a << "\n";
100
    }
101
    Trace("sat-proof") << "PropPfManager::getProof: assertions are:\n";
102
    for (const Node& a : d_assertions)
103
    {
104
      Trace("sat-proof") << "- " << a << "\n";
105
    }
106
    Trace("sat-proof-debug")
107
        << "PropPfManager::getProof: proof is " << *conflictProof.get() << "\n";
108
  }
109
2698
  return conflictProof;
110
}
111
112
}  // namespace prop
113
28191
}  // namespace cvc5