2015-11-09 03:18:40 +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-11-13 18:54:29 +00:00
|
|
|
#include <limits>
|
2015-11-09 03:18:40 +00:00
|
|
|
#include "kernel/abstract.h"
|
|
|
|
#include "kernel/instantiate.h"
|
|
|
|
#include "library/blast/blast.h"
|
2015-11-10 18:47:41 +00:00
|
|
|
#include "library/blast/proof_expr.h"
|
2015-11-09 03:18:40 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
namespace blast {
|
2015-11-10 17:54:28 +00:00
|
|
|
struct intros_proof_step_cell : public proof_step_cell {
|
2015-11-09 03:18:40 +00:00
|
|
|
list<expr> m_new_hs;
|
|
|
|
virtual ~intros_proof_step_cell() {}
|
2015-11-11 00:57:57 +00:00
|
|
|
virtual action_result resolve(expr const & pr) const {
|
2015-11-13 23:21:26 +00:00
|
|
|
expr new_pr = mk_proof_lambda(curr_state(), m_new_hs, pr);
|
2015-11-11 00:57:57 +00:00
|
|
|
return action_result::solved(new_pr);
|
2015-11-09 03:18:40 +00:00
|
|
|
}
|
2015-11-13 18:54:29 +00:00
|
|
|
|
|
|
|
virtual bool is_silent() const override { return true; }
|
2015-11-09 03:18:40 +00:00
|
|
|
};
|
|
|
|
|
2015-11-13 18:54:29 +00:00
|
|
|
bool intros_action(unsigned max) {
|
2015-11-09 03:18:40 +00:00
|
|
|
state & s = curr_state();
|
2015-11-09 21:19:59 +00:00
|
|
|
expr target = whnf(s.get_target());
|
2015-11-09 03:18:40 +00:00
|
|
|
if (!is_pi(target))
|
|
|
|
return false;
|
2015-11-10 17:54:28 +00:00
|
|
|
auto pcell = new intros_proof_step_cell();
|
2015-11-11 00:57:57 +00:00
|
|
|
s.push_proof_step(pcell);
|
2015-11-09 03:18:40 +00:00
|
|
|
buffer<expr> new_hs;
|
2015-11-13 18:54:29 +00:00
|
|
|
for (unsigned i = 0; i < max; i++) {
|
|
|
|
if (!is_pi(target))
|
|
|
|
break;
|
2015-11-13 21:13:48 +00:00
|
|
|
expr href;
|
|
|
|
if (is_default_var_name(binding_name(target)) && closed(binding_body(target))) {
|
|
|
|
href = s.mk_hypothesis(binding_domain(target));
|
|
|
|
} else {
|
|
|
|
href = s.mk_hypothesis(binding_name(target), binding_domain(target));
|
|
|
|
}
|
2015-11-09 03:18:40 +00:00
|
|
|
new_hs.push_back(href);
|
|
|
|
target = whnf(instantiate(binding_body(target), href));
|
|
|
|
}
|
2015-11-10 17:54:28 +00:00
|
|
|
pcell->m_new_hs = to_list(new_hs);
|
2015-11-09 21:19:59 +00:00
|
|
|
s.set_target(target);
|
2015-11-09 03:18:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
2015-11-13 18:54:29 +00:00
|
|
|
|
|
|
|
bool intros_action() {
|
|
|
|
return intros_action(std::numeric_limits<unsigned>::max());
|
|
|
|
}
|
2015-11-09 03:18:40 +00:00
|
|
|
}}
|