Replace macros TypeM, TypeU, Int, Bool, True and False with constant global expressions. The macros were producing counterintuitive behavior. For example, we had an enumeration type with an element called Int.

Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
Leonardo de Moura 2013-09-02 09:11:53 -07:00
parent db88920f81
commit 81d0203ee0
4 changed files with 15 additions and 24 deletions

View file

@ -25,8 +25,8 @@ public:
};
char const * int_type_value::g_kind = "int";
MK_BUILTIN(int_type, int_type_value);
expr const Int = mk_value(*(new int_type_value()));
expr mk_int_type() { return Int; }
class int_value_value : public value {
mpz m_val;

View file

@ -12,7 +12,7 @@ Author: Leonardo de Moura
namespace lean {
expr mk_int_type();
#define Int mk_int_type()
extern expr const Int;
expr mk_int_value(mpz const & v);
inline expr mk_int_value(int v) { return mk_int_value(mpz(v)); }

View file

@ -50,16 +50,8 @@ expr mk_bin_lop(expr const & op, expr const & unit, std::initializer_list<expr>
// Bultin universe variables m and u
static level m_lvl(name("m"));
static level u_lvl(name("u"));
expr mk_type_m() {
static thread_local expr r = Type(m_lvl);
return r;
}
expr mk_type_u() {
static thread_local expr r = Type(u_lvl);
return r;
}
expr const TypeM = Type(m_lvl);
expr const TypeU = Type(u_lvl);
// =======================================
// =======================================
@ -79,7 +71,8 @@ public:
virtual unsigned hash() const { return 17; }
};
char const * bool_type_value::g_kind = g_Bool_str;
MK_BUILTIN(bool_type, bool_type_value);
expr const Bool = mk_value(*(new bool_type_value()));
expr mk_bool_type() { return Bool; }
// =======================================
// =======================================
@ -116,10 +109,10 @@ public:
bool get_val() const { return m_val; }
};
char const * bool_value_value::g_kind = "BoolValue";
expr const True = mk_value(*(new bool_value_value(true)));
expr const False = mk_value(*(new bool_value_value(false)));
expr mk_bool_value(bool v) {
static thread_local expr true_val = mk_value(*(new bool_value_value(true)));
static thread_local expr false_val = mk_value(*(new bool_value_value(false)));
return v ? true_val : false_val;
return v ? True : False;
}
bool is_bool_value(expr const & e) {
return is_value(e) && to_value(e).kind() == bool_value_value::g_kind;

View file

@ -23,21 +23,19 @@ expr mk_bin_lop(expr const & op, expr const & unit, unsigned num_args, expr cons
expr mk_bin_lop(expr const & op, expr const & unit, std::initializer_list<expr> const & l);
/** \brief Return (Type m) m >= bottom + Offset */
expr mk_type_m();
#define TypeM mk_type_m()
extern expr const TypeM;
/** \brief Return (Type u) u >= m + Offset */
expr mk_type_u();
#define TypeU mk_type_u()
extern expr const TypeU;
/** \brief Return the Lean Boolean type. */
expr mk_bool_type();
#define Bool mk_bool_type()
extern expr const Bool;
/** \brief Create a Lean Boolean value (true/false) */
expr mk_bool_value(bool v);
#define True mk_bool_value(true)
#define False mk_bool_value(false)
extern expr const True;
extern expr const False;
/** \brief Return true iff \c e is a Lean Boolean value. */
bool is_bool_value(expr const & e);
/**