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