GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/builtin/proof_checker.h Lines: 1 1 100.0 %
Date: 2021-09-17 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds
4
 *
5
 * This file is part of the cvc5 project.
6
 *
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.
11
 * ****************************************************************************
12
 *
13
 * Builtin proof checker utility.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__BUILTIN__PROOF_CHECKER_H
19
#define CVC5__THEORY__BUILTIN__PROOF_CHECKER_H
20
21
#include "expr/node.h"
22
#include "proof/method_id.h"
23
#include "proof/proof_checker.h"
24
#include "proof/proof_node.h"
25
26
namespace cvc5 {
27
28
class Env;
29
30
namespace theory {
31
namespace builtin {
32
33
/** A checker for builtin proofs */
34
class BuiltinProofRuleChecker : public ProofRuleChecker
35
{
36
 public:
37
  /** Constructor. */
38
  BuiltinProofRuleChecker(Env& env);
39
  /** Destructor. */
40
9939
  ~BuiltinProofRuleChecker() {}
41
  /**
42
   * Get substitution for literal exp. Updates vars/subs to the substitution
43
   * specified by exp for the substitution method ids.
44
   */
45
  static bool getSubstitutionForLit(Node exp,
46
                                    TNode& var,
47
                                    TNode& subs,
48
                                    MethodId ids = MethodId::SB_DEFAULT);
49
  /**
50
   * Get substitution for formula exp. Adds to vars/subs to the substitution
51
   * specified by exp for the substitution method ids, which may be multiple
52
   * substitutions if exp is of kind AND and ids is SB_DEFAULT (note the other
53
   * substitution types always interpret applications of AND as a formula).
54
   * The vector "from" are the literals from exp that each substitution in
55
   * vars/subs are based on. For example, if exp is (and (= x t) (= y s)), then
56
   * vars = { x, y }, subs = { t, s }, from = { (= x y), (= y s) }.
57
   */
58
  static bool getSubstitutionFor(Node exp,
59
                                 std::vector<TNode>& vars,
60
                                 std::vector<TNode>& subs,
61
                                 std::vector<TNode>& from,
62
                                 MethodId ids = MethodId::SB_DEFAULT);
63
64
  /**
65
   * Apply substitution on n in skolem form. This encapsulates the exact
66
   * behavior of a SUBS step in a proof.
67
   *
68
   * @param n The node to substitute,
69
   * @param exp The (set of) equalities/literals/formulas that the substitution
70
   * is derived from
71
   * @param ids The method identifier of the substitution, by default SB_DEFAULT
72
   * specifying that lhs/rhs of equalities are interpreted as a substitution.
73
   * @param ida The method identifier of the substitution application, by
74
   * default SB_SEQUENTIAL specifying that substitutions are to be applied
75
   * sequentially
76
   * @return The substituted form of n.
77
   */
78
  static Node applySubstitution(Node n,
79
                                Node exp,
80
                                MethodId ids = MethodId::SB_DEFAULT,
81
                                MethodId ida = MethodId::SBA_SEQUENTIAL);
82
  static Node applySubstitution(Node n,
83
                                const std::vector<Node>& exp,
84
                                MethodId ids = MethodId::SB_DEFAULT,
85
                                MethodId ida = MethodId::SBA_SEQUENTIAL);
86
  /** Apply substitution + rewriting
87
   *
88
   * Combines the above two steps.
89
   *
90
   * @param n The node to substitute and rewrite,
91
   * @param exp The (set of) equalities corresponding to the substitution
92
   * @param ids The method identifier of the substitution.
93
   * @param ida The method identifier of the substitution application.
94
   * @param idr The method identifier of the rewriter.
95
   * @return The substituted, rewritten form of n.
96
   */
97
  Node applySubstitutionRewrite(Node n,
98
                                const std::vector<Node>& exp,
99
                                MethodId ids = MethodId::SB_DEFAULT,
100
                                MethodId ida = MethodId::SBA_SEQUENTIAL,
101
                                MethodId idr = MethodId::RW_REWRITE);
102
103
  /** get a TheoryId from a node, return false if we fail */
104
  static bool getTheoryId(TNode n, TheoryId& tid);
105
  /** Make a TheoryId into a node */
106
  static Node mkTheoryIdNode(TheoryId tid);
107
108
  /** Register all rules owned by this rule checker into pc. */
109
  void registerTo(ProofChecker* pc) override;
110
 protected:
111
  /** Return the conclusion of the given proof step, or null if it is invalid */
112
  Node checkInternal(PfRule id,
113
                     const std::vector<Node>& children,
114
                     const std::vector<Node>& args) override;
115
116
 private:
117
  /** Reference to the environment. */
118
  Env& d_env;
119
};
120
121
}  // namespace builtin
122
}  // namespace theory
123
}  // namespace cvc5
124
125
#endif /* CVC5__THEORY__BUILTIN__PROOF_CHECKER_H */