From 66d583d279fdd149e3d0e7b777953969bdc7d5f2 Mon Sep 17 00:00:00 2001 From: Leonardo de Moura Date: Sat, 5 Mar 2016 13:09:36 -0800 Subject: [PATCH] feat(library/local_context): add well_formed debugging methods --- src/library/local_context.cpp | 47 +++++++++++++++++++++++++++++++++++ src/library/local_context.h | 14 +++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/library/local_context.cpp b/src/library/local_context.cpp index 2d4b3143a2..645fba02cb 100644 --- a/src/library/local_context.cpp +++ b/src/library/local_context.cpp @@ -6,6 +6,7 @@ Author: Leonardo de Moura */ #include #include "util/fresh_name.h" +#include "kernel/for_each_fn.h" #include "library/local_context.h" namespace lean { @@ -87,6 +88,52 @@ void local_context::for_each_after(local_decl const & d, std::function find_if(std::function const & pred) const; // NOLINT /** \brief Execute fn for each local declaration created after \c d. */ void for_each_after(local_decl const & d, std::function const & fn) const; + local_decls to_local_decls() const { return local_decls(m_name2local_decl); } + void freeze(name const & n); bool is_frozen(name const & n) const { return m_frozen_decls.contains(n); } + + /** \brief We say a local context is well-formed iff all local declarations only + contain local_decl references that were defined before them. + + \remark This method is for debugging purposes. */ + bool well_formed() const; + + /** \brief Return true iff \c e is well-formed with respect to this local context. + That is, all local_decl references in \c e are defined in this context. + + \remark This method is for debugging purposes. */ + bool well_formed(expr const & e) const; }; void initialize_local_context();