fix(library/tactic/inversion_tactic): check whether eliminator can only eliminate to Prop

fixes #571
This commit is contained in:
Leonardo de Moura 2015-05-02 17:48:08 -07:00
parent e379034b95
commit e1dc18f6b6
3 changed files with 27 additions and 1 deletions

View file

@ -379,10 +379,16 @@ class inversion_tac {
name const & I_name = const_name(I);
expr g_type = g.get_type();
expr cases_on;
level g_lvl = sort_level(m_tc.ensure_type(g_type).first);
if (m_cases_on_decl.get_num_univ_params() != m_I_decl.get_num_univ_params()) {
level g_lvl = sort_level(m_tc.ensure_type(g_type).first);
cases_on = mk_constant({I_name, "cases_on"}, cons(g_lvl, const_levels(I)));
} else {
if (!is_zero(g_lvl)) {
if (m_throw_tactic_exception)
throw tactic_exception(sstream() << "invalid 'cases' tactic, '" << const_name(I) << "' can only eliminate to Prop");
else
throw inversion_exception();
}
cases_on = mk_constant({I_name, "cases_on"}, const_levels(I));
}
// add params

7
tests/lean/571.lean Normal file
View file

@ -0,0 +1,7 @@
open nat
variables (P : → Prop)
example (H : ∃n, P n) : :=
begin
cases H with n p,
end

View file

@ -0,0 +1,13 @@
571.lean:6:2: error:invalid 'cases' tactic, 'Exists' can only eliminate to Prop
proof state:
P : → Prop,
H : ∃ (n : ), P n
571.lean:7:0: error: don't know how to synthesize placeholder
P : → Prop,
H : ∃ (n : ), P n
571.lean:7:0: error: failed to add declaration '14.1' to environment, value has metavariables
remark: set 'formatter.hide_full_terms' to false to see the complete term
λ (P : …) (H : …),
?M_1