Skip to content

Commit

Permalink
feat(lift): check whether target is proposition (#1767)
Browse files Browse the repository at this point in the history
* feat(lift): check whether target is proposition

* simplify
  • Loading branch information
fpvandoorn authored and mergify[bot] committed Dec 4, 2019
1 parent c1105de commit 71247eb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tactic/lift.lean
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ if h_some : h.is_some then
-/
meta def lift (p : pexpr) (t : pexpr) (h : option pexpr) (n : list name) : tactic unit :=
do
propositional_goal <|>
fail "lift tactic failed. Tactic is only applicable when the target is a proposition.",
e ← i_to_expr p,
old_tp ← infer_type e,
new_tp ← i_to_expr t,
Expand Down
7 changes: 7 additions & 0 deletions test/tactics.lean
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,13 @@ begin
trivial
end

example (n : ℤ) : ℕ :=
begin
success_if_fail_with_msg {lift n to ℕ}
"lift tactic failed. Tactic is only applicable when the target is a proposition.",
exact 0
end

end lift

private meta def get_exception_message (t : lean.parser unit) : lean.parser string
Expand Down

0 comments on commit 71247eb

Please sign in to comment.