refactor(library): rename equivalence_manager to relation_manager

This commit is contained in:
Leonardo de Moura 2015-05-21 12:25:02 -07:00
parent 2b4233ee8e
commit c2faa0fe98
11 changed files with 46 additions and 46 deletions

View file

@ -14,7 +14,7 @@ Author: Leonardo de Moura
#include "util/buffer.h"
#include "util/interrupt.h"
#include "kernel/environment.h"
#include "library/equivalence_manager.h"
#include "library/relation_manager.h"
#include "library/module.h"
#include "library/constants.h"
#include "library/choice.h"

View file

@ -27,7 +27,7 @@ Author: Leonardo de Moura
#include "library/replace_visitor.h"
#include "library/class.h"
#include "library/abbreviation.h"
#include "library/equivalence_manager.h"
#include "library/relation_manager.h"
#include "library/user_recursors.h"
#include "library/unfold_macros.h"
#include "library/definitional/equations.h"

View file

@ -12,7 +12,7 @@ add_library(library deep_copy.cpp expr_lt.cpp io_state.cpp occurs.cpp
metavar_closure.cpp reducible.cpp init_module.cpp
generic_exception.cpp fingerprint.cpp flycheck.cpp hott_kernel.cpp
local_context.cpp choice_iterator.cpp pp_options.cpp unfold_macros.cpp
app_builder.cpp projection.cpp abbreviation.cpp equivalence_manager.cpp
export.cpp user_recursors.cpp)
app_builder.cpp projection.cpp abbreviation.cpp
relation_manager.cpp export.cpp user_recursors.cpp)
target_link_libraries(library ${LEAN_LIBS})

View file

