GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/expr/buffered_proof_generator.cpp Lines: 33 44 75.0 %
Date: 2021-05-22 Branches: 55 158 34.8 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, 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 a proof generator for buffered proof steps.
14
 */
15
16
#include "expr/buffered_proof_generator.h"
17
18
#include "expr/proof.h"
19
#include "expr/proof_node_manager.h"
20
21
namespace cvc5 {
22
23
10246
BufferedProofGenerator::BufferedProofGenerator(context::Context* c,
24
10246
                                               ProofNodeManager* pnm)
25
10246
    : ProofGenerator(), d_facts(c), d_pnm(pnm)
26
{
27
10246
}
28
29
46208
bool BufferedProofGenerator::addStep(Node fact,
30
                                     ProofStep ps,
31
                                     CDPOverwrite opolicy)
32
{
33
  // check duplicates if we are not always overwriting
34
46208
  if (opolicy != CDPOverwrite::ALWAYS)
35
  {
36
13477
    if (d_facts.find(fact) != d_facts.end())
37
    {
38
      // duplicate
39
88
      return false;
40
    }
41
26866
    Node symFact = CDProof::getSymmFact(fact);
42
13433
    if (!symFact.isNull())
43
    {
44
5208
      if (d_facts.find(symFact) != d_facts.end())
45
      {
46
        // duplicate due to symmetry
47
        return false;
48
      }
49
    }
50
  }
51
  // note that this replaces the value fact is mapped to if there is already one
52
46164
  d_facts.insert(fact, std::make_shared<ProofStep>(ps));
53
46164
  return true;
54
}
55
56
160241
std::shared_ptr<ProofNode> BufferedProofGenerator::getProofFor(Node fact)
57
{
58
320482
  Trace("pfee-fact-gen") << "BufferedProofGenerator::getProofFor: " << fact
59
160241
                         << std::endl;
60
160241
  NodeProofStepMap::iterator it = d_facts.find(fact);
61
160241
  if (it == d_facts.end())
62
  {
63
    Node symFact = CDProof::getSymmFact(fact);
64
    if (symFact.isNull())
65
    {
66
      Trace("pfee-fact-gen") << "...cannot find step" << std::endl;
67
      Assert(false);
68
      return nullptr;
69
    }
70
    it = d_facts.find(symFact);
71
    if (it == d_facts.end())
72
    {
73
      Assert(false);
74
      Trace("pfee-fact-gen") << "...cannot find step (no sym)" << std::endl;
75
      return nullptr;
76
    }
77
  }
78
160241
  Trace("pfee-fact-gen") << "...return via step " << *(*it).second << std::endl;
79
320482
  CDProof cdp(d_pnm);
80
160241
  cdp.addStep(fact, *(*it).second);
81
160241
  return cdp.getProofFor(fact);
82
}
83
84
23647
bool BufferedProofGenerator::hasProofFor(Node f)
85
{
86
23647
  NodeProofStepMap::iterator it = d_facts.find(f);
87
23647
  if (it == d_facts.end())
88
  {
89
16698
    Node symFact = CDProof::getSymmFact(f);
90
16693
    if (symFact.isNull())
91
    {
92
10943
      return false;
93
    }
94
5750
    it = d_facts.find(symFact);
95
5750
    if (it == d_facts.end())
96
    {
97
5745
      return false;
98
    }
99
  }
100
6959
  return true;
101
}
102
103
28194
}  // namespace cvc5