A tactic for type-based naming of variables #
When we name hypotheses or variables, we often do so in a type-directed fashion:
a hypothesis of type ℕ
is called n
or m
; a hypothesis of type list ℕ
is
called ns
; etc. This module provides a tactic,
tactic.typical_variable_names
, which looks up typical variable names for a
given type.
Typical variable names are registered by giving an instance of the type class
has_variable_names
. This file provides has_variable_names
instances for many
of the core Lean types. If you want to override these, you can declare a
high-priority instance (perhaps localised) of has_variable_names
. E.g. to
change the names given to natural numbers:
def foo : has_variable_names ℕ :=
⟨[`i, `j, `k]⟩
local attribute [instance, priority 1000] foo
```
Type class for associating a type α
with typical variable names for elements
of α
. See tactic.typical_variable_names
.
Instances of this typeclass
- d_array.has_variable_names
- bool.has_variable_names
- char.has_variable_names
- fin.has_variable_names
- int.has_variable_names
- list.has_variable_names
- nat.has_variable_names
- Prop.has_variable_names
- thunk.has_variable_names
- prod.has_variable_names
- pprod.has_variable_names
- sigma.has_variable_names
- psigma.has_variable_names
- subtype.has_variable_names
- option.has_variable_names
- bin_tree.has_variable_names
- rbtree.has_variable_names
- native.rb_set.has_variable_names
- set.has_variable_names
- string.has_variable_names
- unsigned.has_variable_names
- pi.has_variable_names
- name.has_variable_names
- tactic.has_variable_names
- expr.has_variable_names
- pexpr.has_variable_names
- level.has_variable_names
- binder_info.has_variable_names
Instances of other typeclasses for has_variable_names
- has_variable_names.has_sizeof_inst
@make_listlike_instance α _ β
creates an instance has_variable_names β
from
an instance has_variable_names α
. If α
has associated names a
, b
, ...,
the generated instance for β
has names as
, bs
, ... This can be used to
create instances for 'containers' such as lists or sets.
Equations
- has_variable_names.make_listlike_instance α = {names := list.map (λ (n : name), n.append_suffix "s") (has_variable_names.names α), names_nonempty := _}
@make_inheriting_instance α _ β
creates an instance has_variable_names β
from an instance has_variable_names α
. The generated instance contains the
same variable names as that of α
. This can be used to create instances for
'wrapper' types like option
and subtype
.
Equations
- has_variable_names.make_inheriting_instance α = {names := has_variable_names.names α _inst_1, names_nonempty := _}
Equations
- bool.has_variable_names = {names := [name.mk_string "b" name.anonymous], names_nonempty := bool.has_variable_names._proof_1}
Equations
- char.has_variable_names = {names := [name.mk_string "c" name.anonymous], names_nonempty := char.has_variable_names._proof_1}
Equations
- fin.has_variable_names = {names := [name.mk_string "n" name.anonymous, name.mk_string "m" name.anonymous, name.mk_string "o" name.anonymous], names_nonempty := fin.has_variable_names._proof_1}
Equations
- int.has_variable_names = {names := [name.mk_string "n" name.anonymous, name.mk_string "m" name.anonymous, name.mk_string "o" name.anonymous], names_nonempty := int.has_variable_names._proof_1}
Equations
- nat.has_variable_names = {names := [name.mk_string "n" name.anonymous, name.mk_string "m" name.anonymous, name.mk_string "o" name.anonymous], names_nonempty := nat.has_variable_names._proof_1}
Equations
- Prop.has_variable_names = {names := [name.mk_string "P" name.anonymous, name.mk_string "Q" name.anonymous, name.mk_string "R" name.anonymous], names_nonempty := Prop.has_variable_names._proof_1}
Equations
- prod.has_variable_names = {names := [name.mk_string "p" name.anonymous], names_nonempty := prod.has_variable_names._proof_1}
Equations
- pprod.has_variable_names = {names := [name.mk_string "p" name.anonymous], names_nonempty := pprod.has_variable_names._proof_1}
Equations
- sigma.has_variable_names = {names := [name.mk_string "p" name.anonymous], names_nonempty := sigma.has_variable_names._proof_1}
Equations
- psigma.has_variable_names = {names := [name.mk_string "p" name.anonymous], names_nonempty := psigma.has_variable_names._proof_1}
Equations
- bin_tree.has_variable_names = {names := [name.mk_string "t" name.anonymous], names_nonempty := bin_tree.has_variable_names._proof_1}
Equations
- string.has_variable_names = {names := [name.mk_string "s" name.anonymous], names_nonempty := string.has_variable_names._proof_1}
Equations
- unsigned.has_variable_names = {names := [name.mk_string "n" name.anonymous, name.mk_string "m" name.anonymous, name.mk_string "o" name.anonymous], names_nonempty := unsigned.has_variable_names._proof_1}
Equations
- pi.has_variable_names = {names := [name.mk_string "f" name.anonymous, name.mk_string "g" name.anonymous, name.mk_string "h" name.anonymous], names_nonempty := pi.has_variable_names._proof_1}
Equations
- name.has_variable_names = {names := [name.mk_string "n" name.anonymous], names_nonempty := name.has_variable_names._proof_1}
Equations
- binder_info.has_variable_names = {names := [name.mk_string "bi" name.anonymous], names_nonempty := binder_info.has_variable_names._proof_1}