refactor(library/placeholder): use different names for different placeholders, it is bad design to assume that two structurally identical expressions are different when they are allocated twice (this design is not compatible with any form of hash-consing
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
fc4b6a92cc
commit
1f6cfce05c
1 changed files with 7 additions and 5 deletions
|
@ -4,17 +4,19 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
|
||||||
Author: Leonardo de Moura
|
Author: Leonardo de Moura
|
||||||
*/
|
*/
|
||||||
|
#include "util/thread.h"
|
||||||
#include "kernel/find_fn.h"
|
#include "kernel/find_fn.h"
|
||||||
#include "library/placeholder.h"
|
#include "library/placeholder.h"
|
||||||
#include "library/kernel_bindings.h"
|
#include "library/kernel_bindings.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
static name g_placeholder_name = name(name::mk_internal_unique_name(), "_");
|
static name g_placeholder_name = name(name::mk_internal_unique_name(), "_");
|
||||||
|
static unsigned LEAN_THREAD_LOCAL g_placeholder_counter = 0;
|
||||||
level mk_level_placeholder() { return mk_global_univ(g_placeholder_name); }
|
level mk_level_placeholder() { return mk_global_univ(name(g_placeholder_name, g_placeholder_counter++)); }
|
||||||
expr mk_expr_placeholder() { return mk_constant(g_placeholder_name); }
|
expr mk_expr_placeholder() { return mk_constant(name(g_placeholder_name, g_placeholder_counter++)); }
|
||||||
bool is_placeholder(level const & e) { return is_global(e) && global_id(e) == g_placeholder_name; }
|
static bool is_placeholder(name const & n) { return !n.is_atomic() && n.get_prefix() == g_placeholder_name; }
|
||||||
bool is_placeholder(expr const & e) { return is_constant(e) && const_name(e) == g_placeholder_name; }
|
bool is_placeholder(level const & e) { return is_global(e) && is_placeholder(global_id(e)); }
|
||||||
|
bool is_placeholder(expr const & e) { return is_constant(e) && is_placeholder(const_name(e)); }
|
||||||
|
|
||||||
bool has_placeholder(level const & l) {
|
bool has_placeholder(level const & l) {
|
||||||
bool r = false;
|
bool r = false;
|
||||||
|
|
Loading…
Reference in a new issue