@ -36,7 +36,7 @@ Author: Leonardo de Moura
#include "library/projection.h"
#include "library/normalize.h"
#include "library/abbreviation.h"
#include "library/equivalence_manager.h"
#include "library/relation_manager.h"
#include "library/user_recursors.h"
namespace lean {
@ -73,13 +73,13 @@ void initialize_library_module() {
initialize_projection();
initialize_normalize();
initialize_abbreviation();
initialize_equivalence_manager();
initialize_relation_manager();
initialize_user_recursors();
}
void finalize_library_module() {
finalize_user_recursors();
finalize_equivalence_manager();
finalize_relation_manager();
finalize_abbreviation();
finalize_normalize();
finalize_projection();

View file

@ -36,14 +36,14 @@ static expr extract_arg_types(environment const & env, name const & f, buffer<ex
enum class op_kind { Subst, Trans, Refl, Symm };
struct eqv_entry {
struct rel_entry {
op_kind m_kind;
name m_name;
eqv_entry() {}
eqv_entry(op_kind k, name const & n):m_kind(k), m_name(n) {}
rel_entry() {}
rel_entry(op_kind k, name const & n):m_kind(k), m_name(n) {}
};
struct eqv_state {
struct rel_state {
typedef name_map<std::tuple<name, unsigned, unsigned>> refl_table;
typedef name_map<std::tuple<name, unsigned, unsigned>> subst_table;
typedef name_map<std::tuple<name, unsigned, unsigned>> symm_table;
@ -52,7 +52,7 @@ struct eqv_state {
refl_table m_refl_table;
subst_table m_subst_table;
symm_table m_symm_table;
eqv_state() {}
rel_state() {}
void add_subst(environment const & env, name const & subst) {
buffer<expr> arg_types;
@ -103,12 +103,12 @@ struct eqv_state {
}
};
static name * g_eqv_name = nullptr;
static name * g_rel_name = nullptr;
static std::string * g_key = nullptr;
struct eqv_config {
typedef eqv_state state;
typedef eqv_entry entry;
struct rel_config {
typedef rel_state state;
typedef rel_entry entry;
static void add_entry(environment const & env, io_state const &, state & s, entry const & e) {
switch (e.m_kind) {
case op_kind::Refl: s.add_refl(env, e.m_name); break;
@ -118,7 +118,7 @@ struct eqv_config {
}
}
static name const & get_class_name() {
return *g_eqv_name;
return *g_rel_name;
}
static std::string const & get_serialization_key() {
return *g_key;
@ -138,23 +138,23 @@ struct eqv_config {
}
};
template class scoped_ext<eqv_config>;
typedef scoped_ext<eqv_config> eqv_ext;
template class scoped_ext<rel_config>;
typedef scoped_ext<rel_config> rel_ext;
environment add_subst(environment const & env, name const & n, bool persistent) {
return eqv_ext::add_entry(env, get_dummy_ios(), eqv_entry(op_kind::Subst, n), persistent);
return rel_ext::add_entry(env, get_dummy_ios(), rel_entry(op_kind::Subst, n), persistent);
}
environment add_refl(environment const & env, name const & n, bool persistent) {
return eqv_ext::add_entry(env, get_dummy_ios(), eqv_entry(op_kind::Refl, n), persistent);
return rel_ext::add_entry(env, get_dummy_ios(), rel_entry(op_kind::Refl, n), persistent);
}
environment add_symm(environment const & env, name const & n, bool persistent) {
return eqv_ext::add_entry(env, get_dummy_ios(), eqv_entry(op_kind::Symm, n), persistent);
return rel_ext::add_entry(env, get_dummy_ios(), rel_entry(op_kind::Symm, n), persistent);
}
environment add_trans(environment const & env, name const & n, bool persistent) {
return eqv_ext::add_entry(env, get_dummy_ios(), eqv_entry(op_kind::Trans, n), persistent);
return rel_ext::add_entry(env, get_dummy_ios(), rel_entry(op_kind::Trans, n), persistent);
}
static optional<std::tuple<name, unsigned, unsigned>> get_info(name_map<std::tuple<name, unsigned, unsigned>> const & table, name const & op) {
@ -166,17 +166,17 @@ static optional<std::tuple<name, unsigned, unsigned>> get_info(name_map<std::tup
}
optional<std::tuple<name, unsigned, unsigned>> get_refl_extra_info(environment const & env, name const & op) {
return get_info(eqv_ext::get_state(env).m_refl_table, op);
return get_info(rel_ext::get_state(env).m_refl_table, op);
}
optional<std::tuple<name, unsigned, unsigned>> get_subst_extra_info(environment const & env, name const & op) {
return get_info(eqv_ext::get_state(env).m_subst_table, op);
return get_info(rel_ext::get_state(env).m_subst_table, op);
}
optional<std::tuple<name, unsigned, unsigned>> get_symm_extra_info(environment const & env, name const & op) {
return get_info(eqv_ext::get_state(env).m_symm_table, op);
return get_info(rel_ext::get_state(env).m_symm_table, op);
}
optional<std::tuple<name, name, unsigned>> get_trans_extra_info(environment const & env, name const & op1, name const & op2) {
if (auto it = eqv_ext::get_state(env).m_trans_table.find(mk_pair(op1, op2))) {
if (auto it = rel_ext::get_state(env).m_trans_table.find(mk_pair(op1, op2))) {
return optional<std::tuple<name, name, unsigned>>(*it);
} else {
return optional<std::tuple<name, name, unsigned>>();
@ -204,15 +204,15 @@ optional<name> get_trans_info(environment const & env, name const & op) {
return optional<name>();
}
void initialize_equivalence_manager() {
g_eqv_name = new name("eqv");
g_key = new std::string("eqv");
eqv_ext::initialize();
void initialize_relation_manager() {
g_rel_name = new name("rel");
g_key = new std::string("rel");
rel_ext::initialize();
}
void finalize_equivalence_manager() {
eqv_ext::finalize();
void finalize_relation_manager() {
rel_ext::finalize();
delete g_key;
delete g_eqv_name;
delete g_rel_name;
}
}

View file

@ -19,6 +19,6 @@ optional<std::tuple<name, name, unsigned>> get_trans_extra_info(environment cons
optional<name> get_refl_info(environment const & env, name const & op);
optional<name> get_symm_info(environment const & env, name const & op);
optional<name> get_trans_info(environment const & env, name const & op);
void initialize_equivalence_manager();
void finalize_equivalence_manager();
void initialize_relation_manager();
void finalize_relation_manager();
}

View file

@ -6,6 +6,6 @@ assert_tactic.cpp clear_tactic.cpp expr_to_tactic.cpp location.cpp
rewrite_tactic.cpp util.cpp class_instance_synth.cpp init_module.cpp
change_tactic.cpp check_expr_tactic.cpp let_tactic.cpp contradiction_tactic.cpp
exfalso_tactic.cpp constructor_tactic.cpp injection_tactic.cpp
congruence_tactic.cpp equivalence_tactics.cpp induction_tactic.cpp)
congruence_tactic.cpp relation_tactics.cpp induction_tactic.cpp)
target_link_libraries(tactic ${LEAN_LIBS})

View file

@ -28,7 +28,7 @@ Author: Leonardo de Moura
#include "library/tactic/constructor_tactic.h"
#include "library/tactic/injection_tactic.h"
#include "library/tactic/congruence_tactic.h"
#include "library/tactic/equivalence_tactics.h"
#include "library/tactic/relation_tactics.h"
#include "library/tactic/induction_tactic.h"
namespace lean {
@ -57,13 +57,13 @@ void initialize_tactic_module() {
initialize_constructor_tactic();
initialize_injection_tactic();
initialize_congruence_tactic();
initialize_equivalence_tactics();
initialize_relation_tactics();
initialize_induction_tactic();
}
void finalize_tactic_module() {
finalize_induction_tactic();
finalize_equivalence_tactics();
finalize_relation_tactics();
finalize_congruence_tactic();
finalize_injection_tactic();
finalize_constructor_tactic();

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
*/
#include "library/equivalence_manager.h"
#include "library/relation_manager.h"
#include "library/explicit.h"
#include "library/placeholder.h"
#include "library/tactic/apply_tactic.h"
@ -79,7 +79,7 @@ tactic trans_tactic(elaborate_fn const & elab, expr const & e) {
return tactic(fn);
}
void initialize_equivalence_tactics() {
void initialize_relation_tactics() {
register_tac(name{"tactic", "reflexivity"},
[](type_checker &, elaborate_fn const & fn, expr const &, pos_info_provider const *) {
return refl_tactic(fn);
@ -94,5 +94,5 @@ void initialize_equivalence_tactics() {
return trans_tactic(fn, get_tactic_expr_expr(app_arg(e)));
});
}
void finalize_equivalence_tactics() {}
void finalize_relation_tactics() {}
}

View file

@ -7,6 +7,6 @@ Author: Leonardo de Moura
#pragma once
namespace lean {
tactic refl_tactic(elaborate_fn const & elab, bool no_meta = false);
void initialize_equivalence_tactics();
void finalize_equivalence_tactics();
void initialize_relation_tactics();
void finalize_relation_tactics();
}

View file

@ -36,7 +36,7 @@ Author: Leonardo de Moura
#include "library/tactic/rewrite_tactic.h"
#include "library/tactic/expr_to_tactic.h"
#include "library/tactic/class_instance_synth.h"
#include "library/tactic/equivalence_tactics.h"
#include "library/tactic/relation_tactics.h"
// #define TRACE_MATCH_PLUGIN