summaryrefslogtreecommitdiff
path: root/src/smt/expand_definitions.h
blob: a3d70542b70ad6ee2ade8b3cef04b9040a4a30c2 (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
/*********************                                                        */
/*! \file expand_definitions.h
 ** \verbatim
 ** Top contributors (to current version):
 **   Andrew Reynolds, Gereon Kremer
 ** This file is part of the CVC4 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.\endverbatim
 **
 ** \brief The module for processing assertions for an SMT engine.
 **/

#include "cvc4_private.h"

#ifndef CVC5__SMT__EXPAND_DEFINITIONS_H
#define CVC5__SMT__EXPAND_DEFINITIONS_H

#include <unordered_map>

#include "expr/node.h"
#include "theory/trust_node.h"

namespace cvc5 {

class ProofNodeManager;
class ResourceManager;
class SmtEngine;
class TConvProofGenerator;

namespace preprocessing {
class AssertionPipeline;
}

namespace smt {

struct SmtEngineStatistics;

/**
 * Module in charge of expanding definitions for an SMT engine.
 *
 * Its main features is expandDefinitions(TNode, ...), which returns the
 * expanded formula of a term.
 */
class ExpandDefs
{
 public:
  ExpandDefs(SmtEngine& smt, ResourceManager& rm, SmtEngineStatistics& stats);
  ~ExpandDefs();
  /**
   * Expand definitions in term n. Return the expanded form of n.
   *
   * @param n The node to expand
   * @param cache Cache of previous results
   * @param expandOnly if true, then the expandDefinitions function of
   * TheoryEngine is not called on subterms of n.
   * @return The expanded term.
   */
  Node expandDefinitions(
      TNode n,
      std::unordered_map<Node, Node, NodeHashFunction>& cache,
      bool expandOnly = false);
  /**
   * Expand defintitions in assertions. This applies this above method to each
   * assertion in the given pipeline.
   */
  void expandAssertions(preprocessing::AssertionPipeline& assertions,
                        bool expandOnly = false);

  /**
   * Set proof node manager, which signals this class to enable proofs using the
   * given proof node manager.
   */
  void setProofNodeManager(ProofNodeManager* pnm);

 private:
  /**
   * Helper function for above, called to specify if we want proof production
   * based on the optional argument tpg.
   */
  theory::TrustNode expandDefinitions(
      TNode n,
      std::unordered_map<Node, Node, NodeHashFunction>& cache,
      bool expandOnly,
      TConvProofGenerator* tpg);
  /** Reference to the SMT engine */
  SmtEngine& d_smt;
  /** Reference to resource manager */
  ResourceManager& d_resourceManager;
  /** Reference to the SMT stats */
  SmtEngineStatistics& d_smtStats;
  /** A proof generator for the term conversion. */
  std::unique_ptr<TConvProofGenerator> d_tpg;
};

}  // namespace smt
}  // namespace cvc5

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