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-07 17:27:48 +00:00
|
|
|
#include "util/sstream.h"
|
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-07 19:59:21 +00:00
|
|
|
#include "library/blast/backward/backward_action.h"
|
|
|
|
#include "library/blast/backward/backward_strategy.h"
|
2015-12-08 04:22:22 +00:00
|
|
|
#include "library/blast/grinder/grinder_strategy.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-30 04:45:24 +00:00
|
|
|
#include "library/blast/strategies/action_strategy.h"
|
2015-12-31 20:35:16 +00:00
|
|
|
#include "library/blast/strategies/rec_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-30 04:45:24 +00:00
|
|
|
return mk_pre_action_strategy("cc", assert_cc_action)();
|
2015-12-06 22:33:21 +00:00
|
|
|
}
|
|
|
|
|
2015-12-06 23:01:49 +00:00
|
|
|
static optional<expr> apply_ematch() {
|
|
|
|
flet<bool> set(get_config().m_ematch, true);
|
2015-12-30 04:45:24 +00:00
|
|
|
return mk_action_strategy("ematch",
|
|
|
|
assert_cc_action,
|
|
|
|
unit_propagate,
|
|
|
|
ematch_action)();
|
2015-12-06 23:01:49 +00:00
|
|
|
}
|
|
|
|
|
2015-12-30 04:04:31 +00:00
|
|
|
static optional<expr> apply_ematch_simp() {
|
|
|
|
flet<bool> set(get_config().m_ematch, true);
|
2015-12-30 04:45:24 +00:00
|
|
|
return mk_action_strategy("ematch_simp",
|
|
|
|
assert_cc_action,
|
|
|
|
unit_propagate,
|
|
|
|
ematch_simp_action)();
|
2015-12-30 04:04:31 +00:00
|
|
|
}
|
|
|
|
|
2015-12-31 20:45:48 +00:00
|
|
|
static optional<expr> apply_rec_ematch_simp() {
|
2015-12-31 20:35:16 +00:00
|
|
|
return rec_and_then(apply_ematch_simp)();
|
|
|
|
}
|
|
|
|
|
2015-12-07 19:59:21 +00:00
|
|
|
static optional<expr> apply_constructor() {
|
2015-12-30 04:45:24 +00:00
|
|
|
return mk_action_strategy("constructor",
|
|
|
|
[]() { return constructor_action(); })();
|
2015-12-07 19:59:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static optional<expr> apply_backward() {
|
|
|
|
return preprocess_and_then(mk_backward_strategy())();
|
|
|
|
}
|
|
|
|
|
2015-12-07 16:45:54 +00:00
|
|
|
static optional<expr> apply_unit() {
|
2015-12-30 04:45:24 +00:00
|
|
|
return mk_action_strategy("unit",
|
|
|
|
unit_preprocess,
|
|
|
|
unit_propagate,
|
|
|
|
[]() { return action_result::failed(); })();
|
2015-12-07 16:45:54 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 04:22:22 +00:00
|
|
|
static optional<expr> apply_grind() {
|
|
|
|
return preprocess_and_then(grind_and_then([]() { return none_expr(); }))();
|
|
|
|
}
|
|
|
|
|
|
|
|
static optional<expr> apply_core_grind() {
|
|
|
|
return grind_and_then([]() { return none_expr(); })();
|
|
|
|
}
|
|
|
|
|
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-07 17:27:48 +00:00
|
|
|
} else if (s_name == "all") {
|
|
|
|
// TODO(Leo):
|
|
|
|
return apply_simple();
|
2015-12-06 22:33:21 +00:00
|
|
|
} else if (s_name == "cc") {
|
|
|
|
return apply_cc();
|
2015-12-08 04:22:22 +00:00
|
|
|
} else if (s_name == "grind") {
|
|
|
|
return apply_grind();
|
|
|
|
} else if (s_name == "core_grind") {
|
|
|
|
return apply_core_grind();
|
2015-12-06 23:01:49 +00:00
|
|
|
} else if (s_name == "ematch") {
|
|
|
|
return apply_ematch();
|
2015-12-30 04:04:31 +00:00
|
|
|
} else if (s_name == "ematch_simp") {
|
|
|
|
return apply_ematch_simp();
|
2015-12-31 20:45:48 +00:00
|
|
|
} else if (s_name == "rec_ematch_simp") {
|
|
|
|
return apply_rec_ematch_simp();
|
2015-12-07 19:59:21 +00:00
|
|
|
} else if (s_name == "constructor") {
|
|
|
|
return apply_constructor();
|
2015-12-07 16:45:54 +00:00
|
|
|
} else if (s_name == "unit") {
|
|
|
|
return apply_unit();
|
2015-12-07 19:59:21 +00:00
|
|
|
} else if (s_name == "backward") {
|
|
|
|
return apply_backward();
|
2015-12-06 02:17:15 +00:00
|
|
|
} else {
|
2015-12-07 17:27:48 +00:00
|
|
|
throw exception(sstream() << "unknown blast strategy '" << s_name << "'");
|
2015-12-06 02:17:15 +00:00
|
|
|
}
|
2015-12-06 00:55:04 +00:00
|
|
|
}
|
|
|
|
}}
|