Martin Escardo, 24-26 October 2023.

A type is called rigid if its only automorphism is the identity. In
HoTT/UF, we would instead say that its type of automorphisms is
contractible.

The type Ξ© is not rigid in boolean toposes, because in such toposes it
has precisely two automorphisms (the identity and negation).

But, in any topos, if there is an automorphism of Ξ© different from the
identity, then the topos is boolean.

\begin{code}

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

open import MLTT.Spartan
open import UF.ClassicalLogic
open import UF.Embeddings
open import UF.Equiv hiding (_β‰…_)
open import UF.Equiv-FunExt
open import UF.FunExt
open import UF.Subsingletons
open import UF.SubtypeClassifier hiding (Ξ©)
open import UF.SubtypeClassifier-Properties

module Higgs.Rigidity
        {𝓀 : Universe}
        (fe : Fun-Ext)
        (pe : propext 𝓀)
       where

open import Higgs.InvolutionTheorem fe pe

\end{code}

From the existence of certain automorphisms of Ξ©, we conclude that
excluded middle holds.

\begin{code}

Ξ©-automorphism-that-maps-⊀-to-βŠ₯-gives-EM
 : (Ξ£ 𝕗 κž‰ Aut Ξ© , ⌜ 𝕗 ⌝ ⊀ = βŠ₯)
 β†’ EM 𝓀
Ξ©-automorphism-that-maps-⊀-to-βŠ₯-gives-EM ((f , f-is-equiv) , e) = II
 where
  f-is-involutive : involutive f
  f-is-involutive = automorphisms-of-Ξ©-are-involutive f f-is-equiv

  I : (P : 𝓀 Μ‡ ) β†’ is-prop P β†’ Ξ£ Q κž‰ 𝓀 Μ‡ , (P ↔ Β¬ Q)
  I P P-is-prop = f p holds , g , h
   where
    p : Ξ©
    p = (P , P-is-prop)

    g : P β†’ Β¬ (f p holds)
    g p-holds = equal-βŠ₯-gives-fails (f p)
                 (f p =⟨ ap f (holds-gives-equal-⊀ pe fe p p-holds) ⟩
                  f ⊀ =⟨ e ⟩
                  βŠ₯   ∎)

    h : Β¬ (f p holds) β†’ P
    h ν = equal-⊀-gives-holds p
           (p       =⟨ (f-is-involutive p)⁻¹ ⟩
            f (f p) =⟨ ap f (fails-gives-equal-βŠ₯ pe fe (f p) Ξ½) ⟩
            f βŠ₯     =⟨ ap f (e ⁻¹) ⟩
            f (f ⊀) =⟨ f-is-involutive ⊀ ⟩
            ⊀       ∎)

  II : EM 𝓀
  II = all-props-negative-gives-EM fe I

Ξ©-automorphism-swap-≃ : (𝕗 : Aut Ξ©)
                      β†’ {p q : Ξ©}
                      β†’ (⌜ 𝕗 ⌝ p = q) ≃ (⌜ 𝕗 ⌝ q = p)
Ξ©-automorphism-swap-≃ 𝕗 {p} {q} =
 involution-swap-≃ ⌜ 𝕗 ⌝
  (automorphisms-of-Ξ©-are-involutive ⌜ 𝕗 ⌝ ⌜ 𝕗 ⌝-is-equiv)
  (Ξ©-is-set fe pe)

\end{code}

A stronger version of the following is proved below.

\begin{code}

Ξ©-automorphism-apart-from-id-gives-EM
 : (Ξ£ 𝕗 κž‰ Aut Ξ© , Ξ£ pβ‚€ κž‰ Ξ© , ⌜ 𝕗 ⌝ pβ‚€ β‰  pβ‚€)
 β†’ EM 𝓀
Ξ©-automorphism-apart-from-id-gives-EM (𝕗@(f , f-is-equiv) , pβ‚€ , Ξ½) = VIII
 where
  I : f ⊀ β‰  ⊀
  I e = VI
   where
    II : pβ‚€ β‰  ⊀
    II eβ‚€ = Ξ½ II'
     where
      II' : f pβ‚€ = pβ‚€
      II' = transport⁻¹ (Ξ» - β†’ f - = -) eβ‚€ e

    III : pβ‚€ = βŠ₯
    III = different-from-⊀-gives-equal-βŠ₯ fe pe pβ‚€ II

    IV : f βŠ₯ β‰  βŠ₯
    IV e₁ = Ξ½ IV'
     where
      IV' : f pβ‚€ = pβ‚€
      IV' = transport⁻¹ (Ξ» - β†’ f - = -) III e₁

    V : f βŠ₯ β‰  ⊀
    V eβ‚‚ = βŠ₯-is-not-⊀
            (βŠ₯       =⟨ (⌜ Ξ©-automorphism-swap-≃ 𝕗 ⌝ eβ‚‚)⁻¹ ⟩
             f ⊀     =⟨ e ⟩
             ⊀       ∎)

    VI : 𝟘
    VI = no-truth-values-other-than-βŠ₯-or-⊀ fe pe (f βŠ₯ , IV , V)

  VII : f ⊀ = βŠ₯
  VII = different-from-⊀-gives-equal-βŠ₯ fe pe (f ⊀) I

  VIII : EM 𝓀
  VIII = Ξ©-automorphism-that-maps-⊀-to-βŠ₯-gives-EM (𝕗 , VII)

