2015-11-10 19:44:18 +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
|
|
|
|
*/
|
|
|
|
#include "library/blast/blast.h"
|
|
|
|
#include "library/blast/options.h"
|
|
|
|
#include "library/blast/choice_point.h"
|
2015-11-11 08:02:47 +00:00
|
|
|
#include "library/blast/simple_actions.h"
|
2015-11-13 23:21:26 +00:00
|
|
|
#include "library/blast/proof_expr.h"
|
2015-11-14 21:21:47 +00:00
|
|
|
#include "library/blast/intros_action.h"
|
|
|
|
#include "library/blast/subst_action.h"
|
2015-11-18 23:41:44 +00:00
|
|
|
#include "library/blast/backward/backward_action.h"
|
|
|
|
#include "library/blast/backward/backward_strategy.h"
|
2015-11-19 18:57:59 +00:00
|
|
|
#include "library/blast/forward/forward_action.h"
|
2015-11-14 21:21:47 +00:00
|
|
|
#include "library/blast/no_confusion_action.h"
|
2015-11-19 23:30:38 +00:00
|
|
|
#include "library/blast/simplifier/simplifier_actions.h"
|
2015-11-15 21:12:21 +00:00
|
|
|
#include "library/blast/recursor_action.h"
|
2015-11-19 20:20:40 +00:00
|
|
|
#include "library/blast/assert_cc_action.h"
|
2015-11-15 21:12:21 +00:00
|
|
|
#include "library/blast/strategy.h"
|
2015-11-18 20:59:53 +00:00
|
|
|
#include "library/blast/trace.h"
|
2015-11-10 19:44:18 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
namespace blast {
|
|
|
|
/** \brief Implement a simple proof strategy for blast.
|
|
|
|
We use it mainly for testing new actions and the whole blast infra-structure. */
|
2015-11-15 21:12:21 +00:00
|
|
|
class simple_strategy : public strategy {
|
2015-11-15 22:30:24 +00:00
|
|
|
action_result activate_hypothesis(bool preprocess) {
|
2015-11-20 18:39:26 +00:00
|
|
|
scope_trace scope(!preprocess && get_config().m_trace);
|
2015-11-18 20:59:53 +00:00
|
|
|
|
2015-11-15 22:30:24 +00:00
|
|
|
auto hidx = curr_state().activate_hypothesis();
|
|
|
|
if (!hidx) return action_result::failed();
|
2015-11-18 20:59:53 +00:00
|
|
|
trace_action("activate");
|
2015-11-15 22:30:24 +00:00
|
|
|
|
2015-11-18 20:27:24 +00:00
|
|
|
Try(assumption_contradiction_actions(*hidx));
|
2015-11-23 01:49:00 +00:00
|
|
|
Try(simplify_hypothesis_action(*hidx));
|
2015-11-20 03:37:11 +00:00
|
|
|
TrySolve(assert_cc_action(*hidx));
|
2015-11-18 20:27:24 +00:00
|
|
|
Try(subst_action(*hidx));
|
|
|
|
Try(no_confusion_action(*hidx));
|
|
|
|
Try(discard_action(*hidx));
|
2015-11-19 18:57:59 +00:00
|
|
|
Try(forward_action(*hidx));
|
2015-11-18 20:27:24 +00:00
|
|
|
Try(recursor_preprocess_action(*hidx));
|
2015-11-15 22:30:24 +00:00
|
|
|
return action_result::new_branch();
|
2015-11-10 19:44:18 +00:00
|
|
|
}
|
|
|
|
|
2015-11-14 23:58:11 +00:00
|
|
|
/* \brief Preprocess state
|
|
|
|
It keeps applying intros, activating and finally simplify target.
|
|
|
|
Return an expression if the goal has been proved during preprocessing step. */
|
2015-11-15 21:12:21 +00:00
|
|
|
virtual optional<expr> preprocess() {
|
2015-11-18 20:59:53 +00:00
|
|
|
trace("* Preprocess");
|
2015-11-14 23:58:11 +00:00
|
|
|
while (true) {
|
2015-11-18 20:27:24 +00:00
|
|
|
if (!failed(intros_action()))
|
2015-11-14 23:58:11 +00:00
|
|
|
continue;
|
2015-11-15 22:30:24 +00:00
|
|
|
auto r = activate_hypothesis(true);
|
|
|
|
if (solved(r)) return r.to_opt_expr();
|
|
|
|
if (failed(r)) break;
|
2015-11-14 23:58:11 +00:00
|
|
|
}
|
2015-11-19 20:20:40 +00:00
|
|
|
TrySolveToOptExpr(assumption_action());
|
|
|
|
TrySolveToOptExpr(simplify_target_action());
|
2015-11-18 20:27:24 +00:00
|
|
|
return none_expr();
|
2015-11-14 23:58:11 +00:00
|
|
|
}
|
|
|
|
|
2015-11-15 21:12:21 +00:00
|
|
|
virtual action_result next_action() {
|
2015-11-18 20:27:24 +00:00
|
|
|
Try(intros_action());
|
|
|
|
Try(activate_hypothesis(false));
|
|
|
|
Try(trivial_action());
|
|
|
|
Try(assumption_action());
|
|
|
|
Try(recursor_action());
|
|
|
|
Try(constructor_action());
|
2015-11-18 23:41:44 +00:00
|
|
|
|
|
|
|
TryStrategy(apply_backward_strategy());
|
|
|
|
|
|
|
|
// TODO(Leo): add more actions...
|
|
|
|
|
2015-11-11 00:57:57 +00:00
|
|
|
return action_result::failed();
|
2015-11-10 19:44:18 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
optional<expr> apply_simple_strategy() {
|
|
|
|
return simple_strategy()();
|
|
|
|
}
|
|
|
|
}}
|