2015-11-13 22:03:43 +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-14 21:21:47 +00:00
|
|
|
#include "library/blast/revert_action.h"
|
2015-11-13 22:03:43 +00:00
|
|
|
#include "library/blast/blast.h"
|
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
namespace blast {
|
|
|
|
struct revert_proof_step_cell : public proof_step_cell {
|
|
|
|
list<expr> m_hs;
|
|
|
|
revert_proof_step_cell(list<expr> const & hs):m_hs(hs) {}
|
|
|
|
|
|
|
|
virtual ~revert_proof_step_cell() {}
|
|
|
|
|
|
|
|
virtual action_result resolve(expr const & pr) const {
|
|
|
|
expr new_pr = mk_app(pr, m_hs);
|
|
|
|
return action_result::solved(new_pr);
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool is_silent() const override { return true; }
|
|
|
|
};
|
|
|
|
|
2015-11-14 00:10:25 +00:00
|
|
|
unsigned revert_action(hypothesis_idx_buffer_set & hidxs) {
|
2015-11-13 22:03:43 +00:00
|
|
|
state & s = curr_state();
|
2015-11-14 00:10:25 +00:00
|
|
|
unsigned hidxs_size = hidxs.as_buffer().size();
|
2015-11-13 22:03:43 +00:00
|
|
|
for (unsigned i = 0; i < hidxs_size; i++) {
|
2015-11-14 00:10:25 +00:00
|
|
|
s.collect_forward_deps(hidxs.as_buffer()[i], hidxs);
|
2015-11-13 22:03:43 +00:00
|
|
|
}
|
|
|
|
s.sort_hypotheses(hidxs);
|
|
|
|
buffer<expr> hs;
|
2015-11-14 00:10:25 +00:00
|
|
|
s.to_hrefs(hidxs.as_buffer(), hs);
|
2015-11-13 22:03:43 +00:00
|
|
|
expr target = s.get_target();
|
|
|
|
expr new_target = s.mk_pi(hs, target);
|
|
|
|
s.set_target(new_target);
|
|
|
|
s.push_proof_step(new revert_proof_step_cell(to_list(hs)));
|
2015-11-14 00:10:25 +00:00
|
|
|
lean_verify(s.del_hypotheses(hidxs.as_buffer()));
|
|
|
|
return hidxs.as_buffer().size();
|
2015-11-13 22:03:43 +00:00
|
|
|
}
|
|
|
|
|
2015-11-13 23:21:26 +00:00
|
|
|
unsigned revert_action(buffer<hypothesis_idx> & hidxs) {
|
2015-11-14 00:10:25 +00:00
|
|
|
hypothesis_idx_buffer_set _hidxs(hidxs);
|
|
|
|
return revert_action(_hidxs);
|
2015-11-13 22:03:43 +00:00
|
|
|
}
|
|
|
|
}}
|