2014-08-12 00:35:25 +00:00
|
|
|
|
-- Copyright (c) 2014 Microsoft Corporation. All rights reserved.
|
|
|
|
|
-- Released under Apache 2.0 license as described in the file LICENSE.
|
2014-10-23 05:24:31 +00:00
|
|
|
|
-- Author: Jeremy Avigad, Jakob von Raumer
|
2014-08-12 00:35:25 +00:00
|
|
|
|
-- Ported from Coq HoTT
|
|
|
|
|
import .path
|
2014-10-23 02:08:47 +00:00
|
|
|
|
open path function
|
2014-08-12 00:35:25 +00:00
|
|
|
|
|
|
|
|
|
-- Equivalences
|
|
|
|
|
-- ------------
|
|
|
|
|
|
2014-09-17 21:39:05 +00:00
|
|
|
|
definition Sect {A B : Type} (s : A → B) (r : B → A) := Πx : A, r (s x) ≈ x
|
2014-08-12 00:35:25 +00:00
|
|
|
|
|
|
|
|
|
-- -- TODO: need better means of declaring structures
|
|
|
|
|
-- -- TODO: note that Coq allows projections to be declared to be coercions on the fly
|
|
|
|
|
|
|
|
|
|
-- Structure IsEquiv
|
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
inductive IsEquiv [class] {A B : Type} (f : A → B) :=
|
2014-08-22 22:46:10 +00:00
|
|
|
|
IsEquiv_mk : Π
|
2014-10-23 02:08:47 +00:00
|
|
|
|
(inv : B → A)
|
|
|
|
|
(retr : Sect inv f)
|
|
|
|
|
(sect : Sect f inv)
|
|
|
|
|
(adj : Πx, retr (f x) ≈ ap f (sect x)),
|
2014-08-12 00:35:25 +00:00
|
|
|
|
IsEquiv f
|
|
|
|
|
|
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
namespace IsEquiv
|
2014-08-12 00:35:25 +00:00
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
definition inv {A B : Type} {f : A → B} (H : IsEquiv f) : B → A :=
|
|
|
|
|
IsEquiv.rec (λinv retr sect adj, inv) H
|
2014-08-12 00:35:25 +00:00
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
-- TODO: note: does not type check without giving the type
|
|
|
|
|
definition retr {A B : Type} {f : A → B} (H : IsEquiv f) : Sect (inv H) f :=
|
|
|
|
|
IsEquiv.rec (λinv retr sect adj, retr) H
|
|
|
|
|
|
|
|
|
|
definition sect {A B : Type} {f : A → B} (H : IsEquiv f) : Sect f (inv H) :=
|
|
|
|
|
IsEquiv.rec (λinv retr sect adj, sect) H
|
|
|
|
|
|
|
|
|
|
definition adj {A B : Type} {f : A → B} (H : IsEquiv f) :
|
2014-10-23 05:24:31 +00:00
|
|
|
|
Πx, retr H (f x) ≈ ap f (sect H x) :=
|
2014-10-23 02:08:47 +00:00
|
|
|
|
IsEquiv.rec (λinv retr sect adj, adj) H
|
|
|
|
|
|
|
|
|
|
end IsEquiv
|
2014-08-12 00:35:25 +00:00
|
|
|
|
|
|
|
|
|
-- Structure Equiv
|
|
|
|
|
|
|
|
|
|
inductive Equiv (A B : Type) : Type :=
|
2014-08-22 22:46:10 +00:00
|
|
|
|
Equiv_mk : Π
|
2014-08-12 00:35:25 +00:00
|
|
|
|
(equiv_fun : A → B)
|
|
|
|
|
(equiv_isequiv : IsEquiv equiv_fun),
|
|
|
|
|
Equiv A B
|
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
namespace Equiv
|
|
|
|
|
|
|
|
|
|
definition equiv_fun [coercion] {A B : Type} (e : Equiv A B) : A → B :=
|
|
|
|
|
Equiv.rec (λequiv_fun equiv_isequiv, equiv_fun) e
|
|
|
|
|
|
|
|
|
|
definition equiv_isequiv [coercion] {A B : Type} (e : Equiv A B) : IsEquiv (equiv_fun e) :=
|
|
|
|
|
Equiv.rec (λequiv_fun equiv_isequiv, equiv_isequiv) e
|
|
|
|
|
|
|
|
|
|
infix `≃`:25 := Equiv
|
|
|
|
|
notation e `⁻¹` := IsEquiv.inv e
|
|
|
|
|
|
|
|
|
|
end Equiv
|
|
|
|
|
|
|
|
|
|
-- Some instances and closure properties of equivalences
|
|
|
|
|
|
|
|
|
|
namespace IsEquiv
|
|
|
|
|
variables {A B C : Type} {f : A → B} {g : B → C} {f' : A → B}
|
|
|
|
|
|
|
|
|
|
-- The identity function is an equivalence.
|
|
|
|
|
|
2014-10-23 03:25:12 +00:00
|
|
|
|
definition id_closed [instance] : (@IsEquiv A A id) := IsEquiv_mk id (λa, idp) (λa, idp) (λa, idp)
|
2014-10-23 02:08:47 +00:00
|
|
|
|
|
|
|
|
|
-- The composition of two equivalences is, again, an equivalence.
|
|
|
|
|
|
|
|
|
|
definition comp_closed [instance] (Hf : IsEquiv f) (Hg : IsEquiv g) : (IsEquiv (g ∘ f)) :=
|
|
|
|
|
IsEquiv_mk ((inv Hf) ∘ (inv Hg))
|
2014-10-23 05:24:31 +00:00
|
|
|
|
(λc, ap g (retr Hf ((inv Hg) c)) ⬝ retr Hg c)
|
|
|
|
|
(λa, ap (inv Hf) (sect Hg (f a)) ⬝ sect Hf a)
|
|
|
|
|
(λa, (whiskerL _ (adj Hg (f a))) ⬝
|
|
|
|
|
(ap_pp g _ _)⁻¹ ⬝
|
|
|
|
|
ap02 g (concat_A1p (retr Hf) (sect Hg (f a))⁻¹ ⬝
|
|
|
|
|
(ap_compose (inv Hf) f _ ◾ adj Hf a) ⬝
|
|
|
|
|
(ap_pp f _ _)⁻¹
|
|
|
|
|
) ⬝
|
|
|
|
|
(ap_compose f g _)⁻¹
|
|
|
|
|
)
|
2014-10-23 02:08:47 +00:00
|
|
|
|
|
|
|
|
|
-- Any function equal to an equivalence is an equivlance as well.
|
|
|
|
|
definition path_closed (Hf : IsEquiv f) (Heq : f ≈ f') : (IsEquiv f') :=
|
|
|
|
|
path.induction_on Heq Hf
|
|
|
|
|
|
|
|
|
|
-- Any function pointwise equal to an equivalence is an equivalence as well.
|
|
|
|
|
definition homotopic (Hf : IsEquiv f) (Heq : f ∼ f') : (IsEquiv f') :=
|
2014-10-23 03:25:12 +00:00
|
|
|
|
let sect' := (λ b, (Heq (inv Hf b))⁻¹ ⬝ retr Hf b) in
|
|
|
|
|
let retr' := (λ a, (ap (inv Hf) (Heq a))⁻¹ ⬝ sect Hf a) in
|
2014-10-23 02:08:47 +00:00
|
|
|
|
let adj' := (λ (a : A),
|
|
|
|
|
let ff'a := Heq a in
|
|
|
|
|
let invf := inv Hf in
|
|
|
|
|
let secta := sect Hf a in
|
|
|
|
|
let retrfa := retr Hf (f a) in
|
|
|
|
|
let retrf'a := retr Hf (f' a) in
|
2014-10-23 03:25:12 +00:00
|
|
|
|
have eq1 : _ ≈ _,
|
|
|
|
|
from calc ap f secta ⬝ ff'a
|
|
|
|
|
≈ retrfa ⬝ ff'a : (ap _ (adj Hf _ ))⁻¹
|
|
|
|
|
... ≈ ap (f ∘ invf) ff'a ⬝ retrf'a : !concat_A1p⁻¹
|
|
|
|
|
... ≈ ap f (ap invf ff'a) ⬝ retr Hf (f' a) : {ap_compose invf f ff'a},
|
|
|
|
|
have eq2 : _ ≈ _,
|
2014-10-23 02:08:47 +00:00
|
|
|
|
from calc retrf'a
|
2014-10-23 03:25:12 +00:00
|
|
|
|
≈ (ap f (ap invf ff'a))⁻¹ ⬝ (ap f secta ⬝ ff'a) : moveL_Vp _ _ _ (eq1⁻¹)
|
|
|
|
|
... ≈ ap f (ap invf ff'a)⁻¹ ⬝ (ap f secta ⬝ Heq a) : {ap_V invf ff'a}
|
|
|
|
|
... ≈ ap f (ap invf ff'a)⁻¹ ⬝ (Heq (invf (f a)) ⬝ ap f' secta) : {!concat_Ap}
|
|
|
|
|
... ≈ (ap f (ap invf ff'a)⁻¹ ⬝ Heq (invf (f a))) ⬝ ap f' secta : {!concat_pp_p⁻¹}
|
|
|
|
|
... ≈ (ap f ((ap invf ff'a)⁻¹) ⬝ Heq (invf (f a))) ⬝ ap f' secta : {!ap_V⁻¹}
|
|
|
|
|
... ≈ (Heq (invf (f' a)) ⬝ ap f' ((ap invf ff'a)⁻¹)) ⬝ ap f' secta : {!concat_Ap}
|
|
|
|
|
... ≈ (Heq (invf (f' a)) ⬝ (ap f' (ap invf ff'a))⁻¹) ⬝ ap f' secta : {!ap_V}
|
|
|
|
|
... ≈ Heq (invf (f' a)) ⬝ ((ap f' (ap invf ff'a))⁻¹ ⬝ ap f' secta) : !concat_pp_p,
|
|
|
|
|
have eq3 : _ ≈ _,
|
|
|
|
|
from calc (Heq (invf (f' a)))⁻¹ ⬝ retr Hf (f' a)
|
|
|
|
|
≈ (ap f' (ap invf ff'a))⁻¹ ⬝ ap f' secta : moveR_Vp _ _ _ eq2
|
|
|
|
|
... ≈ (ap f' ((ap invf ff'a)⁻¹)) ⬝ ap f' secta : {!ap_V⁻¹}
|
|
|
|
|
... ≈ ap f' ((ap invf ff'a)⁻¹ ⬝ secta) : !ap_pp⁻¹,
|
2014-10-23 02:08:47 +00:00
|
|
|
|
eq3) in
|
|
|
|
|
IsEquiv_mk (inv Hf) sect' retr' adj'
|
2014-10-23 05:24:31 +00:00
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
--TODO: Maybe wait until rewrite rules are available.
|
|
|
|
|
definition inv_closed (Hf : IsEquiv f) : (IsEquiv (inv Hf)) :=
|
|
|
|
|
IsEquiv_mk sorry sorry sorry sorry
|
|
|
|
|
|
|
|
|
|
definition cancel_R (Hf : IsEquiv f) (Hgf : IsEquiv (g ∘ f)) : (IsEquiv g) :=
|
|
|
|
|
homotopic (comp_closed (inv_closed Hf) Hgf) (λb, ap g (retr Hf b))
|
|
|
|
|
|
|
|
|
|
definition cancel_L (Hg : IsEquiv g) (Hgf : IsEquiv (g ∘ f)) : (IsEquiv f) :=
|
|
|
|
|
homotopic (comp_closed Hgf (inv_closed Hg)) (λa, sect Hg (f a))
|
|
|
|
|
|
|
|
|
|
definition transport (P : A → Type) {x y : A} (p : x ≈ y) : (IsEquiv (transport P p)) :=
|
2014-10-23 03:25:12 +00:00
|
|
|
|
IsEquiv_mk (transport P (p⁻¹)) (transport_pV P p) (transport_Vp P p) (transport_pVp P p)
|
2014-10-23 02:08:47 +00:00
|
|
|
|
|
|
|
|
|
--Rewrite rules
|
|
|
|
|
section
|
|
|
|
|
variables {Hf : IsEquiv f}
|
2014-10-23 05:24:31 +00:00
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
definition moveR_M {x : A} {y : B} (p : x ≈ (inv Hf) y) : (f x ≈ y) :=
|
2014-10-23 03:25:12 +00:00
|
|
|
|
(ap f p) ⬝ (retr Hf y)
|
2014-10-23 02:08:47 +00:00
|
|
|
|
|
|
|
|
|
definition moveL_M {x : A} {y : B} (p : (inv Hf) y ≈ x) : (y ≈ f x) :=
|
2014-10-23 03:25:12 +00:00
|
|
|
|
(moveR_M (p⁻¹))⁻¹
|
2014-10-23 02:08:47 +00:00
|
|
|
|
|
|
|
|
|
definition moveR_V {x : B} {y : A} (p : x ≈ f y) : (inv Hf) x ≈ y :=
|
2014-10-23 03:25:12 +00:00
|
|
|
|
ap (inv Hf) p ⬝ sect Hf y
|
2014-10-23 02:08:47 +00:00
|
|
|
|
|
|
|
|
|
definition moveL_V {x : B} {y : A} (p : f y ≈ x) : y ≈ (inv Hf) x :=
|
2014-10-23 03:25:12 +00:00
|
|
|
|
(moveR_V (p⁻¹))⁻¹
|
2014-10-23 05:24:31 +00:00
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end IsEquiv
|
|
|
|
|
|
|
|
|
|
namespace Equiv
|
|
|
|
|
|
|
|
|
|
variables {A B C : Type} (eqf : A ≃ B)
|
|
|
|
|
|
2014-10-23 03:25:12 +00:00
|
|
|
|
theorem id : A ≃ A := Equiv_mk id IsEquiv.id_closed
|
2014-10-23 02:08:47 +00:00
|
|
|
|
|
|
|
|
|
theorem compose (eqg: B ≃ C) : A ≃ C :=
|
|
|
|
|
Equiv_mk ((equiv_fun eqg) ∘ (equiv_fun eqf))
|
2014-10-23 05:24:31 +00:00
|
|
|
|
(IsEquiv.comp_closed (equiv_isequiv eqf) (equiv_isequiv eqg))
|
2014-10-23 02:08:47 +00:00
|
|
|
|
|
|
|
|
|
check IsEquiv.path_closed
|
|
|
|
|
|
|
|
|
|
theorem path_closed (f' : A → B) (Heq : equiv_fun eqf ≈ f') : A ≃ B :=
|
|
|
|
|
Equiv_mk f' (IsEquiv.path_closed (equiv_isequiv eqf) Heq)
|
|
|
|
|
|
|
|
|
|
theorem inv_closed : B ≃ A :=
|
|
|
|
|
Equiv_mk (IsEquiv.inv (equiv_isequiv eqf)) (IsEquiv.inv_closed (equiv_isequiv eqf))
|
|
|
|
|
|
2014-10-23 05:24:31 +00:00
|
|
|
|
theorem cancel_L {f : A → B} {g : B → C}
|
2014-10-23 02:08:47 +00:00
|
|
|
|
(Hf : IsEquiv f) (Hgf : IsEquiv (g ∘ f)) : B ≃ C :=
|
|
|
|
|
Equiv_mk g (IsEquiv.cancel_R _ _)
|
2014-10-23 05:24:31 +00:00
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
theorem cancel_R {f : A → B} {g : B → C}
|
|
|
|
|
(Hg : IsEquiv g) (Hgf : IsEquiv (g ∘ f)) : A ≃ B :=
|
|
|
|
|
Equiv_mk f (!IsEquiv.cancel_L _ _)
|
2014-08-12 00:35:25 +00:00
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
theorem transport (P : A → Type) {x y : A} {p : x ≈ y} : (P x) ≃ (P y) :=
|
|
|
|
|
Equiv_mk (transport P p) (IsEquiv.transport P p)
|
2014-08-12 00:35:25 +00:00
|
|
|
|
|
2014-10-23 02:08:47 +00:00
|
|
|
|
end Equiv
|