fix(library/init/meta/interactive): fixes #1733
This commit is contained in:
parent
38c2c7dae8
commit
ced4b6a54d
2 changed files with 33 additions and 5 deletions
|
|
@ -931,9 +931,8 @@ meta def delta : parse ident* → parse location → tactic unit
|
|||
delta_target new_cs,
|
||||
intron n
|
||||
|
||||
private meta def unfold_projs_hyps (cfg : unfold_proj_config := {}) : list name → tactic unit
|
||||
| [] := skip
|
||||
| (h::hs) := get_local h >>= unfold_projs_hyp >> unfold_projs_hyps hs
|
||||
private meta def unfold_projs_hyps (cfg : unfold_proj_config := {}) (hs : list name) : tactic bool :=
|
||||
hs.mfoldl (λ r h, do h ← get_local h, (unfold_projs_hyp h cfg >> return tt) <|> return r) ff
|
||||
|
||||
/--
|
||||
This tactic unfolds all structure projections.
|
||||
|
|
@ -941,8 +940,12 @@ This tactic unfolds all structure projections.
|
|||
meta def unfold_projs (l : parse location) (cfg : unfold_proj_config := {}) : tactic unit :=
|
||||
match l with
|
||||
| (loc.ns []) := tactic.unfold_projs_target cfg
|
||||
| (loc.ns hs) := unfold_projs_hyps cfg hs
|
||||
| (loc.wildcard) := do ls ← local_context, unfold_projs_hyps cfg (ls.map expr.local_pp_name)
|
||||
| (loc.ns hs) := do b ← unfold_projs_hyps cfg hs,
|
||||
when (not b) (fail "unfold_projs failed to simplify")
|
||||
| (loc.wildcard) := do ls ← local_context,
|
||||
b₁ ← unfold_projs_hyps cfg (ls.map expr.local_pp_name),
|
||||
b₂ ← (tactic.unfold_projs_target cfg >> return tt) <|> return ff,
|
||||
when (not b₁ ∧ not b₂) (fail "unfold_projs failed to simplify")
|
||||
end
|
||||
|
||||
end interactive
|
||||
|
|
|
|||
25
tests/lean/run/1733.lean
Normal file
25
tests/lean/run/1733.lean
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
def f (a : nat) := (a, a)
|
||||
|
||||
example (a : nat) (h : (f a).1 ≠ a) : false :=
|
||||
begin
|
||||
unfold_projs at h {md := semireducible},
|
||||
contradiction
|
||||
end
|
||||
|
||||
example (a b : nat) (h₁ : a = b) (h₂ : (a, a).1 ≠ b) : false :=
|
||||
begin
|
||||
unfold_projs at h₁ h₂,
|
||||
contradiction
|
||||
end
|
||||
|
||||
example (a b : nat) (h₁ : a = b) (h₂ : a ≠ b) : (false, true).1 :=
|
||||
begin
|
||||
unfold_projs at *,
|
||||
contradiction
|
||||
end
|
||||
|
||||
example (a b : nat) (h₁ : a = b) (h₂ : a ≠ b) : false :=
|
||||
begin
|
||||
fail_if_success {unfold_projs at *},
|
||||
contradiction
|
||||
end
|
||||
Loading…
Add table
Reference in a new issue