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 sigma-types (dependent sums)
-/
2015-02-26 18:19:54 +00:00
2014-12-12 19:19:06 +00:00
import types.prod
2014-12-12 04:14:53 +00:00
2015-09-11 22:53:08 +00:00
open eq sigma sigma.ops equiv is_equiv function is_trunc sum unit
2014-12-12 04:14:53 +00:00
namespace sigma
variables {A A' : Type} {B : A → Type} {B' : A' → Type} {C : Πa, B a → Type}
{D : Πa b, C a b → Type}
{a a' a'' : A} {b b₁ b₂ : B a} {b' : B a'} {b'' : B a''} {u v w : Σa, B a}
2015-06-27 00:09:50 +00:00
definition destruct := @sigma.cases_on
2015-08-07 16:37:05 +00:00
/- Paths in a sigma-type -/
2015-02-26 00:20:44 +00:00
protected definition eta : Π (u : Σa, B a), ⟨u.1 , u.2⟩ = u
| eta ⟨u₁, u₂⟩ := idp
2014-12-12 04:14:53 +00:00
2015-02-26 00:20:44 +00:00
definition eta2 : Π (u : Σa b, C a b), ⟨u.1, u.2.1, u.2.2⟩ = u
| eta2 ⟨u₁, u₂, u₃⟩ := idp
2014-12-12 04:14:53 +00:00
2015-02-26 00:20:44 +00:00
definition eta3 : Π (u : Σa b c, D a b c), ⟨u.1, u.2.1, u.2.2.1, u.2.2.2⟩ = u
| eta3 ⟨u₁, u₂, u₃, u₄⟩ := idp
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition dpair_eq_dpair (p : a = a') (q : b =[p] b') : ⟨a, b⟩ = ⟨a', b'⟩ :=
2015-06-23 16:47:52 +00:00
by induction q; reflexivity
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition sigma_eq (p : u.1 = v.1) (q : u.2 =[p] v.2) : u = v :=
2015-06-23 16:47:52 +00:00
by induction u; induction v; exact (dpair_eq_dpair p q)
2014-12-12 04:14:53 +00:00
2015-08-13 15:31:15 +00:00
definition eq_pr1 [unfold 5] (p : u = v) : u.1 = v.1 :=
2014-12-20 02:46:06 +00:00
ap pr1 p
2014-12-12 04:14:53 +00:00
2015-02-21 00:30:32 +00:00
postfix `..1`:(max+1) := eq_pr1
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition eq_pr2 (p : u = v) : u.2 =[p..1] v.2 :=
2015-06-23 16:47:52 +00:00
by induction p; exact idpo
2015-02-24 07:28:28 +00:00
2015-02-21 00:30:32 +00:00
postfix `..2`:(max+1) := eq_pr2
2014-12-12 04:14:53 +00:00
2015-06-23 16:47:52 +00:00
definition dpair_sigma_eq (p : u.1 = v.1) (q : u.2 =[p] v.2)
2015-05-22 08:35:44 +00:00
: ⟨(sigma_eq p q)..1, (sigma_eq p q)..2⟩ = ⟨p, q⟩ :=
2015-06-23 16:47:52 +00:00
by induction u; induction v;esimp at *;induction q;esimp
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition sigma_eq_pr1 (p : u.1 = v.1) (q : u.2 =[p] v.2) : (sigma_eq p q)..1 = p :=
2015-02-24 07:28:28 +00:00
(dpair_sigma_eq p q)..1
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition sigma_eq_pr2 (p : u.1 = v.1) (q : u.2 =[p] v.2)
: (sigma_eq p q)..2 =[sigma_eq_pr1 p q] q :=
2015-02-24 07:28:28 +00:00
(dpair_sigma_eq p q)..2
2014-12-12 04:14:53 +00:00
2015-02-21 00:30:32 +00:00
definition sigma_eq_eta (p : u = v) : sigma_eq (p..1) (p..2) = p :=
2015-06-23 16:47:52 +00:00
by induction p; induction u; reflexivity
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition tr_pr1_sigma_eq {B' : A → Type} (p : u.1 = v.1) (q : u.2 =[p] v.2)
: transport (λx, B' x.1) (sigma_eq p q) = transport B' p :=
2015-06-23 16:47:52 +00:00
by induction u; induction v; esimp at *;induction q; reflexivity
2014-12-12 04:14:53 +00:00
2014-12-12 18:17:50 +00:00
/- the uncurried version of sigma_eq. We will prove that this is an equivalence -/
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition sigma_eq_unc : Π (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2), u = v
| sigma_eq_unc ⟨pq₁, pq₂⟩ := sigma_eq pq₁ pq₂
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition dpair_sigma_eq_unc : Π (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2),
⟨(sigma_eq_unc pq)..1, (sigma_eq_unc pq)..2⟩ = pq
| dpair_sigma_eq_unc ⟨pq₁, pq₂⟩ := dpair_sigma_eq pq₁ pq₂
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition sigma_eq_pr1_unc (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2)
: (sigma_eq_unc pq)..1 = pq.1 :=
(dpair_sigma_eq_unc pq)..1
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition sigma_eq_pr2_unc (pq : Σ(p : u.1 = v.1), u.2 =[p] v.2) :
(sigma_eq_unc pq)..2 =[sigma_eq_pr1_unc pq] pq.2 :=
(dpair_sigma_eq_unc pq)..2
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition sigma_eq_eta_unc (p : u = v) : sigma_eq_unc ⟨p..1, p..2⟩ = p :=
2015-02-24 07:28:28 +00:00
sigma_eq_eta p
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition tr_sigma_eq_pr1_unc {B' : A → Type}
(pq : Σ(p : u.1 = v.1), u.2 =[p] v.2)
: transport (λx, B' x.1) (@sigma_eq_unc A B u v pq) = transport B' pq.1 :=
2015-02-21 00:30:32 +00:00
destruct pq tr_pr1_sigma_eq
2014-12-12 04:14:53 +00:00
2015-02-21 00:30:32 +00:00
definition is_equiv_sigma_eq [instance] (u v : Σa, B a)
2015-05-22 08:35:44 +00:00
: is_equiv (@sigma_eq_unc A B u v) :=
adjointify sigma_eq_unc
2014-12-12 04:14:53 +00:00
(λp, ⟨p..1, p..2⟩)
2015-05-22 08:35:44 +00:00
sigma_eq_eta_unc
dpair_sigma_eq_unc
2015-08-06 20:37:52 +00:00
definition sigma_eq_equiv (u v : Σa, B a) : (u = v) ≃ (Σ(p : u.1 = v.1), u.2 =[p] v.2) :=
(equiv.mk sigma_eq_unc _)⁻¹ᵉ
2015-05-22 08:35:44 +00:00
definition dpair_eq_dpair_con (p1 : a = a' ) (q1 : b =[p1] b' )
(p2 : a' = a'') (q2 : b' =[p2] b'') :
dpair_eq_dpair (p1 ⬝ p2) (q1 ⬝o q2) = dpair_eq_dpair p1 q1 ⬝ dpair_eq_dpair p2 q2 :=
2015-06-23 16:47:52 +00:00
by induction q1; induction q2; reflexivity
2015-05-22 08:35:44 +00:00
definition sigma_eq_con (p1 : u.1 = v.1) (q1 : u.2 =[p1] v.2)
(p2 : v.1 = w.1) (q2 : v.2 =[p2] w.2) :
sigma_eq (p1 ⬝ p2) (q1 ⬝o q2) = sigma_eq p1 q1 ⬝ sigma_eq p2 q2 :=
2015-06-23 16:47:52 +00:00
by induction u; induction v; induction w; apply dpair_eq_dpair_con
2014-12-12 04:14:53 +00:00
2015-01-26 19:31:12 +00:00
local attribute dpair_eq_dpair [reducible]
2015-05-22 08:35:44 +00:00
definition dpair_eq_dpair_con_idp (p : a = a') (q : b =[p] b') :
dpair_eq_dpair p q = dpair_eq_dpair p !pathover_tr ⬝
dpair_eq_dpair idp (pathover_idp_of_eq (tr_eq_of_pathover q)) :=
2015-06-23 16:47:52 +00:00
by induction q; reflexivity
2014-12-12 04:14:53 +00:00
2015-02-21 00:30:32 +00:00
/- eq_pr1 commutes with the groupoid structure. -/
2014-12-12 04:14:53 +00:00
2015-02-21 00:30:32 +00:00
definition eq_pr1_idp (u : Σa, B a) : (refl u) ..1 = refl (u.1) := idp
2015-05-22 08:35:44 +00:00
definition eq_pr1_con (p : u = v) (q : v = w) : (p ⬝ q) ..1 = (p..1) ⬝ (q..1) := !ap_con
definition eq_pr1_inv (p : u = v) : p⁻¹ ..1 = (p..1)⁻¹ := !ap_inv
2014-12-12 04:14:53 +00:00
/- Applying dpair to one argument is the same as dpair_eq_dpair with reflexivity in the first place. -/
2015-05-22 08:35:44 +00:00
definition ap_dpair (q : b₁ = b₂) :
ap (sigma.mk a) q = dpair_eq_dpair idp (pathover_idp_of_eq q) :=
2015-06-23 16:47:52 +00:00
by induction q; reflexivity
2014-12-12 04:14:53 +00:00
2014-12-12 18:17:50 +00:00
/- Dependent transport is the same as transport along a sigma_eq. -/
2014-12-12 04:14:53 +00:00
2014-12-12 18:17:50 +00:00
definition transportD_eq_transport (p : a = a') (c : C a b) :
2015-05-22 08:35:44 +00:00
p ▸D c = transport (λu, C (u.1) (u.2)) (dpair_eq_dpair p !pathover_tr) c :=
2015-06-23 16:47:52 +00:00
by induction p; reflexivity
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition sigma_eq_eq_sigma_eq {p1 q1 : a = a'} {p2 : b =[p1] b'} {q2 : b =[q1] b'}
(r : p1 = q1) (s : p2 =[r] q2) : sigma_eq p1 p2 = sigma_eq q1 q2 :=
2015-06-23 16:47:52 +00:00
by induction s; reflexivity
2014-12-12 04:14:53 +00:00
/- A path between paths in a total space is commonly shown component wise. -/
2015-05-22 08:35:44 +00:00
definition sigma_eq2 {p q : u = v} (r : p..1 = q..1) (s : p..2 =[r] q..2)
2015-02-21 00:30:32 +00:00
: p = q :=
2014-12-12 04:14:53 +00:00
begin
2015-04-30 18:00:39 +00:00
revert q r s,
2015-06-23 16:47:52 +00:00
induction p, induction u with u1 u2,
2015-04-30 18:00:39 +00:00
intro q r s,
2015-05-03 05:22:31 +00:00
transitivity sigma_eq q..1 q..2,
apply sigma_eq_eq_sigma_eq r s,
apply sigma_eq_eta,
2014-12-12 04:14:53 +00:00
end
2015-05-22 08:35:44 +00:00
definition sigma_eq2_unc {p q : u = v} (rs : Σ(r : p..1 = q..1), p..2 =[r] q..2) : p = q :=
2015-02-21 00:30:32 +00:00
destruct rs sigma_eq2
2014-12-12 04:14:53 +00:00
/- Transport -/
/- The concrete description of transport in sigmas (and also pis) is rather trickier than in the other types. In particular, these cannot be described just in terms of transport in simpler types; they require also the dependent transport [transportD].
In particular, this indicates why `transport` alone cannot be fully defined by induction on the structure of types, although Id-elim/transportD can be (cf. Observational Type Theory). A more thorough set of lemmas, along the lines of the present ones but dealing with Id-elim rather than just transport, might be nice to have eventually? -/
2015-08-06 20:37:52 +00:00
definition sigma_transport (p : a = a') (bc : Σ(b : B a), C a b)
2015-05-22 08:35:44 +00:00
: p ▸ bc = ⟨p ▸ bc.1, p ▸D bc.2⟩ :=
2015-06-23 16:47:52 +00:00
by induction p; induction bc; reflexivity
2014-12-12 04:14:53 +00:00
/- The special case when the second variable doesn't depend on the first is simpler. -/
2015-08-13 15:31:15 +00:00
definition sigma_transport_nondep {B : Type} {C : A → B → Type} (p : a = a')
(bc : Σ(b : B), C a b) : p ▸ bc = ⟨bc.1, p ▸ bc.2⟩ :=
2015-06-23 16:47:52 +00:00
by induction p; induction bc; reflexivity
2014-12-12 04:14:53 +00:00
/- Or if the second variable contains a first component that doesn't depend on the first. -/
2015-08-06 20:37:52 +00:00
definition sigma_transport2_nondep {C : A → Type} {D : Π a:A, B a → C a → Type} (p : a = a')
2015-05-01 03:23:12 +00:00
(bcd : Σ(b : B a) (c : C a), D a b c) : p ▸ bcd = ⟨p ▸ bcd.1, p ▸ bcd.2.1, p ▸D2 bcd.2.2⟩ :=
2014-12-12 04:14:53 +00:00
begin
2015-06-23 16:47:52 +00:00
induction p, induction bcd with b cd, induction cd, reflexivity
2014-12-12 04:14:53 +00:00
end
2015-05-22 08:35:44 +00:00
/- Pathovers -/
2015-08-07 16:37:05 +00:00
definition etao (p : a = a') (bc : Σ(b : B a), C a b)
2015-05-22 08:35:44 +00:00
: bc =[p] ⟨p ▸ bc.1, p ▸D bc.2⟩ :=
2015-06-23 16:47:52 +00:00
by induction p; induction bc; apply idpo
2015-05-22 08:35:44 +00:00
definition sigma_pathover (p : a = a') (u : Σ(b : B a), C a b) (v : Σ(b : B a'), C a' b)
(r : u.1 =[p] v.1) (s : u.2 =[apo011 C p r] v.2) : u =[p] v :=
2015-06-23 16:47:52 +00:00
begin
induction u, induction v, esimp at *, induction r,
esimp [apo011] at s, induction s using idp_rec_on, apply idpo
end
2015-05-22 08:35:44 +00:00
2015-08-07 16:37:05 +00:00
/-
TODO:
2015-05-22 08:35:44 +00:00
* define the projections from the type u =[p] v
* show that the uncurried version of sigma_pathover is an equivalence
-/
2014-12-12 04:14:53 +00:00
/- Functorial action -/
variables (f : A → A') (g : Πa, B a → B' (f a))
2015-07-07 23:37:06 +00:00
definition sigma_functor [unfold 7] (u : Σa, B a) : Σa', B' a' :=
2014-12-12 04:14:53 +00:00
⟨f u.1, g u.1 u.2⟩
/- Equivalences -/
2015-02-21 00:30:32 +00:00
definition is_equiv_sigma_functor [H1 : is_equiv f] [H2 : Π a, is_equiv (g a)]
: is_equiv (sigma_functor f g) :=
adjointify (sigma_functor f g)
2015-02-28 00:02:18 +00:00
(sigma_functor f⁻¹ (λ(a' : A') (b' : B' a'),
2015-04-27 19:39:36 +00:00
((g (f⁻¹ a'))⁻¹ (transport B' (right_inv f a')⁻¹ b'))))
2014-12-12 04:14:53 +00:00
begin
2015-06-23 16:47:52 +00:00
intro u', induction u' with a' b',
2015-04-30 18:00:39 +00:00
apply sigma_eq (right_inv f a'),
2015-05-22 08:35:44 +00:00
rewrite [▸*,right_inv (g (f⁻¹ a')),▸*],
apply tr_pathover
2014-12-12 04:14:53 +00:00
end
begin
intro u,
2015-06-23 16:47:52 +00:00
induction u with a b,
2015-04-27 19:39:36 +00:00
apply (sigma_eq (left_inv f a)),
2015-05-22 08:35:44 +00:00
apply pathover_of_tr_eq,
rewrite [▸*,adj f,-(fn_tr_eq_tr_fn (left_inv f a) (λ a, (g a)⁻¹)),
2015-08-06 13:09:49 +00:00
▸*,tr_compose B' f,tr_inv_tr,left_inv]
2014-12-12 04:14:53 +00:00
end
2015-09-22 16:01:55 +00:00
definition sigma_equiv_sigma_of_is_equiv [constructor]
[H1 : is_equiv f] [H2 : Π a, is_equiv (g a)] : (Σa, B a) ≃ (Σa', B' a') :=
2015-02-21 00:30:32 +00:00
equiv.mk (sigma_functor f g) !is_equiv_sigma_functor
2014-12-12 04:14:53 +00:00
2015-09-22 16:01:55 +00:00
definition sigma_equiv_sigma [constructor] (Hf : A ≃ A') (Hg : Π a, B a ≃ B' (to_fun Hf a)) :
2014-12-12 04:14:53 +00:00
(Σa, B a) ≃ (Σa', B' a') :=
2015-02-21 00:30:32 +00:00
sigma_equiv_sigma_of_is_equiv (to_fun Hf) (λ a, to_fun (Hg a))
2014-12-12 04:14:53 +00:00
2015-09-22 16:01:55 +00:00
definition sigma_equiv_sigma_id [constructor] {B' : A → Type} (Hg : Π a, B a ≃ B' a)
: (Σa, B a) ≃ Σa, B' a :=
2015-02-21 00:30:32 +00:00
sigma_equiv_sigma equiv.refl Hg
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
definition ap_sigma_functor_eq_dpair (p : a = a') (q : b =[p] b') :
ap (sigma_functor f g) (sigma_eq p q) = sigma_eq (ap f p) (pathover.rec_on q idpo) :=
2015-06-23 16:47:52 +00:00
by induction q; reflexivity
2014-12-12 04:14:53 +00:00
2015-05-22 08:35:44 +00:00
-- definition ap_sigma_functor_eq (p : u.1 = v.1) (q : u.2 =[p] v.2)
-- : ap (sigma_functor f g) (sigma_eq p q) =
-- sigma_eq (ap f p)
2015-08-06 13:09:49 +00:00
-- ((tr_compose B' f p (g u.1 u.2))⁻¹ ⬝ (fn_tr_eq_tr_fn p g u.2)⁻¹ ⬝ ap (g v.1) q) :=
2015-06-23 16:47:52 +00:00
-- by induction u; induction v; apply ap_sigma_functor_eq_dpair
2014-12-12 04:14:53 +00:00
/- definition 3.11.9(i): Summing up a contractible family of types does nothing. -/
2015-08-13 15:31:15 +00:00
2015-09-11 22:53:08 +00:00
definition is_equiv_pr1 [instance] [constructor] (B : A → Type) [H : Π a, is_contr (B a)]
2014-12-20 02:46:06 +00:00
: is_equiv (@pr1 A B) :=
adjointify pr1
2014-12-12 04:14:53 +00:00
(λa, ⟨a, !center⟩)
(λa, idp)
2015-05-22 08:35:44 +00:00
(λu, sigma_eq idp (pathover_idp_of_eq !center_eq))
2014-12-12 04:14:53 +00:00
2015-09-11 22:53:08 +00:00
definition sigma_equiv_of_is_contr_right [constructor] [H : Π a, is_contr (B a)]
: (Σa, B a) ≃ A :=
2014-12-20 02:46:06 +00:00
equiv.mk pr1 _
2014-12-12 04:14:53 +00:00
/- definition 3.11.9(ii): Dually, summing up over a contractible type does nothing. -/
2015-09-11 22:53:08 +00:00
definition sigma_equiv_of_is_contr_left [constructor] (B : A → Type) [H : is_contr A]
: (Σa, B a) ≃ B (center A) :=
equiv.MK
2015-05-01 03:23:12 +00:00
(λu, (center_eq u.1)⁻¹ ▸ u.2)
2014-12-12 04:14:53 +00:00
(λb, ⟨!center, b⟩)
2015-05-01 03:23:12 +00:00
(λb, ap (λx, x ▸ b) !hprop_eq_of_is_contr)
2015-09-11 22:53:08 +00:00
(λu, sigma_eq !center_eq !tr_pathover)
2014-12-12 04:14:53 +00:00
/- Associativity -/
--this proof is harder than in Coq because we don't have eta definitionally for sigma
2015-09-22 16:01:55 +00:00
definition sigma_assoc_equiv [constructor] (C : (Σa, B a) → Type)
: (Σa b, C ⟨a, b⟩) ≃ (Σu, C u) :=
2014-12-12 04:14:53 +00:00
equiv.mk _ (adjointify
(λav, ⟨⟨av.1, av.2.1⟩, av.2.2⟩)
2015-05-19 05:35:18 +00:00
(λuc, ⟨uc.1.1, uc.1.2, !sigma.eta⁻¹ ▸ uc.2⟩)
2015-06-23 16:47:52 +00:00
begin intro uc, induction uc with u c, induction u, reflexivity end
begin intro av, induction av with a v, induction v, reflexivity end)
2014-12-12 04:14:53 +00:00
2015-05-02 21:17:50 +00:00
open prod prod.ops
2015-09-22 16:01:55 +00:00
definition assoc_equiv_prod [constructor] (C : (A × A') → Type) : (Σa a', C (a,a')) ≃ (Σu, C u) :=
2014-12-12 04:14:53 +00:00
equiv.mk _ (adjointify
(λav, ⟨(av.1, av.2.1), av.2.2⟩)
2015-05-01 03:23:12 +00:00
(λuc, ⟨pr₁ (uc.1), pr₂ (uc.1), !prod.eta⁻¹ ▸ uc.2⟩)
2014-12-12 04:14:53 +00:00
proof (λuc, destruct uc (λu, prod.destruct u (λa b c, idp))) qed
proof (λav, destruct av (λa v, destruct v (λb c, idp))) qed)
/- Symmetry -/
2015-02-21 00:30:32 +00:00
2015-05-22 08:35:44 +00:00
definition comm_equiv_unc (C : A × A' → Type) : (Σa a', C (a, a')) ≃ (Σa' a, C (a, a')) :=
2014-12-12 04:14:53 +00:00
calc
2015-09-22 16:01:55 +00:00
(Σa a', C (a, a')) ≃ Σu, C u : assoc_equiv_prod
... ≃ Σv, C (flip v) : sigma_equiv_sigma !prod_comm_equiv
(λu, prod.destruct u (λa a', equiv.refl))
... ≃ Σa' a, C (a, a') : assoc_equiv_prod
2014-12-12 04:14:53 +00:00
2015-09-22 16:01:55 +00:00
definition sigma_comm_equiv [constructor] (C : A → A' → Type)
: (Σa a', C a a') ≃ (Σa' a, C a a') :=
2015-05-22 08:35:44 +00:00
comm_equiv_unc (λu, C (prod.pr1 u) (prod.pr2 u))
2014-12-12 04:14:53 +00:00
2015-09-22 16:01:55 +00:00
definition equiv_prod [constructor] (A B : Type) : (Σ(a : A), B) ≃ A × B :=
2014-12-12 04:14:53 +00:00
equiv.mk _ (adjointify
(λs, (s.1, s.2))
(λp, ⟨pr₁ p, pr₂ p⟩)
proof (λp, prod.destruct p (λa b, idp)) qed
proof (λs, destruct s (λa b, idp)) qed)
2015-02-21 00:30:32 +00:00
definition comm_equiv_nondep (A B : Type) : (Σ(a : A), B) ≃ Σ(b : B), A :=
2014-12-12 04:14:53 +00:00
calc
2015-03-13 03:18:49 +00:00
(Σ(a : A), B) ≃ A × B : equiv_prod
... ≃ B × A : prod_comm_equiv
2014-12-12 04:14:53 +00:00
... ≃ Σ(b : B), A : equiv_prod
2015-09-11 22:53:08 +00:00
/- Interaction with other type constructors -/
definition sigma_empty_left [constructor] (B : empty → Type) : (Σx, B x) ≃ empty :=
begin
fapply equiv.MK,
{ intro v, induction v, contradiction},
{ intro x, contradiction},
{ intro x, contradiction},
{ intro v, induction v, contradiction},
end
definition sigma_empty_right [constructor] (A : Type) : (Σ(a : A), empty) ≃ empty :=
begin
fapply equiv.MK,
{ intro v, induction v, contradiction},
{ intro x, contradiction},
{ intro x, contradiction},
{ intro v, induction v, contradiction},
end
definition sigma_unit_left [constructor] (B : unit → Type) : (Σx, B x) ≃ B star :=
!sigma_equiv_of_is_contr_left
definition sigma_unit_right [constructor] (A : Type) : (Σ(a : A), unit) ≃ A :=
!sigma_equiv_of_is_contr_right
definition sigma_sum_left [constructor] (B : A + A' → Type)
: (Σp, B p) ≃ (Σa, B (inl a)) + (Σa, B (inr a)) :=
begin
fapply equiv.MK,
{ intro v,
induction v with p b, induction p: append (apply inl) (apply inr); constructor; assumption },
{ intro p, induction p with v v: induction v; constructor; assumption},
{ intro p, induction p with v v: induction v; reflexivity},
{ intro v, induction v with p b, induction p: reflexivity},
end
definition sigma_sum_right [constructor] (B C : A → Type)
: (Σa, B a + C a) ≃ (Σa, B a) + (Σa, C a) :=
begin
fapply equiv.MK,
{ intro v,
induction v with a p, induction p: append (apply inl) (apply inr); constructor; assumption},
{ intro p,
induction p with v v: induction v; constructor; append (apply inl) (apply inr); assumption},
{ intro p, induction p with v v: induction v; reflexivity},
{ intro v, induction v with a p, induction p: reflexivity},
end
2014-12-12 04:14:53 +00:00
/- ** Universal mapping properties -/
/- *** The positive universal property. -/
section
2015-02-21 00:30:32 +00:00
definition is_equiv_sigma_rec [instance] (C : (Σa, B a) → Type)
2015-04-10 01:41:23 +00:00
: is_equiv (sigma.rec : (Πa b, C ⟨a, b⟩) → Πab, C ab) :=
2014-12-12 04:14:53 +00:00
adjointify _ (λ g a b, g ⟨a, b⟩)
2015-02-21 00:30:32 +00:00
(λ g, proof eq_of_homotopy (λu, destruct u (λa b, idp)) qed)
2014-12-12 19:19:06 +00:00
(λ f, refl f)
2014-12-12 04:14:53 +00:00
2015-02-21 00:30:32 +00:00
definition equiv_sigma_rec (C : (Σa, B a) → Type)
2014-12-12 04:14:53 +00:00
: (Π(a : A) (b: B a), C ⟨a, b⟩) ≃ (Πxy, C xy) :=
equiv.mk sigma.rec _
/- *** The negative universal property. -/
2015-05-22 08:35:44 +00:00
protected definition coind_unc (fg : Σ(f : Πa, B a), Πa, C a (f a)) (a : A)
2015-03-03 21:35:51 +00:00
: Σ(b : B a), C a b :=
⟨fg.1 a, fg.2 a⟩
2014-12-12 04:14:53 +00:00
2015-02-21 00:30:32 +00:00
protected definition coind (f : Π a, B a) (g : Π a, C a (f a)) (a : A) : Σ(b : B a), C a b :=
2015-05-22 08:35:44 +00:00
sigma.coind_unc ⟨f, g⟩ a
2014-12-12 04:14:53 +00:00
--is the instance below dangerous?
--in Coq this can be done without function extensionality
2015-02-21 00:30:32 +00:00
definition is_equiv_coind [instance] (C : Πa, B a → Type)
2015-05-22 08:35:44 +00:00
: is_equiv (@sigma.coind_unc _ _ C) :=
2014-12-12 04:14:53 +00:00
adjointify _ (λ h, ⟨λa, (h a).1, λa, (h a).2⟩)
2015-05-19 05:35:18 +00:00
(λ h, proof eq_of_homotopy (λu, !sigma.eta) qed)
2014-12-12 04:14:53 +00:00
(λfg, destruct fg (λ(f : Π (a : A), B a) (g : Π (x : A), C x (f x)), proof idp qed))
2015-03-04 05:10:48 +00:00
definition sigma_pi_equiv_pi_sigma : (Σ(f : Πa, B a), Πa, C a (f a)) ≃ (Πa, Σb, C a b) :=
2015-05-22 08:35:44 +00:00
equiv.mk sigma.coind_unc _
2014-12-12 04:14:53 +00:00
end
2015-08-07 17:23:00 +00:00
/- Subtypes (sigma types whose second components are hprops) -/
definition subtype [reducible] {A : Type} (P : A → Type) [H : Πa, is_hprop (P a)] :=
Σ(a : A), P a
notation [parsing-only] `{` binder `|` r:(scoped:1 P, subtype P) `}` := r
2014-12-12 04:14:53 +00:00
/- To prove equality in a subtype, we only need equality of the first component. -/
2015-08-07 17:23:00 +00:00
definition subtype_eq [H : Πa, is_hprop (B a)] (u v : {a | B a}) : u.1 = v.1 → u = v :=
2015-05-22 08:35:44 +00:00
sigma_eq_unc ∘ inv pr1
2014-12-12 04:14:53 +00:00
2015-08-07 17:23:00 +00:00
definition is_equiv_subtype_eq [H : Πa, is_hprop (B a)] (u v : {a | B a})
2015-02-21 00:30:32 +00:00
: is_equiv (subtype_eq u v) :=
!is_equiv_compose
2015-03-03 21:35:51 +00:00
local attribute is_equiv_subtype_eq [instance]
2014-12-12 04:14:53 +00:00
2015-08-07 17:23:00 +00:00
definition equiv_subtype [H : Πa, is_hprop (B a)] (u v : {a | B a}) : (u.1 = v.1) ≃ (u = v) :=
2015-02-21 00:30:32 +00:00
equiv.mk !subtype_eq _
2014-12-12 04:14:53 +00:00
/- truncatedness -/
2015-09-11 23:05:48 +00:00
theorem is_trunc_sigma (B : A → Type) (n : trunc_index)
2014-12-12 04:14:53 +00:00
[HA : is_trunc n A] [HB : Πa, is_trunc n (B a)] : is_trunc n (Σa, B a) :=
begin
2015-04-30 18:00:39 +00:00
revert A B HA HB,
2015-05-22 08:35:44 +00:00
induction n with n IH,
2015-09-11 22:53:08 +00:00
{ intro A B HA HB, fapply is_trunc_equiv_closed_rev, apply sigma_equiv_of_is_contr_left},
2015-05-22 08:35:44 +00:00
{ intro A B HA HB, apply is_trunc_succ_intro, intro u v,
2015-08-06 20:37:52 +00:00
apply is_trunc_equiv_closed_rev,
apply sigma_eq_equiv,
2015-05-22 08:35:44 +00:00
exact IH _ _ _ _}
2014-12-12 04:14:53 +00:00
end
end sigma
2015-08-06 20:37:52 +00:00
attribute sigma.is_trunc_sigma [instance] [priority 1490]