diff --git a/src/library/blast/CMakeLists.txt b/src/library/blast/CMakeLists.txt index 0549b34f7..dbeb4b3a0 100644 --- a/src/library/blast/CMakeLists.txt +++ b/src/library/blast/CMakeLists.txt @@ -1 +1 @@ -add_library(blast OBJECT state.cpp expr.cpp hypothesis.cpp) +add_library(blast OBJECT state.cpp expr.cpp) diff --git a/src/library/blast/goal.h b/src/library/blast/goal.h index a9a47eb9b..9d80f5e7f 100644 --- a/src/library/blast/goal.h +++ b/src/library/blast/goal.h @@ -14,8 +14,9 @@ namespace blast { class goal { typedef rb_map context; friend class state; - unsigned m_next; - context m_context; + unsigned m_next; + context m_context; + expr m_type; expr const & mk_lref(expr const & type, optional const & value); public: goal():m_next(0) {} diff --git a/src/library/blast/hypothesis.cpp b/src/library/blast/hypothesis.cpp deleted file mode 100644 index 2674b362e..000000000 --- a/src/library/blast/hypothesis.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* -Copyright (c) 2015 Microsoft Corporation. All rights reserved. -Released under Apache 2.0 license as described in the file LICENSE. - -Author: Leonardo de Moura -*/ -#include "library/blast/hypothesis.h" - -namespace lean { -namespace blast { -struct justification_idx_gen { - unsigned m_next_idx; - list m_free_list; -public: - justification_idx_gen():m_next_idx(0) {} - void recycle(unsigned idx) { - m_free_list = cons(idx, m_free_list); - } - unsigned next() { - if (m_free_list) { - unsigned r = head(m_free_list); - m_free_list = tail(m_free_list); - return r; - } else { - unsigned r = m_next_idx; - m_next_idx++; - return r; - } - } -}; - -MK_THREAD_LOCAL_GET_DEF(justification_idx_gen, get_justification_idx_gen) - -justification_cell::justification_cell():m_rc(0) { - m_idx = get_justification_idx_gen().next(); -} - -void justification_cell::dealloc() { - get_justification_idx_gen().recycle(m_idx); - delete this; -} - -justification::justification():m_ptr(nullptr) {} -justification::justification(justification_cell & ptr):m_ptr(&ptr) { if (m_ptr) m_ptr->inc_ref(); } -justification::justification(justification const & s):m_ptr(s.m_ptr) { if (m_ptr) m_ptr->inc_ref(); } -justification::justification(justification && s):m_ptr(s.m_ptr) { s.m_ptr = nullptr; } -justification::~justification() { if (m_ptr) m_ptr->dec_ref(); } -justification & justification::operator=(justification const & s) { LEAN_COPY_REF(s); } -justification & justification::operator=(justification && s) { LEAN_MOVE_REF(s); } -}} diff --git a/src/library/blast/hypothesis.h b/src/library/blast/hypothesis.h index 65324fa26..228a94eda 100644 --- a/src/library/blast/hypothesis.h +++ b/src/library/blast/hypothesis.h @@ -15,32 +15,6 @@ class hypothesis; class state; class goal; -class justification_cell { - MK_LEAN_RC(); - unsigned m_idx; - void dealloc(); -public: - justification_cell(); - virtual ~justification_cell() {} - virtual expr to_expr(hypothesis const &) const = 0; - /** \brief Return thread local unique identifier associated with justification object */ - unsigned get_idx() const { return m_idx; } -}; - -class justification { - justification_cell * m_ptr; -public: - justification(); - justification(justification_cell & c); - justification(justification const & s); - justification(justification && s); - ~justification(); - - justification & operator=(justification const & s); - justification & operator=(justification && s); - expr to_expr(hypothesis const & h) const { return m_ptr->to_expr(h); } -}; - typedef rb_tree hypothesis_set; class hypothesis { @@ -51,7 +25,7 @@ class hypothesis { hypothesis_set m_forward_deps; expr m_type; optional m_value; - justification m_jst; + optional m_justification; public: hypothesis(); bool is_active() const { return m_active; } @@ -60,7 +34,7 @@ public: hypothesis_set const & get_forward_deps() const { return m_forward_deps; } expr const & get_type() const { return m_type; } optional const & get_value() const { return m_value; } - justification const & get_justification() const { return m_jst; } + optional const & get_justification() const { return m_justification; } }; } } diff --git a/src/library/blast/state.h b/src/library/blast/state.h index 6afa2edac..6f85d935e 100644 --- a/src/library/blast/state.h +++ b/src/library/blast/state.h @@ -5,9 +5,19 @@ Released under Apache 2.0 license as described in the file LICENSE. Author: Leonardo de Moura */ #pragma once +#include "util/rb_map.h" #include "kernel/expr.h" +#include "library/blast/hypothesis.h" + namespace lean { namespace blast { +class metavar_decl { + hypothesis_set m_context; + expr m_type; +}; + class state { + typedef rb_map metavar_decls; + metavar_decls m_metavar_decls; }; }}