summaryrefslogtreecommitdiff
path: root/src/theory/arith/nl/pow2_solver.h
blob: 42586f2064f9b43af70aa8d806d79df6c3e2410b (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/******************************************************************************
 * Top contributors (to current version):
 *   Yoni Zohar
 *
 * 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.
 * ****************************************************************************
 *
 * Solver for pow2 constraints.
 */

#ifndef CVC5__THEORY__ARITH__NL__POW2_SOLVER_H
#define CVC5__THEORY__ARITH__NL__POW2_SOLVER_H

#include <vector>

#include "context/cdhashset.h"
#include "expr/node.h"
#include "smt/env_obj.h"

namespace cvc5 {
namespace theory {
namespace arith {

class ArithState;
class InferenceManager;

namespace nl {

class NlModel;

/** pow2 solver class
 *
 */
class Pow2Solver : protected EnvObj
{
  using NodeSet = context::CDHashSet<Node>;

 public:
  Pow2Solver(Env& env, InferenceManager& im, ArithState& state, NlModel& model);
  ~Pow2Solver();

  /** init last call
   *
   * This is called at the beginning of last call effort check, where
   * assertions are the set of assertions belonging to arithmetic,
   * false_asserts is the subset of assertions that are false in the current
   * model, and xts is the set of extended function terms that are active in
   * the current context.
   */
  void initLastCall(const std::vector<Node>& assertions,
                    const std::vector<Node>& false_asserts,
                    const std::vector<Node>& xts);
  //-------------------------------------------- lemma schemas
  /** check initial refine
   *
   * Returns a set of valid theory lemmas, based on simple facts about pow2.
   *
   * Examples
   *
   * x>=0 --> x < pow2(x)
   *
   * This should be a heuristic incomplete check that only introduces a
   * small number of new terms in the lemmas it returns.
   */
  void checkInitialRefine();
  /** check full refine
   *
   * This should be a complete check that returns at least one lemma to
   * rule out the current model.
   */
  void checkFullRefine();

  /** sort d_pow2 according to their values in the current model */
  void sortPow2sBasedOnModel();

  //-------------------------------------------- end lemma schemas
 private:
  // The inference manager that we push conflicts and lemmas to.
  InferenceManager& d_im;
  /** Reference to the non-linear model object */
  NlModel& d_model;
  /** commonly used terms */
  Node d_false;
  Node d_true;
  Node d_zero;
  Node d_one;
  Node d_two;

  NodeSet d_initRefine;
  /** all pow2 terms
   * Cleared at each last call effort check.
   * */
  std::vector<Node> d_pow2s;

  /**
   * Value-based refinement lemma for i of the form (pow2 x). Returns:
   *   x = M(x) /\ x>= 0 ---->
   *     (pow2 x) = rewrite((pow2 M(x)))
   */
  Node valueBasedLemma(Node i);
}; /* class Pow2Solver */

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

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