GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/expr/buffered_proof_generator.cpp Lines: 23 34 67.6 %
Date: 2021-03-23 Branches: 39 136 28.7 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file buffered_proof_generator.cpp
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Andrew Reynolds, Haniel Barbosa
6
 ** This file is part of the CVC4 project.
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.\endverbatim
11
 **
12
 ** \brief Implementation of a proof generator for buffered proof steps
13
 **/
14
15
#include "expr/buffered_proof_generator.h"
16
17
#include "expr/proof.h"
18
#include "expr/proof_node_manager.h"
19
20
namespace CVC4 {
21
22
8131
BufferedProofGenerator::BufferedProofGenerator(context::Context* c,
23
8131
                                               ProofNodeManager* pnm)
24
8131
    : ProofGenerator(), d_facts(c), d_pnm(pnm)
25
{
26
8131
}
27
28
692927
bool BufferedProofGenerator::addStep(Node fact,
29
                                     ProofStep ps,
30
                                     CDPOverwrite opolicy)
31
{
32
  // check duplicates if we are not always overwriting
33
692927
  if (opolicy != CDPOverwrite::ALWAYS)
34
  {
35
692927
    if (d_facts.find(fact) != d_facts.end())
36
    {
37
      // duplicate
38
1334388
      return false;
39
    }
40
51466
    Node symFact = CDProof::getSymmFact(fact);
41
25733
    if (!symFact.isNull())
42
    {
43
5571
      if (d_facts.find(symFact) != d_facts.end())
44
      {
45
        // duplicate due to symmetry
46
        return false;
47
      }
48
    }
49
  }
50
  // note that this replaces the value fact is mapped to if there is already one
51
25733
  d_facts.insert(fact, std::make_shared<ProofStep>(ps));
52
25733
  return true;
53
}
54
55
80608
std::shared_ptr<ProofNode> BufferedProofGenerator::getProofFor(Node fact)
56
{
57
161216
  Trace("pfee-fact-gen") << "BufferedProofGenerator::getProofFor: " << fact
58
80608
                         << std::endl;
59
80608
  NodeProofStepMap::iterator it = d_facts.find(fact);
60
80608
  if (it == d_facts.end())
61
  {
62
    Node symFact = CDProof::getSymmFact(fact);
63
    if (symFact.isNull())
64
    {
65
      Trace("pfee-fact-gen") << "...cannot find step" << std::endl;
66
      Assert(false);
67
      return nullptr;
68
    }
69
    it = d_facts.find(symFact);
70
    if (it == d_facts.end())
71
    {
72
      Assert(false);
73
      Trace("pfee-fact-gen") << "...cannot find step (no sym)" << std::endl;
74
      return nullptr;
75
    }
76
  }
77
80608
  Trace("pfee-fact-gen") << "...return via step " << *(*it).second << std::endl;
78
161216
  CDProof cdp(d_pnm);
79
80608
  cdp.addStep(fact, *(*it).second);
80
80608
  return cdp.getProofFor(fact);
81
}
82
83
26685
}  // namespace CVC4