lean4-htt/tests/lean/tactic_state_pp.lean
Leonardo de Moura 54f7bf9391 fix(frontends/lean, library/tactic): remove redundant error messages, and fix position of error messages
Summary:

We minimize the number of "'sorry' used warning messages".  We also
re-target the error to the main declaration. Example: foo._main ==> foo
We do not report for auxiliary declarations such as "_example" and
"foo.equations._eqn_1"

Get rid of the redundant error message "error : failed" for tactics.
We added "silent failures" in the tactic framework.

We do not store line/col information for tactics nested in notation
declarations.  Before this commit, we would have tactics such
as (tactic.save_info line col) nested inside of notation declarations.
2017-02-07 20:25:28 -08:00

39 lines
1.1 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

universe variables u
inductive Vec (α : Type u) : nat → Type u
| nil : Vec 0
| cons : ∀ {n}, α → Vec n → Vec (nat.succ n)
constant f {α : Type u} {n : nat} : Vec α n → nat
axiom fax1 (α : Type u) : f (Vec.nil α) = 0
axiom fax2 {α : Type u} {n : nat} (v : Vec α (nat.succ n)) : f v = 1
open tactic
meta def pp_state_core : tactic format :=
do t ← target,
t_fmt ← pp t,
return $ to_fmt "Goal: " ++ t_fmt
meta def pp_state (s : tactic_state) : format :=
match pp_state_core s with
| tactic_result.success r _ := r
| tactic_result.exception _ _ _ := "failed to pretty print"
end
meta instance i2 : has_to_format tactic_state :=
⟨λ s, to_fmt "My custom goal visualizer" ++ format.line ++ pp_state s⟩
example {α : Type u} {n : nat} (v : Vec α n) : f v ≠ 2 :=
begin
destruct v,
intros, intro, note h := fax1 α, cc,
-- intros n1 h t, intros, intro, note h := fax2 (Vec.cons h t), cc
end
open nat
example : ∀ n, 0 < n → succ (pred n) = n :=
begin
intro n,
destruct n,
dsimp, intros, note h := lt_irrefl 0, cc,
end