2015-11-19 20:20: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
|
|
|
|
*/
|
|
|
|
#include "library/blast/assert_cc_action.h"
|
|
|
|
#include "library/blast/congruence_closure.h"
|
|
|
|
#include "library/blast/blast.h"
|
|
|
|
#include "library/blast/trace.h"
|
2015-11-22 01:45:25 +00:00
|
|
|
#include "library/blast/options.h"
|
2015-11-19 20:20:40 +00:00
|
|
|
|
|
|
|
namespace lean {
|
|
|
|
namespace blast {
|
|
|
|
action_result assert_cc_action(hypothesis_idx hidx) {
|
2015-11-22 01:45:25 +00:00
|
|
|
if (!get_config().m_cc)
|
|
|
|
return action_result::failed();
|
2015-11-19 20:20:40 +00:00
|
|
|
congruence_closure & cc = get_cc();
|
2015-11-25 02:32:20 +00:00
|
|
|
if (has_expr_metavar(curr_state().get_hypothesis_decl(hidx).get_type()))
|
|
|
|
return action_result::failed();
|
2015-11-19 20:20:40 +00:00
|
|
|
cc.add(hidx);
|
2015-11-20 20:18:52 +00:00
|
|
|
// cc.display();
|
2015-11-19 20:20:40 +00:00
|
|
|
if (cc.is_inconsistent()) {
|
|
|
|
try {
|
|
|
|
app_builder & b = get_app_builder();
|
|
|
|
expr false_proof = *cc.get_inconsistency_proof();
|
|
|
|
trace_action("contradiction by congruence closure");
|
|
|
|
return action_result(b.mk_false_rec(curr_state().get_target(), false_proof));
|
|
|
|
} catch (app_builder_exception &) {
|
|
|
|
return action_result::failed();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
expr const & target = curr_state().get_target();
|
|
|
|
name R; expr lhs, rhs;
|
|
|
|
if (is_relation_app(target, R, lhs, rhs) && cc.is_eqv(R, lhs, rhs)) {
|
|
|
|
expr proof = *cc.get_eqv_proof(R, lhs, rhs);
|
|
|
|
trace_action("equivalence by congruence closure");
|
|
|
|
return action_result(proof);
|
|
|
|
} else if (is_prop(target) && !is_false(target) && cc.proved(target)) {
|
|
|
|
expr proof = *cc.get_proof(target);
|
|
|
|
trace_action("equivalent to true by congruence closure");
|
|
|
|
return action_result(proof);
|
|
|
|
} else {
|
|
|
|
return action_result::new_branch();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|