2015-02-26 18:19:54 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2014 Jakob von Raumer. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
|
|
|
Author: Jakob von Raumer
|
|
|
|
|
|
|
|
Ported from Coq HoTT
|
|
|
|
-/
|
|
|
|
|
2014-12-12 18:17:50 +00:00
|
|
|
prelude
|
2015-04-24 23:58:50 +00:00
|
|
|
import .equiv
|
2015-04-27 21:39:23 +00:00
|
|
|
open eq equiv is_equiv equiv.ops
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
--Ensure that the types compared are in the same universe
|
|
|
|
section
|
|
|
|
universe variable l
|
|
|
|
variables {A B : Type.{l}}
|
|
|
|
|
2015-04-27 21:39:23 +00:00
|
|
|
definition is_equiv_cast_of_eq (H : A = B) : is_equiv (cast H) :=
|
2015-02-21 00:30:32 +00:00
|
|
|
(@is_equiv_tr Type (λX, X) A B H)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-02-21 00:30:32 +00:00
|
|
|
definition equiv_of_eq (H : A = B) : A ≃ B :=
|
2015-04-27 21:39:23 +00:00
|
|
|
equiv.mk _ (is_equiv_cast_of_eq H)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
2015-02-21 00:30:32 +00:00
|
|
|
axiom univalence (A B : Type) : is_equiv (@equiv_of_eq A B)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-02-21 00:30:32 +00:00
|
|
|
attribute univalence [instance]
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2014-12-17 16:58:47 +00:00
|
|
|
-- This is the version of univalence axiom we will probably use most often
|
2015-04-27 21:39:23 +00:00
|
|
|
definition ua [reducible] {A B : Type} : A ≃ B → A = B :=
|
|
|
|
equiv_of_eq⁻¹
|
|
|
|
|
2015-04-28 21:31:26 +00:00
|
|
|
definition eq_equiv_equiv (A B : Type) : (A = B) ≃ (A ≃ B) :=
|
|
|
|
equiv.mk equiv_of_eq _
|
|
|
|
|
2015-04-27 21:39:23 +00:00
|
|
|
definition equiv_of_eq_ua [reducible] {A B : Type} (f : A ≃ B) : equiv_of_eq (ua f) = f :=
|
|
|
|
right_inv equiv_of_eq f
|
|
|
|
|
|
|
|
definition cast_ua_fn {A B : Type} (f : A ≃ B) : cast (ua f) = f :=
|
|
|
|
ap to_fun (equiv_of_eq_ua f)
|
|
|
|
|
|
|
|
definition cast_ua {A B : Type} (f : A ≃ B) (a : A) : cast (ua f) a = f a :=
|
|
|
|
ap10 (cast_ua_fn f) a
|
|
|
|
|
|
|
|
definition ua_equiv_of_eq [reducible] {A B : Type} (p : A = B) : ua (equiv_of_eq p) = p :=
|
|
|
|
left_inv equiv_of_eq p
|
|
|
|
|
2015-06-24 21:59:17 +00:00
|
|
|
definition eq_of_equiv_lift {A B : Type} (f : A ≃ B) : A = lift B :=
|
|
|
|
ua (f ⬝e !equiv_lift)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-14 02:01:48 +00:00
|
|
|
namespace equiv
|
|
|
|
-- One consequence of UA is that we can transport along equivalencies of types
|
|
|
|
-- We can use this for calculation evironments
|
|
|
|
protected definition transport_of_equiv [subst] (P : Type → Type) {A B : Type} (H : A ≃ B)
|
2014-12-17 16:58:47 +00:00
|
|
|
: P A → P B :=
|
|
|
|
eq.transport P (ua H)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-14 02:01:48 +00:00
|
|
|
-- we can "recurse" on equivalences, by replacing them by (equiv_of_eq _)
|
2015-05-18 22:08:19 +00:00
|
|
|
definition rec_on_ua [recursor] {A B : Type} {P : A ≃ B → Type}
|
2015-05-14 02:01:48 +00:00
|
|
|
(f : A ≃ B) (H : Π(q : A = B), P (equiv_of_eq q)) : P f :=
|
|
|
|
right_inv equiv_of_eq f ▸ H (ua f)
|
|
|
|
|
2015-05-21 07:24:00 +00:00
|
|
|
-- a variant where we immediately recurse on the equality in the new goal
|
|
|
|
definition rec_on_ua_idp [recursor] {A : Type} {P : Π{B}, A ≃ B → Type} {B : Type}
|
|
|
|
(f : A ≃ B) (H : P equiv.refl) : P f :=
|
|
|
|
rec_on_ua f (λq, eq.rec_on q H)
|
|
|
|
|
2015-05-14 02:01:48 +00:00
|
|
|
-- a variant where (equiv_of_eq (ua f)) will be replaced by f in the new goal
|
2015-05-21 07:24:00 +00:00
|
|
|
definition rec_on_ua' {A B : Type} {P : A ≃ B → A = B → Type}
|
2015-05-14 02:01:48 +00:00
|
|
|
(f : A ≃ B) (H : Π(q : A = B), P (equiv_of_eq q) q) : P f (ua f) :=
|
|
|
|
right_inv equiv_of_eq f ▸ H (ua f)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-21 07:24:00 +00:00
|
|
|
-- a variant where we do both
|
|
|
|
definition rec_on_ua_idp' {A : Type} {P : Π{B}, A ≃ B → A = B → Type} {B : Type}
|
2015-05-14 02:01:48 +00:00
|
|
|
(f : A ≃ B) (H : P equiv.refl idp) : P f (ua f) :=
|
2015-05-21 07:24:00 +00:00
|
|
|
rec_on_ua' f (λq, eq.rec_on q H)
|
2015-03-13 14:32:48 +00:00
|
|
|
|
2015-02-21 00:30:32 +00:00
|
|
|
end equiv
|