Lattice Land Core Library
Loading...
Searching...
No Matches
pre_bdec.hpp
Go to the documentation of this file.
1// Copyright 2023 Pierre Talbot
2
3#ifndef LALA_CORE_PRE_BDEC_HPP
4#define LALA_CORE_PRE_BDEC_HPP
5
6#include "../logic/logic.hpp"
7#include "pre_binc.hpp"
8
9namespace lala {
10
11/** `PreBDec` is a pre-abstract universe \f$ \langle \{\mathit{true}, \mathit{false}\}, \leq \rangle \f$ such that \f$ \mathit{false} \geq \mathit{true} \f$.
12 It is used to represent Boolean variables which truth's value progresses from \f$ \mathit{true} \f$ to \f$ \mathit{false} \f$.
13 Note that this type is unable to represent Boolean domain which requires four states: unknown (bot), true, false and failed (top).
14 To obtain such a domain, you should use `Interval<BInc>`.
15*/
16struct PreBDec {
21
22 constexpr static const bool is_totally_ordered = true;
23 constexpr static const bool preserve_bot = true;
24 constexpr static const bool preserve_top = false;
25 constexpr static const bool preserve_join = true;
26 constexpr static const bool preserve_meet = true;
27 constexpr static const bool injective_concretization = true;
28 constexpr static const bool preserve_concrete_covers = true;
29 constexpr static const bool complemented = false;
30 constexpr static const bool increasing = false;
31 constexpr static const char* name = "BDec";
32 constexpr static const bool is_arithmetic = true;
33 CUDA constexpr static value_type zero() { return false; }
34 CUDA constexpr static value_type one() { return true; }
35
36 template<bool diagnose, class F>
37 CUDA static bool interpret_tell(const F& f, value_type& tell, IDiagnostics& diagnostics) {
38 return dual_type::template interpret_ask<diagnose>(f, tell, diagnostics);
39 }
40
41 template<bool diagnose, class F>
42 CUDA static bool interpret_ask(const F& f, value_type& ask, IDiagnostics& diagnostics) {
43 return dual_type::template interpret_tell<diagnose>(f, ask, diagnostics);
44 }
45
46 template<bool diagnose, class F>
47 CUDA static bool interpret_type(const F& f, value_type& k, IDiagnostics& diagnostics) {
48 bool res = dual_type::template interpret_type<diagnose>(f, k, diagnostics);
49 if (res && k == dual_type::bot()) {
50 k = bot();
51 }
52 return res;
53 }
54
55 template<class F>
56 CUDA static F deinterpret(const value_type& v) {
57 return dual_type::template deinterpret<F>(v);
58 }
59
60 CUDA static constexpr Sig sig_order() { return GEQ; }
61 CUDA static constexpr Sig sig_strict_order() { return GT; }
62 CUDA static constexpr value_type bot() { return dual_type::top(); }
63 CUDA static constexpr value_type top() { return dual_type::bot(); }
64 CUDA static constexpr value_type join(value_type x, value_type y) { return dual_type::meet(x, y);}
65 CUDA static constexpr value_type meet(value_type x, value_type y) { return dual_type::join(x, y);}
66 CUDA static constexpr bool order(value_type x, value_type y) { return dual_type::order(y, x);}
67 CUDA static constexpr bool strict_order(value_type x, value_type y) { return dual_type::strict_order(y, x);}
68 CUDA static constexpr value_type next(value_type x) { return dual_type::prev(x); }
69 CUDA static constexpr value_type prev(value_type x) { return dual_type::next(x); }
70 CUDA static constexpr bool is_supported_fun(Sig sig) { return dual_type::is_supported_fun(sig); }
71 template<Sig sig> CUDA static constexpr value_type fun(value_type x) { return dual_type::template fun<sig>(x); }
72 template<Sig sig> CUDA static constexpr value_type fun(value_type x, value_type y) { return dual_type::template fun<sig>(x, y); }
73};
74
75} // namespace lala
76
77#endif
Definition diagnostics.hpp:19
Definition abstract_deps.hpp:14
Sig
Definition ast.hpp:94
@ GEQ
Unary arithmetic function symbols.
Definition ast.hpp:113
@ GT
Arithmetic comparison predicates. When applied to set, it corresponds to the lexicographic ordering o...
Definition ast.hpp:113
Definition pre_bdec.hpp:16
static CUDA constexpr value_type next(value_type x)
Definition pre_bdec.hpp:68
CUDA static constexpr value_type one()
Definition pre_bdec.hpp:34
static constexpr const bool preserve_join
Definition pre_bdec.hpp:25
static constexpr const bool is_arithmetic
Definition pre_bdec.hpp:32
static CUDA bool interpret_type(const F &f, value_type &k, IDiagnostics &diagnostics)
Definition pre_bdec.hpp:47
static constexpr const bool preserve_meet
Definition pre_bdec.hpp:26
static CUDA constexpr Sig sig_strict_order()
Definition pre_bdec.hpp:61
static constexpr const bool preserve_top
Definition pre_bdec.hpp:24
static CUDA bool interpret_tell(const F &f, value_type &tell, IDiagnostics &diagnostics)
Definition pre_bdec.hpp:37
static CUDA constexpr value_type top()
Definition pre_bdec.hpp:63
static CUDA bool interpret_ask(const F &f, value_type &ask, IDiagnostics &diagnostics)
Definition pre_bdec.hpp:42
static CUDA constexpr value_type meet(value_type x, value_type y)
Definition pre_bdec.hpp:65
static constexpr const bool increasing
Definition pre_bdec.hpp:30
static CUDA constexpr value_type fun(value_type x)
Definition pre_bdec.hpp:71
static constexpr const bool complemented
Definition pre_bdec.hpp:29
static CUDA constexpr value_type fun(value_type x, value_type y)
Definition pre_bdec.hpp:72
static CUDA constexpr Sig sig_order()
Definition pre_bdec.hpp:60
CUDA static constexpr value_type zero()
Definition pre_bdec.hpp:33
static constexpr const char * name
Definition pre_bdec.hpp:31
static CUDA constexpr bool order(value_type x, value_type y)
Definition pre_bdec.hpp:66
static CUDA constexpr value_type prev(value_type x)
Definition pre_bdec.hpp:69
static CUDA F deinterpret(const value_type &v)
Definition pre_bdec.hpp:56
static constexpr const bool is_totally_ordered
Definition pre_bdec.hpp:22
static constexpr const bool preserve_concrete_covers
Definition pre_bdec.hpp:28
static CUDA constexpr value_type bot()
Definition pre_bdec.hpp:62
static constexpr const bool injective_concretization
Definition pre_bdec.hpp:27
static CUDA constexpr bool is_supported_fun(Sig sig)
Definition pre_bdec.hpp:70
static constexpr const bool preserve_bot
Definition pre_bdec.hpp:23
static CUDA constexpr value_type join(value_type x, value_type y)
Definition pre_bdec.hpp:64
dual_type::value_type value_type
Definition pre_bdec.hpp:19
static CUDA constexpr bool strict_order(value_type x, value_type y)
Definition pre_bdec.hpp:67
Definition pre_binc.hpp:17
CUDA static NI constexpr bool is_supported_fun(Sig sig)
Definition pre_binc.hpp:117
static CUDA constexpr value_type prev(value_type x)
Definition pre_binc.hpp:115
static CUDA constexpr bool strict_order(value_type x, value_type y)
Definition pre_binc.hpp:105
static CUDA constexpr value_type bot()
Definition pre_binc.hpp:88
static CUDA constexpr value_type meet(value_type x, value_type y)
Definition pre_binc.hpp:97
static CUDA constexpr value_type join(value_type x, value_type y)
Definition pre_binc.hpp:94
static CUDA constexpr value_type top()
Definition pre_binc.hpp:91
static CUDA constexpr bool order(value_type x, value_type y)
Definition pre_binc.hpp:101
bool value_type
Definition pre_binc.hpp:20
static CUDA constexpr value_type next(value_type x)
Definition pre_binc.hpp:110