1 |
|
/****************************************************************************** |
2 |
|
* Top contributors (to current version): |
3 |
|
* Gereon Kremer, Mathias Preiner |
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 |
|
* Utils for indexed root predicates. |
14 |
|
*/ |
15 |
|
|
16 |
|
#include "cvc5_public.h" |
17 |
|
|
18 |
|
#ifndef CVC5__UTIL__INDEXED_ROOT_PREDICATE_H |
19 |
|
#define CVC5__UTIL__INDEXED_ROOT_PREDICATE_H |
20 |
|
|
21 |
|
namespace cvc5 { |
22 |
|
|
23 |
|
/** |
24 |
|
* The structure representing the index of a root predicate. |
25 |
|
* An indexed root predicate has the form |
26 |
|
* IRP_k(x ~ 0, p) |
27 |
|
* where k is a positive integer (d_index), x is a real variable, |
28 |
|
* ~ an arithmetic relation symbol and p a (possibly multivariate polynomial). |
29 |
|
* The evaluation of the predicate is obtained by comparing the k'th root of p |
30 |
|
* (as polynomial in x) to the value of x according to the relation symbol ~. |
31 |
|
* Note that p may be multivariate: in this case we can only evaluate with |
32 |
|
* respect to a (partial) variable assignment, that (at least) contains values |
33 |
|
* for all variables from p except x. |
34 |
|
* |
35 |
|
* Some examples: |
36 |
|
* IRP_1(x > 0, x) <=> x > 0 |
37 |
|
* IRP_1(x < 0, x*x-1) <=> x < -1 |
38 |
|
* IRP_2(x < 0, x*x-1) <=> x < 1 |
39 |
|
* IRP_1(x = 0, x*x-2) <=> x = -sqrt(2) |
40 |
|
* IRP_1(x = 0, x*x-y), y=3 <=> x = -sqrt(3) |
41 |
|
*/ |
42 |
|
struct IndexedRootPredicate |
43 |
|
{ |
44 |
|
/** The index of the root */ |
45 |
|
std::uint64_t d_index; |
46 |
|
|
47 |
5 |
IndexedRootPredicate(unsigned index) : d_index(index) {} |
48 |
|
|
49 |
6 |
bool operator==(const IndexedRootPredicate& irp) const |
50 |
|
{ |
51 |
6 |
return d_index == irp.d_index; |
52 |
|
} |
53 |
|
}; /* struct IndexedRootPredicate */ |
54 |
|
|
55 |
|
inline std::ostream& operator<<(std::ostream& os, |
56 |
|
const IndexedRootPredicate& irp); |
57 |
|
inline std::ostream& operator<<(std::ostream& os, |
58 |
|
const IndexedRootPredicate& irp) |
59 |
|
{ |
60 |
|
return os << "k=" << irp.d_index; |
61 |
|
} |
62 |
|
|
63 |
|
struct IndexedRootPredicateHashFunction |
64 |
|
{ |
65 |
9 |
std::size_t operator()(const IndexedRootPredicate& irp) const |
66 |
|
{ |
67 |
9 |
return irp.d_index; |
68 |
|
} |
69 |
|
}; /* struct IndexedRootPredicateHashFunction */ |
70 |
|
|
71 |
|
} // namespace cvc5 |
72 |
|
|
73 |
|
#endif |