feat(library/blast/forward): branch extension
This commit is contained in:
parent
a8700e6778
commit
46e60abda6
10 changed files with 185 additions and 0 deletions
|
@ -351,6 +351,8 @@ add_subdirectory(library/blast/backward)
|
||||||
set(LEAN_OBJS ${LEAN_OBJS} $<TARGET_OBJECTS:backward>)
|
set(LEAN_OBJS ${LEAN_OBJS} $<TARGET_OBJECTS:backward>)
|
||||||
add_subdirectory(library/blast/unit)
|
add_subdirectory(library/blast/unit)
|
||||||
set(LEAN_OBJS ${LEAN_OBJS} $<TARGET_OBJECTS:unit>)
|
set(LEAN_OBJS ${LEAN_OBJS} $<TARGET_OBJECTS:unit>)
|
||||||
|
add_subdirectory(library/blast/forward)
|
||||||
|
set(LEAN_OBJS ${LEAN_OBJS} $<TARGET_OBJECTS:forward>)
|
||||||
add_subdirectory(library/blast/simplifier)
|
add_subdirectory(library/blast/simplifier)
|
||||||
set(LEAN_OBJS ${LEAN_OBJS} $<TARGET_OBJECTS:simplifier>)
|
set(LEAN_OBJS ${LEAN_OBJS} $<TARGET_OBJECTS:simplifier>)
|
||||||
add_subdirectory(library/error_handling)
|
add_subdirectory(library/error_handling)
|
||||||
|
|
1
src/library/blast/forward/CMakeLists.txt
Normal file
1
src/library/blast/forward/CMakeLists.txt
Normal file
|
@ -0,0 +1 @@
|
||||||
|
add_library(forward OBJECT init_module.cpp forward_extension.cpp qcf.cpp)
|
15
src/library/blast/forward/forward_actions.h
Normal file
15
src/library/blast/forward/forward_actions.h
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2015 Daniel Selsam. All rights reserved.
|
||||||
|
Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
Author: Daniel Selsam
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#include "library/blast/action_result.h"
|
||||||
|
#include "library/blast/gexpr.h"
|
||||||
|
|
||||||
|
namespace lean {
|
||||||
|
namespace blast {
|
||||||
|
|
||||||
|
action_result qfc_action(list<gexpr> const & lemmas);
|
||||||
|
|
||||||
|
}}
|
72
src/library/blast/forward/forward_extension.cpp
Normal file
72
src/library/blast/forward/forward_extension.cpp
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2015 Daniel Selsam. All rights reserved.
|
||||||
|
Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
Author: Daniel Selsam
|
||||||
|
*/
|
||||||
|
#include "library/blast/blast.h"
|
||||||
|
#include "library/blast/forward/forward_extension.h"
|
||||||
|
#include "library/blast/hypothesis.h"
|
||||||
|
#include "library/blast/util.h"
|
||||||
|
|
||||||
|
namespace lean {
|
||||||
|
namespace blast {
|
||||||
|
|
||||||
|
static unsigned g_ext_id = 0;
|
||||||
|
static optional<head_index> to_head_index(expr type) {
|
||||||
|
// TODO(dhs): we will want to filter this set,
|
||||||
|
// because some constants are treated specially by this module
|
||||||
|
// (e.g. [eq] and [not])
|
||||||
|
expr const & f = get_app_fn(type);
|
||||||
|
if (is_constant(f) || is_local(f))
|
||||||
|
return optional<head_index>(head_index(f));
|
||||||
|
else
|
||||||
|
return optional<head_index>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void forward_branch_extension::initialized() { }
|
||||||
|
|
||||||
|
void forward_branch_extension::hypothesis_activated(hypothesis const & h, hypothesis_idx ) {
|
||||||
|
index_expr(h.get_type());
|
||||||
|
}
|
||||||
|
|
||||||
|
void forward_branch_extension::hypothesis_deleted(hypothesis const & , hypothesis_idx ) {
|
||||||
|
// TODO(dhs): remove from indices
|
||||||
|
}
|
||||||
|
|
||||||
|
void forward_branch_extension::index_expr(expr const & e) {
|
||||||
|
// TODO(dhs): index the target when it gets updated
|
||||||
|
|
||||||
|
if (auto head_idx = to_head_index(e)) {
|
||||||
|
m_index.insert(head_index(e), e);
|
||||||
|
}
|
||||||
|
switch (e.kind()) {
|
||||||
|
case expr_kind::Var:
|
||||||
|
lean_unreachable(); // LCOV_EXCL_LINE
|
||||||
|
case expr_kind::Local:
|
||||||
|
case expr_kind::Meta:
|
||||||
|
case expr_kind::Sort:
|
||||||
|
case expr_kind::Constant:
|
||||||
|
case expr_kind::Macro: // TODO(dhs): do I unfold macros?
|
||||||
|
break;
|
||||||
|
case expr_kind::Lambda:
|
||||||
|
case expr_kind::Pi:
|
||||||
|
// TODO(dhs): confirm that I only index quantified-free hypotheses
|
||||||
|
break;
|
||||||
|
case expr_kind::App:
|
||||||
|
index_expr(app_fn(e));
|
||||||
|
index_expr(app_arg(e));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void initialize_forward_extension() {
|
||||||
|
g_ext_id = register_branch_extension(new forward_branch_extension());
|
||||||
|
}
|
||||||
|
|
||||||
|
void finalize_forward_extension() { }
|
||||||
|
|
||||||
|
forward_branch_extension & get_extension() {
|
||||||
|
return static_cast<forward_branch_extension&>(curr_state().get_extension(g_ext_id));
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
32
src/library/blast/forward/forward_extension.h
Normal file
32
src/library/blast/forward/forward_extension.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2015 Daniel Selsam. All rights reserved.
|
||||||
|
Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
Author: Daniel Selsam
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
#include "library/blast/action_result.h"
|
||||||
|
#include "library/blast/gexpr.h"
|
||||||
|
#include "library/blast/blast.h"
|
||||||
|
|
||||||
|
namespace lean {
|
||||||
|
namespace blast {
|
||||||
|
|
||||||
|
struct forward_branch_extension : public branch_extension {
|
||||||
|
head_map<expr> m_index;
|
||||||
|
forward_branch_extension() {}
|
||||||
|
forward_branch_extension(forward_branch_extension const & b): m_index(b.m_index) {}
|
||||||
|
virtual ~forward_branch_extension() {}
|
||||||
|
virtual branch_extension * clone() override { return new forward_branch_extension(*this); }
|
||||||
|
virtual void initialized() override;
|
||||||
|
virtual void hypothesis_activated(hypothesis const & h, hypothesis_idx hidx) override;
|
||||||
|
virtual void hypothesis_deleted(hypothesis const & , hypothesis_idx ) override;
|
||||||
|
void index_expr(expr const & e);
|
||||||
|
public:
|
||||||
|
head_map<expr> const & get_index() { return m_index; }
|
||||||
|
};
|
||||||
|
|
||||||
|
forward_branch_extension & get_extension();
|
||||||
|
|
||||||
|
void initialize_forward_extension();
|
||||||
|
void finalize_forward_extension();
|
||||||
|
}}
|
19
src/library/blast/forward/init_module.cpp
Normal file
19
src/library/blast/forward/init_module.cpp
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2015 Daniel Selsam. All rights reserved.
|
||||||
|
Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
Author: Daniel Selsam
|
||||||
|
*/
|
||||||
|
#include "library/blast/forward/init_module.h"
|
||||||
|
#include "library/blast/forward/forward_extension.h"
|
||||||
|
|
||||||
|
namespace lean {
|
||||||
|
namespace blast {
|
||||||
|
|
||||||
|
void initialize_forward_module() {
|
||||||
|
initialize_forward_extension();
|
||||||
|
}
|
||||||
|
|
||||||
|
void finalize_forward_module() {
|
||||||
|
finalize_forward_extension();
|
||||||
|
}
|
||||||
|
}}
|
13
src/library/blast/forward/init_module.h
Normal file
13
src/library/blast/forward/init_module.h
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2015 Daniel Selsam. All rights reserved.
|
||||||
|
Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
Author: Daniel Selsam
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace lean {
|
||||||
|
namespace blast {
|
||||||
|
void initialize_forward_module();
|
||||||
|
void finalize_forward_module();
|
||||||
|
}
|
||||||
|
}
|
26
src/library/blast/forward/qcf.cpp
Normal file
26
src/library/blast/forward/qcf.cpp
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
Copyright (c) 2015 Daniel Selsam. All rights reserved.
|
||||||
|
Released under Apache 2.0 license as described in the file LICENSE.
|
||||||
|
Author: Daniel Selsam
|
||||||
|
*/
|
||||||
|
#include "kernel/instantiate.h"
|
||||||
|
#include "kernel/abstract.h"
|
||||||
|
#include "kernel/inductive/inductive.h"
|
||||||
|
#include "library/blast/blast.h"
|
||||||
|
#include "library/blast/action_result.h"
|
||||||
|
#include "library/blast/forward/forward_actions.h"
|
||||||
|
#include "library/blast/proof_expr.h"
|
||||||
|
#include "library/blast/choice_point.h"
|
||||||
|
#include "library/blast/hypothesis.h"
|
||||||
|
#include "library/blast/util.h"
|
||||||
|
#include "library/expr_lt.h"
|
||||||
|
#include "library/head_map.h"
|
||||||
|
|
||||||
|
namespace lean {
|
||||||
|
namespace blast {
|
||||||
|
|
||||||
|
action_result qfc_action(list<gexpr> const & lemmas) {
|
||||||
|
return action_result::failed();
|
||||||
|
}
|
||||||
|
|
||||||
|
}}
|
|
@ -14,6 +14,7 @@ Author: Leonardo de Moura
|
||||||
#include "library/blast/assert_cc_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/unit/init_module.h"
|
#include "library/blast/unit/init_module.h"
|
||||||
|
|
||||||
namespace lean {
|
namespace lean {
|
||||||
|
@ -24,6 +25,7 @@ void initialize_blast_module() {
|
||||||
initialize_blast();
|
initialize_blast();
|
||||||
blast::initialize_simplifier_module();
|
blast::initialize_simplifier_module();
|
||||||
blast::initialize_backward_module();
|
blast::initialize_backward_module();
|
||||||
|
blast::initialize_forward_module();
|
||||||
blast::initialize_unit_module();
|
blast::initialize_unit_module();
|
||||||
initialize_blast_tactic();
|
initialize_blast_tactic();
|
||||||
blast::initialize_recursor_action();
|
blast::initialize_recursor_action();
|
||||||
|
@ -36,6 +38,7 @@ void finalize_blast_module() {
|
||||||
blast::finalize_recursor_action();
|
blast::finalize_recursor_action();
|
||||||
finalize_blast_tactic();
|
finalize_blast_tactic();
|
||||||
blast::finalize_unit_module();
|
blast::finalize_unit_module();
|
||||||
|
blast::finalize_forward_module();
|
||||||
blast::finalize_backward_module();
|
blast::finalize_backward_module();
|
||||||
blast::finalize_simplifier_module();
|
blast::finalize_simplifier_module();
|
||||||
finalize_blast();
|
finalize_blast();
|
||||||
|
|
|
@ -13,6 +13,7 @@ Author: Leonardo de Moura
|
||||||
#include "library/blast/subst_action.h"
|
#include "library/blast/subst_action.h"
|
||||||
#include "library/blast/backward/backward_action.h"
|
#include "library/blast/backward/backward_action.h"
|
||||||
#include "library/blast/backward/backward_strategy.h"
|
#include "library/blast/backward/backward_strategy.h"
|
||||||
|
#include "library/blast/forward/forward_actions.h"
|
||||||
#include "library/blast/unit/unit_action.h"
|
#include "library/blast/unit/unit_action.h"
|
||||||
#include "library/blast/no_confusion_action.h"
|
#include "library/blast/no_confusion_action.h"
|
||||||
#include "library/blast/simplifier/simplifier_actions.h"
|
#include "library/blast/simplifier/simplifier_actions.h"
|
||||||
|
@ -68,6 +69,7 @@ class simple_strategy : public strategy {
|
||||||
Try(constructor_action());
|
Try(constructor_action());
|
||||||
|
|
||||||
TryStrategy(apply_backward_strategy());
|
TryStrategy(apply_backward_strategy());
|
||||||
|
Try(qfc_action(list<gexpr>()));
|
||||||
|
|
||||||
// TODO(Leo): add more actions...
|
// TODO(Leo): add more actions...
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue