summaryrefslogtreecommitdiff
path: root/src/theory/arith/nl/icp/candidate.h
blob: 5d8c2b2d05cd354613ae681e42f70055c51ebe12 (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
/*********************                                                        */
/*! \file candidate.h
 ** \verbatim
 ** Top contributors (to current version):
 **   Gereon Kremer
 ** This file is part of the CVC4 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.\endverbatim
 **
 ** \brief Represents a contraction candidate for ICP-style propagation.
 **/

#ifndef CVC4__THEORY__ARITH__ICP__CANDIDATE_H
#define CVC4__THEORY__ARITH__ICP__CANDIDATE_H

#include "cvc4_private.h"

#ifdef CVC4_POLY_IMP
#include <poly/polyxx.h>

#include "expr/node.h"
#include "theory/arith/nl/icp/intersection.h"

namespace CVC4 {
namespace theory {
namespace arith {
namespace nl {
namespace icp {

/**
 * A contraction candidate for ICP-style propagation with the following
 * semantics:
 *
 *   lhs  ~rel~  rhsmult*rhs
 *
 * where lhs is the variable whose interval we aim to contract, rel is a
 * relation symbol (other than disequality), rhsmult is a fractional constant
 * and rhs a polynomial. As poly::Polynomial only holds integer polynomials,
 * rhsmult is necessary to encode polynomials with rational coefficients.
 *
 * Additionally, we store the origin of this constraints (a single theory
 * constraint) and the variables contained in rhs.
 *
 * A candidate is evaluated (or propagated) by evaluating the rhsmult*rhs over
 * an interval assignment and then updating the interval assignment for lhs with
 * the result of this evaluation, properly considering the relation.
 */
struct Candidate
{
  /** The target variable */
  poly::Variable lhs;
  /** The relation symbol */
  poly::SignCondition rel;
  /** The (integer) polynomial on the right hand side */
  poly::Polynomial rhs;
  /** The rational multiplier */
  poly::Rational rhsmult;
  /** The origin of this candidate */
  Node origin;
  /** The variable within rhs */
  std::vector<Node> rhsVariables;

  /**
   * Contract the interval assignment based on this candidate.
   * Only contract if the new interval is below the given threshold, see
   * intersect_interval_with().
   */
  PropagationResult propagate(poly::IntervalAssignment& ia,
                              std::size_t size_threshold) const;
};

/** Print a candidate. */
std::ostream& operator<<(std::ostream& os, const Candidate& c);

}  // namespace icp
}  // namespace nl
}  // namespace arith
}  // namespace theory
}  // namespace CVC4

#endif

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