feat(library/blast/congruence_closure): expose get_cc()
This commit is contained in:
parent
11f838c13a
commit
712f60d003
5 changed files with 19 additions and 27 deletions
|
@ -12,27 +12,6 @@ Author: Leonardo de Moura
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
namespace blast {
|
namespace blast {
|
||||||
static unsigned g_ext_id = 0;
|
|
||||||
struct cc_branch_extension : public branch_extension {
|
|
||||||
congruence_closure m_cc;
|
|
||||||
cc_branch_extension() {}
|
|
||||||
cc_branch_extension(cc_branch_extension const & o):m_cc(o.m_cc) {}
|
|
||||||
virtual ~cc_branch_extension() {}
|
|
||||||
virtual branch_extension * clone() override { return new cc_branch_extension(*this); }
|
|
||||||
virtual void initialized() override { m_cc.initialize(); }
|
|
||||||
virtual void target_updated() override { m_cc.internalize(curr_state().get_target()); }
|
|
||||||
};
|
|
||||||
|
|
||||||
void initialize_assert_cc_action() {
|
|
||||||
g_ext_id = register_branch_extension(new cc_branch_extension());
|
|
||||||
}
|
|
||||||
|
|
||||||
void finalize_assert_cc_action() {}
|
|
||||||
|
|
||||||
static congruence_closure & get_cc() {
|
|
||||||
return static_cast<cc_branch_extension&>(curr_state().get_extension(g_ext_id)).m_cc;
|
|
||||||
}
|
|
||||||
|
|
||||||
action_result assert_cc_action(hypothesis_idx hidx) {
|
action_result assert_cc_action(hypothesis_idx hidx) {
|
||||||
if (!get_config().m_cc)
|
if (!get_config().m_cc)
|
||||||
return action_result::failed();
|
return action_result::failed();
|
||||||
|
|
|
@ -12,7 +12,4 @@ namespace lean {
|
||||||
namespace blast {
|
namespace blast {
|
||||||
/** \brief Assert the given hypothesis into the congruence closure module */
|
/** \brief Assert the given hypothesis into the congruence closure module */
|
||||||
action_result assert_cc_action(hypothesis_idx hidx);
|
action_result assert_cc_action(hypothesis_idx hidx);
|
||||||
|
|
||||||
void initialize_assert_cc_action();
|
|
||||||
void finalize_assert_cc_action();
|
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -1324,7 +1324,23 @@ bool congruence_closure::check_invariant() const {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static unsigned g_ext_id = 0;
|
||||||
|
struct cc_branch_extension : public branch_extension {
|
||||||
|
congruence_closure m_cc;
|
||||||
|
cc_branch_extension() {}
|
||||||
|
cc_branch_extension(cc_branch_extension const & o):m_cc(o.m_cc) {}
|
||||||
|
virtual ~cc_branch_extension() {}
|
||||||
|
virtual branch_extension * clone() override { return new cc_branch_extension(*this); }
|
||||||
|
virtual void initialized() override { m_cc.initialize(); }
|
||||||
|
virtual void target_updated() override { m_cc.internalize(curr_state().get_target()); }
|
||||||
|
};
|
||||||
|
|
||||||
|
congruence_closure & get_cc() {
|
||||||
|
return static_cast<cc_branch_extension&>(curr_state().get_extension(g_ext_id)).m_cc;
|
||||||
|
}
|
||||||
|
|
||||||
void initialize_congruence_closure() {
|
void initialize_congruence_closure() {
|
||||||
|
g_ext_id = register_branch_extension(new cc_branch_extension());
|
||||||
name prefix = name::mk_internal_unique_name();
|
name prefix = name::mk_internal_unique_name();
|
||||||
g_congr_mark = new expr(mk_constant(name(prefix, "[congruence]")));
|
g_congr_mark = new expr(mk_constant(name(prefix, "[congruence]")));
|
||||||
g_iff_true_mark = new expr(mk_constant(name(prefix, "[iff-true]")));
|
g_iff_true_mark = new expr(mk_constant(name(prefix, "[iff-true]")));
|
||||||
|
|
|
@ -216,6 +216,9 @@ public:
|
||||||
~scope_congruence_closure();
|
~scope_congruence_closure();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** \brief Return the congruence closure object associated with the current state */
|
||||||
|
congruence_closure & get_cc();
|
||||||
|
|
||||||
void initialize_congruence_closure();
|
void initialize_congruence_closure();
|
||||||
void finalize_congruence_closure();
|
void finalize_congruence_closure();
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -11,7 +11,6 @@ Author: Leonardo de Moura
|
||||||
#include "library/blast/options.h"
|
#include "library/blast/options.h"
|
||||||
#include "library/blast/congruence_closure.h"
|
#include "library/blast/congruence_closure.h"
|
||||||
#include "library/blast/recursor_action.h"
|
#include "library/blast/recursor_action.h"
|
||||||
#include "library/blast/assert_cc_action.h"
|
|
||||||
#include "library/blast/simplifier/init_module.h"
|
#include "library/blast/simplifier/init_module.h"
|
||||||
#include "library/blast/backward/init_module.h"
|
#include "library/blast/backward/init_module.h"
|
||||||
#include "library/blast/forward/init_module.h"
|
#include "library/blast/forward/init_module.h"
|
||||||
|
@ -29,12 +28,10 @@ void initialize_blast_module() {
|
||||||
blast::initialize_unit_module();
|
blast::initialize_unit_module();
|
||||||
initialize_blast_tactic();
|
initialize_blast_tactic();
|
||||||
blast::initialize_recursor_action();
|
blast::initialize_recursor_action();
|
||||||
blast::initialize_assert_cc_action();
|
|
||||||
blast::initialize_congruence_closure();
|
blast::initialize_congruence_closure();
|
||||||
}
|
}
|
||||||
void finalize_blast_module() {
|
void finalize_blast_module() {
|
||||||
blast::finalize_congruence_closure();
|
blast::finalize_congruence_closure();
|
||||||
blast::finalize_assert_cc_action();
|
|
||||||
blast::finalize_recursor_action();
|
blast::finalize_recursor_action();
|
||||||
finalize_blast_tactic();
|
finalize_blast_tactic();
|
||||||
blast::finalize_unit_module();
|
blast::finalize_unit_module();
|
||||||
|
|
Loading…
Reference in a new issue