Given lifted kernels lhs rhs and morphisms lh rh with proofs pl : lh = lhs.hom and
pr : rh = rhs.hom, construct a proof of (lhs = rhs) = (lh = rh).
9.Β Implementation of the translation
The translation performed by kernel_hom traverses the kernel expression twice (once to lift it to a common universe level, once to translate it into SFinKer) and builds, at each node, an instance of a translation lemma such as comp_hom or comp_lift. Two design choices keep this cheap.
9.1.Β Proofs by congruence
The proof of equivalence between the original equality and the translated one is not obtained by rewriting the goal with the translation lemmas (which requires abstracting a pattern and type-checking a motive at each step), but by congruence: each translation function returns the translated expression together with a proof that it is the translation of the original one, built from the proofs of its subterms with mkCongr, mkCongrArg and mkEqTrans. The equality of propositions is then obtained from hom_congr (or lift_congr) and propext, see mkHomCongrProof.
9.2.Β Explicit constructors and memoization
The terms and lemma instances are built directly with mkAppN, with explicit universe levels and instances, instead of mkAppM, whose unification and instance synthesis dominated the cost of the translation. This requires a fixed order of the universe parameters of the translation lemmas, which is why the universes of KernelHom.Kernel.Hom are declared explicitly (x y t z u xβ yβ zβ).
The instances (MeasurableSpace X, IsSFiniteKernel ΞΊ, the category-theoretic instances of SFinKer, ...), the inferred types of kernels and the recursively built objects (measurable equivalences, objects of SFinKer) are memoized in a cache which is reset at the beginning of each transformation. The cache lives in Eq-Lift:
The cache of the lifting/unlifting transformations.
Constructor
TransformCache.mk
Fields
insts : Std.HashMap Lean.Expr Lean.Expr
Synthesized instances, keyed by the class application.
types : Std.HashMap Lean.Expr Lean.Expr
Inferred types, keyed by the expression.
memo : Std.HashMap (Lean.Name Γ Lean.Expr) (Array Lean.Expr)
Memoized computations, keyed by a tag and an expression.
Empties the cache. To be called at the beginning of each transformation.
synthInstance with memoization.
inferType with memoization.
9.3.Β Carriers
A measurable space is represented during the transformations by its carrier type and universe level, from which the MeasurableSpace instance is obtained through the cache.
A measurable space: the carrier type and its universe level.
Constructor
Carrier.mk
Fields
type : Lean.Expr
The carrier type.
lvl : Lean.Level
The universe level of the carrier type.
The MeasurableSpace instance of a carrier (cached).
Extract the source and target carriers of a kernel.
constructMeasurableEquiv (e : Lean.Expr) (eLevel maxLvl : Lean.Level) : Lean.MetaM (Lean.Expr Γ Lean.Expr)constructMeasurableEquiv (e : Lean.Expr) (eLevel maxLvl : Lean.Level) : Lean.MetaM (Lean.Expr Γ Lean.Expr)
Build the measurable equivalence X' βα΅ X between the lift X' of e to the universe
maxLvl and e itself, recursively on products. Returns the equivalence and X'.
The translation to SFinKer needs more data about each carrier X: the object of SFinKer it is translated to (SFinKer.of X, or a tensor product of such objects when X is a product, so that the monoidal tactics see the tensor structure) and the measurable equivalence between the carrier of this object and X, which is the argument ex of hom and of the translation lemmas. These are computed once per carrier by computeSFinkerOf and idME, and gathered in a HomCarrier.
A carrier X together with its MeasurableSpace instance, its object obj in SFinKer and
the measurable equivalence equiv : obj βα΅ X.
Constructor
HomCarrier.mk
Extends
The IsSFiniteKernel instance of ΞΊ : Kernel X Y (cached).
Compute the SFinKer object corresponding to a measurable space X : Type xLvl, decomposing
products into tensor products and PUnit into the monoidal unit (memoized).
The measurable equivalence X βα΅ X, built recursively on products so that it matches the
decomposition of computeSFinkerOf (memoized).
Finally, every morphism built during the translation (β«, ββ, whiskers, π, Ξ΅, Ξ, braiding) takes as implicit arguments the category-theoretic instances of SFinKer (Category, MonoidalCategory, ...). Since the constructors are explicit, these instances have to be provided, and they are synthesized once per universe level and gathered in a SFinKerInsts, which also provides the constructors of the morphisms.
The category-theoretic instances of SFinKer.{u}.
Constructor
SFinKerInsts.mk
Fields
u : Lean.Level
The universe level.
C : Lean.Expr
SFinKer.{u}.
cat : Lean.Expr
Category SFinKer.
catStruct : Lean.Expr
CategoryStruct SFinKer.
monoidal : Lean.Expr
MonoidalCategory SFinKer.
monStruct : Lean.Expr
MonoidalCategoryStruct SFinKer.
The category-theoretic instances of SFinKer.{u} (cached).