3#ifndef LALA_CORE_PRE_ZINC_HPP
4#define LALA_CORE_PRE_ZINC_HPP
23 static_assert(std::is_integral_v<value_type>,
"PreZInc only works over integer types.");
54 constexpr static const char*
name =
"ZInc";
61 template<
bool diagnose,
bool is_tell,
class F>
65 if(z ==
bot() || z ==
top()) {
66 RETURN_INTERPRETATION_ERROR(
"Constant of sort `Int` with the minimal or maximal representable value of the underlying integer type. We use those values to model negative and positive infinities. Example: Suppose we use a byte type, `x >= 256` is interpreted as `x >= INF` which is always false and thus is different from the intended constraint.");
72 if constexpr(is_tell) {
73 k = battery::ru_cast<value_type>(battery::get<0>(f.r()));
76 k = battery::ru_cast<value_type>(battery::get<1>(f.r()));
98 template<
bool diagnose,
class F>
100 return interpret<diagnose, true>(f, tell, diagnostics);
104 template<
bool diagnose,
class F>
106 return interpret<diagnose, false>(f, ask, diagnostics);
112 template<
bool diagnose,
class F>
115 const auto& sort = battery::get<1>(f.exists());
121 const auto& vname = battery::get<0>(f.exists());
147 return battery::limits<value_type>::bot();
152 return battery::limits<value_type>::top();
173 return x + (x !=
top() && x !=
bot());
183 return x - (x !=
top() && x !=
bot());
209 case GT:
return true;
210 default:
return false;
221 static_assert(sig ==
NEG || sig ==
ABS,
"Unsupported unary function.");
224 case ABS:
return abs(x);
225 default: assert(0);
return x;
234 "Unsupported binary function.");
236 case ADD:
return x + y;
237 case SUB:
return x - y;
238 case MUL:
return x * y;
240 case TDIV:
return x / y;
241 case TMOD:
return x % y;
243 case FDIV:
return battery::fdiv(x, y);
244 case FMOD:
return battery::fmod(x, y);
246 case CDIV:
return battery::cdiv(x, y);
247 case CMOD:
return battery::cmod(x, y);
249 case EDIV:
return battery::ediv(x, y);
250 case EMOD:
return battery::emod(x, y);
251 case POW:
return battery::ipow(x, y);
252 case MIN:
return battery::min(x, y);
253 case MAX:
return battery::max(x, y);
254 case EQ:
return x == y;
255 case NEQ:
return x != y;
256 case LEQ:
return x <= y;
257 case GEQ:
return x >= y;
258 case LT:
return x < y;
259 case GT:
return x >= y;
260 default: assert(0);
return x;
Definition diagnostics.hpp:19
#define RETURN_INTERPRETATION_ERROR(MSG)
Definition diagnostics.hpp:155
Definition abstract_deps.hpp:14
@ NEQ
Equality relations.
Definition ast.hpp:112
@ LEQ
Unary arithmetic function symbols.
Definition ast.hpp:113
@ TMOD
Truncated division, present in most programming languages, is defined as , i.e., it rounds towards ze...
Definition ast.hpp:102
@ EQ
Unary arithmetic function symbols.
Definition ast.hpp:112
@ GEQ
Unary arithmetic function symbols.
Definition ast.hpp:113
@ ADD
Unary arithmetic function symbols.
Definition ast.hpp:97
@ POW
Unary arithmetic function symbols.
Definition ast.hpp:97
@ MIN
Unary arithmetic function symbols.
Definition ast.hpp:97
@ EDIV
Unary arithmetic function symbols.
Definition ast.hpp:105
@ GT
Arithmetic comparison predicates. When applied to set, it corresponds to the lexicographic ordering o...
Definition ast.hpp:113
@ FMOD
Floor division (Knuth D. (1972). The Art of Computer Programming, Vol 1, Fundamental Algorithms),...
Definition ast.hpp:103
@ MAX
Binary arithmetic function symbols.
Definition ast.hpp:97
@ LT
Unary arithmetic function symbols.
Definition ast.hpp:113
@ TDIV
Unary arithmetic function symbols.
Definition ast.hpp:102
@ FDIV
Unary arithmetic function symbols.
Definition ast.hpp:103
@ ABS
Unary arithmetic function symbols.
Definition ast.hpp:96
@ SUB
Unary arithmetic function symbols.
Definition ast.hpp:97
@ MUL
Unary arithmetic function symbols.
Definition ast.hpp:97
@ CMOD
Ceil division is defined as . Modulus is defined as .
Definition ast.hpp:104
@ CDIV
Unary arithmetic function symbols.
Definition ast.hpp:104
@ NEG
Unary arithmetic function symbols.
Definition ast.hpp:96
@ EMOD
Euclidean division (Boute T. R. (1992). The Euclidean definition of the functions div and mod)....
Definition ast.hpp:105
Definition pre_zdec.hpp:18
Definition pre_zinc.hpp:17
VT value_type
Definition pre_zinc.hpp:20
CUDA static constexpr value_type one()
Definition pre_zinc.hpp:58
static constexpr const bool preserve_join
Definition pre_zinc.hpp:34
static constexpr const bool preserve_concrete_covers
Definition pre_zinc.hpp:46
static constexpr const bool increasing
Definition pre_zinc.hpp:52
static CUDA constexpr bool order(value_type x, value_type y)
Definition pre_zinc.hpp:162
static constexpr const bool is_arithmetic
Definition pre_zinc.hpp:56
static CUDA constexpr Sig sig_order()
Definition pre_zinc.hpp:138
static constexpr const char * name
Definition pre_zinc.hpp:54
static CUDA bool interpret_tell(const F &f, value_type &tell, IDiagnostics &diagnostics)
Definition pre_zinc.hpp:99
CUDA static constexpr value_type zero()
Definition pre_zinc.hpp:57
static constexpr const bool preserve_meet
Definition pre_zinc.hpp:37
PreZInc< VT > this_type
Definition pre_zinc.hpp:18
CUDA static NI constexpr bool is_supported_fun(Sig sig)
Definition pre_zinc.hpp:186
static CUDA bool interpret_ask(const F &f, value_type &ask, IDiagnostics &diagnostics)
Definition pre_zinc.hpp:105
static constexpr const bool preserve_top
Definition pre_zinc.hpp:31
static CUDA constexpr value_type top()
Definition pre_zinc.hpp:151
static CUDA constexpr Sig sig_strict_order()
Definition pre_zinc.hpp:143
static CUDA constexpr value_type fun(value_type x)
Definition pre_zinc.hpp:220
CUDA static NI bool interpret_type(const F &f, value_type &k, IDiagnostics &diagnostics)
Definition pre_zinc.hpp:113
static constexpr const bool complemented
Definition pre_zinc.hpp:49
static CUDA constexpr value_type bot()
Definition pre_zinc.hpp:146
static constexpr const bool injective_concretization
Definition pre_zinc.hpp:41
static constexpr const bool preserve_bot
Definition pre_zinc.hpp:28
static CUDA constexpr value_type prev(value_type x)
Definition pre_zinc.hpp:181
static CUDA constexpr value_type next(value_type x)
Definition pre_zinc.hpp:172
CUDA static NI constexpr value_type fun(value_type x, value_type y)
Definition pre_zinc.hpp:231
static constexpr const bool is_totally_ordered
Definition pre_zinc.hpp:25
static CUDA constexpr value_type join(value_type x, value_type y)
Definition pre_zinc.hpp:156
static CUDA F deinterpret(const value_type &v)
Definition pre_zinc.hpp:131
static CUDA constexpr value_type meet(value_type x, value_type y)
Definition pre_zinc.hpp:159
static CUDA constexpr bool strict_order(value_type x, value_type y)
Definition pre_zinc.hpp:165