GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/inference_manager.h Lines: 1 1 100.0 %
Date: 2021-05-22 Branches: 0 0 0.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   Gereon Kremer, Makai Mann
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
 * Customized inference manager for the theory of nonlinear arithmetic.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__ARITH__INFERENCE_MANAGER_H
19
#define CVC5__THEORY__ARITH__INFERENCE_MANAGER_H
20
21
#include <vector>
22
23
#include "theory/inference_id.h"
24
#include "theory/inference_manager_buffered.h"
25
26
namespace cvc5 {
27
namespace theory {
28
namespace arith {
29
30
class ArithState;
31
class TheoryArith;
32
33
/**
34
 * A specialized variant of the InferenceManagerBuffered, tailored to the
35
 * arithmetic theory.
36
 *
37
 * It adds some convenience methods to send ArithLemma and adds a mechanism for
38
 * waiting lemmas that can be flushed into the pending lemmas of this
39
 * buffered inference manager.
40
 * It also extends the caching mechanism of TheoryInferenceManager to cache
41
 * preprocessing lemmas and non-preprocessing lemmas separately. For the former,
42
 * it uses the cache provided by the TheoryInferenceManager base class.
43
 */
44
9459
class InferenceManager : public InferenceManagerBuffered
45
{
46
  using NodeSet = context::CDHashSet<Node>;
47
48
 public:
49
  InferenceManager(TheoryArith& ta, ArithState& astate, ProofNodeManager* pnm);
50
51
  /**
52
   * Add a lemma as pending lemma to this inference manager.
53
   * If isWaiting is true, the lemma is first stored as waiting lemma and only
54
   * added as pending lemma when calling flushWaitingLemmas.
55
   */
56
  void addPendingLemma(std::unique_ptr<SimpleTheoryLemma> lemma,
57
                       bool isWaiting = false);
58
  /**
59
   * Add a lemma as pending lemma to this inference manager.
60
   * If isWaiting is true, the lemma is first stored as waiting lemma and only
61
   * added as pending lemma when calling flushWaitingLemmas.
62
   */
63
  void addPendingLemma(const SimpleTheoryLemma& lemma, bool isWaiting = false);
64
  /**
65
   * Add a lemma as pending lemma to this inference manager.
66
   * If isWaiting is true, the lemma is first stored as waiting lemma and only
67
   * added as pending lemma when calling flushWaitingLemmas.
68
   */
69
  void addPendingLemma(const Node& lemma,
70
                       InferenceId inftype,
71
                       ProofGenerator* pg = nullptr,
72
                       bool isWaiting = false,
73
                       LemmaProperty p = LemmaProperty::NONE);
74
75
  /**
76
   * Flush all waiting lemmas to this inference manager (as pending
77
   * lemmas). To actually send them, call doPendingLemmas() afterwards.
78
   */
79
  void flushWaitingLemmas();
80
81
  /**
82
   * Removes all waiting lemmas without sending them anywhere.
83
   */
84
  void clearWaitingLemmas();
85
86
  /**
87
   * Checks whether we have made any progress, that is whether a conflict,
88
   * lemma or fact was added or whether a lemma or fact is pending.
89
   */
90
  bool hasUsed() const;
91
92
  /** Checks whether we have waiting lemmas. */
93
  bool hasWaitingLemma() const;
94
95
  /** Returns the number of pending lemmas. */
96
  std::size_t numWaitingLemmas() const;
97
98
  /** Checks whether the given lemma is already present in the cache. */
99
  virtual bool hasCachedLemma(TNode lem, LemmaProperty p) override;
100
101
 protected:
102
  /**
103
   * Adds the given lemma to the cache. Returns true if it has not been in the
104
   * cache yet.
105
   */
106
  virtual bool cacheLemma(TNode lem, LemmaProperty p) override;
107
108
 private:
109
  /**
110
   * Checks whether the lemma is entailed to be false. In this case, it is a
111
   * conflict.
112
   */
113
  bool isEntailedFalse(const SimpleTheoryLemma& lem);
114
115
  /** The waiting lemmas. */
116
  std::vector<std::unique_ptr<SimpleTheoryLemma>> d_waitingLem;
117
};
118
119
}  // namespace arith
120
}  // namespace theory
121
}  // namespace cvc5
122
123
#endif