1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/********************* */
/*! \file eq_proof.h
** \verbatim
** Top contributors (to current version):
** Haniel Barbosa, Andrew Reynolds
** This file is part of the CVC4 project.
** Copyright (c) 2009-2020 by the authors listed in the file AUTHORS
** in the top-level source directory) and their institutional affiliations.
** All rights reserved. See the file COPYING in the top-level source
** directory for licensing information.\endverbatim
**
** \brief A proof as produced by the equality engine.
**
**/
#include "cvc4_private.h"
#pragma once
#include <deque>
#include <memory>
#include <queue>
#include <unordered_map>
#include <vector>
#include "expr/node.h"
#include "theory/uf/equality_engine_types.h"
namespace CVC4 {
class CDProof;
namespace theory {
namespace eq {
class EqProof
{
public:
class PrettyPrinter
{
public:
virtual ~PrettyPrinter() {}
virtual std::string printTag(unsigned tag) = 0;
};
EqProof() : d_id(MERGED_THROUGH_REFLEXIVITY) {}
unsigned d_id;
Node d_node;
std::vector<std::shared_ptr<EqProof>> d_children;
/**
* Debug print this proof on debug trace c with tabulation tb and pretty
* printer prettyPrinter.
*/
void debug_print(const char* c,
unsigned tb = 0,
PrettyPrinter* prettyPrinter = nullptr) const;
/**
* Debug print this proof on output stream os with tabulation tb and pretty
* printer prettyPrinter.
*/
void debug_print(std::ostream& os,
unsigned tb = 0,
PrettyPrinter* prettyPrinter = nullptr) const;
/** Add to proof
*
* This method adds all of its steps to p via calls to CDProof::addStep.
*
* This method can be seen as a translation from EqProof to ProofNode. It is
* temporary until we update the EqualityEngine to the new proof
* infrastructure.
*
* It returns the node that is the conclusion of the proof as added to p.
*/
Node addToProof(CDProof* p) const;
private:
/** as above, but with a cache of previously processed nodes and their results
* (for DAG traversal). The caching is in terms of the original conclusions of
* EqProof
*/
Node addToProof(
CDProof* p,
std::unordered_map<Node, Node, NodeHashFunction>& visited,
std::unordered_set<Node, NodeHashFunction>& assumptions) const;
/** Removes all reflexivity steps, i.e. premises (= t t), from premises
*
* Such premisis are spurious for a trastivity steps. The reordering of
* premises in a transtivity step assumes no such steps are part of the
* premises.
*/
void cleanReflPremisesInTranstivity(std::vector<Node>& premises) const;
bool foldTransitivityChildren(
Node conclusion,
std::vector<Node>& premises,
CDProof* p,
std::unordered_set<Node, NodeHashFunction>& assumptions) const;
bool buildTransitivityChain(Node conclusion, std::vector<Node>& premises) const;
// returns whether it did reordering
void maybeAddSymmOrTrueIntroToProof(unsigned i,
std::vector<Node>& premises,
bool first,
Node termInEq,
CDProof* p) const;
void reduceNestedCongruence(
unsigned i,
Node conclusion,
std::vector<std::vector<Node>>& children,
CDProof* p,
std::unordered_map<Node, Node, NodeHashFunction>& visited,
std::unordered_set<Node, NodeHashFunction>& assumptions) const;
}; /* class EqProof */
} // Namespace eq
} // Namespace theory
} // Namespace CVC4
|