Linters about type classes
This file defines several linters checking the correct usage of type classes and the appropriate definition of instances:
instance_priorityensures that blanket instances have low priorityhas_inhabited_instanceschecks that every type has aninhabitedinstanceimpossible_instancechecks that there are no instances which can never applyincorrect_type_class_argumentchecks that only type classes are used in instance-implicit argumentsdangerous_instancechecks for instances that generate subproblems with metavariablesfails_quicklychecks that type class resolution finishes quicklyhas_coe_variablechecks that there is no instance of typehas_coe α tinhabited_nonemptychecks whether[inhabited α]arguments could be generalized to[nonempty α]decidable_classicalchecks propositions for[decidable_... p]hypotheses that are not used in the statement, and could thus be removed by usingclassicalin 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].