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::is_upper_bound);
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;
54 constexpr static const char*
name =
"Flat";
55 constexpr static const bool is_arithmetic = pre_universe::is_arithmetic;
64 using atomic_type = memory_type::template atomic_type<value_type>;
99 memory_type::store(val, other.
value());
104 memory_type::store(val, other.
value());
116 return value() == U::top();
123 return value() == U::bot();
127 memory_type::store(val, U::top());
136 memory_type::store(val, other.
value());
145 memory_type::store(val, U::bot());
154 memory_type::store(val, other.
value());
165 template<
class Env,
class Allocator =
typename Env::allocator_type>
169 return F::make_false();
172 return F::make_true();
174 return F::make_binary(
210 template<
bool diagnose = false,
class F,
class Env,
class M2>
214 bool res = pre_universe::template interpret_type<diagnose>(f, k, diagnostics);
221 if(f.is_binary() && f.sig() ==
EQ) {
222 int idx_constant = f.seq(0).is_constant() ? 0 : (f.seq(1).is_constant() ? 1 : 100);
223 int idx_variable = f.seq(0).is_variable() ? 0 : (f.seq(1).is_variable() ? 1 : 100);
224 if(idx_constant + idx_variable == 1) {
225 const auto& k = f.seq(idx_constant);
226 const auto& x = f.seq(idx_variable);
244 "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).");
249 template<
bool diagnose = false,
class F,
class Env,
class M2>
252 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).")
257 template<IKind kind,
bool diagnose = false,
class F,
class Env,
class M2>
285 if(
is_division(fun) && b == pre_universe::zero()) {
294 template<
class Pre2,
class Mem2>
332template<
class Pre,
class M1,
class M2>
333CUDA
constexpr bool operator<=(
const FlatUniverse<Pre, M1>& a,
const FlatUniverse<Pre, M2>& b) {
334 return a.is_bot() || b.is_top() || a == b;
337template<
class Pre,
class M1,
class M2>
342template<
class Pre,
class M1,
class M2>
343CUDA
constexpr bool operator>=(
const FlatUniverse<Pre, M1>& a,
const FlatUniverse<Pre, M2>& b) {
347template<
class Pre,
class M1,
class M2>
352template<
class Pre,
class M1,
class M2>
357template<
class Pre,
class M1,
class M2>
358CUDA
constexpr bool operator!=(
const FlatUniverse<Pre, M1>& a,
const FlatUniverse<Pre, M2>& b) {
359 return a.value() != b.value();
362template<
class Pre,
class M>
Definition arith_bound.hpp:118
Definition flat_universe.hpp:30
typename pre_universe::value_type value_type
Definition flat_universe.hpp:34
CUDA constexpr local::B is_top() const
Definition flat_universe.hpp:115
CUDA constexpr void join_top()
Definition flat_universe.hpp:126
CUDA constexpr FlatUniverse(const this_type2< M > &other)
Definition flat_universe.hpp:85
static constexpr const char * name
Definition flat_universe.hpp:54
CUDA NI F deinterpret() const
Definition flat_universe.hpp:183
static constexpr const bool is_arithmetic
Definition flat_universe.hpp:55
CUDA static NI bool interpret(const F &f, const Env &env, this_type2< M2 > &value, IDiagnostics &diagnostics)
Definition flat_universe.hpp:258
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 void project(Sig fun, const local_type &a, const local_type &b)
Definition flat_universe.hpp:279
CUDA constexpr FlatUniverse(this_type &&other)
Definition flat_universe.hpp:82
CUDA constexpr void meet_bot()
Definition flat_universe.hpp:144
CUDA constexpr FlatUniverse(const ArithBound< typename pre_universe::dual_type, M > &other)
Definition flat_universe.hpp:92
CUDA NI void print() const
Definition flat_universe.hpp:195
CUDA constexpr value_type value() const
Definition flat_universe.hpp:108
CUDA static NI bool interpret_ask(const F &f, const Env &env, this_type2< M2 > &ask, IDiagnostics &diagnostics)
Definition flat_universe.hpp:250
CUDA constexpr bool join(const this_type2< M1 > &other)
Definition flat_universe.hpp:131
static CUDA constexpr local_type bot()
Definition flat_universe.hpp:69
static constexpr const bool preserve_join
Definition flat_universe.hpp:50
CUDA constexpr void project(Sig fun, const local_type &a)
Definition flat_universe.hpp:269
this_type2< battery::local_memory > local_type
Definition flat_universe.hpp:38
CUDA constexpr FlatUniverse(const ArithBound< pre_universe, M > &other)
Definition flat_universe.hpp:88
CUDA constexpr FlatUniverse()
Definition flat_universe.hpp:78
static constexpr const bool sequential
Definition flat_universe.hpp:46
CUDA constexpr this_type & operator=(const this_type &other)
Definition flat_universe.hpp:103
static CUDA constexpr local_type top()
Definition flat_universe.hpp:74
static constexpr const bool preserve_concrete_covers
Definition flat_universe.hpp:53
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:59
CUDA constexpr this_type & operator=(const this_type2< M > &other)
Definition flat_universe.hpp:98
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:81
CUDA NI TFormula< Allocator > deinterpret(AVar avar, const Env &env, const Allocator &allocator=Allocator()) const
Definition flat_universe.hpp:166
CUDA constexpr local::B is_bot() const
Definition flat_universe.hpp:122
CUDA constexpr bool extract(local_type &ua) const
Definition flat_universe.hpp:189
CUDA constexpr FlatUniverse(value_type k)
Definition flat_universe.hpp:80
CUDA static NI bool interpret_tell(const F &f, const Env &env, this_type2< M2 > &tell, IDiagnostics &diagnostics)
Definition flat_universe.hpp:211
static constexpr const bool preserve_top
Definition flat_universe.hpp:49
CUDA constexpr bool meet(const this_type2< M1 > &other)
Definition flat_universe.hpp:149
PreUniverse pre_universe
Definition flat_universe.hpp:33
Definition diagnostics.hpp:19
#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:530
CUDA constexpr LDual dual(const L &x)
Definition arith_bound.hpp:110
CUDA constexpr auto fjoin(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:463
CUDA constexpr bool operator==(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:503
@ EQ
Unary arithmetic function symbols.
Definition ast.hpp:112
CUDA constexpr bool operator<(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:484
CUDA NI constexpr bool is_division(Sig sig)
Definition ast.hpp:196
CUDA constexpr auto fmeet(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:470
CUDA constexpr bool operator>(const CartesianProduct< As... > &a, const CartesianProduct< Bs... > &b)
Definition cartesian_product.hpp:497
#define UNTYPED
Definition sort.hpp:21