GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/theory_arith.h Lines: 3 4 75.0 %
Date: 2021-08-14 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/branch_and_bound.h"
25
#include "theory/arith/inference_manager.h"
26
#include "theory/arith/pp_rewrite_eq.h"
27
#include "theory/theory.h"
28
29
namespace cvc5 {
30
namespace theory {
31
namespace arith {
32
namespace nl {
33
class NonlinearExtension;
34
}
35
36
class EqualitySolver;
37
class TheoryArithPrivate;
38
39
/**
40
 * Implementation of linear and non-linear integer and real arithmetic.
41
 * The linear arithmetic solver is based upon:
42
 * http://research.microsoft.com/en-us/um/people/leonardo/cav06.pdf
43
 */
44
class TheoryArith : public Theory {
45
  friend class TheoryArithPrivate;
46
 public:
47
  TheoryArith(context::Context* c,
48
              context::UserContext* u,
49
              OutputChannel& out,
50
              Valuation valuation,
51
              const LogicInfo& logicInfo,
52
              ProofNodeManager* pnm = nullptr);
53
  virtual ~TheoryArith();
54
55
  //--------------------------------- initialization
56
  /** get the official theory rewriter of this theory */
57
  TheoryRewriter* getTheoryRewriter() override;
58
  /** get the proof checker of this theory */
59
  ProofRuleChecker* getProofChecker() override;
60
  /**
61
   * Returns true if this theory needs an equality engine, which is assigned
62
   * to it (d_equalityEngine) by the equality engine manager during
63
   * TheoryEngine::finishInit, prior to calling finishInit for this theory.
64
   * If this method returns true, it stores instructions for the notifications
65
   * this Theory wishes to receive from its equality engine.
66
   */
67
  bool needsEqualityEngine(EeSetupInfo& esi) override;
68
  /** finish initialization */
69
  void finishInit() override;
70
  //--------------------------------- end initialization
71
  /**
72
   * Does non-context dependent setup for a node connected to a theory.
73
   */
74
  void preRegisterTerm(TNode n) override;
75
76
  //--------------------------------- standard check
77
  /** Pre-check, called before the fact queue of the theory is processed. */
78
  bool preCheck(Effort level) override;
79
  /** Post-check, called after the fact queue of the theory is processed. */
80
  void postCheck(Effort level) override;
81
  /** Pre-notify fact, return true if processed. */
82
  bool preNotifyFact(TNode atom,
83
                     bool pol,
84
                     TNode fact,
85
                     bool isPrereg,
86
                     bool isInternal) override;
87
  //--------------------------------- end standard check
88
  bool needsCheckLastEffort() override;
89
  void propagate(Effort e) override;
90
  TrustNode explain(TNode n) override;
91
92
  bool collectModelInfo(TheoryModel* m, const std::set<Node>& termSet) override;
93
  /**
94
   * Collect model values in m based on the relevant terms given by termSet.
95
   */
96
  bool collectModelValues(TheoryModel* m,
97
                          const std::set<Node>& termSet) override;
98
99
9847
  void shutdown() override {}
100
101
  void presolve() override;
102
  void notifyRestart() override;
103
  PPAssertStatus ppAssert(TrustNode tin,
104
                          TrustSubstitutionMap& outSubstitutions) override;
105
  /**
106
   * Preprocess rewrite terms, return the trust node encapsulating the
107
   * preprocessed form of n, and the proof generator that can provide the
108
   * proof for the equivalence of n and this term.
109
   *
110
   * This calls the operator elimination utility to eliminate extended
111
   * symbols.
112
   */
113
  TrustNode ppRewrite(TNode atom, std::vector<SkolemLemma>& lems) override;
114
  void ppStaticLearn(TNode in, NodeBuilder& learned) override;
115
116
  std::string identify() const override { return std::string("TheoryArith"); }
117
118
  EqualityStatus getEqualityStatus(TNode a, TNode b) override;
119
120
  void notifySharedTerm(TNode n) override;
121
122
  Node getModelValue(TNode var) override;
123
124
  std::pair<bool, Node> entailmentCheck(TNode lit) override;
125
126
  /** Return a reference to the arith::InferenceManager. */
127
5145
  InferenceManager& getInferenceManager()
128
  {
129
5145
    return d_im;
130
  }
131
132
 private:
133
  /** Get the proof equality engine */
134
  eq::ProofEqEngine* getProofEqEngine();
135
  /** Timer for ppRewrite */
136
  TimerStat d_ppRewriteTimer;
137
  /** The state object wrapping TheoryArithPrivate  */
138
  ArithState d_astate;
139
  /** The arith::InferenceManager. */
140
  InferenceManager d_im;
141
  /** The preprocess rewriter for equality */
142
  PreprocessRewriteEq d_ppre;
143
  /** The branch and bound utility */
144
  BranchAndBound d_bab;
145
  /** The equality solver */
146
  std::unique_ptr<EqualitySolver> d_eqSolver;
147
  /** The (old) linear arithmetic solver */
148
  TheoryArithPrivate* d_internal;
149
150
  /**
151
   * The non-linear extension, responsible for all approaches for non-linear
152
   * arithmetic.
153
   */
154
  std::unique_ptr<nl::NonlinearExtension> d_nonlinearExtension;
155
  /** The operator elimination utility */
156
  OperatorElim d_opElim;
157
  /** The preprocess utility */
158
  ArithPreprocess d_arithPreproc;
159
  /** The theory rewriter for this theory. */
160
  ArithRewriter d_rewriter;
161
};/* class TheoryArith */
162
163
}  // namespace arith
164
}  // namespace theory
165
}  // namespace cvc5