fix(library/init/meta/constructor_tactic): fixes #1598

This commit is contained in:
Leonardo de Moura 2017-05-25 09:56:38 -07:00
parent 5583893991
commit 0bf51e63e8
4 changed files with 13 additions and 2 deletions

View file

@ -69,7 +69,7 @@ instance decidable_bex : ∀ (l : list α), decidable (∃ x ∈ l, p x)
match decidable_bex xs with
| is_true hxs := is_true $ begin
cases hxs with x' hx', cases hx' with hx' hpx',
existsi x', existsi (or.inr hx'), assumption, exact x' = x
existsi x', existsi (or.inr hx'), assumption
end
| is_false hxs := is_false $ begin
intro hxxs, cases hxxs with x' hx', cases hx' with hx' hpx',

View file

@ -58,6 +58,10 @@ do [c] ← target >>= get_constructors_for | fail "existsi tactic failed, ta
n ← get_arity fn,
when (n < 2) (fail "existsi tactic failed, constructor must have at least two arguments"),
t ← apply_num_metavars fn fn_type (n - 2),
apply (app t e)
apply (app t e),
t_type ← infer_type t >>= whnf,
e_type ← infer_type e,
(guard t_type.is_pi <|> fail "existsi tactic failed, failed to infer type"),
(unify t_type.binding_domain e_type <|> fail "existsi tactic failed, type mismatch between given term witness and expected type")
end tactic

4
tests/lean/1598.lean Normal file
View file

@ -0,0 +1,4 @@
lemma notc : exists b, b = false :=
begin
existsi 0, -- ERROR here
end

View file

@ -0,0 +1,3 @@
1598.lean:3:3: error: existsi tactic failed, type mismatch between given term witness and expected type
state:
⊢ 0 = false