lean4-htt/library/init/meta/occurrences.lean
Leonardo de Moura 0163c1aa5b feat(library/init): use mk_dec_eq_instance in the init folder
We cannot mk_dec_eq_instance everywhere in the init folder because some
dec_eq instances are used to define the tactic mk_dec_eq_instance.
2016-07-20 20:21:58 -04:00

47 lines
1.4 KiB
Text

/-
Copyright (c) 2016 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
prelude
import init.logic init.to_string init.meta.format
import init.meta.contradiction_tactic init.meta.constructor_tactic
import init.meta.relation_tactics init.meta.injection_tactic
/- We can specify the scope of application of some tactics using
the following type.
- all : all occurrences of a given term are considered.
- pos [1, 3] : only the first and third occurrences of a given
term are consiered.
- neg [2] : all but the second occurrence of a given term
are considered. -/
inductive occurrences :=
| all
| pos : list nat → occurrences
| neg : list nat → occurrences
open occurrences
definition occurrences_is_inhabited [instance] : inhabited occurrences :=
inhabited.mk all
definition occurrences_to_string : occurrences → string
| all := "*"
| (pos l) := to_string l
| (neg l) := "-" ++ to_string l
definition occurrences_has_to_string [instance] : has_to_string occurrences :=
has_to_string.mk occurrences_to_string
meta_definition occurrences_to_format : occurrences → format
| all := to_fmt "*"
| (pos l) := to_fmt l
| (neg l) := to_fmt "-" ++ to_fmt l
meta_definition occurrences_has_to_format [instance] : has_to_format occurrences :=
has_to_format.mk occurrences_to_format
open decidable tactic