3#ifndef LALA_CORE_FLAT_UNIVERSE_HPP
4#define LALA_CORE_FLAT_UNIVERSE_HPP
10template<
class PreUniverse,
class Mem>
14template<
class VT,
class Mem>
18template<
class VT,
class Mem>
28template<
class PreUniverse,
class Mem>
31 using U = PreUniverse;
40 static_assert(pre_universe::increasing);
41 static_assert(pre_universe::preserve_bot && pre_universe::preserve_top,
42 "The Flat lattice construction reuse the bottom and top elements of the pre-universe.\
43 Therefore, it must preserve bottom and top.");
46 constexpr static const bool sequential = Mem::sequential;
55 constexpr static const char*
name =
"Flat";
56 constexpr static const bool is_arithmetic = pre_universe::is_arithmetic;
65 using atomic_type = memory_type::template atomic_type<value_type>;
101 memory_type::store(val, other.
value());
105 static_assert(
sequential,
"The operator= in `FlatUniverse` can only be used when the underlying memory is `sequential`.");
111 memory_type::store(val, other.
value());
115 static_assert(
sequential,
"The operator= in `FlatUniverse` can only be used when the underlying memory is `sequential`.");
125 return value() == U::top();
130 return value() == U::bot();
134 memory_type::store(val, U::top());
138 template<
class M1,
class M2>
145 memory_type::store(val, other.
value());
159 memory_type::store(val, other.
value());
168 memory_type::store(val, U::bot());
172 template<
class M1,
class M2>
179 memory_type::store(val, other.
value());
193 memory_type::store(val, other.
value());
208 return F::make_false();
211 return F::make_true();
213 return F::make_binary(
223 return pre_universe::template deinterpret<F>(
value());
249 template<
bool diagnose = false,
class F,
class Env,
class M2>
253 bool res = pre_universe::template interpret_type<diagnose>(f, k, diagnostics);
260 if(f.is_binary() && f.sig() ==
EQ) {
261 int idx_constant = f.seq(0).is_constant() ? 0 : (f.seq(1).is_constant() ? 1 : 100);
262 int idx_variable = f.seq(0).is_variable() ? 0 : (f.seq(1).is_variable() ? 1 : 100);
263 if(idx_constant + idx_variable == 1) {
264 const auto& k = f.seq(idx_constant);
265 const auto& x = f.seq(idx_variable);
267 if(pre_universe::template interpret_tell<diagnose>(k, t, diagnostics)) {
269 if(pre_universe::template interpret_ask<diagnose>(k, a, diagnostics)) {
283 "Tell interpretation only supports existential quantifier and binary formulas of the form `t1 = t2` where t1 is a constant and t2 is a variable (or conversely).");
288 template<
bool diagnose = false,
class F,
class Env,
class M2>
291 RETURN_INTERPRETATION_ERROR(
"Ask interpretation only supports binary formulas of the form `t1 = t2` where t1 is a constant and t2 is a variable (or conversely).")
293 return interpret_tell<diagnose>(f, env, ask, diagnostics);
296 template<IKind kind,
bool diagnose = false,
class F,
class Env,
class M2>
299 return interpret_ask<diagnose>(f, env,
value, diagnostics);
302 return interpret_tell<diagnose>(f, env,
value, diagnostics);
307 return pre_universe::is_supported_fun(sig);
312 template<Sig sig,
class M1>
319 else if(U::bot() == a) {
322 return pre_universe::template fun<sig>(a);
326 template<Sig sig,
class M1,
class M2>
331 if(U::top() == a || U::top() == b) {
334 else if(U::bot() == a || U::bot() == b) {
338 if(b == pre_universe::zero()) {
342 return pre_universe::template fun<sig>(a, b);
345 template<
class Pre2,
class Mem2>
351template<
class Pre,
class M1,
class M2>
367template<
class Pre,
class M1,
class M2>
383template<
class Pre,
class M1,
class M2>
384CUDA
constexpr bool operator<=(
const FlatUniverse<Pre, M1>& a,
const FlatUniverse<Pre, M2>& b) {
385 return a.is_bot() || b.is_top() || a == b;
388template<
class Pre,
class M1,
class M2>
393template<
class Pre,
class M1,
class M2>
394CUDA
constexpr bool operator>=(
const FlatUniverse<Pre, M1>& a,
const FlatUniverse<Pre, M2>& b) {
398template<
class Pre,
class M1,
class M2>
403template<
class Pre,
class M1,
class M2>
408template<
class Pre,
class M1,
class M2>
409CUDA
constexpr bool operator!=(
const FlatUniverse<Pre, M1>& a,
const FlatUniverse<Pre, M2>& b) {
410 return a.value() != b.value();
413template<
class Pre,
class M>
Definition flat_universe.hpp:30
CUDA constexpr FlatUniverse(const PrimitiveUpset< typename pre_universe::dual_type, M > &other)
Definition flat_universe.hpp:93
typename pre_universe::value_type value_type
Definition flat_universe.hpp:34
CUDA constexpr FlatUniverse(const this_type2< M > &other)
Definition flat_universe.hpp:86
static CUDA constexpr bool is_supported_fun(Sig sig)
Definition flat_universe.hpp:306
static constexpr const char * name
Definition flat_universe.hpp:55
CUDA NI F deinterpret() const
Definition flat_universe.hpp:222
static constexpr const bool is_arithmetic
Definition flat_universe.hpp:56
CUDA constexpr local::BDec is_bot() const
Definition flat_universe.hpp:129
CUDA static NI bool interpret(const F &f, const Env &env, this_type2< M2 > &value, IDiagnostics &diagnostics)
Definition flat_universe.hpp:297
static constexpr const bool injective_concretization
Definition flat_universe.hpp:52
static constexpr const bool is_abstract_universe
Definition flat_universe.hpp:45
Mem memory_type
Definition flat_universe.hpp:35
CUDA constexpr FlatUniverse(this_type &&other)
Definition flat_universe.hpp:83
CUDA constexpr this_type & dtell_bot()
Definition flat_universe.hpp:167
static constexpr const bool complemented
Definition flat_universe.hpp:54
CUDA constexpr local::BInc is_top() const
Definition flat_universe.hpp:124
CUDA NI void print() const
Definition flat_universe.hpp:234
CUDA constexpr value_type value() const
Definition flat_universe.hpp:119
CUDA constexpr this_type & dtell(const this_type2< M1 > &other, BInc< M2 > &has_changed)
Definition flat_universe.hpp:173
CUDA static NI bool interpret_ask(const F &f, const Env &env, this_type2< M2 > &ask, IDiagnostics &diagnostics)
Definition flat_universe.hpp:289
static CUDA constexpr local_type bot()
Definition flat_universe.hpp:70
static constexpr const bool preserve_join
Definition flat_universe.hpp:50
CUDA constexpr this_type & tell_top()
Definition flat_universe.hpp:133
this_type2< battery::local_memory > local_type
Definition flat_universe.hpp:38
CUDA constexpr FlatUniverse()
Definition flat_universe.hpp:79
static constexpr const bool sequential
Definition flat_universe.hpp:46
CUDA NI TFormula< typename Env::allocator_type > deinterpret(AVar avar, const Env &env) const
Definition flat_universe.hpp:205
CUDA constexpr this_type & operator=(const this_type &other)
Definition flat_universe.hpp:109
static CUDA constexpr local_type fun(const this_type2< M1 > &l, const this_type2< M2 > &k)
Definition flat_universe.hpp:327
static CUDA constexpr local_type top()
Definition flat_universe.hpp:75
static CUDA constexpr local_type fun(const this_type2< M1 > &u)
Definition flat_universe.hpp:313
static constexpr const bool preserve_concrete_covers
Definition flat_universe.hpp:53
CUDA constexpr this_type & tell(const this_type2< M1 > &other, BInc< M2 > &has_changed)
Definition flat_universe.hpp:139
static constexpr const bool preserve_meet
Definition flat_universe.hpp:51
static CUDA constexpr local_type eq_k(value_type k)
Definition flat_universe.hpp:60
CUDA constexpr this_type & operator=(const this_type2< M > &other)
Definition flat_universe.hpp:99
static constexpr const bool is_totally_ordered
Definition flat_universe.hpp:47
static constexpr const bool preserve_bot
Definition flat_universe.hpp:48
CUDA constexpr FlatUniverse(const this_type &other)
Definition flat_universe.hpp:82
CUDA constexpr this_type & tell(const this_type2< M1 > &other)
Definition flat_universe.hpp:154
CUDA constexpr bool extract(local_type &ua) const
Definition flat_universe.hpp:228
CUDA constexpr FlatUniverse(value_type k)
Definition flat_universe.hpp:81
CUDA constexpr this_type & dtell(const this_type2< M1 > &other)
Definition flat_universe.hpp:188
CUDA static NI bool interpret_tell(const F &f, const Env &env, this_type2< M2 > &tell, IDiagnostics &diagnostics)
Definition flat_universe.hpp:250
static constexpr const bool preserve_top
Definition flat_universe.hpp:49
CUDA constexpr FlatUniverse(const PrimitiveUpset< pre_universe, M > &other)
Definition flat_universe.hpp:89
PreUniverse pre_universe
Definition flat_universe.hpp:33
Definition diagnostics.hpp:19
Definition primitive_upset.hpp:118
CUDA constexpr this_type & tell_top()
Definition primitive_upset.hpp:233
#define RETURN_INTERPRETATION_ERROR(MSG)
Definition diagnostics.hpp:155
CUDA NI void print(const lala::Sig &sig)
Definition ast.hpp:212
Definition abstract_deps.hpp:14
std::ostream & operator<<(std::ostream &s, const CartesianProduct< A, As... > &cp)
Definition cartesian_product.hpp:597
CUDA constexpr LDual dual(const L &x)
Definition primitive_upset.hpp:110
CUDA constexpr bool operator==(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:572
@ EQ
Unary arithmetic function symbols.
Definition ast.hpp:112
CUDA constexpr auto join(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:534
CUDA constexpr auto meet(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:541
CUDA constexpr bool operator<(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:554
CUDA NI constexpr bool is_division(Sig sig)
Definition ast.hpp:196
CUDA constexpr bool operator>(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:566
#define UNTYPED
Definition sort.hpp:21