blob: 10e4bd07bdd3281cde5ea8c7d6200cc98b16e7db (
plain)
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
|
/********************* */
/*! \file witness_form.h
** \verbatim
** Top contributors (to current version):
** 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 The module for managing witness form conversion in proofs
**/
#include "cvc4_private.h"
#ifndef CVC4__SMT__WITNESS_FORM_H
#define CVC4__SMT__WITNESS_FORM_H
#include <unordered_set>
#include "expr/node_manager.h"
#include "expr/proof.h"
#include "expr/proof_generator.h"
#include "expr/term_conversion_proof_generator.h"
namespace CVC4 {
namespace smt {
/**
* The witness form proof generator, which acts as a wrapper around a
* TConvProofGenerator for adding rewrite steps for witness introduction.
*
* The proof steps managed by this class are stored in a context-independent
* manager, which matches how witness forms are managed in SkolemManager.
*/
class WitnessFormGenerator : public ProofGenerator
{
public:
WitnessFormGenerator(ProofNodeManager* pnm);
~WitnessFormGenerator() {}
/**
* Get proof for, which expects an equality of the form t = toWitness(t).
* This returns a proof based on the term conversion proof generator utility.
* This proof may contain open assumptions of the form:
* k = toWitness(k)
* Each of these assumptions are included in the set getWitnessFormEqs()
* below after returning this call.
*/
std::shared_ptr<ProofNode> getProofFor(Node eq) override;
/** Identify */
std::string identify() const override;
/**
* Does the rewrite require witness form conversion?
* When calling this method, it should be the case that:
* Rewriter::rewrite(toWitness(t)) == Rewriter::rewrite(toWitness(s))
* The rule MACRO_SR_PRED_TRANSFORM concludes t == s if the above holds.
* This method returns false if:
* Rewriter::rewrite(t) == Rewriter::rewrite(s)
* which means that the proof of the above fact does not need to do
* witness form conversion to prove conclusions of MACRO_SR_PRED_TRANSFORM.
*/
bool requiresWitnessFormTransform(Node t, Node s) const;
/**
* Same as above, with s = true. This is intended for use with
* MACRO_SR_PRED_INTRO.
*/
bool requiresWitnessFormIntro(Node t) const;
/**
* Get witness form equalities. This returns a set of equalities of the form:
* k = toWitness(k)
* where k is a skolem, containing all rewrite steps used in calls to
* getProofFor during the entire lifetime of this generator.
*/
const std::unordered_set<Node, NodeHashFunction>& getWitnessFormEqs() const;
private:
/**
* Convert to witness form. This internally constructs rewrite steps that
* suffice to show t = toWitness(t) using the term conversion proof generator
* of this class (d_tcpg).
*/
Node convertToWitnessForm(Node t);
/** The term conversion proof generator */
TConvProofGenerator d_tcpg;
/** The nodes we have already added rewrite steps for in d_tcpg */
std::unordered_set<TNode, TNodeHashFunction> d_visited;
/** The set of equalities added as proof steps */
std::unordered_set<Node, NodeHashFunction> d_eqs;
/** Lazy proof storing witness intro steps */
LazyCDProof d_wintroPf;
};
} // namespace smt
} // namespace CVC4
#endif
|