2015-12-06 00:55:04 +00:00
|
|
|
/*
|
|
|
|
Copyright (c) 2015 Microsoft Corporation. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
|
|
|
|
Author: Leonardo de Moura
|
|
|
|
*/
|
2015-12-06 02:17:15 +00:00
|
|
|
#include <string>
|
2015-12-06 22:33:21 +00:00
|
|
|
#include "library/blast/actions/assert_cc_action.h"
|
2015-12-06 21:04:41 +00:00
|
|
|
#include "library/blast/simplifier/simplifier_strategies.h"
|
2015-12-06 23:01:49 +00:00
|
|
|
#include "library/blast/unit/unit_actions.h"
|
|
|
|
#include "library/blast/forward/ematch.h"
|
2015-12-06 00:55:04 +00:00
|
|
|
#include "library/blast/strategies/simple_strategy.h"
|
|
|
|
#include "library/blast/strategies/preprocess_strategy.h"
|
2015-12-06 22:33:21 +00:00
|
|
|
#include "library/blast/strategies/debug_action_strategy.h"
|
2015-12-06 00:55:04 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
namespace blast {
|
2015-12-06 02:17:15 +00:00
|
|
|
static optional<expr> apply_preprocess() {
|
|
|
|
return preprocess_and_then([]() { return none_expr(); })();
|
|
|
|
}
|
|
|
|
|
2015-12-06 21:04:41 +00:00
|
|
|
static optional<expr> apply_simp() {
|
2015-12-06 23:01:49 +00:00
|
|
|
flet<bool> set(get_config().m_simp, true);
|
2015-12-06 21:04:41 +00:00
|
|
|
return mk_simplify_using_hypotheses_strategy()();
|
|
|
|
}
|
|
|
|
|
|
|
|
static optional<expr> apply_simp_nohyps() {
|
2015-12-06 23:01:49 +00:00
|
|
|
flet<bool> set(get_config().m_simp, true);
|
2015-12-06 21:04:41 +00:00
|
|
|
return mk_simplify_all_strategy()();
|
|
|
|
}
|
|
|
|
|
2015-12-06 00:55:04 +00:00
|
|
|
static optional<expr> apply_simple() {
|
|
|
|
return preprocess_and_then(mk_simple_strategy())();
|
|
|
|
}
|
|
|
|
|
2015-12-06 22:33:21 +00:00
|
|
|
static optional<expr> apply_cc() {
|
2015-12-06 23:01:49 +00:00
|
|
|
flet<bool> set(get_config().m_cc, true);
|
2015-12-06 22:33:21 +00:00
|
|
|
return mk_debug_pre_action_strategy(assert_cc_action)();
|
|
|
|
}
|
|
|
|
|
2015-12-06 23:01:49 +00:00
|
|
|
static optional<expr> apply_ematch() {
|
|
|
|
flet<bool> set(get_config().m_ematch, true);
|
|
|
|
return mk_debug_action_strategy([](hypothesis_idx hidx) { Try(unit_propagate(hidx)); TrySolve(assert_cc_action(hidx)); return action_result::new_branch(); },
|
|
|
|
unit_propagate,
|
|
|
|
ematch_action)();
|
|
|
|
}
|
|
|
|
|
2015-12-06 00:55:04 +00:00
|
|
|
optional<expr> apply_strategy() {
|
2015-12-06 02:17:15 +00:00
|
|
|
std::string s_name(get_config().m_strategy);
|
|
|
|
if (s_name == "preprocess") {
|
|
|
|
return apply_preprocess();
|
2015-12-06 21:04:41 +00:00
|
|
|
} else if (s_name == "simp") {
|
|
|
|
return apply_simp();
|
|
|
|
} else if (s_name == "simp_nohyps") {
|
|
|
|
return apply_simp_nohyps();
|
2015-12-06 02:17:15 +00:00
|
|
|
} else if (s_name == "simple") {
|
|
|
|
return apply_simple();
|
2015-12-06 22:33:21 +00:00
|
|
|
} else if (s_name == "cc") {
|
|
|
|
return apply_cc();
|
2015-12-06 23:01:49 +00:00
|
|
|
} else if (s_name == "ematch") {
|
|
|
|
return apply_ematch();
|
2015-12-06 02:17:15 +00:00
|
|
|
} else {
|
|
|
|
// TODO(Leo): add more builtin strategies
|
|
|
|
return apply_simple();
|
|
|
|
}
|
2015-12-06 00:55:04 +00:00
|
|
|
}
|
|
|
|
}}
|