GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/theory_arith.h Lines: 3 4 75.0 %
Date: 2021-03-22 Branches: 0 2 0.0 %

Line Exec Source
1
/*********************                                                        */
2
/*! \file theory_arith.h
3
 ** \verbatim
4
 ** Top contributors (to current version):
5
 **   Andrew Reynolds, Tim King, Gereon Kremer
6
 ** This file is part of the CVC4 project.
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.\endverbatim
11
 **
12
 ** \brief Arithmetic theory.
13
 ** Arithmetic theory.
14
 **/
15
16
#include "cvc4_private.h"
17
18
#pragma once
19
20
#include "expr/node.h"
21
#include "theory/arith/arith_preprocess.h"
22
#include "theory/arith/arith_rewriter.h"
23
#include "theory/arith/arith_state.h"
24
#include "theory/arith/inference_manager.h"
25
#include "theory/theory.h"
26
27
namespace CVC4 {
28
namespace theory {
29
namespace arith {
30
namespace nl {
31
class NonlinearExtension;
32
}
33
34
class TheoryArithPrivate;
35
36
/**
37
 * Implementation of linear and non-linear integer and real arithmetic.
38
 * The linear arithmetic solver is based upon:
39
 * http://research.microsoft.com/en-us/um/people/leonardo/cav06.pdf
40
 */
41
class TheoryArith : public Theory {
42
 private:
43
  friend class TheoryArithPrivate;
44
45
  TheoryArithPrivate* d_internal;
46
47
  TimerStat d_ppRewriteTimer;
48
49
  /** Used to prove pp-rewrites */
50
  EagerProofGenerator d_ppPfGen;
51
52
 public:
53
  TheoryArith(context::Context* c,
54
              context::UserContext* u,
55
              OutputChannel& out,
56
              Valuation valuation,
57
              const LogicInfo& logicInfo,
58
              ProofNodeManager* pnm = nullptr);
59
  virtual ~TheoryArith();
60
61
  //--------------------------------- initialization
62
  /** get the official theory rewriter of this theory */
63
  TheoryRewriter* getTheoryRewriter() override;
64
  /**
65
   * Returns true if this theory needs an equality engine, which is assigned
66
   * to it (d_equalityEngine) by the equality engine manager during
67
   * TheoryEngine::finishInit, prior to calling finishInit for this theory.
68
   * If this method returns true, it stores instructions for the notifications
69
   * this Theory wishes to receive from its equality engine.
70
   */
71
  bool needsEqualityEngine(EeSetupInfo& esi) override;
72
  /** finish initialization */
73
  void finishInit() override;
74
  //--------------------------------- end initialization
75
  /**
76
   * Expand definition, which eliminates extended operators like div/mod in
77
   * the given node.
78
   */
79
  TrustNode expandDefinition(Node node) override;
80
  /**
81
   * Does non-context dependent setup for a node connected to a theory.
82
   */
83
  void preRegisterTerm(TNode n) override;
84
85
  //--------------------------------- standard check
86
  /** Pre-check, called before the fact queue of the theory is processed. */
87
  bool preCheck(Effort level) override;
88
  /** Post-check, called after the fact queue of the theory is processed. */
89
  void postCheck(Effort level) override;
90
  /** Pre-notify fact, return true if processed. */
91
  bool preNotifyFact(TNode atom,
92
                     bool pol,
93
                     TNode fact,
94
                     bool isPrereg,
95
                     bool isInternal) override;
96
  //--------------------------------- end standard check
97
  bool needsCheckLastEffort() override;
98
  void propagate(Effort e) override;
99
  TrustNode explain(TNode n) override;
100
101
  bool collectModelInfo(TheoryModel* m, const std::set<Node>& termSet) override;
102
  /**
103
   * Collect model values in m based on the relevant terms given by termSet.
104
   */
105
  bool collectModelValues(TheoryModel* m,
106
                          const std::set<Node>& termSet) override;
107
108
8986
  void shutdown() override {}
109
110
  void presolve() override;
111
  void notifyRestart() override;
112
  PPAssertStatus ppAssert(TrustNode tin,
113
                          TrustSubstitutionMap& outSubstitutions) override;
114
  /**
115
   * Preprocess rewrite terms, return the trust node encapsulating the
116
   * preprocessed form of n, and the proof generator that can provide the
117
   * proof for the equivalence of n and this term.
118
   *
119
   * This calls the operator elimination utility to eliminate extended
120
   * symbols.
121
   */
122
  TrustNode ppRewrite(TNode atom, std::vector<SkolemLemma>& lems) override;
123
  void ppStaticLearn(TNode in, NodeBuilder<>& learned) override;
124
125
  std::string identify() const override { return std::string("TheoryArith"); }
126
127
  EqualityStatus getEqualityStatus(TNode a, TNode b) override;
128
129
  void notifySharedTerm(TNode n) override;
130
131
  Node getModelValue(TNode var) override;
132
133
  std::pair<bool, Node> entailmentCheck(TNode lit) override;
134
135
  /** Return a reference to the arith::InferenceManager. */
136
4389
  InferenceManager& getInferenceManager()
137
  {
138
4389
    return d_im;
139
  }
140
141
 private:
142
  /**
143
   * Preprocess equality, applies ppRewrite for equalities. This method is
144
   * distinct from ppRewrite since it is not allowed to construct lemmas.
145
   */
146
  TrustNode ppRewriteEq(TNode eq);
147
  /** Get the proof equality engine */
148
  eq::ProofEqEngine* getProofEqEngine();
149
  /** The state object wrapping TheoryArithPrivate  */
150
  ArithState d_astate;
151
  /** The arith::InferenceManager. */
152
  InferenceManager d_im;
153
154
  /**
155
   * The non-linear extension, responsible for all approaches for non-linear
156
   * arithmetic.
157
   */
158
  std::unique_ptr<nl::NonlinearExtension> d_nonlinearExtension;
159
  /** The preprocess utility */
160
  ArithPreprocess d_arithPreproc;
161
  /** The theory rewriter for this theory. */
162
  ArithRewriter d_rewriter;
163
164
};/* class TheoryArith */
165
166
}/* CVC4::theory::arith namespace */
167
}/* CVC4::theory namespace */
168
}/* CVC4 namespace */