\end{code}

Notice that we can replace "Ξ£" by "βˆƒ" in the above propositions, to
get the same conclusion EM 𝓀, because the type EM 𝓀 is a proposition.

Notice also that the converses of the above propositions hold.

We show that there can't be any automorphism of Ξ© distinct from the
identity unless excluded middle holds.

The fact eval-at-⊀-is-lc stated and proved below, which is our main
lemma, is attributed to Denis Higgs in the literature [1] [2], without
any explicit citation I could find, with diagrammatic proofs in topos
theory rather than proofs in the internal language of a topos. Our
internal proofs don't necessarily follow the external diagrammatic
proofs.

[1] Peter T. Johnstone. Automorphisms of Ξ©. Algebra Universalis,
    9 (1979) 1-7.
    https://doi.org/10.1007/BF02488012

[2] Peter Freyd. Choice and well-ordering.  Annals of Pure and Applied
    Logic 35 (1987) 149-166.
    https://doi.org/10.1016/0168-0072(87)90060-1
    https://core.ac.uk/download/pdf/81927529.pdf

\begin{code}

private
 fe' : FunExt
 fe' π“₯ 𝓦 = fe {π“₯} {𝓦}

eval-at-⊀ : Aut Ξ© β†’ Ξ©
eval-at-⊀ 𝕗 = ⌜ 𝕗 ⌝ ⊀

eval-at-⊀-is-lc : left-cancellable eval-at-⊀
eval-at-⊀-is-lc {𝕗@(f , _)} {π•˜@(g , _)} e = III
 where
  have-e : f ⊀ = g ⊀
  have-e = e

  I : (p : Ξ©) β†’ (f p = ⊀) ≃ (g p = ⊀)
  I p = (f p = ⊀) β‰ƒβŸ¨ Ξ©-automorphism-swap-≃ 𝕗 ⟩
        (f ⊀ = p) β‰ƒβŸ¨ transport-≃ (_= p) e ⟩
        (g ⊀ = p) β‰ƒβŸ¨ Ξ©-automorphism-swap-≃ π•˜ ⟩
        (g p = ⊀) β– 

  II : f ∼ g
  II p = Ξ©-ext' pe fe (I p)

  III : 𝕗 = π•˜
  III = to-≃-= fe II

eval-at-⊀-is-embedding : is-embedding eval-at-⊀
eval-at-⊀-is-embedding = lc-maps-into-sets-are-embeddings
                          eval-at-⊀ eval-at-⊀-is-lc
                          (Ξ©-is-set fe pe)

\end{code}

From this we conclude that there can't be any automorphism of Ξ©
distinct from the identity unless excluded middle holds. I don't think
this has been observed before in the literature, but it may have been
observed in the folklore.

\begin{code}

Ξ©-automorphism-distinct-from-π•šπ••-gives-EM
 : (Ξ£ 𝕗 κž‰ Aut Ξ© , 𝕗 β‰  π•šπ••)
 β†’ EM 𝓀
Ξ©-automorphism-distinct-from-π•šπ••-gives-EM (𝕗 , Ξ½) = IV
 where
  f : Ξ© β†’ Ξ©
  f = ⌜ 𝕗 ⌝

  I : f ⊀ = ⊀ β†’ 𝕗 = π•šπ••
  I = eval-at-⊀-is-lc {𝕗} {π•šπ••}

  II : f ⊀ β‰  ⊀
  II = contrapositive I Ξ½

  III : f ⊀ = βŠ₯
  III = different-from-⊀-gives-equal-βŠ₯ fe pe (f ⊀) II

  IV : EM 𝓀
  IV = Ξ©-automorphism-that-maps-⊀-to-βŠ₯-gives-EM (𝕗 , III)

\end{code}

It follows that the type Ξ£ f κž‰ Aut Ξ© , f β‰  id is a proposition,
constructively. In boolean toposes it is a singleton, in non-boolean
toposes it is empty, and in all toposes it is a subsingleton.  This is
because from any hypothetical element (f , Ξ½) of this type we conclude
that excluded middle holds, and hence Ξ© ≃ 𝟚, and therefore f is
negation. So this is a constructive proof in which we deduce excluded
middle as an intermediate step. And once we conclude that this type is
a proposition, we see that it is equivalent to the type EM 𝓀, which is
also a proposition, as these two propositions imply each other:

(Ξ£ f κž‰ Aut Ξ© , f β‰  id) ≃ EM 𝓀

and hence they are equal if we further assume propositional
extensionality (which follows from univalence).

TODO. Write down this argument in Agda.