summaryrefslogtreecommitdiff
path: root/src/smt/witness_form.h
blob: 938fc40d15a417c1f26cc124201d4ed533981fc9 (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
98
99
100
101
102
103
/******************************************************************************
 * Top contributors (to current version):
 *   Andrew Reynolds
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 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.
 * ****************************************************************************
 *
 * The module for managing witness form conversion in proofs.
 */

#include "cvc4_private.h"

#ifndef CVC5__SMT__WITNESS_FORM_H
#define CVC5__SMT__WITNESS_FORM_H

#include <unordered_set>

#include "expr/proof.h"
#include "expr/proof_generator.h"
#include "expr/term_conversion_proof_generator.h"

namespace cvc5 {
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);
  /**
   * Return a proof generator that can prove the given axiom exists.
   */
  ProofGenerator* convertExistsInternal(Node exists);
  /** 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;
  /** CDProof for justifying purification existentials */
  CDProof d_pskPf;
};

}  // namespace smt
}  // namespace cvc5

#endif
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback