Martin Escardo.
Formulation of function extensionality. Notice that this file doesn't
postulate function extensionality. It only defines the concept, which
is used explicitly as a hypothesis each time it is needed.
\begin{code}
{-# OPTIONS --without-K --exact-split --safe #-}
module UF-FunExt where
open import SpartanMLTT
open import UF-Base
open import UF-Equiv
open import UF-LeftCancellable
\end{code}
The appropriate notion of function extensionality in univalent
mathematics is funext, define below. It is implied, by an argument due
to Voevodky, by naive, non-dependent function extensionality, written
naive-funext here.
\begin{code}
naive-funext : โ ๐ค ๐ฅ โ ๐ค โบ โ ๐ฅ โบ ฬ
naive-funext ๐ค ๐ฅ = {X : ๐ค ฬ } {Y : ๐ฅ ฬ } {f g : X โ Y} โ f โผ g โ f โก g
DN-funext : โ ๐ค ๐ฅ โ ๐ค โบ โ ๐ฅ โบ ฬ
DN-funext ๐ค ๐ฅ = {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ } {f g : ฮ A} โ f โผ g โ f โก g
funext : โ ๐ค ๐ฅ โ ๐ค โบ โ ๐ฅ โบ ฬ
funext ๐ค ๐ฅ = {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ } (f g : ฮ A) โ is-equiv (happly' f g)
FunExt : ๐คฯ
FunExt = (๐ค ๐ฅ : Universe) โ funext ๐ค ๐ฅ
Fun-Ext : ๐คฯ
Fun-Ext = {๐ค ๐ฅ : Universe} โ funext ๐ค ๐ฅ
FunExt' : ๐คฯ
FunExt' = {๐ค ๐ฅ : Universe} โ funext ๐ค ๐ฅ
โ-funext : funext ๐ค ๐ฅ โ {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ } (f g : ฮ A)
โ (f โก g) โ (f โผ g)
โ-funext fe f g = happly' f g , fe f g
abstract
dfunext : funext ๐ค ๐ฅ โ DN-funext ๐ค ๐ฅ
dfunext fe {X} {A} {f} {g} = inverse (happly' f g) (fe f g)
happly-funext : {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ }
(fe : funext ๐ค ๐ฅ) (f g : ฮ A) (h : f โผ g)
โ happly (dfunext fe h) โก h
happly-funext fe f g = inverses-are-sections happly (fe f g)
funext-lc : {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ } (fe : funext ๐ค ๐ฅ) (f g : ฮ A)
โ left-cancellable (dfunext fe {X} {A} {f} {g})
funext-lc fe f g = section-lc (dfunext fe) (happly , happly-funext fe f g)
happly-lc : {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ } (fe : funext ๐ค ๐ฅ) (f g : ฮ A)
โ left-cancellable (happly' f g)
happly-lc fe f g = section-lc happly (equivs-are-sections happly (fe f g))
dfunext-refl : {X : ๐ค ฬ } {A : X โ ๐ฅ ฬ } (fe : funext ๐ค ๐ฅ) (f : ฮ A)
โ dfunext fe (ฮป (x : X) โ ๐ป๐ฎ๐ป๐ต (f x)) โก refl
dfunext-refl fe f = happly-lc fe f f (happly-funext fe f f (ฮป x โ refl))
ap-funext : {X : ๐ฅ ฬ } {Y : ๐ฆ ฬ } (f g : X โ Y) {A : ๐ฆ' ฬ } (k : Y โ A) (h : f โผ g)
โ (fe : funext ๐ฅ ๐ฆ) (x : X) โ ap (ฮป (- : X โ Y) โ k (- x)) (dfunext fe h) โก ap k (h x)
ap-funext f g k h fe x = ap (ฮป - โ k (- x)) (dfunext fe h) โกโจ refl โฉ
ap (k โ (ฮป - โ - x)) (dfunext fe h) โกโจ (ap-ap (ฮป - โ - x) k (dfunext fe h))โปยน โฉ
ap k (ap (ฮป - โ - x) (dfunext fe h)) โกโจ refl โฉ
ap k (happly (dfunext fe h) x) โกโจ ap (ฮป - โ ap k (- x)) (happly-funext fe f g h) โฉ
ap k (h x) โ
\end{code}
The following is taken from this thread:
https://groups.google.com/forum/#!msg/homotopytypetheory/VaLJM7S4d18/Lezr_ZhJl6UJ
\begin{code}
transport-funext : {X : ๐ค ฬ } (A : X โ ๐ฅ ฬ ) (P : (x : X) โ A x โ ๐ฆ ฬ ) (fe : funext ๐ค ๐ฅ)
(f g : ฮ A)
(ฯ : (x : X) โ P x (f x))
(h : f โผ g)
(x : X)
โ transport (ฮป - โ (x : X) โ P x (- x)) (dfunext fe h) ฯ x
โก transport (P x) (h x) (ฯ x)
transport-funext A P fe f g ฯ h x = q โ r
where
l : (f g : ฮ A) (ฯ : โ x โ P x (f x)) (p : f โก g)
โ โ x โ transport (ฮป - โ โ x โ P x (- x)) p ฯ x
โก transport (P x) (happly p x) (ฯ x)
l f .f ฯ refl x = refl
q : transport (ฮป - โ โ x โ P x (- x)) (dfunext fe h) ฯ x
โก transport (P x) (happly (dfunext fe h) x) (ฯ x)
q = l f g ฯ (dfunext fe h) x
r : transport (P x) (happly (dfunext fe h) x) (ฯ x)
โก transport (P x) (h x) (ฯ x)
r = ap (ฮป - โ transport (P x) (- x) (ฯ x)) (happly-funext fe f g h)
\end{code}