Linters about type classes
This file defines several linters checking the correct usage of type classes and the appropriate definition of instances:
instance_priority
ensures that blanket instances have low priorityhas_inhabited_instances
checks that every type has aninhabited
instanceimpossible_instance
checks that there are no instances which can never applyincorrect_type_class_argument
checks that only type classes are used in instance-implicit argumentsdangerous_instance
checks for instances that generate subproblems with metavariablesfails_quickly
checks that type class resolution finishes quicklyhas_coe_variable
checks that there is no instance of typehas_coe α t
inhabited_nonempty
checks whether[inhabited α]
arguments could be generalized to[nonempty α]
decidable_classical
checks propositions for[decidable_... p]
hypotheses that are not used in the statement, and could thus be removed by usingclassical
in the proof.
Pretty prints a list of arguments of a declaration. Assumes l
is a list of argument positions
and binders (or any other element that can be pretty printed).
l
can be obtained e.g. by applying list.indexes_values
to a list obtained by
get_pi_binders
.
A linter object for checking instance priorities of instances that always apply. This is in the default linter set.
A linter object for incorrect_type_class_argument
.
Applies expression e
to local constants, but lifts all the arguments that are Sort
-valued to
Type
-valued sorts.
Tests whether type-class inference search for a class will end quickly when applied to
variables. This tactic succeeds if mk_instance
succeeds quickly or fails quickly with the error
message that it cannot find an instance. It fails if the tactic takes too long, or if any other
error message is raised.
We make sure that we apply the tactic to variables living in Type u
instead of Sort u
,
because many instances only apply in that special case, and we do want to catch those loops.
A linter object for fails_quickly
. If we want to increase the maximum number of steps
type-class inference is allowed to take, we can increase the number 3000
in the definition.
As of 5 Mar 2020 the longest trace (for is_add_hom
) takes 2900-3000 "heartbeats".
Linter that checks whether has_coe_to_fun
instances comply with Note [function coercion].