InjectiveTypes.Structure
Martin Escardo, 13th June 2025 We repackage the definitions of algebraic injective and flabby types in a more convenient way, which we refer to as injective structure and flabby structure. We also prove some useful lemmas about them.{-# OPTIONS --safe --without-K --lossy-unification #-} open import MLTT.Spartan module InjectiveTypes.Structure {π¦ : Universe} (D : π¦ Μ ) where open import UF.Embeddings open import UF.SubtypeClassifier flabby-structure : (π€ : Universe) β π€ βΊ β π¦ Μ flabby-structure π€ = Ξ£ β¨ κ ((P : Ξ© π€) β (P holds β D) β D) , ((P : Ξ© π€) (f : P holds β D) (p : P holds) β β¨ P f οΌ f p) injective-structure : (π€ π₯ : Universe) β π€ βΊ β π₯ βΊ β π¦ Μ injective-structure π€ π₯ = Ξ£ _β£_ κ ({X : π€ Μ } {Y : π₯ Μ } β (X β D) β (X βͺ Y) β (Y β D)) , ({X : π€ Μ } {Y : π₯ Μ } (f : X β D) (π : X βͺ Y) β (f β£ π) β β π β βΌ f) derived-injective-structure : flabby-structure (π€ β π₯) β injective-structure π€ π₯ derived-injective-structure {π€} {π₯} (β¨ , e) = _β£_ , e' where _β£_ : {X : π€ Μ } {Y : π₯ Μ } β (X β D) β (X βͺ Y) β (Y β D) (f β£ π) y = β¨ (Fiber π y) (f β fiber-point) e' : {X : π€ Μ } {Y : π₯ Μ } (f : X β D) (π : X βͺ Y) β (f β£ π) β β π β βΌ f e' f π x = e (Fiber π (β π β x)) (f β fiber-point) (x , refl) derived-flabby-structure : injective-structure π€ π₯ β flabby-structure π€ derived-flabby-structure {π€} (_β£_ , e) = β¨ , e' where β¨ : (P : Ξ© π€) β (P holds β D) β D β¨ P f = (f β£ embedding-to-π) β e' : (P : Ξ© π€) (f : P holds β D) (p : P holds) β β¨ P f οΌ f p e' P f = e f embedding-to-πWe had already given (in InjectiveTypes.BlackBoard) conversions between ainjective types and a flabby types. We now record that the ones we gave here agree definitionally with those there, via the "repackaging" equivalences gives below. Unfortunately, InjectiveTypes has a global assumption of function extensionality, which is not used for the definitions of algebraic injective and flabby structure. Fortunately, we don't need to use the proofs below (particularly because they are proved with refl), which are here only for the purpose of emphasizing that we are working with the same definitions repackaged in a different way.open import UF.FunExt open import UF.Equiv module _ (fe : FunExt) where open import InjectiveTypes.Blackboard fe ainjective-type-repackaging : injective-structure π€ π₯ β ainjective-type D π€ π₯ ainjective-type-repackaging = qinveq (Ξ» (_β£_ , e) β Ξ» {X} {Y} j i f β (f β£ (j , i)) , e f (j , i)) ((Ξ» ainj β (Ξ» {X} {Y} f π β prβ (ainj β π β β π β-is-embedding f)) , (Ξ» {X} {Y} f π β prβ (ainj β π β β π β-is-embedding f))) , (Ξ» _ β refl) , (Ξ» _ β refl)) aflabby-repackaging : flabby-structure π€ β aflabby D π€ aflabby-repackaging = qinveq (Ξ» (β¨ , e) P i f β β¨ (P , i) f , e (P , i) f) ((Ξ» aflab β (Ξ» P f β prβ (aflab (P holds) (holds-is-prop P) f)) , (Ξ» P f β prβ (aflab (P holds) (holds-is-prop P) f))) , (Ξ» _ β refl) , (Ξ» _ β refl))TODO. Write the commutative squares corresponding to the following two proofs as a comment.derived-flabby-structure-agreement : (s : injective-structure π€ π₯) β β aflabby-repackaging β (derived-flabby-structure s) οΌ ainjective-types-are-aflabby D (β ainjective-type-repackaging β s) derived-flabby-structure-agreement s = reflFor the second one we need to do a manual eta expasion to deal with the way Agda works with implicit arguments, which gives unsolved constraints otherwise (this is a well known design issue).derived-injective-structure-agreement : (s : flabby-structure π€) β (Ξ» {X Y : π€ Μ} (j : X β Y) β β ainjective-type-repackaging β (derived-injective-structure s) {X} {Y} j) οΌ aflabby-types-are-ainjective D (β aflabby-repackaging β s) derived-injective-structure-agreement s = reflWe can change variables in β¨ in the following sense. Notice that there is a similar fact proved with the stronger assumption of univalence in the development of the lifting monad. But propositional and functional extensionality are enough.open import UF.Subsingletons module _ (pe : propext π€) (fe : funext π€ π€) (β¨ : (P : Ξ© π€) β (P holds β D) β D) {P Q : Ξ© π€} (f : P holds β D) where β¨-change-of-variable : ((g , h) : (P holds) β Q holds) β β¨ P f οΌ β¨ Q (f β h) β¨-change-of-variable (g , h) = IV where h' : (e : P οΌ Q) β Q holds β P holds h' e = β idtoeq _ _ (ap _holds e) ββ»ΒΉ I : (e : P οΌ Q) β h' e οΌ h I e = dfunext fe (Ξ» p β holds-is-prop P (h' e p) (h p)) II : (e : P οΌ Q) β β¨ P f οΌ β¨ Q (f β h' e) II refl = refl e : P οΌ Q e = Ξ©-extensionality pe fe g h III : β¨ P f οΌ β¨ Q (f β h' e) III = II e IV : β¨ P f οΌ β¨ Q (f β h) IV = transport (Ξ» - β β¨ P f οΌ β¨ Q (f β -)) (I e) III β¨-change-of-variable-β : (π : (P holds) β Q holds) β β¨ P f οΌ β¨ Q (f β β π ββ»ΒΉ) β¨-change-of-variable-β π = β¨-change-of-variable (β π β , β π ββ»ΒΉ)TODO. The above just be placed in a better home, as it is not specific to what we are doing here. We give names to the projections.injective-extension-operator : injective-structure π€ π₯ β {X : π€ Μ } {Y : π₯ Μ } β (X β D) β (X βͺ Y) β (Y β D) injective-extension-operator (_β£_ , e) = _β£_ injective-identification : ((_β£_ , e) : injective-structure π€ π₯) β {X : π€ Μ } {Y : π₯ Μ } (f : X β D) (π : X βͺ Y) β (f β£ π) β β π β βΌ f injective-identification (_β£_ , e) = e flabby-extension-operator : flabby-structure π€ β (P : Ξ© π€) β (P holds β D) β D flabby-extension-operator (β¨ , h) = β¨ flabby-identification : ((β¨ , e) : flabby-structure π€) β (P : Ξ© π€) (f : P holds β D) (p : P holds) β β¨ P f οΌ f p flabby-identification (_β£_ , e) = e\end{code} Maybe we should have worked with the following equivalent derived injective structure, as this would have avoided some detours in proofs in the module InjectiveTypes.Algebra.module _ {π€ π₯ : Universe} (s@(β¨ , e) : flabby-structure (π€ β π₯)) where private module _ {X : π€ Μ } {Y : π₯ Μ } (π : X βͺ Y) (y : Y) where k : fiber β π β y β π k = unique-to-π {π€ β π₯} {π€ β π₯} g : fiber β π β y β fiber k β g w = w , refl h : fiber k β β fiber β π β y h = prβ derived-injective-structure' : injective-structure π€ π₯ derived-injective-structure' = _β£_ , e' where _β£_ : {X : π€ Μ } {Y : π₯ Μ } β (X β D) β (X βͺ Y) β (Y β D) (f β£ π) y = β¨ (Fiber (fiber-to-π π y) β) (f β fiber-point β h π y) e' : {X : π€ Μ } {Y : π₯ Μ } (f : X β D) (π : X βͺ Y) β (f β£ π) β β π β βΌ f e' f π x = e (Fiber (fiber-to-π π (β π β x)) β) (f β fiber-point β h π (β π β x)) ((x , refl) , refl) private _β£_ _β£'_ : {X : π€ Μ } {Y : π₯ Μ } β (X β D) β (X βͺ Y) β (Y β D) _β£_ = injective-extension-operator (derived-injective-structure s) _β£'_ = injective-extension-operator derived-injective-structure'The agreement of these two extension operators is a direct application of change of variables in β¨, defined above.derived-injective-structure-operator-lemma : propext (π€ β π₯) β funext (π€ β π₯) (π€ β π₯) β {X : π€ Μ } {Y : π₯ Μ } (f : X β D) (π : X βͺ Y) β f β£ π βΌ f β£' π derived-injective-structure-operator-lemma pe fe f π y = (f β£ π) y οΌβ¨reflβ© β¨ (Fiber π y) (f β fiber-point) οΌβ¨ I β© β¨ (Fiber (fiber-to-π π y) β) (f β fiber-point β h π y) οΌβ¨reflβ© (f β£' π) y β where I = β¨-change-of-variable pe fe β¨ (f β fiber-point) (g π y , h π y)