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

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Andrew Reynolds, Tim King, Gereon Kremer
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
 * Arithmetic theory.
14
 */
15
16
#include "cvc5_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 cvc5 {
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
  /** get the proof checker of this theory */
65
  ProofRuleChecker* getProofChecker() override;
66
  /**
67
   * Returns true if this theory needs an equality engine, which is assigned
68
   * to it (d_equalityEngine) by the equality engine manager during
69
   * TheoryEngine::finishInit, prior to calling finishInit for this theory.
70
   * If this method returns true, it stores instructions for the notifications
71
   * this Theory wishes to receive from its equality engine.
72
   */
73
  bool needsEqualityEngine(EeSetupInfo& esi) override;
74
  /** finish initialization */
75
  void finishInit() override;
76
  //--------------------------------- end initialization
77
  /**
78
   * Does non-context dependent setup for a node connected to a theory.
79
   */
80
  void preRegisterTerm(TNode n) override;
81
82
  //--------------------------------- standard check
83
  /** Pre-check, called before the fact queue of the theory is processed. */
84
  bool preCheck(Effort level) override;
85
  /** Post-check, called after the fact queue of the theory is processed. */
86
  void postCheck(Effort level) override;
87
  /** Pre-notify fact, return true if processed. */
88
  bool preNotifyFact(TNode atom,
89
                     bool pol,
90
                     TNode fact,
91
                     bool isPrereg,
92
                     bool isInternal) override;
93
  //--------------------------------- end standard check
94
  bool needsCheckLastEffort() override;
95
  void propagate(Effort e) override;
96
  TrustNode explain(TNode n) override;
97
98
  bool collectModelInfo(TheoryModel* m, const std::set<Node>& termSet) override;
99
  /**
100
   * Collect model values in m based on the relevant terms given by termSet.
101
   */
102
  bool collectModelValues(TheoryModel* m,
103
                          const std::set<Node>& termSet) override;
104
105
9453
  void shutdown() override {}
106
107
  void presolve() override;
108
  void notifyRestart() override;
109
  PPAssertStatus ppAssert(TrustNode tin,
110
                          TrustSubstitutionMap& outSubstitutions) override;
111
  /**
112
   * Preprocess rewrite terms, return the trust node encapsulating the
113
   * preprocessed form of n, and the proof generator that can provide the
114
   * proof for the equivalence of n and this term.
115
   *
116
   * This calls the operator elimination utility to eliminate extended
117
   * symbols.
118
   */
119
  TrustNode ppRewrite(TNode atom, std::vector<SkolemLemma>& lems) override;
120
  void ppStaticLearn(TNode in, NodeBuilder& learned) override;
121
122
  std::string identify() const override { return std::string("TheoryArith"); }
123
124
  EqualityStatus getEqualityStatus(TNode a, TNode b) override;
125
126
  void notifySharedTerm(TNode n) override;
127
128
  Node getModelValue(TNode var) override;
129
130
  std::pair<bool, Node> entailmentCheck(TNode lit) override;
131
132
  /** Return a reference to the arith::InferenceManager. */
133
4914
  InferenceManager& getInferenceManager()
134
  {
135
4914
    return d_im;
136
  }
137
138
 private:
139
  /**
140
   * Preprocess equality, applies ppRewrite for equalities. This method is
141
   * distinct from ppRewrite since it is not allowed to construct lemmas.
142
   */
143
  TrustNode ppRewriteEq(TNode eq);
144
  /** Get the proof equality engine */
145
  eq::ProofEqEngine* getProofEqEngine();
146
  /** The state object wrapping TheoryArithPrivate  */
147
  ArithState d_astate;
148
  /** The arith::InferenceManager. */
149
  InferenceManager d_im;
150
151
  /**
152
   * The non-linear extension, responsible for all approaches for non-linear
153
   * arithmetic.
154
   */
155
  std::unique_ptr<nl::NonlinearExtension> d_nonlinearExtension;
156
  /** The operator elimination utility */
157
  OperatorElim d_opElim;
158
  /** The preprocess utility */
159
  ArithPreprocess d_arithPreproc;
160
  /** The theory rewriter for this theory. */
161
  ArithRewriter d_rewriter;
162
163
};/* class TheoryArith */
164
165
}  // namespace arith
166
}  // namespace theory
167
}  // namespace cvc5