lean2/src/library/num.h

33 lines
1,015 B
C
Raw Normal View History

/*
Copyright (c) 2014 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include "util/numerics/mpz.h"
#include "kernel/environment.h"
namespace lean {
2015-10-11 22:03:00 +00:00
/** \brief Return true iff the given environment contains the declarations needed to encode numerals:
zero, one, bit0, bit1 */
bool has_num_decls(environment const & env);
2015-10-11 22:03:00 +00:00
/** \brief Return true iff the given expression encodes a numeral. */
bool is_num(expr const & e);
2015-10-11 22:03:00 +00:00
bool is_zero(expr const & e);
bool is_one(expr const & e);
optional<expr> is_bit0(expr const & e);
optional<expr> is_bit1(expr const & e);
2015-10-11 22:03:00 +00:00
/** \brief If the given expression encodes a numeral, then convert it back to mpz numeral.
\see from_num */
optional<mpz> to_num(expr const & e);
2015-10-11 22:03:00 +00:00
/** \brief If the given expression is a numeral encode the num and pos_num types, return the encoded numeral */
optional<mpz> to_num_core(expr const & e);
void initialize_num();
void finalize_num();
}