Martin Escardo & Tom de Jong, July 2023.

Some constructions with iterative sets.

 * The type of iterative sets is large.

 * The type of iterative sets is algebraically injective.

\begin{code}

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

open import MLTT.Spartan
open import UF.Univalence

module Iterative.Sets-Addendum
        (ua : Univalence)
        (๐“ค : Universe)
       where

open import Iterative.Multisets ๐“ค
open import Iterative.Multisets-Addendum ua ๐“ค
open import Iterative.Sets ua ๐“ค
open import UF.ClassicalLogic
open import UF.FunExt
open import UF.PropTrunc
open import UF.Size
open import UF.Subsingletons-FunExt
open import UF.UA-FunExt
open import W.Type

private
 ๐“คโบ : Universe
 ๐“คโบ = ๐“ค โบ

 fe : Fun-Ext
 fe = Univalence-gives-Fun-Ext ua

 fe' : FunExt
 fe' ๐“ค ๐“ฅ = fe {๐“ค} {๐“ฅ}

open import Taboos.Decomposability fe'

๐Ÿ˜โฑฝ : ๐•
๐Ÿ˜โฑฝ = ๐Ÿ˜แดน , ๐Ÿ˜แดน-is-iset

๐Ÿ™โฑฝ : ๐•
๐Ÿ™โฑฝ = ๐Ÿ™แดน , ๐Ÿ™แดน-is-iset

๐Ÿ˜โฑฝ-is-not-๐Ÿ™โฑฝ : ๐Ÿ˜โฑฝ โ‰  ๐Ÿ™โฑฝ
๐Ÿ˜โฑฝ-is-not-๐Ÿ™โฑฝ p = ๐Ÿ˜แดน-is-not-๐Ÿ™แดน (ap underlying-mset p)

\end{code}

Subsets.

\begin{code}

open import UF.Equiv
open import UF.Embeddings
open import UF.Subsingletons
open import UF.SubtypeClassifier

๐•-separation : (A : ๐•) (P : ๐• โ†’ ฮฉ ๐“ค)
             โ†’ ฮฃ A' ๊ž‰ ๐• , ((B : ๐•) โ†’ (B โˆˆ A') โ†” (B โˆˆ A ร— P B holds))
๐•-separation A@(ssup X ฯ† , ฯ†-emb , ฯ†-iter) P = A' , Q
 where
  A' : ๐•
  A' = (ssup (ฮฃ x ๊ž‰ X , P (ฯ† x , ฯ†-iter x) holds) (ฮป (x , p) โ†’ ฯ† x)) ,
       โˆ˜-is-embedding
        (prโ‚-is-embedding (ฮป x โ†’ holds-is-prop (P (ฯ† x , ฯ†-iter x))))
        ฯ†-emb ,
       (ฮป (x , p) โ†’ ฯ†-iter x)

  Qโ†’ : (B : ๐•) โ†’ B โˆˆ A' โ†’ B โˆˆ A ร— P B holds
  Qโ†’ B ((x , p) , refl) =
   (x , refl) , transport (_holds โˆ˜ P) (to-subtype-๏ผ being-iset-is-prop refl) p

  Qโ† : (B : ๐•) โ†’ B โˆˆ A ร— P B holds โ†’ B โˆˆ A'
  Qโ† B ((x , refl) , p) =
   (x , transport (_holds โˆ˜ P) (to-subtype-๏ผ being-iset-is-prop refl) p) , refl

  Q : (B : ๐•) โ†’ B โˆˆ A' โ†” (B โˆˆ A ร— P B holds)
  Q B = Qโ†’ B ,  Qโ† B

subset : ๐• โ†’ (P : ๐• โ†’ ฮฉ ๐“ค) โ†’ ๐•
subset A P = prโ‚ (๐•-separation A P)

subset-โ†” : (A : ๐•) (P : ๐• โ†’ ฮฉ ๐“ค)
         โ†’ (B : ๐•) โ†’ (B โˆˆ subset A P) โ†” (B โˆˆ A ร— P B holds)
subset-โ†” A P = prโ‚‚ (๐•-separation A P)

\end{code}

The type of multisets is large, in the sense that it doesn' have a
small copy.

\begin{code}

๐•-is-large : is-large ๐•
๐•-is-large (X , ๐•—) = III
 where
  have-๐•— : X โ‰ƒ ๐•
  have-๐•— = ๐•—

  private
   remark-X : ๐“ค ฬ‡
   remark-X = X

   remark-๐• : ๐“คโบ ฬ‡
   remark-๐• = ๐•

  A : ๐•
  A = ๐•-ssup X โŒœ ๐•— โŒ (equivs-are-embeddings' ๐•—)

  A-universal : (B : ๐•) โ†’ B โˆˆ A
  A-universal B = โŒœ ๐•— โŒโปยน B , ap underlying-mset (inverses-are-sections' ๐•— B)

  P : (B : ๐•) โ†’ ฮฉ ๐“ค
  P B = ยฌ (B โˆˆโป B) , negations-are-props fe

  R : ๐•
  R = subset A P

  g : (B : ๐•) โ†’ (B โˆˆ R) โ†” (B โˆˆ A ร— ยฌ (B โˆˆโป B))
  g = subset-โ†” A P

  h : (R โˆˆ R) โ‰ƒ (R โˆˆโป R)
  h = โˆˆโปโ‰ƒโˆˆ R R

  I : R โˆˆโป R โ†’ ยฌ (R โˆˆโป R)
  I i = prโ‚‚ (lr-implication (g R) (โŒœ h โŒโปยน i))

  II : ยฌ (R โˆˆโป R) โ†’ R โˆˆโป R
  II ฮฝ = โŒœ h โŒ (rl-implication (g R) (A-universal R , ฮฝ))

  III : ๐Ÿ˜
  III = not-equivalent-to-own-negation (I , II)

\end{code}

The type of iterative sets is algebraically injective, which is a new
result.

\begin{code}

open import InjectiveTypes.Blackboard fe'

module _ (pt : propositional-truncations-exist)
         (sr : Set-Replacement pt)
       where

 ๐•-is-ainjective : ainjective-type ๐• ๐“ค ๐“ค
 ๐•-is-ainjective = retract-of-ainjective ๐• ๐•„ ๐•„-is-ainjective ๐•-is-retract-of-๐•„
  where
   open unions-of-iterative-sets pt sr

\end{code}

It follows that ๐• has no non-trivial decidable properties unless weak
excluded middle holds.

\begin{code}

 decomposition-of-๐•-gives-WEM : decomposition ๐• โ†’ typal-WEM ๐“ค
 decomposition-of-๐•-gives-WEM =
  decomposition-of-ainjective-type-gives-WEM
   (univalence-gives-propext (ua ๐“ค))
   ๐•
   ๐•-is-ainjective

\end{code}

The results of this file seem to be new.