GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/arith_preprocess.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
 *   Andrew Reynolds, 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 preprocess.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__ARITH__ARITH_PREPROCESS_H
19
#define CVC5__THEORY__ARITH__ARITH_PREPROCESS_H
20
21
#include "context/cdhashmap.h"
22
#include "theory/arith/operator_elim.h"
23
#include "theory/logic_info.h"
24
25
namespace cvc5 {
26
namespace theory {
27
28
class SkolemLemma;
29
30
namespace arith {
31
32
class ArithState;
33
class InferenceManager;
34
class OperatorElim;
35
36
/**
37
 * This module can be used for (on demand) elimination of extended arithmetic
38
 * operators like div, mod, to_int, is_int, sqrt, and so on. It uses the
39
 * operator elimination utility for determining how to reduce formulas. It
40
 * extends that utility with the ability to generate lemmas on demand via
41
 * the provided inference manager.
42
 */
43
class ArithPreprocess
44
{
45
 public:
46
  ArithPreprocess(ArithState& state,
47
                  InferenceManager& im,
48
                  ProofNodeManager* pnm,
49
                  OperatorElim& oe);
50
9459
  ~ArithPreprocess() {}
51
  /**
52
   * Call eliminate operators on formula n, return the resulting trust node,
53
   * which is of TrustNodeKind REWRITE and whose node is the result of
54
   * eliminating extended operators from n.
55
   *
56
   * @param n The node to eliminate operators from
57
   * @param partialOnly Whether we are eliminating partial operators only.
58
   * @return the trust node proving (= n nr) where nr is the return of
59
   * eliminating operators in n, or the null trust node if n was unchanged.
60
   */
61
  TrustNode eliminate(TNode n,
62
                      std::vector<SkolemLemma>& lems,
63
                      bool partialOnly = false);
64
  /**
65
   * Reduce assertion. This sends a lemma via the inference manager if atom
66
   * contains any extended operators. When applicable, the lemma is of the form:
67
   *   atom == d_opElim.eliminate(atom)
68
   * This method returns true if a lemma of the above form was added to
69
   * the inference manager. Note this returns true even if this lemma was added
70
   * on a previous call.
71
   */
72
  bool reduceAssertion(TNode atom);
73
  /**
74
   * Is the atom reduced? Returns true if a call to method reduceAssertion was
75
   * made for the given atom and returned a lemma. In this case, the atom
76
   * can be ignored.
77
   */
78
  bool isReduced(TNode atom) const;
79
80
 private:
81
  /** Reference to the inference manager */
82
  InferenceManager& d_im;
83
  /** The operator elimination utility */
84
  OperatorElim& d_opElim;
85
  /** The set of assertions that were reduced */
86
  context::CDHashMap<Node, bool> d_reduced;
87
};
88
89
}  // namespace arith
90
}  // namespace theory
91
}  // namespace cvc5
92
93
#endif