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.
\begin{code}
{-# 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-๐
\end{code}
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.
\begin{code}
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))
\end{code}
TODO. Write the commutative squares corresponding to the following two
proofs as a comment.
\begin{code}
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 = refl
\end{code}
For 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).
\begin{code}
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 = refl
\end{code}
We 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.
\begin{code}
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 (โ ๐ โ , โ ๐ โโปยน)
\end{code}
We give names to the projections.
\begin{code}
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}
\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.
\begin{code}
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'
\end{code}
The agreement of these two extension operators is a direct application
of change of variables in โจ, defined above.
\begin{code}
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)
\end{code}