2014-12-12 04:14:53 +00:00
|
|
|
/-
|
|
|
|
Copyright (c) 2014 Floris van Doorn. All rights reserved.
|
|
|
|
Released under Apache 2.0 license as described in the file LICENSE.
|
2015-02-26 18:19:54 +00:00
|
|
|
|
|
|
|
Module: types.W
|
2014-12-12 04:14:53 +00:00
|
|
|
Author: Floris van Doorn
|
|
|
|
|
|
|
|
Theorems about W-types (well-founded trees)
|
|
|
|
-/
|
|
|
|
|
|
|
|
import .sigma .pi
|
2014-12-12 19:19:06 +00:00
|
|
|
open eq sigma sigma.ops equiv is_equiv
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-11 20:23:21 +00:00
|
|
|
inductive Wtype.{l k} {A : Type.{l}} (B : A → Type.{k}) : Type.{max l k} :=
|
2014-12-12 19:19:06 +00:00
|
|
|
sup : Π (a : A), (B a → Wtype.{l k} B) → Wtype.{l k} B
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
namespace Wtype
|
|
|
|
notation `W` binders `,` r:(scoped B, Wtype B) := r
|
|
|
|
|
|
|
|
universe variables u v
|
|
|
|
variables {A A' : Type.{u}} {B B' : A → Type.{v}} {C : Π(a : A), B a → Type}
|
|
|
|
{a a' : A} {f : B a → W a, B a} {f' : B a' → W a, B a} {w w' : W(a : A), B a}
|
|
|
|
|
2015-05-11 20:23:21 +00:00
|
|
|
protected definition pr1 [unfold-c 3] (w : W(a : A), B a) : A :=
|
|
|
|
by cases w with a f; exact a
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-11 20:23:21 +00:00
|
|
|
protected definition pr2 [unfold-c 3] (w : W(a : A), B a) : B (pr1 w) → W(a : A), B a :=
|
|
|
|
by cases w with a f; exact f
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
namespace ops
|
|
|
|
postfix `.1`:(max+1) := Wtype.pr1
|
|
|
|
postfix `.2`:(max+1) := Wtype.pr2
|
|
|
|
notation `⟨` a `,` f `⟩`:0 := Wtype.sup a f --input ⟨ ⟩ as \< \>
|
|
|
|
end ops
|
|
|
|
open ops
|
|
|
|
|
2014-12-12 19:19:06 +00:00
|
|
|
protected definition eta (w : W a, B a) : ⟨w.1 , w.2⟩ = w :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases w; exact idp
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition sup_eq_sup (p : a = a') (q : p ▸ f = f') : ⟨a, f⟩ = ⟨a', f'⟩ :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases p; cases q; exact idp
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
protected definition Wtype_eq (p : w.1 = w'.1) (q : p ▸ w.2 = w'.2) : w = w' :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases w; cases w';exact (sup_eq_sup p q)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-02-21 00:30:32 +00:00
|
|
|
protected definition Wtype_eq_pr1 (p : w = w') : w.1 = w'.1 :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases p;exact idp
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
protected definition Wtype_eq_pr2 (p : w = w') : Wtype_eq_pr1 p ▸ w.2 = w'.2 :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases p;exact idp
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
namespace ops
|
2015-02-21 00:30:32 +00:00
|
|
|
postfix `..1`:(max+1) := Wtype_eq_pr1
|
|
|
|
postfix `..2`:(max+1) := Wtype_eq_pr2
|
2015-05-11 20:23:21 +00:00
|
|
|
end ops open ops open sigma
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition sup_path_W (p : w.1 = w'.1) (q : p ▸ w.2 = w'.2)
|
2015-05-11 20:23:21 +00:00
|
|
|
: ⟨(Wtype_eq p q)..1,(Wtype_eq p q)..2⟩ = ⟨p, q⟩ :=
|
|
|
|
by cases w; cases w'; cases p; cases q; exact idp
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition pr1_path_W (p : w.1 = w'.1) (q : p ▸ w.2 = w'.2) : (Wtype_eq p q)..1 = p :=
|
2015-05-11 20:23:21 +00:00
|
|
|
!sup_path_W..1
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition pr2_path_W (p : w.1 = w'.1) (q : p ▸ w.2 = w'.2)
|
|
|
|
: pr1_path_W p q ▸ (Wtype_eq p q)..2 = q :=
|
2015-05-11 20:23:21 +00:00
|
|
|
!sup_path_W..2
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-02-21 00:30:32 +00:00
|
|
|
definition eta_path_W (p : w = w') : Wtype_eq (p..1) (p..2) = p :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases p; cases w; exact idp
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition transport_pr1_path_W {B' : A → Type} (p : w.1 = w'.1) (q : p ▸ w.2 = w'.2)
|
2015-02-21 00:30:32 +00:00
|
|
|
: transport (λx, B' x.1) (Wtype_eq p q) = transport B' p :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases w; cases w'; cases p; cases q; exact idp
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition path_W_uncurried (pq : Σ(p : w.1 = w'.1), p ▸ w.2 = w'.2) : w = w' :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases pq with p q; exact (Wtype_eq p q)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition sup_path_W_uncurried (pq : Σ(p : w.1 = w'.1), p ▸ w.2 = w'.2)
|
2015-05-11 20:23:21 +00:00
|
|
|
: ⟨(path_W_uncurried pq)..1, (path_W_uncurried pq)..2⟩ = pq :=
|
|
|
|
by cases pq with p q; exact (sup_path_W p q)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition pr1_path_W_uncurried (pq : Σ(p : w.1 = w'.1), p ▸ w.2 = w'.2)
|
2014-12-12 19:19:06 +00:00
|
|
|
: (path_W_uncurried pq)..1 = pq.1 :=
|
2015-05-11 20:23:21 +00:00
|
|
|
!sup_path_W_uncurried..1
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition pr2_path_W_uncurried (pq : Σ(p : w.1 = w'.1), p ▸ w.2 = w'.2)
|
|
|
|
: (pr1_path_W_uncurried pq) ▸ (path_W_uncurried pq)..2 = pq.2 :=
|
2015-05-11 20:23:21 +00:00
|
|
|
!sup_path_W_uncurried..2
|
2014-12-12 04:14:53 +00:00
|
|
|
|
2015-05-11 20:23:21 +00:00
|
|
|
definition eta_path_W_uncurried (p : w = w') : path_W_uncurried ⟨p..1, p..2⟩ = p :=
|
2014-12-12 04:14:53 +00:00
|
|
|
!eta_path_W
|
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition transport_pr1_path_W_uncurried {B' : A → Type} (pq : Σ(p : w.1 = w'.1), p ▸ w.2 = w'.2)
|
2014-12-12 19:19:06 +00:00
|
|
|
: transport (λx, B' x.1) (@path_W_uncurried A B w w' pq) = transport B' pq.1 :=
|
2015-05-11 20:23:21 +00:00
|
|
|
by cases pq with p q; exact (transport_pr1_path_W p q)
|
2014-12-12 04:14:53 +00:00
|
|
|
|
|
|
|
definition isequiv_path_W /-[instance]-/ (w w' : W a, B a)
|
|
|
|
: is_equiv (@path_W_uncurried A B w w') :=
|
|
|
|
adjointify path_W_uncurried
|
2015-05-11 20:23:21 +00:00
|
|
|
(λp, ⟨p..1, p..2⟩)
|
2014-12-12 04:14:53 +00:00
|
|
|
eta_path_W_uncurried
|
|
|
|
sup_path_W_uncurried
|
|
|
|
|
2015-05-01 03:23:12 +00:00
|
|
|
definition equiv_path_W (w w' : W a, B a) : (Σ(p : w.1 = w'.1), p ▸ w.2 = w'.2) ≃ (w = w') :=
|
2014-12-12 04:14:53 +00:00
|
|
|
equiv.mk path_W_uncurried !isequiv_path_W
|
|
|
|
|
|
|
|
definition double_induction_on {P : (W a, B a) → (W a, B a) → Type} (w w' : W a, B a)
|
|
|
|
(H : ∀ (a a' : A) (f : B a → W a, B a) (f' : B a' → W a, B a),
|
|
|
|
(∀ (b : B a) (b' : B a'), P (f b) (f' b')) → P (sup a f) (sup a' f')) : P w w' :=
|
|
|
|
begin
|
|
|
|
revert w',
|
2015-05-11 20:23:21 +00:00
|
|
|
eapply (Wtype.rec_on w), intro a f IH w',
|
|
|
|
cases w' with a' f',
|
2015-04-30 18:00:39 +00:00
|
|
|
apply H, intro b b',
|
2014-12-12 04:14:53 +00:00
|
|
|
apply IH
|
|
|
|
end
|
|
|
|
|
|
|
|
/- truncatedness -/
|
2015-05-11 20:23:21 +00:00
|
|
|
open is_trunc
|
|
|
|
definition trunc_W [instance] (n : trunc_index)
|
2015-02-21 00:30:32 +00:00
|
|
|
[HA : is_trunc (n.+1) A] : is_trunc (n.+1) (W a, B a) :=
|
2014-12-12 04:14:53 +00:00
|
|
|
begin
|
2015-05-11 20:23:21 +00:00
|
|
|
fapply is_trunc_succ_intro, intro w w',
|
|
|
|
eapply (double_induction_on w w'), intro a a' f f' IH,
|
2015-02-21 00:30:32 +00:00
|
|
|
fapply is_trunc_equiv_closed,
|
2015-05-11 20:23:21 +00:00
|
|
|
{ apply equiv_path_W},
|
|
|
|
{ fapply is_trunc_sigma,
|
|
|
|
intro p, cases p, esimp,
|
|
|
|
apply pi.is_trunc_eq_pi}
|
2014-12-12 04:14:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
end Wtype
|