GCC Code Coverage Report
Directory: . Exec Total Coverage
File: src/theory/arith/nl/cad/cdcac_utils.h Lines: 1 1 100.0 %
Date: 2021-11-07 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 interval id, used to map the interval to its (partial) proof,
42
 * - the actual interval, either an open or a point interal,
43
 * - the characterizing polynomials of the lower and upper bound,
44
 * - the characterizing polynomials in the main variable,
45
 * - the characterizing polynomials in lower variables and
46
 * - the constraints used to derive this interval.
47
 */
48
32740
struct CACInterval
49
{
50
  /** Id of this interval to couple it to the proof */
51
  size_t d_id;
52
  /** The actual interval. */
53
  poly::Interval d_interval;
54
  /** The polynomials characterizing the lower bound. */
55
  PolyVector d_lowerPolys;
56
  /** The polynomials characterizing the upper bound. */
57
  PolyVector d_upperPolys;
58
  /** The characterizing polynomials in the main variable. */
59
  PolyVector d_mainPolys;
60
  /** The characterizing polynomials in lower variables. */
61
  PolyVector d_downPolys;
62
  /** The constraints used to derive this interval. */
63
  std::vector<Node> d_origins;
64
};
65
/** Check whether to intervals are the same. */
66
bool operator==(const CACInterval& lhs, const CACInterval& rhs);
67
/** Compare two intervals. */
68
bool operator<(const CACInterval& lhs, const CACInterval& rhs);
69
70
/** Check whether lhs covers rhs. */
71
bool intervalCovers(const poly::Interval& lhs, const poly::Interval& rhs);
72
/**
73
 * Check whether two intervals connect, assuming lhs < rhs.
74
 * They connect, if their union has no gap.
75
 */
76
bool intervalConnect(const poly::Interval& lhs, const poly::Interval& rhs);
77
78
/**
79
 * Sort intervals according to section 4.4.1.
80
 * Also removes fully redundant intervals as in 4.5. 1.
81
 */
82
void cleanIntervals(std::vector<CACInterval>& intervals);
83
84
/**
85
 * Collect all origins from the list of intervals to construct the origins for a
86
 * whole covering.
87
 */
88
std::vector<Node> collectConstraints(const std::vector<CACInterval>& intervals);
89
90
/**
91
 * Sample a point outside of the infeasible intervals.
92
 * Stores the sample in sample, returns whether such a sample exists.
93
 * If false is returned, the infeasible intervals cover the real line.
94
 * Implements sample_outside() from section 4.3
95
 */
96
bool sampleOutside(const std::vector<CACInterval>& infeasible,
97
                   poly::Value& sample);
98
99
/**
100
 * Compute the finest square of the upper polynomials of lhs and the lower
101
 * polynomials of rhs. Also pushes reduced polynomials to lower level if
102
 * necessary.
103
 */
104
void makeFinestSquareFreeBasis(CACInterval& lhs, CACInterval& rhs);
105
106
}  // namespace cad
107
}  // namespace nl
108
}  // namespace arith
109
}  // namespace theory
110
}  // namespace cvc5
111
112
#endif
113
114
#endif