Martin Escardo, 23 June 2025.

The following paper has a notion of flabbiness in the internal
language of a 1-topos.

[1] Ingo Blechschmidt (2018). Flabby and injective objects in toposes.
    https://arxiv.org/abs/1810.12708

    More recent version at
    https://www.speicherleck.de/iblech/stuff/paper-flabby-objects.pdf

This definition of flabbiness uses the two notions of "subterminal"
and "subsingleton" subsets, as defined in e.g.

[2] Kock, A. (1991). Algebras for the partial map classifier
    monad. In: Carboni, A., Pedicchio, M.C., Rosolini, G. (eds)
    Category Theory. Lecture Notes in Mathematics, vol 1488. Springer,
    Berlin, Heidelberg. https://doi.org/10.1007/BFb0084225

We show that the notion of flabbiness defined in [1] coincides with
ours for types that are sets, or 1-types, in the sense of HoTT/UF.

*Terminological warning.* Sometimes we use, in names of functions, and
in discussions, the word "set" to refer to "subset", to e.g. avoid
awkward names such as "is-subterminal-subset".

\begin{code}

{-# OPTIONS --safe --without-K #-}

open import UF.FunExt

module InjectiveTypes.AlternativeFlabbiness
        (fe : Fun-Ext)
       where

open import InjectiveTypes.Blackboard
open import InjectiveTypes.Structure
open import MLTT.Spartan
open import UF.Embeddings
open import UF.Equiv
open import UF.Powerset
open import UF.PropTrunc
open import UF.Sets
open import UF.Subsingletons
open import UF.Subsingletons-FunExt
open import UF.SubtypeClassifier

\end{code}

The references [1] and [2] work with the following two concepts, in
the internal language of an elementary 1-topos.

(1) A set K : ๐“Ÿ X is *subterminal* if and only if any two elements of
    K are equal.

(2) A set K : ๐“Ÿ X is a *subsingleton* if there is xโ‚€ : X with K โІ {xโ‚€}.

In our more general setting of HoTT/UF, which can be considered as an
internal language for โˆž-toposes, the singleton {xโ‚€} can be formed if X
is a set, or 1-type, in the sense of HoTT/UF (and if and only if xโ‚€ is
homotopy isolated, meaning that the equality xโ‚€ = x is a proposition
for every x : X).

But K โІ {xโ‚€}, in their setting, amounts to the implication
x โˆˆ K โ†’ x ๏ผ xโ‚€, and so that we can circumvent this obstacle.

(2') A set K : ๐“Ÿ X is a *subsingleton* if there is xโ‚€ : X such that
     x โˆˆ K implies x ๏ผ xโ‚€ for all x : X.

In the setting of [1] and [2], conditions (2) and (2') are equivalent,
but only (2') makes sense in our setting for an arbitrary type X,
which is what we adopt below.

However, in any case, we will eventually need to assume that X is a
1-type, as the internal definition of flabbiness given in [1] is
tailored for 1-toposes.

We have that (1) is property if X is a set, and that the above
reformulation (2') of (2) is always property.

To begin with, we will work with the following notion, which is data
rather than property.

(3) *Subsingleton data* for a set K : ๐“Ÿ X consists of a designated point
     xโ‚€ : X such that x โˆˆ K implies x = xโ‚€ for all x : X.

The difference between (2) and (3) is that in (2) the point xโ‚€ merely
exists, but in (3) it is part of the data.

We begin by formally discussing (1) and (3), leaving (2) for later.

\begin{code}

module _ {X : ๐“ค ฬ‡ } (K : ๐“Ÿ X) where

 subterminal-set : ๐“ค ฬ‡
 subterminal-set = (x y : X) โ†’ x โˆˆ K โ†’ y โˆˆ K โ†’ x ๏ผ y

\end{code}

Notice that the above is strictly speaking data unless X is a set.

\begin{code}

 being-subterminal-set-is-prop
  : is-set X
  โ†’ is-prop subterminal-set
 being-subterminal-set-is-prop X-is-set
  = ฮ โ‚„-is-prop fe (ฮป _ _ _ _ โ†’ X-is-set)

 subsingleton-set-data : ๐“ค ฬ‡
 subsingleton-set-data = ฮฃ xโ‚€ ๊ž‰ X , ((x : X) โ†’ x โˆˆ K โ†’ x ๏ผ xโ‚€)

\end{code}

As observed in [1], subsingleton sets are subterminal. We also have
the following, replacing the subsigleton property by subsingleton
data.

\begin{code}

 sets-with-subsingleton-data-are-subterminal
  : subsingleton-set-data
  โ†’ subterminal-set
 sets-with-subsingleton-data-are-subterminal (xโ‚€ , ฯ•) x y i j
  = x  ๏ผโŸจ ฯ• x i โŸฉ
    xโ‚€ ๏ผโŸจ (ฯ• y j)โปยน โŸฉ
    y  โˆŽ

\end{code}

The following is the internal definition of functional flabbiness
proposed in [1], as a converse of the above fact.

We make the converse construction, which isn't always possible, into
an alternative definition of flabby structure. This appears in [1]
under the name "functionally flabby".

\begin{code}

functionally-flabby : ๐“ค ฬ‡ โ†’ ๐“ค โบ ฬ‡
functionally-flabby X = (K : ๐“Ÿ X)
                      โ†’ subterminal-set K
                      โ†’ subsingleton-set-data K

\end{code}

The following two observations are not used directly in our
discussion, but may be enlightening. They say that the total space
๐•‹ K := ฮฃ x ๊ž‰ X , x โˆˆ K of the subset K of X is a proposition, assuming
that K is subterminal, and, in particular, that it is equipped with
subsingleton data.

\begin{code}

module _ {X : ๐“ค ฬ‡ } (K : ๐“Ÿ X) where

 subterminals-have-propositional-total-space
  : subterminal-set K
  โ†’ is-prop (๐•‹ K)
 subterminals-have-propositional-total-space s (x , m) (y , n)
  = to-subtype-๏ผ (โˆˆ-is-prop K) (s x y m n)

 types-with-subsubgleton-data-have-propositional-total-space
  : subsingleton-set-data K
  โ†’ is-prop (๐•‹ K)
 types-with-subsubgleton-data-have-propositional-total-space s
  = subterminals-have-propositional-total-space
     (sets-with-subsingleton-data-are-subterminal K s)

\end{code}

We define, in an imported module, flabby structure for a type X to be
a map โจ† : (P : ฮฉ) โ†’ (P โ†’ X) โ†’ X together with equality data โจ† P f = f p
for every p : P.

We now show that we can construct flabby structure from functional
flabbiness, and conversely.

The first direction requires X to be a 1-type, or set.

\begin{code}

module _ {X : ๐“ค ฬ‡ } where

 functionally-flabby-gives-flabby-structure
  : is-set X
  โ†’ functionally-flabby X
  โ†’ flabby-structure X ๐“ค
 functionally-flabby-gives-flabby-structure X-is-set a = โจ† , e
  where
   module _ (P : ฮฉ ๐“ค) (f : P holds โ†’ X) where

    K : ๐“Ÿ X
    K x = fiber f x ,
          maps-of-props-into-sets-are-embeddings f (holds-is-prop P) X-is-set x

    I : subterminal-set K
    I x y (p , d) (q , e) =
     x   ๏ผโŸจ d โปยน โŸฉ
     f p ๏ผโŸจ ap f (holds-is-prop P p q) โŸฉ
     f q ๏ผโŸจ e โŸฉ
     y   โˆŽ

    II : subsingleton-set-data K
    II = a K I

    โจ† : X
    โจ† = prโ‚ II

    _ : (x : X) โ†’ fiber f x โ†’ x ๏ผ โจ†
    _ = prโ‚‚ II

    e : (p : P holds) โ†’ โจ† ๏ผ f p
    e p = (prโ‚‚ II (f p) (p , refl))โปยน

\end{code}

The converse doesn't require X to be a 1-type.

\begin{code}

 flabby-structure-gives-functionally-flabby
  : flabby-structure X ๐“ค
  โ†’ functionally-flabby X
 flabby-structure-gives-functionally-flabby (โจ† , e) K K-subterminal = xโ‚€ , I
  where
   P : ฮฉ ๐“ค
   P = (ฮฃ x ๊ž‰ X , x โˆˆ K) ,
       (ฮป {(x , m) (y , n) โ†’ to-subtype-๏ผ
                              (โˆˆ-is-prop K)
                              (K-subterminal x y m n)})

   f : P holds โ†’ X
   f = prโ‚

   xโ‚€ : X
   xโ‚€ = โจ† P f

   I : (x : X) โ†’ x โˆˆ K โ†’ x ๏ผ xโ‚€
   I x m = (e P f (x , m))โปยน

\end{code}

We now discuss the truncated version.

We have already defined the notions (1) and (3) above, and it remains
to define the notion (2), which we call is-subsingleton-set. For that
purpose, we need to assume that propositional truncations exist, so
that we have the existential quantifier โˆƒ available.

\begin{code}

 module _ (pt : propositional-truncations-exist) where

  open PropositionalTruncation pt
  open injective (ฮป ๐“ค ๐“ฅ โ†’ fe {๐“ค} {๐“ฅ}) pt

  module _ (K : ๐“Ÿ X) where

   is-subsingleton-set : ๐“ค ฬ‡
   is-subsingleton-set = โˆƒ xโ‚€ ๊ž‰ X , ((x : X) โ†’ x โˆˆ K โ†’ x ๏ผ xโ‚€)

   being-subsingleton-set-is-prop : is-prop is-subsingleton-set
   being-subsingleton-set-is-prop = โˆƒ-is-prop

\end{code}

As observed in [1], subsingleton sets are subterminal. In our more
general setting, we need to assume that X is a 1-type to reach the
same conclusion.

\begin{code}

   subsingleton-sets-are-subterminal
    : is-set X
    โ†’ is-subsingleton-set
    โ†’ subterminal-set K
   subsingleton-sets-are-subterminal X-is-set =
    โˆฅโˆฅ-rec
     (being-subterminal-set-is-prop K X-is-set)
     (sets-with-subsingleton-data-are-subterminal K)

\end{code}

And the following is the internal definition of flabbiness proposed in [1],
as a converse of the above fact.

\begin{code}

  flabby' : ๐“ค โบ ฬ‡
  flabby' = (K : ๐“Ÿ X)
          โ†’ subterminal-set K
          โ†’ is-subsingleton-set K

\end{code}

In this repository we have our own internal definition of flabbiness
of a type X, called "flabby", which says that for every propositon P
and function f : P โ†’ X, there exists x : X such that x = f p
for all p : P.

We now show that this is equivalent to the definition given in [1],
where the first direction assumes that X is a set.

Notice that this is a logical equivalence, as stated, but also a typal
equivalence, as a consequence, because the two notions of flabbiness
are property, when X is a 1-type, or set.

\begin{code}

  flabby'-gives-flabby : is-set X โ†’ flabby' โ†’ flabby X ๐“ค
  flabby'-gives-flabby X-is-set ฯ•' P P-is-prop f = IV
   where
    K : ๐“Ÿ X
    K x = fiber f x ,
          maps-of-props-into-sets-are-embeddings f P-is-prop X-is-set x

    I : subterminal-set K
    I x y (p , d) (q , e) =
     x   ๏ผโŸจ d โปยน โŸฉ
     f p ๏ผโŸจ ap f (P-is-prop p q) โŸฉ
     f q ๏ผโŸจ e โŸฉ
     y   โˆŽ

    II : is-subsingleton-set K
    II = ฯ•' K I

    III : (ฮฃ xโ‚€ ๊ž‰ X , ((x : X) โ†’ x โˆˆ K โ†’ x ๏ผ xโ‚€))
        โ†’ (ฮฃ x ๊ž‰ X , ((p : P) โ†’ x ๏ผ f p))
    III (xโ‚€ , ฮฑ) = xโ‚€ , (ฮป p โ†’ (ฮฑ (f p) (p , refl))โปยน)

    IV : โˆƒ x ๊ž‰ X , ((p : P) โ†’ x ๏ผ f p)
    IV = โˆฅโˆฅ-functor III II

  flabby-gives-flabby' : flabby X ๐“ค โ†’ flabby'
  flabby-gives-flabby' ฯ• K K-subterminal = II
   where
    P : ฮฉ ๐“ค
    P = (ฮฃ x ๊ž‰ X , x โˆˆ K) ,
        (ฮป {(x , m) (y , n) โ†’ to-subtype-๏ผ
                               (โˆˆ-is-prop K)
                               (K-subterminal x y m n)})

    f : P holds โ†’ X
    f = prโ‚

    I : โˆƒ xโ‚€ ๊ž‰ X , ((p : P holds) โ†’ xโ‚€ ๏ผ prโ‚ p)
    I = ฯ• (P holds) (holds-is-prop P) f

    II : โˆƒ xโ‚€ ๊ž‰ X , ((x : X) โ†’ x โˆˆ K โ†’ x ๏ผ xโ‚€)
    II = โˆฅโˆฅ-functor (ฮป (xโ‚€ , e) โ†’ xโ‚€ , (ฮป x m โ†’ (e (x , m))โปยน)) I

\end{code}

So, at least for sets, this justifies our internal definition of
flabbiness used in this repository. Perhaps an โˆž-topos theorist can
chime in and discuss whether our proposed internal definition does
correspond to any external definition of flabbiness discussed in the
โˆž-topos literature.