Properties of equivalences depending on function extensionality.
(Not included in UF-Equiv because the module funext defines function
extensionality as the equivalence of happly for suitable parameters.)
\begin{code}
{-# OPTIONS --without-K --exact-split --safe #-}
module UF-Equiv-FunExt where
open import SpartanMLTT
open import UF-Base
open import UF-Subsingletons
open import UF-Subsingletons-FunExt
open import UF-Retracts
open import UF-FunExt
open import UF-Equiv
open import UF-EquivalenceExamples
being-vv-equiv-is-prop' : funext ๐ฅ (๐ค โ ๐ฅ) โ funext (๐ค โ ๐ฅ) (๐ค โ ๐ฅ)
โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-prop (is-vv-equiv f)
being-vv-equiv-is-prop' {๐ค} {๐ฅ} fe fe' f = ฮ -is-prop
fe
(ฮป x โ being-singleton-is-prop fe' )
being-vv-equiv-is-prop : FunExt
โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-prop (is-vv-equiv f)
being-vv-equiv-is-prop {๐ค} {๐ฅ} fe = being-vv-equiv-is-prop' (fe ๐ฅ (๐ค โ ๐ฅ)) (fe (๐ค โ ๐ฅ) (๐ค โ ๐ฅ))
qinv-post' : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {A : ๐ฆ ฬ }
โ naive-funext ๐ฆ ๐ค โ naive-funext ๐ฆ ๐ฅ
โ (f : X โ Y) โ qinv f โ qinv (ฮป (h : A โ X) โ f โ h)
qinv-post' {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A} nfe nfe' f (g , ฮท , ฮต) = (g' , ฮท' , ฮต')
where
f' : (A โ X) โ (A โ Y)
f' h = f โ h
g' : (A โ Y) โ (A โ X)
g' k = g โ k
ฮท' : (h : A โ X) โ g' (f' h) โก h
ฮท' h = nfe (ฮท โ h)
ฮต' : (k : A โ Y) โ f' (g' k) โก k
ฮต' k = nfe' (ฮต โ k)
qinv-post : (โ ๐ค ๐ฅ โ naive-funext ๐ค ๐ฅ) โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {A : ๐ฆ ฬ } (f : X โ Y)
โ qinv f โ qinv (ฮป (h : A โ X) โ f โ h)
qinv-post {๐ค} {๐ฅ} {๐ฆ} nfe = qinv-post' (nfe ๐ฆ ๐ค) (nfe ๐ฆ ๐ฅ)
equiv-post : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {A : ๐ฆ ฬ }
โ naive-funext ๐ฆ ๐ค โ naive-funext ๐ฆ ๐ฅ
โ (f : X โ Y) โ is-equiv f โ is-equiv (ฮป (h : A โ X) โ f โ h)
equiv-post nfe nfe' f e = qinvs-are-equivs (ฮป h โ f โ h) (qinv-post' nfe nfe' f (equivs-are-qinvs f e))
qinv-pre' : {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {A : ๐ฆ ฬ }
โ naive-funext ๐ฅ ๐ฆ โ naive-funext ๐ค ๐ฆ
โ (f : X โ Y) โ qinv f โ qinv (ฮป (h : Y โ A) โ h โ f)
qinv-pre' {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A} nfe nfe' f (g , ฮท , ฮต) = (g' , ฮท' , ฮต')
where
f' : (Y โ A) โ (X โ A)
f' h = h โ f
g' : (X โ A) โ (Y โ A)
g' k = k โ g
ฮท' : (h : Y โ A) โ g' (f' h) โก h
ฮท' h = nfe (ฮป y โ ap h (ฮต y))
ฮต' : (k : X โ A) โ f' (g' k) โก k
ฮต' k = nfe' (ฮป x โ ap k (ฮท x))
qinv-pre : (โ ๐ค ๐ฅ โ naive-funext ๐ค ๐ฅ) โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {A : ๐ฆ ฬ } (f : X โ Y)
โ qinv f โ qinv (ฮป (h : Y โ A) โ h โ f)
qinv-pre {๐ค} {๐ฅ} {๐ฆ} nfe = qinv-pre' (nfe ๐ฅ ๐ฆ) (nfe ๐ค ๐ฆ)
retractions-have-at-most-one-section' : {X : ๐ค ฬ } {Y : ๐ฅ ฬ }
โ funext ๐ฅ ๐ค โ funext ๐ฅ ๐ฅ
โ (f : X โ Y) โ is-section f โ is-prop (has-section f)
retractions-have-at-most-one-section' {๐ค} {๐ฅ} {X} {Y} fe fe' f (g , gf) (h , fh) =
singletons-are-props c (h , fh)
where
a : qinv f
a = equivs-are-qinvs f ((h , fh) , g , gf)
b : is-singleton(fiber (ฮป h โ f โ h) id)
b = qinvs-are-vv-equivs (ฮป h โ f โ h) (qinv-post' (dfunext fe) (dfunext fe') f a) id
r : fiber (ฮป h โ f โ h) id โ has-section f
r (h , p) = (h , happly' (f โ h) id p)
s : has-section f โ fiber (ฮป h โ f โ h) id
s (h , ฮท) = (h , dfunext fe' ฮท)
rs : (ฯ : has-section f) โ r (s ฯ) โก ฯ
rs (h , ฮท) = ap (ฮป - โ (h , -)) q
where
q : happly' (f โ h) id (dfunext fe' ฮท) โก ฮท
q = happly-funext fe' (f โ h) id ฮท
c : is-singleton (has-section f)
c = retract-of-singleton (r , s , rs) b
sections-have-at-most-one-retraction' : {X : ๐ค ฬ } {Y : ๐ฅ ฬ }
โ funext ๐ค ๐ค โ funext ๐ฅ ๐ค
โ (f : X โ Y) โ has-section f โ is-prop (is-section f)
sections-have-at-most-one-retraction' {๐ค} {๐ฅ} {X} {Y} fe fe' f (g , fg) (h , hf) =
singletons-are-props c (h , hf)
where
a : qinv f
a = equivs-are-qinvs f ((g , fg) , (h , hf))
b : is-singleton(fiber (ฮป h โ h โ f) id)
b = qinvs-are-vv-equivs (ฮป h โ h โ f) (qinv-pre' (dfunext fe') (dfunext fe) f a) id
r : fiber (ฮป h โ h โ f) id โ is-section f
r (h , p) = (h , happly' (h โ f) id p)
s : is-section f โ fiber (ฮป h โ h โ f) id
s (h , ฮท) = (h , dfunext fe ฮท)
rs : (ฯ : is-section f) โ r (s ฯ) โก ฯ
rs (h , ฮท) = ap (ฮป - โ (h , -)) q
where
q : happly' (h โ f) id (dfunext fe ฮท) โก ฮท
q = happly-funext fe (h โ f) id ฮท
c : is-singleton (is-section f)
c = retract-of-singleton (r , s , rs) b
retractions-have-at-most-one-section : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-section f โ is-prop (has-section f)
retractions-have-at-most-one-section {๐ค} {๐ฅ} fe = retractions-have-at-most-one-section' (fe ๐ฅ ๐ค) (fe ๐ฅ ๐ฅ)
sections-have-at-most-one-retraction : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ has-section f โ is-prop (is-section f)
sections-have-at-most-one-retraction {๐ค} {๐ฅ} fe = sections-have-at-most-one-retraction' (fe ๐ค ๐ค) (fe ๐ฅ ๐ค)
being-equiv-is-prop' : {X : ๐ค ฬ } {Y : ๐ฅ ฬ }
โ funext ๐ฅ ๐ค โ funext ๐ฅ ๐ฅ โ funext ๐ค ๐ค โ funext ๐ฅ ๐ค
โ (f : X โ Y) โ is-prop (is-equiv f)
being-equiv-is-prop' fe fe' fe'' fe''' f = ร-prop-criterion (retractions-have-at-most-one-section' fe fe' f ,
sections-have-at-most-one-retraction' fe'' fe''' f)
being-equiv-is-prop : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (f : X โ Y)
โ is-prop (is-equiv f)
being-equiv-is-prop {๐ค} {๐ฅ} fe f = being-equiv-is-prop' (fe ๐ฅ ๐ค) (fe ๐ฅ ๐ฅ) (fe ๐ค ๐ค) (fe ๐ฅ ๐ค) f
being-equiv-is-prop'' : {X Y : ๐ค ฬ }
โ funext ๐ค ๐ค
โ (f : X โ Y) โ is-prop (is-equiv f)
being-equiv-is-prop'' fe = being-equiv-is-prop' fe fe fe fe
โ-assoc : FunExt
โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {Z : ๐ฆ ฬ } {T : ๐ฃ ฬ }
(ฮฑ : X โ Y) (ฮฒ : Y โ Z) (ฮณ : Z โ T)
โ ฮฑ โ (ฮฒ โ ฮณ) โก (ฮฑ โ ฮฒ) โ ฮณ
โ-assoc fe (f , a) (g , b) (h , c) = to-ฮฃ-โก (p , q)
where
p : (h โ g) โ f โก h โ (g โ f)
p = refl
d e : is-equiv (h โ g โ f)
d = โ-is-equiv a (โ-is-equiv b c)
e = โ-is-equiv (โ-is-equiv a b) c
q : transport is-equiv p d โก e
q = being-equiv-is-prop fe (h โ g โ f) _ _
\end{code}
The above proof can be condensed to one line in the style of the
following two proofs, which exploit the fact that the identity map is
a neutral element for ordinary function composition, definitionally:
\begin{code}
โ-refl-left' : funext ๐ฅ ๐ค โ funext ๐ฅ ๐ฅ โ funext ๐ค ๐ค
โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (ฮฑ : X โ Y) โ โ-refl X โ ฮฑ โก ฮฑ
โ-refl-left' feโ feโ feโ ฮฑ = to-ฮฃ-โก' (being-equiv-is-prop' feโ feโ feโ feโ _ _ _)
โ-refl-right' : funext ๐ฅ ๐ค โ funext ๐ฅ ๐ฅ โ funext ๐ค ๐ค โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (ฮฑ : X โ Y) โ ฮฑ โ โ-refl Y โก ฮฑ
โ-refl-right' feโ feโ feโ ฮฑ = to-ฮฃ-โก' (being-equiv-is-prop' feโ feโ feโ feโ _ _ _)
โ-sym-involutive' : funext ๐ฅ ๐ค โ funext ๐ฅ ๐ฅ โ funext ๐ค ๐ค
โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (ฮฑ : X โ Y) โ โ-sym (โ-sym ฮฑ) โก ฮฑ
โ-sym-involutive' feโ feโ feโ (f , a) = to-ฮฃ-โก
(inversion-involutive f a ,
being-equiv-is-prop' feโ feโ feโ feโ f _ a)
โ-Sym' : funext ๐ฅ ๐ค โ funext ๐ฅ ๐ฅ โ funext ๐ค ๐ค โ funext ๐ค ๐ฅ
โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ (Y โ X)
โ-Sym' feโ feโ feโ feโ = qinveq โ-sym (โ-sym , โ-sym-involutive' feโ feโ feโ , โ-sym-involutive' feโ feโ feโ)
โ-Sym'' : funext ๐ค ๐ค
โ {X Y : ๐ค ฬ } โ (X โ Y) โ (Y โ X)
โ-Sym'' fe = โ-Sym' fe fe fe fe
โ-Sym : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } โ (X โ Y) โ (Y โ X)
โ-Sym {๐ค} {๐ฅ} fe = โ-Sym' (fe ๐ฅ ๐ค) (fe ๐ฅ ๐ฅ) (fe ๐ค ๐ค) (fe ๐ค ๐ฅ)
โ-refl-left : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (ฮฑ : X โ Y) โ โ-refl X โ ฮฑ โก ฮฑ
โ-refl-left fe = โ-refl-left' (fe _ _) (fe _ _) (fe _ _)
โ-refl-right : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (ฮฑ : X โ Y) โ ฮฑ โ โ-refl Y โก ฮฑ
โ-refl-right fe = โ-refl-right' (fe _ _) (fe _ _) (fe _ _)
โ-sym-involutive : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (ฮฑ : X โ Y) โ โ-sym (โ-sym ฮฑ) โก ฮฑ
โ-sym-involutive {๐ค} {๐ฅ} fe = โ-sym-involutive' (fe ๐ฅ ๐ค) (fe ๐ฅ ๐ฅ) (fe ๐ค ๐ค)
โ-sym-left-inverse : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (ฮฑ : X โ Y) โ โ-sym ฮฑ โ ฮฑ โก โ-refl Y
โ-sym-left-inverse {๐ค} {๐ฅ} fe (f , e) = to-ฮฃ-โก (p , being-equiv-is-prop fe _ _ _)
where
p : f โ inverse f e โก id
p = dfunext (fe ๐ฅ ๐ฅ) (inverses-are-sections f e)
โ-sym-right-inverse : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (ฮฑ : X โ Y) โ ฮฑ โ โ-sym ฮฑ โก โ-refl X
โ-sym-right-inverse {๐ค} {๐ฅ} fe (f , e) = to-ฮฃ-โก (p , being-equiv-is-prop fe _ _ _)
where
p : inverse f e โ f โก id
p = dfunext (fe ๐ค ๐ค) (inverses-are-retractions f e)
โ-Comp : FunExt โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } (Z : ๐ฆ ฬ ) โ X โ Y โ (Y โ Z) โ (X โ Z)
โ-Comp fe Z ฮฑ = qinveq (ฮฑ โ_) ((โ-sym ฮฑ โ_), p , q)
where
p = ฮป ฮฒ โ โ-sym ฮฑ โ (ฮฑ โ ฮฒ) โกโจ โ-assoc fe (โ-sym ฮฑ) ฮฑ ฮฒ โฉ
(โ-sym ฮฑ โ ฮฑ) โ ฮฒ โกโจ ap (_โ ฮฒ) (โ-sym-left-inverse fe ฮฑ) โฉ
โ-refl _ โ ฮฒ โกโจ โ-refl-left fe _ โฉ
ฮฒ โ
q = ฮป ฮณ โ ฮฑ โ (โ-sym ฮฑ โ ฮณ) โกโจ โ-assoc fe ฮฑ (โ-sym ฮฑ) ฮณ โฉ
(ฮฑ โ โ-sym ฮฑ) โ ฮณ โกโจ ap (_โ ฮณ) (โ-sym-right-inverse fe ฮฑ) โฉ
โ-refl _ โ ฮณ โกโจ โ-refl-left fe _ โฉ
ฮณ โ
Eq-Eq-cong : FunExt
โ {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {A : ๐ฆ ฬ } {B : ๐ฃ ฬ }
โ X โ A โ Y โ B โ (X โ Y) โ (A โ B)
Eq-Eq-cong fe {X} {Y} {A} {B} ฮฑ ฮฒ =
(X โ Y) โโจ โ-Comp fe Y (โ-sym ฮฑ) โฉ
(A โ Y) โโจ โ-Sym fe โฉ
(Y โ A) โโจ โ-Comp fe A (โ-sym ฮฒ) โฉ
(B โ A) โโจ โ-Sym fe โฉ
(A โ B) โ
\end{code}
Propositional and functional extesionality give univalence for
propositions. Notice that P is assumed to be a proposition, but X
ranges over arbitrary types:
\begin{code}
propext-funext-give-prop-ua : propext ๐ค โ funext ๐ค ๐ค
โ (X : ๐ค ฬ ) (P : ๐ค ฬ ) โ is-prop P โ is-equiv (idtoeq X P)
propext-funext-give-prop-ua {๐ค} pe fe X P i = (eqtoid , ฮท) , (eqtoid , ฮต)
where
l : X โ P โ is-prop X
l e = equiv-to-prop e i
eqtoid : X โ P โ X โก P
eqtoid (f , (r , rf) , h) = pe (l (f , (r , rf) , h)) i f r
m : is-prop (X โ P)
m (f , e) (f' , e') = to-ฮฃ-โก (dfunext fe (ฮป x โ i (f x) (f' x)) ,
being-equiv-is-prop'' fe f' _ e')
ฮท : (e : X โ P) โ idtoeq X P (eqtoid e) โก e
ฮท e = m (idtoeq X P (eqtoid e)) e
ฮต : (q : X โก P) โ eqtoid (idtoeq X P q) โก q
ฮต q = identifications-of-props-are-props pe fe P i X (eqtoid (idtoeq X P q)) q
prop-univalent-โ : propext ๐ค โ funext ๐ค ๐ค โ (X P : ๐ค ฬ ) โ is-prop P โ (X โก P) โ (X โ P)
prop-univalent-โ pe fe X P i = idtoeq X P , propext-funext-give-prop-ua pe fe X P i
prop-univalent-โ' : propext ๐ค โ funext ๐ค ๐ค โ (X P : ๐ค ฬ ) โ is-prop P โ (P โก X) โ (P โ X)
prop-univalent-โ' pe fe X P i = (P โก X) โโจ โก-flip โฉ
(X โก P) โโจ prop-univalent-โ pe fe X P i โฉ
(X โ P) โโจ โ-Sym'' fe โฉ
(P โ X) โ
\end{code}
The so-called type-theoretic axiom of choice (already defined in
SpartanMLTT with another name - TODO):
\begin{code}
TT-choice : {X : ๐ค ฬ } {Y : X โ ๐ฅ ฬ } {A : (x : X) โ Y x โ ๐ฆ ฬ }
โ (ฮ x ๊ X , ฮฃ y ๊ Y x , A x y)
โ ฮฃ f ๊ ((x : X) โ Y x) , ฮ x ๊ X , A x (f x)
TT-choice ฯ = (ฮป x โ prโ(ฯ x)) , (ฮป x โ prโ(ฯ x))
\end{code}
Its inverse (also already defined - TODO):
\begin{code}
TT-unchoice : {X : ๐ค ฬ } {Y : X โ ๐ฅ ฬ } {A : (x : X) โ Y x โ ๐ฆ ฬ }
โ (ฮฃ f ๊ ((x : X) โ Y x) , ฮ x ๊ X , A x (f x))
โ ฮ x ๊ X , ฮฃ y ๊ Y x , A x y
TT-unchoice (f , g) x = (f x) , (g x)
\end{code}
The proof that they are mutually inverse, where one direction requires
function extensionality (this already occurs in UF-EquivalenceExamples
- TODO):
\begin{code}
TT-choice-unchoice : {X : ๐ค ฬ } {Y : X โ ๐ฅ ฬ } {A : (x : X) โ Y x โ ๐ฆ ฬ }
โ (t : ฮฃ f ๊ ((x : X) โ Y x) , ฮ x ๊ X , A x (f x))
โ TT-choice (TT-unchoice {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A} t) โก t
TT-choice-unchoice t = refl
TT-choice-has-section : {X : ๐ค ฬ } {Y : X โ ๐ฅ ฬ } {A : (x : X) โ Y x โ ๐ฆ ฬ }
โ has-section (TT-choice {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A})
TT-choice-has-section {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A} = TT-unchoice ,
TT-choice-unchoice {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A}
TT-unchoice-choice : {X : ๐ค ฬ } {Y : X โ ๐ฅ ฬ } {A : (x : X) โ Y x โ ๐ฆ ฬ }
โ funext ๐ค (๐ฅ โ ๐ฆ)
โ (ฯ : ฮ x ๊ X , ฮฃ y ๊ Y x , A x y)
โ TT-unchoice (TT-choice ฯ) โก ฯ
TT-unchoice-choice fe ฯ = dfunext fe (ฮป x โ refl)
TT-choice-is-equiv : {X : ๐ค ฬ } {Y : X โ ๐ฅ ฬ } {A : (x : X) โ Y x โ ๐ฆ ฬ }
โ funext ๐ค (๐ฅ โ ๐ฆ)
โ is-equiv TT-choice
TT-choice-is-equiv {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A} fe = TT-choice-has-section {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A} ,
(TT-unchoice , TT-unchoice-choice fe)
TT-unchoice-is-equiv : {X : ๐ค ฬ } {Y : X โ ๐ฅ ฬ } {A : (x : X) โ Y x โ ๐ฆ ฬ }
โ funext ๐ค (๐ฅ โ ๐ฆ)
โ is-equiv TT-unchoice
TT-unchoice-is-equiv {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A} fe =
(TT-choice , TT-unchoice-choice {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A} fe) ,
(TT-choice , TT-choice-unchoice {๐ค} {๐ฅ} {๐ฆ} {X} {Y} {A})
\end{code}