The Mathlib Handbook

The volumes of the handbook are not written yet. This site shows the map of Mathlib that they will follow, at Mathlib 4472534b60.

The areas / V34. The tactics of Mathlib

Mathlib.Tactic.FastInstance

3 declarations. Mathlib docs · Source

The fast_instance% and inferInstanceAs% term elaborators

def Mathlib.Elab.FastInstance.fastInstance E1 #

Lean.ParserDescr

fast_instance% inst takes an expression for a typeclass instance inst, and unfolds it into constructor applications that leverage existing instances. It uses the expected type to fill in the constructor applications and lambda binders of data fields.

For instance, when used as

instance instSemiring : Semiring X := sorry
instance instRing : Ring X := fast_instance% Function.Injective.ring ..

this will define instRing as a nested constructor application that refers to instSemiring rather than applications of Function.Injective.ring or other non-canonical constructors. The advantage is then that instRing.toSemiring unifies almost immediately with instSemiring, rather than having to break it down into smaller pieces.

def Mathlib.Elab.FastInstance.elabFastInstance E1 #

Lean.Elab.Term.TermElab

fast_instance% inst takes an expression for a typeclass instance inst, and unfolds it into constructor applications that leverage existing instances. It uses the expected type to fill in the constructor applications and lambda binders of data fields.

For instance, when used as

instance instSemiring : Semiring X := sorry
instance instRing : Ring X := fast_instance% Function.Injective.ring ..

this will define instRing as a nested constructor application that refers to instSemiring rather than applications of Function.Injective.ring or other non-canonical constructors. The advantage is then that instRing.toSemiring unifies almost immediately with instSemiring, rather than having to break it down into smaller pieces.

def Mathlib.Elab.FastInstance.«termInferInstanceAs%_» E1 #

Lean.ParserDescr

inferInstanceAs% A is shorthand for fast_instance% _root_.inferInstanceAs A. This is preferred over _root_.inferInstanceAs when the instance can be reduced to constructor applications. In that case, the parameters of the constructors will be filled in using the expected type, so that the instance will unfold nicely during unification.