GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/nl/cad/cdcac_utils.h Lines: 1 1 100.0 %
Date: 2021-05-22 Branches: 5 10 50.0 %

Line Exec Source
1
/******************************************************************************
2
 * Top contributors (to current version):
3
 *   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
 * Implements utilities for cdcac.
14
 */
15
16
#include "cvc5_private.h"
17
18
#ifndef CVC5__THEORY__ARITH__NL__CAD__CDCAC_UTILS_H
19
#define CVC5__THEORY__ARITH__NL__CAD__CDCAC_UTILS_H
20
21
#ifdef CVC5_POLY_IMP
22
23
#include <poly/polyxx.h>
24
25
#include <vector>
26
27
#include "expr/node.h"
28
#include "theory/arith/nl/cad/projections.h"
29
30
namespace cvc5 {
31
namespace theory {
32
namespace arith {
33
namespace nl {
34
namespace cad {
35
36
/**
37
 * An interval as specified in section 4.1 of
38
 * https://arxiv.org/pdf/2003.05633.pdf.
39
 *
40
 * It consists of
41
 * - the actual interval, either an open or a point interal,
42
 * - the characterizing polynomials of the lower and upper bound,
43
 * - the characterizing polynomials in the main variable,
44
 * - the characterizing polynomials in lower variables and
45
 * - the constraints used to derive this interval.
46
 */
47
11842
struct CACInterval
48
{
49
  /** The actual interval. */
50
  poly::Interval d_interval;
51
  /** The polynomials characterizing the lower bound. */
52
  PolyVector d_lowerPolys;
53
  /** The polynomials characterizing the upper bound. */
54
  PolyVector d_upperPolys;
55
  /** The characterizing polynomials in the main variable. */
56
  PolyVector d_mainPolys;
57
  /** The characterizing polynomials in lower variables. */
58
  PolyVector d_downPolys;
59
  /** The constraints used to derive this interval. */
60
  std::vector<Node> d_origins;
61
};
62
/** Check whether to intervals are the same. */
63
bool operator==(const CACInterval& lhs, const CACInterval& rhs);
64
/** Compare two intervals. */
65
bool operator<(const CACInterval& lhs, const CACInterval& rhs);
66
67
/** Check whether lhs covers rhs. */
68
bool intervalCovers(const poly::Interval& lhs, const poly::Interval& rhs);
69
/**
70
 * Check whether two intervals connect, assuming lhs < rhs.
71
 * They connect, if their union has no gap.
72
 */
73
bool intervalConnect(const poly::Interval& lhs, const poly::Interval& rhs);
74
75
/**
76
 * Sort intervals according to section 4.4.1.
77
 * Also removes fully redundant intervals as in 4.5. 1.
78
 */
79
void cleanIntervals(std::vector<CACInterval>& intervals);
80
81
/**
82
 * Collect all origins from the list of intervals to construct the origins for a
83
 * whole covering.
84
 */
85
std::vector<Node> collectConstraints(const std::vector<CACInterval>& intervals);
86
87
/**
88
 * Sample a point outside of the infeasible intervals.
89
 * Stores the sample in sample, returns whether such a sample exists.
90
 * If false is returned, the infeasible intervals cover the real line.
91
 * Implements sample_outside() from section 4.3
92
 */
93
bool sampleOutside(const std::vector<CACInterval>& infeasible,
94
                   poly::Value& sample);
95
96
/**
97
 * Compute the finest square of the upper polynomials of lhs and the lower
98
 * polynomials of rhs. Also pushes reduced polynomials to lower level if
99
 * necessary.
100
 */
101
void makeFinestSquareFreeBasis(CACInterval& lhs, CACInterval& rhs);
102
103
}  // namespace cad
104
}  // namespace nl
105
}  // namespace arith
106
}  // namespace theory
107
}  // namespace cvc5
108
109
#endif
110
111
#endif