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