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