2014-12-12 04:14:53 +00:00
/-
2015-04-28 21:31:26 +00:00
Copyright (c) 2014-15 Floris van Doorn. All rights reserved.
2014-12-12 04:14:53 +00:00
Released under Apache 2.0 license as described in the file LICENSE.
Author: Floris van Doorn
2015-05-22 08:35:44 +00:00
Partially ported from Coq HoTT
2014-12-12 04:14:53 +00:00
Theorems about pi-types (dependent function spaces)
-/
2015-02-26 18:19:54 +00:00
2015-05-27 01:17:26 +00:00
import types.sigma arity
2014-12-12 19:19:06 +00:00
2015-09-11 22:53:08 +00:00
open eq equiv is_equiv funext sigma unit bool is_trunc prod
2014-12-12 04:14:53 +00:00
namespace pi
2015-02-24 00:54:16 +00:00
variables {A A' : Type} {B : A → Type} {B' : A' → Type} {C : Πa, B a → Type}
2014-12-12 04:14:53 +00:00
{D : Πa b, C a b → Type}
{a a' a'' : A} {b b₁ b₂ : B a} {b' : B a'} {b'' : B a''} {f g : Πa, B a}
/- Paths -/
2015-07-29 12:17:16 +00:00
/-
Paths [p : f ≈ g] in a function type [Πx:X, P x] are equivalent to functions taking values
in path types, [H : Πx:X, f x ≈ g x], or concisely, [H : f ~ g].
2014-12-12 04:14:53 +00:00
2015-07-29 12:17:16 +00:00
This equivalence, however, is just the combination of [apd10] and function extensionality
[funext], and as such, [eq_of_homotopy]
2014-12-12 04:14:53 +00:00
2015-07-29 12:17:16 +00:00
Now we show how these things compute.
-/
2014-12-12 04:14:53 +00:00
2015-06-17 19:58:58 +00:00
definition apd10_eq_of_homotopy (h : f ~ g) : apd10 (eq_of_homotopy h) ~ h :=
2015-04-27 19:39:36 +00:00
apd10 (right_inv apd10 h)
2014-12-12 04:14:53 +00:00
2015-04-24 21:00:32 +00:00
definition eq_of_homotopy_eta (p : f = g) : eq_of_homotopy (apd10 p) = p :=
2015-04-27 19:39:36 +00:00
left_inv apd10 p
2014-12-12 04:14:53 +00:00
2015-02-21 00:30:32 +00:00
definition eq_of_homotopy_idp (f : Πa, B a) : eq_of_homotopy (λx : A, refl (f x)) = refl f :=
!eq_of_homotopy_eta
2014-12-12 04:14:53 +00:00
2015-07-29 12:17:16 +00:00
/-
The identification of the path space of a dependent function space,
up to equivalence, is of course just funext.
-/
2014-12-12 04:14:53 +00:00
2015-06-17 19:58:58 +00:00
definition eq_equiv_homotopy (f g : Πx, B x) : (f = g) ≃ (f ~ g) :=
2015-07-29 12:17:16 +00:00
equiv.mk apd10 _
2014-12-12 04:14:53 +00:00
2015-08-06 20:37:52 +00:00
definition pi_eq_equiv (f g : Πx, B x) : (f = g) ≃ (f ~ g) := !eq_equiv_homotopy
2015-08-31 16:23:34 +00:00
definition is_equiv_eq_of_homotopy (f g : Πx, B x)
: is_equiv (eq_of_homotopy : f ~ g → f = g) :=
2015-07-29 12:17:16 +00:00
_
2014-12-12 04:14:53 +00:00
2015-06-17 19:58:58 +00:00
definition homotopy_equiv_eq (f g : Πx, B x) : (f ~ g) ≃ (f = g) :=
2015-07-29 12:17:16 +00:00
equiv.mk eq_of_homotopy _
2014-12-12 04:14:53 +00:00
/- Transport -/
2015-02-21 00:30:32 +00:00
definition pi_transport (p : a = a') (f : Π(b : B a), C a b)
2015-08-31 16:23:34 +00:00
: (transport (λa, Π(b : B a), C a b) p f) ~ (λb, !tr_inv_tr ▸ (p ▸D (f (p⁻¹ ▸ b)))) :=
by induction p; reflexivity
2014-12-12 04:14:53 +00:00
/- A special case of [transport_pi] where the type [B] does not depend on [A],
and so it is just a fixed type [B]. -/
2015-04-19 19:58:13 +00:00
definition pi_transport_constant {C : A → A' → Type} (p : a = a') (f : Π(b : A'), C a b) (b : A')
2015-07-29 12:17:16 +00:00
: (transport _ p f) b = p ▸ (f b) :=
2015-08-31 16:23:34 +00:00
by induction p; reflexivity
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
/- Pathovers -/
definition pi_pathover {f : Πb, C a b} {g : Πb', C a' b'} {p : a = a'}
(r : Π(b : B a) (b' : B a') (q : b =[p] b'), f b =[apo011 C p q] g b') : f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
apply eq_of_pathover_idp, apply r
end
2015-05-27 01:17:26 +00:00
definition pi_pathover_left {f : Πb, C a b} {g : Πb', C a' b'} {p : a = a'}
(r : Π(b : B a), f b =[apo011 C p !pathover_tr] g (p ▸ b)) : f =[p] g :=
2015-05-22 08:35:44 +00:00
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
2015-05-27 01:17:26 +00:00
apply eq_of_pathover_idp, apply r
2015-05-22 08:35:44 +00:00
end
2015-05-27 01:17:26 +00:00
definition pi_pathover_right {f : Πb, C a b} {g : Πb', C a' b'} {p : a = a'}
(r : Π(b' : B a'), f (p⁻¹ ▸ b') =[apo011 C p !tr_pathover] g b') : f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
apply eq_of_pathover_idp, apply r
end
definition pi_pathover_constant {C : A → A' → Type} {f : Π(b : A'), C a b}
{g : Π(b : A'), C a' b} {p : a = a'}
(r : Π(b : A'), f b =[p] g b) : f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
exact eq_of_pathover_idp (r b),
end
2015-05-22 08:35:44 +00:00
2015-10-26 22:29:19 +00:00
-- a version where C is uncurried, but where the conclusion of r is still a proper pathover
-- instead of a heterogenous equality
definition pi_pathover' {C : (Σa, B a) → Type} {f : Πb, C ⟨a, b⟩} {g : Πb', C ⟨a', b'⟩}
{p : a = a'} (r : Π(b : B a) (b' : B a') (q : b =[p] b'), f b =[dpair_eq_dpair p q] g b')
: f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
apply (@eq_of_pathover_idp _ C), exact (r b b (pathover.idpatho b)),
end
definition pi_pathover_left' {C : (Σa, B a) → Type} {f : Πb, C ⟨a, b⟩} {g : Πb', C ⟨a', b'⟩}
{p : a = a'} (r : Π(b : B a), f b =[dpair_eq_dpair p !pathover_tr] g (p ▸ b))
: f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
apply eq_of_pathover_idp, esimp at r, exact !pathover_ap (r b)
end
definition pi_pathover_right' {C : (Σa, B a) → Type} {f : Πb, C ⟨a, b⟩} {g : Πb', C ⟨a', b'⟩}
{p : a = a'} (r : Π(b' : B a'), f (p⁻¹ ▸ b') =[dpair_eq_dpair p !tr_pathover] g b')
: f =[p] g :=
begin
cases p, apply pathover_idp_of_eq,
apply eq_of_homotopy, intro b,
apply eq_of_pathover_idp, esimp at r, exact !pathover_ap (r b)
end
2014-12-12 04:14:53 +00:00
/- Maps on paths -/
/- The action of maps given by lambda. -/
2015-02-21 00:30:32 +00:00
definition ap_lambdaD {C : A' → Type} (p : a = a') (f : Πa b, C b) :
ap (λa b, f a b) p = eq_of_homotopy (λb, ap (λa, f a b) p) :=
2014-12-12 04:14:53 +00:00
begin
2014-12-12 18:17:50 +00:00
apply (eq.rec_on p),
2014-12-12 04:14:53 +00:00
apply inverse,
2015-02-21 00:30:32 +00:00
apply eq_of_homotopy_idp
2014-12-12 04:14:53 +00:00
end
/- Dependent paths -/
/- with more implicit arguments the conclusion of the following theorem is
2015-02-21 00:30:32 +00:00
(Π(b : B a), transportD B C p b (f b) = g (transport B p b)) ≃
(transport (λa, Π(b : B a), C a b) p f = g) -/
definition heq_piD (p : a = a') (f : Π(b : B a), C a b)
2015-05-01 03:23:12 +00:00
(g : Π(b' : B a'), C a' b') : (Π(b : B a), p ▸D (f b) = g (p ▸ b)) ≃ (p ▸ f = g) :=
2015-02-21 00:30:32 +00:00
eq.rec_on p (λg, !homotopy_equiv_eq) g
2014-12-12 04:14:53 +00:00
2015-02-24 00:54:16 +00:00
definition heq_pi {C : A → Type} (p : a = a') (f : Π(b : B a), C a)
2015-05-01 03:23:12 +00:00
(g : Π(b' : B a'), C a') : (Π(b : B a), p ▸ (f b) = g (p ▸ b)) ≃ (p ▸ f = g) :=
2015-02-21 00:30:32 +00:00
eq.rec_on p (λg, !homotopy_equiv_eq) g
section
open sigma sigma.ops
2014-12-12 04:14:53 +00:00
/- more implicit arguments:
2015-05-01 03:23:12 +00:00
(Π(b : B a), transport C (sigma_eq p idp) (f b) = g (p ▸ b)) ≃
2015-02-21 00:30:32 +00:00
(Π(b : B a), transportD B (λ(a : A) (b : B a), C ⟨a, b⟩) p b (f b) = g (transport B p b)) -/
definition heq_pi_sigma {C : (Σa, B a) → Type} (p : a = a')
2014-12-12 04:14:53 +00:00
(f : Π(b : B a), C ⟨a, b⟩) (g : Π(b' : B a'), C ⟨a', b'⟩) :
2015-05-22 08:35:44 +00:00
(Π(b : B a), (sigma_eq p !pathover_tr) ▸ (f b) = g (p ▸ b)) ≃
(Π(b : B a), p ▸D (f b) = g (p ▸ b)) :=
2014-12-12 18:17:50 +00:00
eq.rec_on p (λg, !equiv.refl) g
2014-12-12 04:14:53 +00:00
end
2015-02-21 00:30:32 +00:00
/- Functorial action -/
variables (f0 : A' → A) (f1 : Π(a':A'), B (f0 a') → B' a')
/- The functoriality of [forall] is slightly subtle: it is contravariant in the domain type and covariant in the codomain, but the codomain is dependent on the domain. -/
2015-10-09 20:21:03 +00:00
definition pi_functor [unfold_full] : (Π(a:A), B a) → (Π(a':A'), B' a') := λg a', f1 a' (g (f0 a'))
2015-02-21 00:30:32 +00:00
2015-06-17 19:58:58 +00:00
definition ap_pi_functor {g g' : Π(a:A), B a} (h : g ~ g')
2015-07-29 12:17:16 +00:00
: ap (pi_functor f0 f1) (eq_of_homotopy h)
= eq_of_homotopy (λa':A', (ap (f1 a') (h (f0 a')))) :=
2015-02-21 00:30:32 +00:00
begin
2015-08-04 17:00:12 +00:00
apply (is_equiv_rect (@apd10 A B g g')), intro p, clear h,
2015-03-04 05:10:48 +00:00
cases p,
apply concat,
2015-02-21 00:30:32 +00:00
exact (ap (ap (pi_functor f0 f1)) (eq_of_homotopy_idp g)),
apply symm, apply eq_of_homotopy_idp
end
/- Equivalences -/
2015-09-10 22:32:52 +00:00
definition is_equiv_pi_functor [instance] [constructor] [H0 : is_equiv f0]
2015-08-31 16:23:34 +00:00
[H1 : Πa', is_equiv (f1 a')] : is_equiv (pi_functor f0 f1) :=
2015-02-21 00:30:32 +00:00
begin
2015-02-28 00:02:18 +00:00
apply (adjointify (pi_functor f0 f1) (pi_functor f0⁻¹
2015-04-27 19:39:36 +00:00
(λ(a : A) (b' : B' (f0⁻¹ a)), transport B (right_inv f0 a) ((f1 (f0⁻¹ a))⁻¹ b')))),
2015-02-24 21:27:57 +00:00
begin
2015-07-29 12:17:16 +00:00
intro h, apply eq_of_homotopy, intro a', esimp,
2015-08-06 13:09:49 +00:00
rewrite [adj f0 a',-tr_compose,fn_tr_eq_tr_fn _ f1,right_inv (f1 _)],
2015-04-24 21:00:32 +00:00
apply apd
2015-02-24 21:27:57 +00:00
end,
begin
2015-07-29 12:17:16 +00:00
intro h, apply eq_of_homotopy, intro a, esimp,
rewrite [left_inv (f1 _)],
2015-04-24 21:00:32 +00:00
apply apd
2015-02-24 21:27:57 +00:00
end
2015-02-21 00:30:32 +00:00
end
2015-09-10 22:32:52 +00:00
definition pi_equiv_pi_of_is_equiv [constructor] [H : is_equiv f0]
2015-08-31 16:23:34 +00:00
[H1 : Πa', is_equiv (f1 a')] : (Πa, B a) ≃ (Πa', B' a') :=
2015-02-21 00:30:32 +00:00
equiv.mk (pi_functor f0 f1) _
2015-09-10 22:32:52 +00:00
definition pi_equiv_pi [constructor] (f0 : A' ≃ A) (f1 : Πa', (B (to_fun f0 a') ≃ B' a'))
2015-02-21 00:30:32 +00:00
: (Πa, B a) ≃ (Πa', B' a') :=
pi_equiv_pi_of_is_equiv (to_fun f0) (λa', to_fun (f1 a'))
2015-09-10 22:32:52 +00:00
definition pi_equiv_pi_id [constructor] {P Q : A → Type} (g : Πa, P a ≃ Q a)
: (Πa, P a) ≃ (Πa, Q a) :=
2015-03-04 05:10:48 +00:00
pi_equiv_pi equiv.refl g
2015-02-21 00:30:32 +00:00
2015-09-11 22:53:08 +00:00
/- Equivalence if one of the types is contractible -/
definition pi_equiv_of_is_contr_left [constructor] (B : A → Type) [H : is_contr A]
: (Πa, B a) ≃ B (center A) :=
begin
fapply equiv.MK,
{ intro f, exact f (center A)},
{ intro b a, exact (center_eq a) ▸ b},
{ intro b, rewrite [hprop_eq_of_is_contr (center_eq (center A)) idp]},
{ intro f, apply eq_of_homotopy, intro a, induction (center_eq a),
rewrite [hprop_eq_of_is_contr (center_eq (center A)) idp]}
end
definition pi_equiv_of_is_contr_right [constructor] [H : Πa, is_contr (B a)]
: (Πa, B a) ≃ unit :=
begin
fapply equiv.MK,
{ intro f, exact star},
{ intro u a, exact !center},
{ intro u, induction u, reflexivity},
{ intro f, apply eq_of_homotopy, intro a, apply is_hprop.elim}
end
/- Interaction with other type constructors -/
-- most of these are in the file of the other type constructor
definition pi_empty_left [constructor] (B : empty → Type) : (Πx, B x) ≃ unit :=
begin
fapply equiv.MK,
{ intro f, exact star},
{ intro x y, contradiction},
{ intro x, induction x, reflexivity},
{ intro f, apply eq_of_homotopy, intro y, contradiction},
end
definition pi_unit_left [constructor] (B : unit → Type) : (Πx, B x) ≃ B star :=
!pi_equiv_of_is_contr_left
definition pi_bool_left [constructor] (B : bool → Type) : (Πx, B x) ≃ B ff × B tt :=
begin
fapply equiv.MK,
{ intro f, exact (f ff, f tt)},
{ intro x b, induction x, induction b: assumption},
{ intro x, induction x, reflexivity},
{ intro f, apply eq_of_homotopy, intro b, induction b: reflexivity},
end
2015-02-21 00:30:32 +00:00
/- Truncatedness: any dependent product of n-types is an n-type -/
2015-09-11 23:05:48 +00:00
theorem is_trunc_pi (B : A → Type) (n : trunc_index)
2014-12-12 04:14:53 +00:00
[H : ∀a, is_trunc n (B a)] : is_trunc n (Πa, B a) :=
begin
2015-04-30 18:00:39 +00:00
revert B H,
2015-05-01 22:07:28 +00:00
eapply (trunc_index.rec_on n),
2015-04-30 18:00:39 +00:00
{intro B H,
2014-12-12 04:14:53 +00:00
fapply is_contr.mk,
2015-02-07 01:27:56 +00:00
intro a, apply center,
2015-02-21 00:30:32 +00:00
intro f, apply eq_of_homotopy,
2015-04-28 21:31:26 +00:00
intro x, apply (center_eq (f x))},
2015-04-30 18:00:39 +00:00
{intro n IH B H,
fapply is_trunc_succ_intro, intro f g,
2015-02-21 00:30:32 +00:00
fapply is_trunc_equiv_closed,
apply equiv.symm, apply eq_equiv_homotopy,
2014-12-12 04:14:53 +00:00
apply IH,
intro a,
2014-12-12 18:17:50 +00:00
show is_trunc n (f a = g a), from
2015-02-24 21:27:57 +00:00
is_trunc_eq n (f a) (g a)}
2014-12-12 04:14:53 +00:00
end
2015-04-25 03:04:24 +00:00
local attribute is_trunc_pi [instance]
2015-09-11 23:05:48 +00:00
theorem is_trunc_pi_eq [instance] [priority 500] (n : trunc_index) (f g : Πa, B a)
2014-12-12 18:17:50 +00:00
[H : ∀a, is_trunc n (f a = g a)] : is_trunc n (f = g) :=
2014-12-12 04:14:53 +00:00
begin
2015-05-05 22:33:17 +00:00
apply is_trunc_equiv_closed_rev,
2015-02-21 00:30:32 +00:00
apply eq_equiv_homotopy
2014-12-12 04:14:53 +00:00
end
2015-09-11 23:05:48 +00:00
theorem is_trunc_not [instance] (n : trunc_index) (A : Type) : is_trunc (n.+1) ¬A :=
2015-08-07 16:37:05 +00:00
by unfold not;exact _
2015-09-11 23:05:48 +00:00
theorem is_hprop_pi_eq [instance] [priority 490] (a : A) : is_hprop (Π(a' : A), a = a') :=
2015-05-05 22:33:17 +00:00
is_hprop_of_imp_is_contr
( assume (f : Πa', a = a'),
assert H : is_contr A, from is_contr.mk a f,
_)
2015-02-21 00:30:32 +00:00
2015-09-11 23:05:48 +00:00
theorem is_hprop_neg (A : Type) : is_hprop (¬A) := _
2015-08-31 16:23:34 +00:00
2015-05-05 22:33:17 +00:00
/- Symmetry of Π -/
2015-08-31 16:23:34 +00:00
definition is_equiv_flip [instance] {P : A → A' → Type}
: is_equiv (@function.flip A A' P) :=
2015-02-21 00:30:32 +00:00
begin
2015-02-24 21:27:57 +00:00
fapply is_equiv.mk,
exact (@function.flip _ _ (function.flip P)),
repeat (intro f; apply idp)
2015-02-21 00:30:32 +00:00
end
definition pi_comm_equiv {P : A → A' → Type} : (Πa b, P a b) ≃ (Πb a, P a b) :=
equiv.mk (@function.flip _ _ P) _
2014-12-12 04:14:53 +00:00
end pi
2015-02-21 00:30:32 +00:00
2015-09-11 22:53:08 +00:00
attribute pi.is_trunc_pi [instance] [priority 1520]