summaryrefslogtreecommitdiff
path: root/src/theory/arith/arith_preprocess.h
blob: 939306a6eb693dc5b6dc3bccc493587af2319fd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/******************************************************************************
 * Top contributors (to current version):
 *   Andrew Reynolds, Gereon Kremer
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 * in the top-level source directory and their institutional affiliations.
 * All rights reserved.  See the file COPYING in the top-level source
 * directory for licensing information.
 * ****************************************************************************
 *
 * Arithmetic preprocess.
 */

#include "cvc5_private.h"

#ifndef CVC5__THEORY__ARITH__ARITH_PREPROCESS_H
#define CVC5__THEORY__ARITH__ARITH_PREPROCESS_H

#include "context/cdhashmap.h"
#include "smt/env_obj.h"
#include "theory/arith/operator_elim.h"
#include "theory/logic_info.h"

namespace cvc5 {
namespace theory {

class SkolemLemma;

namespace arith {

class ArithState;
class InferenceManager;
class OperatorElim;

/**
 * This module can be used for (on demand) elimination of extended arithmetic
 * operators like div, mod, to_int, is_int, sqrt, and so on. It uses the
 * operator elimination utility for determining how to reduce formulas. It
 * extends that utility with the ability to generate lemmas on demand via
 * the provided inference manager.
 */
class ArithPreprocess : protected EnvObj
{
 public:
  ArithPreprocess(Env& env,
                  ArithState& state,
                  InferenceManager& im,
                  ProofNodeManager* pnm,
                  OperatorElim& oe);
  ~ArithPreprocess() {}
  /**
   * Call eliminate operators on formula n, return the resulting trust node,
   * which is of TrustNodeKind REWRITE and whose node is the result of
   * eliminating extended operators from n.
   *
   * @param n The node to eliminate operators from
   * @param partialOnly Whether we are eliminating partial operators only.
   * @return the trust node proving (= n nr) where nr is the return of
   * eliminating operators in n, or the null trust node if n was unchanged.
   */
  TrustNode eliminate(TNode n,
                      std::vector<SkolemLemma>& lems,
                      bool partialOnly = false);
  /**
   * Reduce assertion. This sends a lemma via the inference manager if atom
   * contains any extended operators. When applicable, the lemma is of the form:
   *   atom == d_opElim.eliminate(atom)
   * This method returns true if a lemma of the above form was added to
   * the inference manager. Note this returns true even if this lemma was added
   * on a previous call.
   */
  bool reduceAssertion(TNode atom);
  /**
   * Is the atom reduced? Returns true if a call to method reduceAssertion was
   * made for the given atom and returned a lemma. In this case, the atom
   * can be ignored.
   */
  bool isReduced(TNode atom) const;

 private:
  /** Reference to the inference manager */
  InferenceManager& d_im;
  /** The operator elimination utility */
  OperatorElim& d_opElim;
  /** The set of assertions that were reduced */
  context::CDHashMap<Node, bool> d_reduced;
};

}  // namespace arith
}  // namespace theory
}  // namespace cvc5

#endif
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback