refactor(library/blast): we don't need blast::justification
This commit is contained in:
parent
7be1c015d1
commit
86e8508711
5 changed files with 16 additions and 81 deletions
|
@ -1 +1 @@
|
||||||
add_library(blast OBJECT state.cpp expr.cpp hypothesis.cpp)
|
add_library(blast OBJECT state.cpp expr.cpp)
|
||||||
|
|
|
@ -14,8 +14,9 @@ namespace blast {
|
||||||
class goal {
|
class goal {
|
||||||
typedef rb_map<unsigned, hypothesis, unsigned_cmp> context;
|
typedef rb_map<unsigned, hypothesis, unsigned_cmp> context;
|
||||||
friend class state;
|
friend class state;
|
||||||
unsigned m_next;
|
unsigned m_next;
|
||||||
context m_context;
|
context m_context;
|
||||||
|
expr m_type;
|
||||||
expr const & mk_lref(expr const & type, optional<expr> const & value);
|
expr const & mk_lref(expr const & type, optional<expr> const & value);
|
||||||
public:
|
public:
|
||||||
goal():m_next(0) {}
|
goal():m_next(0) {}
|
||||||
|
|
|
@ -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<unsigned> 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); }
|
|
||||||
}}
|
|
|
@ -15,32 +15,6 @@ class hypothesis;
|
||||||
class state;
|
class state;
|
||||||
class goal;
|
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<unsigned, unsigned_cmp> hypothesis_set;
|
typedef rb_tree<unsigned, unsigned_cmp> hypothesis_set;
|
||||||
|
|
||||||
class hypothesis {
|
class hypothesis {
|
||||||
|
@ -51,7 +25,7 @@ class hypothesis {
|
||||||
hypothesis_set m_forward_deps;
|
hypothesis_set m_forward_deps;
|
||||||
expr m_type;
|
expr m_type;
|
||||||
optional<expr> m_value;
|
optional<expr> m_value;
|
||||||
justification m_jst;
|
optional<expr> m_justification;
|
||||||
public:
|
public:
|
||||||
hypothesis();
|
hypothesis();
|
||||||
bool is_active() const { return m_active; }
|
bool is_active() const { return m_active; }
|
||||||
|
@ -60,7 +34,7 @@ public:
|
||||||
hypothesis_set const & get_forward_deps() const { return m_forward_deps; }
|
hypothesis_set const & get_forward_deps() const { return m_forward_deps; }
|
||||||
expr const & get_type() const { return m_type; }
|
expr const & get_type() const { return m_type; }
|
||||||
optional<expr> const & get_value() const { return m_value; }
|
optional<expr> const & get_value() const { return m_value; }
|
||||||
justification const & get_justification() const { return m_jst; }
|
optional<expr> const & get_justification() const { return m_justification; }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,9 +5,19 @@ Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
Author: Leonardo de Moura
|
Author: Leonardo de Moura
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "util/rb_map.h"
|
||||||
#include "kernel/expr.h"
|
#include "kernel/expr.h"
|
||||||
|
#include "library/blast/hypothesis.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
namespace blast {
|
namespace blast {
|
||||||
|
class metavar_decl {
|
||||||
|
hypothesis_set m_context;
|
||||||
|
expr m_type;
|
||||||
|
};
|
||||||
|
|
||||||
class state {
|
class state {
|
||||||
|
typedef rb_map<unsigned, metavar_decl, unsigned_cmp> metavar_decls;
|
||||||
|
metavar_decls m_metavar_decls;
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in a new issue