GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/proof/cnf_proof.h Lines: 1 1 100.0 %
Date: 2021-03-23 Branches: 0 0 0.0 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file cnf_proof.h
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Liana Hadarean, Haniel Barbosa, Tim King
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 A manager for CnfProofs.
13
 **
14
 ** A manager for CnfProofs.
15
 **
16
 **
17
 **/
18
19
#include "cvc4_private.h"
20
21
#ifndef CVC4__CNF_PROOF_H
22
#define CVC4__CNF_PROOF_H
23
24
#include <unordered_map>
25
#include <unordered_set>
26
27
#include "context/cdhashmap.h"
28
#include "proof/clause_id.h"
29
#include "proof/proof_manager.h"
30
31
namespace CVC4 {
32
namespace prop {
33
  class CnfStream;
34
}/* CVC4::prop namespace */
35
36
class CnfProof;
37
38
typedef std::unordered_map<Node, Node, NodeHashFunction> NodeToNode;
39
typedef std::unordered_set<ClauseId> ClauseIdSet;
40
41
typedef context::CDHashMap<ClauseId, Node> ClauseIdToNode;
42
typedef std::pair<Node, Node> NodePair;
43
typedef std::set<NodePair> NodePairSet;
44
45
typedef std::unordered_set<Node, NodeHashFunction> NodeSet;
46
47
class CnfProof {
48
protected:
49
  CVC4::prop::CnfStream* d_cnfStream;
50
51
  /** Map from ClauseId to the assertion that lead to adding this clause **/
52
  ClauseIdToNode d_clauseToAssertion;
53
54
  /** Top of stack is assertion currently being converted to CNF. Also saves
55
   * whether it is input (rather than a lemma). **/
56
  std::vector<std::pair<Node, bool>> d_currentAssertionStack;
57
58
  /** Map from top-level fact to facts/assertion that it follows from **/
59
  NodeToNode d_cnfDeps;
60
61
  ClauseIdSet d_explanations;
62
63
  // The clause ID of the unit clause defining the true SAT literal.
64
  ClauseId d_trueUnitClause;
65
  // The clause ID of the unit clause defining the false SAT literal.
66
  ClauseId d_falseUnitClause;
67
68
  std::string d_name;
69
public:
70
  CnfProof(CVC4::prop::CnfStream* cnfStream,
71
           context::Context* ctx,
72
           const std::string& name);
73
  ~CnfProof();
74
75
  /** Methods for logging what the CnfStream does **/
76
  // map the clause back to the current assertion where it came from
77
  void registerConvertedClause(ClauseId clause);
78
79
  /** Clause is one of the clauses defining top-level assertion node*/
80
  void setClauseAssertion(ClauseId clause, Node node);
81
82
  /** Current assertion being converted and whether it is an input (rather than
83
   * a lemma) */
84
  void pushCurrentAssertion(Node assertion, bool isInput = false);
85
  void popCurrentAssertion();
86
  Node getCurrentAssertion();
87
  bool getCurrentAssertionKind();
88
89
  /**
90
   * Checks whether the assertion stack is empty.
91
   */
92
908
  bool isAssertionStackEmpty() const { return d_currentAssertionStack.empty(); }
93
94
  // accessors for the leaf assertions that are being converted to CNF
95
  Node getAssertionForClause(ClauseId clause);
96
};/* class CnfProof */
97
98
} /* CVC4 namespace */
99
100
#endif /* CVC4__CNF_PROOF_H */